Class: Rundock::Runner
Constant Summary collapse
- ScenarioNotFoundError =
Class.new(StandardError)
- RUNDOCK_PLUGINS =
%w[operation hook]
Instance Attribute Summary collapse
-
#scenario ⇒ Object
readonly
Returns the value of attribute scenario.
Class Method Summary collapse
Instance Method Summary collapse
- #build(options) ⇒ Object
-
#initialize(options) ⇒ Runner
constructor
A new instance of Runner.
- #load_plugins ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(options) ⇒ Runner
Returns a new instance of Runner.
22 23 24 |
# File 'lib/rundock/runner.rb', line 22 def initialize() @options = end |
Instance Attribute Details
#scenario ⇒ Object (readonly)
Returns the value of attribute scenario.
20 21 22 |
# File 'lib/rundock/runner.rb', line 20 def scenario @scenario end |
Class Method Details
Instance Method Details
#build(options) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rundock/runner.rb', line 30 def build() if [:scenario] || [:targetgroup] raise ScenarioNotFoundError, "'#{[:scenario]}' scenario file is not found." if [:scenario] && !FileTest.exist?([:scenario]) raise ScenarioNotFoundError, "'#{[:targetgroup]}' targetgroup file is not found." if [:command] && [:targetgroup] && !FileTest.exist?([:targetgroup]) [:scenario] = [:targetgroup] if [:command] && [:targetgroup] # parse scenario if [:scenario] =~ %r{^(http|https)://} # read from http/https open([:scenario]) do |f| @scenario = Rundock::Builder::ScenarioBuilder.new(, f).build end else File.open([:scenario]) do |f| @scenario = Rundock::Builder::ScenarioBuilder.new(, f).build end end else # do rundock ssh @scenario = Rundock::Builder::ScenarioBuilder.new(, nil).build end end |
#load_plugins ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/rundock/runner.rb', line 57 def load_plugins # load from current lib dir(for development) Dir.glob('./lib/rundock/plugin/**/*.rb').each do |f| require f.gsub(/.rb$/, '') end # load from local project Dir.glob("#{__dir__}/plugin/**/*.rb").each do |f| require f.gsub(/.rb$/, '') end # load from installed gems gems = [] Gem::Specification.each do |gem| gems << gem.name end gems.uniq! gems.each do |g| RUNDOCK_PLUGINS.each do |plugin| next if g !~ /^(rundock-plugin-#{plugin})-/ next if Gem::Specification.find_by_name(g).nil? Logger.debug("Loading rundock plugin: #{g}") libdir = "#{Gem::Specification.find_by_name(g).full_gem_path}/lib/#{Regexp.last_match(1).tr('-', '/')}" Dir.glob("#{libdir}/*.rb").each do |f| require f.gsub(/.rb$/, '') end end end end |
#run ⇒ Object
26 27 28 |
# File 'lib/rundock/runner.rb', line 26 def run @scenario.run end |