diff options
Diffstat (limited to 'danger/plugins/helper.rb')
-rw-r--r-- | danger/plugins/helper.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/danger/plugins/helper.rb b/danger/plugins/helper.rb index f4eb9119266..1a2710463ad 100644 --- a/danger/plugins/helper.rb +++ b/danger/plugins/helper.rb @@ -30,5 +30,22 @@ module Danger .to_a .sort end + + # @return [Hash<String,Array<String>>] + def changes_by_category + all_changed_files.inject(Hash.new { |h, k| h[k] = [] }) do |hsh, file| + hsh[category_for_file(file)] << file + end + end + + def category_for_file(file) + _, category = CATEGORIES.find { |regexp, _| regexp.match?(file) } + + category || :unknown + end + + CATEGORIES = { + %r{\Adoc/} => :documentation + } end end |