Class: CF::Run
Instance Attribute Summary collapse
-
#errors ⇒ Object
Contains Error Message if any.
-
#file ⇒ Object
File attribute to upload for Production Run.
-
#input ⇒ Object
Input to be passed for Production Run.
-
#line ⇒ Object
Line attribute with which run is associated.
-
#title ⇒ Object
Title of the “run” object.
Class Method Summary collapse
- .all(line_title = nil) ⇒ Object
-
.create(line, title, file) ⇒ Object
Creates a new Run ===Usage Example:.
-
.final_output(title) ⇒ Object
Returns Final Output of production Run ===Usage Example: CF::Run.final_output(“run_title”).
-
.find(title) ⇒ Object
Searches Run for the given “run_title” ===Usage Example: CF::Run.find(“run_title”).
-
.output(options = {}) ⇒ Object
Returns Output of production Run for any specific Station and for given Run Title ===Usage Example: CF::Run.output(=> “run_title”, :station => 2) Will return output of second station.
- .progress(run_title) ⇒ Object
- .progress_details(run_title) ⇒ Object
- .resume(run_title) ⇒ Object
Instance Method Summary collapse
-
#final_output ⇒ Object
Returns Final Output of production Run ===Usage Example: run_object.final_output.
-
#initialize(line, title, input) ⇒ Run
constructor
Initializes a new Run ===Usage Example:.
-
#output(options = {}) ⇒ Object
Returns Output of Run object for any specific Station ===Usage Example: run_object.output(:station => 2) Will return output of second station.
- #progress ⇒ Object
- #progress_details ⇒ Object
Constructor Details
#initialize(line, title, input) ⇒ Run
29 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 56 57 58 59 60 61 62 |
# File 'lib/cf/run.rb', line 29 def initialize(line, title, input) if line.class == CF::Line || Hashie::Mash @line = line @line_title = @line.title else @line_title = line end @title = title if File.exist?(input.to_s) @file = input @param_data = File.new(input, 'rb') @param_for_input = :file resp = self.class.post("/lines/#{CF.account_name}/#{@line_title.downcase}/runs.json", {:data => {:run => {:title => @title}}, @param_for_input => @param_data}) if resp.code != 200 self.errors = resp.error. end else @input = input @param_data = input @param_for_input = :inputs = { :body => { :api_key => CF.api_key, :data =>{:run => { :title => @title }, :inputs => @param_data} } } run = HTTParty.post("#{CF.api_url}#{CF.api_version}/lines/#{CF.account_name}/#{@line_title.downcase}/runs.json",) if run.code != 200 self.errors = run.parsed_response['error']['message'] end end end |
Instance Attribute Details
#errors ⇒ Object
Contains Error Message if any
19 20 21 |
# File 'lib/cf/run.rb', line 19 def errors @errors end |
#file ⇒ Object
File attribute to upload for Production Run
10 11 12 |
# File 'lib/cf/run.rb', line 10 def file @file end |
#input ⇒ Object
Input to be passed for Production Run
13 14 15 |
# File 'lib/cf/run.rb', line 13 def input @input end |
#line ⇒ Object
Line attribute with which run is associated
16 17 18 |
# File 'lib/cf/run.rb', line 16 def line @line end |
#title ⇒ Object
Title of the “run” object
7 8 9 |
# File 'lib/cf/run.rb', line 7 def title @title end |
Class Method Details
.all(line_title = nil) ⇒ Object
155 156 157 158 159 160 161 |
# File 'lib/cf/run.rb', line 155 def self.all(line_title=nil) if line_title.blank? get("/runs/#{CF.account_name}.json") else get("/lines/#{CF.account_name}/#{line_title}/list_runs.json") end end |
.create(line, title, file) ⇒ Object
72 73 74 |
# File 'lib/cf/run.rb', line 72 def self.create(line, title, file) Run.new(line, title, file) end |
.final_output(title) ⇒ Object
98 99 100 101 |
# File 'lib/cf/run.rb', line 98 def self.final_output(title) resp = get("/runs/#{CF.account_name}/#{title.downcase}/output.json") return resp['output'] end |
.find(title) ⇒ Object
127 128 129 130 131 132 133 134 135 |
# File 'lib/cf/run.rb', line 127 def self.find(title) resp = get("/runs/#{CF.account_name}/#{title.downcase}.json") if resp.code != 200 resp.error = resp.error. resp.merge!(:errors => "#{resp.error}") resp.delete(:error) end return resp end |
.output(options = {}) ⇒ Object
107 108 109 110 111 112 |
# File 'lib/cf/run.rb', line 107 def self.output(={}) station_no = [:station] title = [:title] resp = get("/runs/#{CF.account_name}/#{title.downcase}/output/#{station_no}.json") return resp['output'] end |
.progress(run_title) ⇒ Object
137 138 139 |
# File 'lib/cf/run.rb', line 137 def self.progress(run_title) get("/runs/#{CF.account_name}/#{run_title}/progress.json") end |
.progress_details(run_title) ⇒ Object
145 146 147 148 |
# File 'lib/cf/run.rb', line 145 def self.progress_details(run_title) resp = get("/runs/#{CF.account_name}/#{run_title}/details.json") return resp['progress_details'] end |
.resume(run_title) ⇒ Object
163 164 165 |
# File 'lib/cf/run.rb', line 163 def self.resume(run_title) post("/runs/#{CF.account_name}/#{run_title}/resume.json") end |
Instance Method Details
#final_output ⇒ Object
Returns Final Output of production Run
Usage Example:
run_object.final_output
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/cf/run.rb', line 79 def final_output resp = self.class.get("/runs/#{CF.account_name}/#{self.title.downcase}/output.json") @final_output =[] resp['output'].each do |r| result = FinalOutput.new() r.to_hash.each_pair do |k,v| result.send("#{k}=",v) if result.respond_to?(k) end if result.final_output == nil result.final_output = resp.output end @final_output << result end return @final_output end |
#output(options = {}) ⇒ Object
Returns Output of Run object for any specific Station
Usage Example:
run_object.output(:station => 2)
Will return output of second station
118 119 120 121 122 |
# File 'lib/cf/run.rb', line 118 def output(={}) station_no = [:station] resp = self.class.get("/runs/#{CF.account_name}/#{self.title.downcase}/output/#{station_no}.json") return resp['output'].first.to_hash end |
#progress ⇒ Object
141 142 143 |
# File 'lib/cf/run.rb', line 141 def progress self.class.get("/runs/#{CF.account_name}/#{self.title}/progress.json") end |
#progress_details ⇒ Object
150 151 152 153 |
# File 'lib/cf/run.rb', line 150 def progress_details resp = self.class.get("/runs/#{CF.account_name}/#{self.title}/details.json") return resp['progress_details'] end |