lib/instapusher/job_submission.rb in instapusher-0.1.7 vs lib/instapusher/job_submission.rb in instapusher-0.1.8

- old
+ new

@@ -7,21 +7,21 @@ def initialize debug, options @debug = debug @options = options - puts "options is #{options.inspect}" + log "options is #{options.inspect}" end def success? job_status_url && job_status_url != "" end def pre_submission_feedback_to_user - puts "url to hit: #{url_to_submit_job.inspect}" - puts "options being passed to the url: #{options.inspect}" - puts "connecting to #{url_to_submit_job} to send data" + log "url to hit: #{url_to_submit_job.inspect}" + log "options being passed to the url: #{options.inspect}" + log "connecting to #{url_to_submit_job} to send data" end def feedback_to_user puts 'The application will be deployed to: ' + response_body['heroku_app_url'] puts 'Monitor the job status at: ' + job_status_url @@ -32,18 +32,18 @@ def error_message response_body['error'] end def submit_the_job - pre_submission_feedback_to_user if debug + pre_submission_feedback_to_user response = Net::HTTP.post_form URI.parse(url_to_submit_job), options raw_body = response.body - puts "response raw body: #{raw_body}" if debug + log "response raw body: #{raw_body}" @response_body = ::JSON.parse(raw_body) - puts "JSON parsed response raw body: #{response_body.inspect}" if debug + log "JSON parsed response raw body: #{response_body.inspect}" @job_status_url = response_body['status_url'] end def url_to_submit_job @url ||= begin @@ -59,9 +59,13 @@ end end def use_ssl? !(ENV['INSTAPUSHER_HOST'] || options[:local]) + end + + def log msg + puts msg if debug end end end