bin/mustache in mustache-0.99.6 vs bin/mustache in mustache-0.99.7

- old
+ new

@@ -62,41 +62,27 @@ opts.separator "" opts.parse!(args) end - def self.yaml_is_array?(yaml) - yaml.is_a? Array and yaml.length == 1 and yaml[0].is_a? Array - end - - def self.yaml_is_object?(yaml) - yaml.is_a? Array and yaml.length == 1 and yaml[0].is_a? Hash - end - # Does the dirty work of reading files from the command line then # processing them. The meat of this script, if you will. def self.process_files(input_files) doc = input_files.file.read yaml = nil begin - yaml = RUBY_VERSION >= '1.9.3' ? YAML.load_stream(doc) : YAML.each_document(doc) + yaml = YAML.load_stream(doc) rescue puts "Unable to parse yaml!" end if yaml.nil? puts Mustache.render(doc) else template = input_files.skip.file.read - if self.yaml_is_array?(yaml) - puts Mustache.render(template, yaml[0].reduce({}) {|hash, currentHash| hash.merge(currentHash)}) - elsif self.yaml_is_object?(yaml) - puts Mustache.render(template, yaml[0]) - else - puts Mustache.render(template, yaml) - end + puts Mustache.render template, yaml.compact.reduce(&:merge) end end end end