class DuplicatedFilenameChecker::Formatter
Public Class Methods
new(result_of_duplicate_filename_checker_check_execute)
click to toggle source
# File lib/duplicated_filename_checker/formatter.rb, line 2 def initialize(result_of_duplicate_filename_checker_check_execute) @duplicate_file_profiles = result_of_duplicate_filename_checker_check_execute end
Public Instance Methods
exclude_basename(exclude_basename_regexp)
click to toggle source
# File lib/duplicated_filename_checker/formatter.rb, line 6 def exclude_basename(exclude_basename_regexp) @exclude_basename_regexp = exclude_basename_regexp end
hash()
click to toggle source
# File lib/duplicated_filename_checker/formatter.rb, line 10 def hash duplicate_file_profiles_with_filter end
markdown()
click to toggle source
@example ### duplicate_filename.sample
-
/Users/nagai_shinya/gem/duplicated_filename_checker/test/sample_for_test/dir_a1/duplicate_filename.sample
* md5: 5258bf47639b8f906c1a17aee86c54dd * mtime: 2015-03-07 13:44:05 +0900
-
/Users/nagai_shinya/gem/duplicated_filename_checker/test/sample_for_test/dir_b1/dir_b2/duplicate_filename.sample
* md5: 5258bf47639b8f906c1a17aee86c54dd * mtime: 2015-03-07 13:44:05 +0900
# File lib/duplicated_filename_checker/formatter.rb, line 27 def markdown duplicate_file_profiles_with_filter.map do |basename, duplicate_file_profiles| [ "## #{basename}\n", "#{file_profile_to_markdown(duplicate_file_profiles)}", ] end.flatten.join end
only_basename()
click to toggle source
# File lib/duplicated_filename_checker/formatter.rb, line 14 def only_basename duplicate_file_profiles_with_filter.keys end
Private Instance Methods
duplicate_file_profiles_with_filter()
click to toggle source
# File lib/duplicated_filename_checker/formatter.rb, line 38 def duplicate_file_profiles_with_filter unless @exclude_basename_regexp return @duplicate_file_profiles end @duplicate_file_profiles.select do |basename, _| !(basename =~ Regexp.new(@exclude_basename_regexp)) end end
file_profile_to_markdown(duplicate_file_profiles)
click to toggle source
# File lib/duplicated_filename_checker/formatter.rb, line 48 def file_profile_to_markdown(duplicate_file_profiles) duplicate_file_profiles.map.with_index(1) do |file_profile, index| [ "#{index}. #{file_profile.path}\n", " * md5: #{file_profile.md5_digest}\n", " * mtime: #{file_profile.stat.mtime}\n", "\n" ] end.join end