lib/avm/files/formatter.rb in avm-tools-0.75.1 vs lib/avm/files/formatter.rb in avm-tools-0.76.0

- old
+ new

@@ -8,11 +8,15 @@ class Formatter include ::EacRubyUtils::Fs::Traversable require_sub __FILE__ enable_simple_cache enable_console_speaker - common_constructor :source_paths, :options + enable_listable + lists.add_symbol :option, :apply, :recursive, :verbose + common_constructor :source_paths, :options, default: [{}] do + options.assert_valid_keys(self.class.lists.option.values) + end FORMATS = %w[ruby php html python xml json generic_plain].freeze def run clear @@ -25,19 +29,19 @@ def apply infom "Applying #{@formats_files.count} format(s)... " @formats_files.each do |format, files| infom "Applying format #{format.name} (Files matched: #{files.count})..." - next unless options.fetch(:apply) + next unless options[OPTION_APPLY] @result += format.apply(files) end end def traverser_check_file(file) format = find_format(file) - infov file, format ? format.class : '-' if options.fetch(:verbose) + infov file, format ? format.class : '-' if options[OPTION_VERBOSE] return unless format @formats_files[format] ||= [] @formats_files[format] << file end @@ -77,10 +81,10 @@ end infov('Files changed', "#{changed.count}/#{@result.count}") end def traverser_recursive - options.fetch(:recursive) + options[OPTION_RECURSIVE] end end end end