Class: Unitsdb::Commands::Normalize
- Defined in:
- lib/unitsdb/commands/normalize.rb
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Unitsdb::Commands::Base
Instance Method Details
#run(input = nil, output = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/unitsdb/commands/normalize.rb', line 9 def run(input = nil, output = nil) unless @options[:all] || (input && output) puts "Error: INPUT and OUTPUT are required when not using --all" exit(1) end if @options[:all] Unitsdb::Utils::DEFAULT_YAML_FILES.each do |file| path = File.join(@options[:database], file) next unless File.exist?(path) normalize_file(path, path) puts "Normalized #{path}" end puts "All YAML files normalized successfully!" end return unless input && output normalize_file(input, output) puts "Normalized YAML written to #{output}" end |