# File lib/cucumber/cli/profile_loader.rb, line 10
10: def args_from(profile)
11: unless cucumber_yml.has_key?(profile)
12: raise(ProfileNotFound, Could not find profile: '#{profile}'Defined profiles in cucumber.yml: * #{cucumber_yml.keys.join("\n * ")})
13: end
14:
15: args_from_yml = cucumber_yml[profile] || ''
16:
17: case(args_from_yml)
18: when String
19: raise YmlLoadError, "The '#{profile}' profile in cucumber.yml was blank. Please define the command line arguments for the '#{profile}' profile in cucumber.yml.\n" if args_from_yml =~ /^\s*$/
20: if(Cucumber::WINDOWS)
21: #Shellwords treats backslash as an escape character so here's a rudimentary approximation of the same code
22: args_from_yml = args_from_yml.split
23: args_from_yml = args_from_yml.collect {|x| x.gsub(/^\"(.*)\"/,'\1') }
24: else
25: require 'shellwords'
26: args_from_yml = Shellwords.shellwords(args_from_yml)
27: end
28: when Array
29: raise YmlLoadError, "The '#{profile}' profile in cucumber.yml was empty. Please define the command line arguments for the '#{profile}' profile in cucumber.yml.\n" if args_from_yml.empty?
30: else
31: raise YmlLoadError, "The '#{profile}' profile in cucumber.yml was a #{args_from_yml.class}. It must be a String or Array"
32: end
33: args_from_yml
34: end
Locates cucumber.yml file. The file can end in .yml or .yaml, and be located in the current directory (eg. project root) or in a .config/ or config/ subdirectory of the current directory.
# File lib/cucumber/cli/profile_loader.rb, line 82
82: def cucumber_file
83: @cucumber_file ||= Dir.glob('{,.config/,config/}cucumber{.yml,.yaml}').first
84: end
Loads the profile, processing it through ERB and YAML, and returns it as a hash.
# File lib/cucumber/cli/profile_loader.rb, line 52
52: def cucumber_yml
53: return @cucumber_yml if @cucumber_yml
54: unless cucumber_yml_defined?
55: raise(ProfilesNotDefinedError,"cucumber.yml was not found. Current directory is #{Dir.pwd}. Please refer to cucumber's documentation on defining profiles in cucumber.yml. You must define a 'default' profile to use the cucumber command without any arguments.\nType 'cucumber --help' for usage.\n")
56: end
57:
58: require 'erb'
59: require 'yaml'
60: begin
61: @cucumber_erb = ERB.new(IO.read(cucumber_file)).result(binding)
62: rescue Exception => e
63: raise(YmlLoadError,"cucumber.yml was found, but could not be parsed with ERB. Please refer to cucumber's documentation on correct profile usage.\n#{$!.inspect}")
64: end
65:
66: begin
67: @cucumber_yml = YAML::load(@cucumber_erb)
68: rescue StandardError => e
69: raise(YmlLoadError,"cucumber.yml was found, but could not be parsed. Please refer to cucumber's documentation on correct profile usage.\n")
70: end
71:
72: if @cucumber_yml.nil? || !@cucumber_yml.is_a?(Hash)
73: raise(YmlLoadError,"cucumber.yml was found, but was blank or malformed. Please refer to cucumber's documentation on correct profile usage.\n")
74: end
75:
76: return @cucumber_yml
77: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.