bin/masticate in masticate-0.0.3 vs bin/masticate in masticate-0.0.4

- old
+ new

@@ -1,45 +1,42 @@ #!/usr/bin/env ruby -require "masticate" +require_relative "../lib/masticate" command, filename = ARGV case ARGV.shift when 'sniff' - file = File.open(filename) - results = Masticate.sniff(file) + results = Masticate.sniff(filename) col_sep = results[:col_sep] col_sep = "TAB" if col_sep == "\t" - file.close $stderr.puts <<-EOT Processing complete. Input delimiter: #{col_sep} - Field counts: #{results[:field_counts].join(',')} + Field counts: #{results[:field_counts].inspect} EOT when 'mend' - file = File.open(filename) - metadata = Masticate.sniff(file) + metadata = Masticate.sniff(filename) col_sep = metadata[:col_sep] col_sep = "TAB" if col_sep == "\t" - file.close - file = File.open(filename) - results = Masticate.mend(file, metadata.merge(:output => $stdout)) - file.close + results = Masticate.mend(filename, metadata) $stderr.puts <<-EOT Processing complete. Input delimiter: #{col_sep} Lines in input: #{results[:input_records]} Lines in output: #{results[:output_records]} EOT when 'csvify' - file = File.open(filename) - metadata = Masticate.sniff(file) - file.close - file = File.open(filename) - Masticate.csvify(file, metadata.merge(:output => $stdout)) + metadata = Masticate.sniff(filename) + results = Masticate.csvify(filename, metadata) + $stderr.puts <<-EOT +Processing complete. + Input delimiter: #{metadata[:col_sep]} + Lines in input: #{results[:input_count]} + Lines in output: #{results[:output_count]} +EOT else raise "unknown command #{command}" end