Class: Instapusher2::JobSubmission
- Inherits:
-
Object
- Object
- Instapusher2::JobSubmission
- Defined in:
- lib/instapusher2/job_submission.rb
Constant Summary collapse
- DEFAULT_HOSTNAME =
'instapusher.com'
Instance Attribute Summary collapse
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#job_status_url ⇒ Object
readonly
Returns the value of attribute job_status_url.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#response_body ⇒ Object
readonly
Returns the value of attribute response_body.
Instance Method Summary collapse
- #error_message ⇒ Object
- #feedback_to_user ⇒ Object
-
#initialize(debug, options) ⇒ JobSubmission
constructor
A new instance of JobSubmission.
- #pre_submission_feedback_to_user ⇒ Object
- #submit_the_job ⇒ Object
- #success? ⇒ Boolean
- #url_to_submit_job ⇒ Object
Constructor Details
#initialize(debug, options) ⇒ JobSubmission
Returns a new instance of JobSubmission.
8 9 10 11 |
# File 'lib/instapusher2/job_submission.rb', line 8 def initialize debug, @debug = debug @options = end |
Instance Attribute Details
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
4 5 6 |
# File 'lib/instapusher2/job_submission.rb', line 4 def debug @debug end |
#job_status_url ⇒ Object (readonly)
Returns the value of attribute job_status_url.
4 5 6 |
# File 'lib/instapusher2/job_submission.rb', line 4 def job_status_url @job_status_url end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/instapusher2/job_submission.rb', line 4 def @options end |
#response_body ⇒ Object (readonly)
Returns the value of attribute response_body.
4 5 6 |
# File 'lib/instapusher2/job_submission.rb', line 4 def response_body @response_body end |
Instance Method Details
#error_message ⇒ Object
30 31 32 |
# File 'lib/instapusher2/job_submission.rb', line 30 def response_body['error'] end |
#feedback_to_user ⇒ Object
23 24 25 26 27 28 |
# File 'lib/instapusher2/job_submission.rb', line 23 def feedback_to_user puts 'The application will be deployed to: ' + response_body['heroku_url'] puts 'Monitor the job status at: ' + job_status_url cmd = "open #{job_status_url}" `#{cmd}` end |
#pre_submission_feedback_to_user ⇒ Object
17 18 19 20 21 |
# File 'lib/instapusher2/job_submission.rb', line 17 def pre_submission_feedback_to_user puts "url to hit: #{url_to_submit_job.inspect}" puts "options being passed to the url: #{.inspect}" puts "connecting to #{url_to_submit_job} to send data" end |
#submit_the_job ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/instapusher2/job_submission.rb', line 34 def submit_the_job pre_submission_feedback_to_user if debug response = Net::HTTP.post_form URI.parse(url_to_submit_job), @response_body = ::JSON.parse(response.body) puts "response_body: #{response_body.inspect}" if debug @job_status_url = response_body['status'] || response_body['job_status_url'] end |
#success? ⇒ Boolean
13 14 15 |
# File 'lib/instapusher2/job_submission.rb', line 13 def success? job_status_url && job_status_url != "" end |
#url_to_submit_job ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/instapusher2/job_submission.rb', line 43 def url_to_submit_job @url ||= begin hostname = if [:local] "localhost:3000" else ENV['INSTAPUSHER_HOST'] || DEFAULT_HOSTNAME end "http://#{hostname}/heroku.json" end end |