Class: CIScripts::Script

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

Instance Method Summary collapse

Constructor Details

#initialize(script_name) ⇒ Script

Returns a new instance of Script.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ci_scripts.rb', line 11

def initialize(script_name)
  script_name = script_name.strip
  full_path = File.join(File.dirname(__FILE__), "scripts", script_name)

  unless File.exist?("#{full_path}.rb")
    log_error "#{script_name} does not exists"
    return
  end

  require full_path

  @class_name = parse_script_name(script_name)
end

Instance Method Details

#runObject



25
26
27
28
29
30
31
# File 'lib/ci_scripts.rb', line 25

def run
  return false unless @class_name

  result = Object.const_get(@class_name).new.send("run")
  return true if result.nil?
  result
end