Class: Cucumber::Cli::ProfileLoader
- Defined in:
- lib/cucumber/cli/profile_loader.rb
Instance Method Summary collapse
- #args_from(profile) ⇒ Object
- #cucumber_yml_defined? ⇒ Boolean
- #has_profile?(profile) ⇒ Boolean
-
#initialize ⇒ ProfileLoader
constructor
A new instance of ProfileLoader.
Constructor Details
#initialize ⇒ ProfileLoader
Returns a new instance of ProfileLoader.
6 7 8 |
# File 'lib/cucumber/cli/profile_loader.rb', line 6 def initialize @cucumber_yml = nil end |
Instance Method Details
#args_from(profile) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cucumber/cli/profile_loader.rb', line 10 def args_from(profile) unless cucumber_yml.has_key?(profile) raise(ProfileNotFound, <<-END_OF_ERROR) Could not find profile: '#{profile}' Defined profiles in cucumber.yml: * #{cucumber_yml.keys.join("\n * ")} END_OF_ERROR end args_from_yml = cucumber_yml[profile] || '' case(args_from_yml) when String 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*$/ args_from_yml = args_from_yml.split(' ') when Array 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? else raise YmlLoadError, "The '#{profile}' profile in cucumber.yml was a #{args_from_yml.class}. It must be a String or Array" end args_from_yml end |
#cucumber_yml_defined? ⇒ Boolean
38 39 40 |
# File 'lib/cucumber/cli/profile_loader.rb', line 38 def cucumber_yml_defined? cucumber_file && File.exist?(cucumber_file) end |
#has_profile?(profile) ⇒ Boolean
34 35 36 |
# File 'lib/cucumber/cli/profile_loader.rb', line 34 def has_profile?(profile) cucumber_yml.has_key?(profile) end |