Skip to content

Commit

Permalink
Update generated changelog filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
koic committed Jan 7, 2023
1 parent 33ee88d commit a1e0556
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tasks/changelog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ def extract_id(body)

def str_to_filename(str)
str
.downcase
.split
.each { |s| s.gsub!(/\W/, '') }
.reject(&:empty?)
.map { |s| prettify(s) }
.inject do |result, word|
s = "#{result}_#{word}"
return result if s.length > MAX_LENGTH
Expand All @@ -76,6 +75,21 @@ def github_user

user
end

private

def prettify(str)
str.gsub!(/\W/, '_')

# Separate word boundaries by `_`.
str.gsub!(/([A-Z]+)(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) do
(Regexp.last_match(1) || Regexp.last_match(2)) << '_'
end

str.gsub!(/\A_+|_+\z/, '')
str.downcase!
str
end
end

def self.pending?
Expand Down

0 comments on commit a1e0556

Please sign in to comment.