Class: TDRunner::TDRunnerProfileLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/tdrunner_profile.rb

Overview

Class for loading tdrunner exeution profile from tdrunner.yml file

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ TDRunnerProfileLoader

Returns a new instance of TDRunnerProfileLoader.



30
31
32
33
# File 'lib/tdrunner_profile.rb', line 30

def initialize(args)
  @execution_profiles=Array.new
  parse_execution_profiles(args)
end

Instance Method Details

#args_from(profile) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/tdrunner_profile.rb', line 41

def args_from(profile)
  unless tdrunner_yml.has_key?(profile)
    raise(<<-END_OF_ERROR)
      Could not find profile: '#{profile}'

      Defined profiles in tdrunner.yml:
    * #{tdrunner_yml.keys.join("\n  * ")}
    END_OF_ERROR
  end

  args_from_yml = tdrunner_yml[profile] || ''

  case(args_from_yml)
  when String
    raise "The '#{profile}' profile in tdrunner.yml was blank.  Please define the command line arguments for the '#{profile}' profile in tdrunner.yml.\n" if args_from_yml =~ /^\s*$/
    args_from_yml = args_from_yml.split(' ')
  when Array
    raise "The '#{profile}' profile in tdrunner.yml was empty.  Please define the command line arguments for the '#{profile}' profile in tdrunner.yml.\n" if args_from_yml.empty?
  else
    raise "The '#{profile}' profile in tdrunner.yml was a #{args_from_yml.class}. It must be a String or Array"
  end
  args_from_yml
end

#get_execution_profilesObject



73
74
75
# File 'lib/tdrunner_profile.rb', line 73

def get_execution_profiles
  @execution_profiles
end

#has_profile?(profile) ⇒ Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/tdrunner_profile.rb', line 65

def has_profile?(profile)
  tdrunner_yml.has_key?(profile)
end

#parse_execution_profiles(args) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/tdrunner_profile.rb', line 34

def parse_execution_profiles(args)
  args.each do |value|
    if value != '-p'
      @execution_profiles << value.gsub(' ','')
    end
  end
end

#tdrunner_yml_defined?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/tdrunner_profile.rb', line 69

def tdrunner_yml_defined?
  tdrunner_file && File.exist?(tdrunner_file)
end