Class: Konstant::Runner
- Inherits:
-
Object
- Object
- Konstant::Runner
- Defined in:
- lib/konstant/runner.rb
Instance Attribute Summary collapse
-
#build ⇒ Object
readonly
Returns the value of attribute build.
-
#task ⇒ Object
readonly
Returns the value of attribute task.
Instance Method Summary collapse
- #environment ⇒ Object
-
#initialize(build, task) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
- #status_file ⇒ Object
- #stderr_file ⇒ Object
- #stdout_file ⇒ Object
Constructor Details
#initialize(build, task) ⇒ Runner
Returns a new instance of Runner.
5 6 7 8 |
# File 'lib/konstant/runner.rb', line 5 def initialize(build, task) @build = build @task = task end |
Instance Attribute Details
#build ⇒ Object (readonly)
Returns the value of attribute build.
10 11 12 |
# File 'lib/konstant/runner.rb', line 10 def build @build end |
#task ⇒ Object (readonly)
Returns the value of attribute task.
10 11 12 |
# File 'lib/konstant/runner.rb', line 10 def task @task end |
Instance Method Details
#environment ⇒ Object
33 34 35 36 37 38 |
# File 'lib/konstant/runner.rb', line 33 def environment return { "KONSTANT_PROJECT_ROOT" => File.(build.project.path), "KONSTANT_TIMESTAMP" => build. } end |
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/konstant/runner.rb', line 12 def run if task == "build" || File.exists?("#{build.project.path}/#{task}") duration = Konstant.measure do build.create File.open status_file, "w" do |f| ::Bundler.with_clean_env do system environment, "#{build.project.path}/#{task} > #{stdout_file} 2> #{stderr_file}" f.puts $?.exitstatus end end end File.open "#{build.path}/#{task}.duration", "w" do |f| f.puts duration end build.status(task) == 0 else false end end |
#status_file ⇒ Object
48 49 50 |
# File 'lib/konstant/runner.rb', line 48 def status_file "#{build.path}/#{task}.status" end |
#stderr_file ⇒ Object
44 45 46 |
# File 'lib/konstant/runner.rb', line 44 def stderr_file "#{build.path}/#{task}.stderr" end |
#stdout_file ⇒ Object
40 41 42 |
# File 'lib/konstant/runner.rb', line 40 def stdout_file "#{build.path}/#{task}.stdout" end |