lib/rambo.rb in rambo_ruby-0.2.0 vs lib/rambo.rb in rambo_ruby-0.2.1

- old
+ new

@@ -1,25 +1,28 @@ +require "active_support/core_ext/hash" + Dir["#{File.dirname(__FILE__)}/rambo/**/*.rb"].each {|file| require file } module Rambo class << self attr_reader :options, :file - def generate_contract_tests!(file = nil, opts = nil) - @options = opts || yaml_options - @file = file || @options.fetch(:raml, nil) || raml_file + def generate_contract_tests!(file = nil, opts = {}) + @options = yaml_options.merge(opts) + @options[:rails] = true unless @options.fetch(:rails, nil) == false + @file = file || @options.delete(:raml) || raml_file DocumentGenerator.generate!(@file, @options) end private def yaml_options - opts = YAML.load(File.read(File.expand_path(".rambo.yml"))) + opts = YAML.load(File.read(File.expand_path(".rambo.yml"))).symbolize_keys - if opts && opts.fetch("raml", nil) - opts["raml"] = File.expand_path(opts.fetch("raml")) + if opts && opts.fetch(:raml, nil) + opts[:raml] = File.expand_path(opts.fetch(:raml)) end opts rescue { rails: true } @@ -27,10 +30,12 @@ # TODO: Permit use of multiple RAML files, since right now this only takes # the first one it finds in the "doc" directory. def raml_file - return options.fetch("raml") if options && options.fetch("raml", nil) - Dir.foreach("doc/raml") {|file| return "doc/raml/#{file}" if file.match(/\.raml$/) } + return options.fetch(:raml) if options && options.fetch(:raml, nil) + + raml_path = File.expand_path("doc/raml") + Dir[raml_path].each {|file| return File.join(raml_path, file) if file.match(/\.raml$/) } end end end