We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c0e3784 commit 5911c68Copy full SHA for 5911c68
tasks/changelog.rb
@@ -58,10 +58,9 @@ def extract_id(body)
58
59
def str_to_filename(str)
60
str
61
- .downcase
62
.split
63
- .each { |s| s.gsub!(/\W/, '') }
64
.reject(&:empty?)
+ .map { |s| prettify(s) }
65
.inject do |result, word|
66
s = "#{result}_#{word}"
67
return result if s.length > MAX_LENGTH
@@ -76,6 +75,21 @@ def github_user
76
75
77
user
78
end
+
79
+ private
80
81
+ def prettify(str)
82
+ str.gsub!(/\W/, '_')
83
84
+ # Separate word boundaries by `_`.
85
+ str.gsub!(/([A-Z]+)(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) do
86
+ (Regexp.last_match(1) || Regexp.last_match(2)) << '_'
87
+ end
88
89
+ str.gsub!(/\A_+|_+\z/, '')
90
+ str.downcase!
91
+ str
92
93
94
95
def self.pending?
0 commit comments