phocoder-rails 0.0.51 → 0.0.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1,4 +1,4 @@
1
- 0.0.51
1
+ 0.0.52
2
2
 
3
3
 
4
4
 
@@ -533,6 +533,27 @@ module ActsAsPhocodable
533
533
  needed_thumbs
534
534
  end
535
535
 
536
+ def create_phocoder_job(params)
537
+ response = nil
538
+ tries = 0
539
+ max_tries = 3
540
+ sleeps = [2,4,8]
541
+ while response.blank? do
542
+ begin
543
+ response = Phocoder::Job.create(params)
544
+ rescue Exception => e
545
+ if tries < max_tries
546
+ sleep sleeps[tries]
547
+ tries += 1
548
+ response = nil
549
+ else
550
+ raise
551
+ end
552
+ end
553
+ end
554
+ response
555
+ end
556
+
536
557
  def phocode(input_thumbs = self.parent_class.phocoder_thumbnails)
537
558
  #puts " input_thumbs.count = #{input_thumbs.size}"
538
559
  input_thumbs = dedupe_input_thumbs(input_thumbs)
@@ -550,7 +571,7 @@ module ActsAsPhocodable
550
571
 
551
572
  Rails.logger.debug "trying to phocode for #{Phocoder.base_url} "
552
573
  Rails.logger.debug "callback url = #{callback_url}"
553
- response = Phocoder::Job.create(phocoder_params(input_thumbs))
574
+ response = create_phocoder_job(phocoder_params(input_thumbs))
554
575
  Rails.logger.debug "the phocode response = #{response.to_json}" if Rails.env != "test"
555
576
  #puts "the phocode response = #{response.to_json}" if Rails.env != "test"
556
577
  if ActsAsPhocodable.track_components
@@ -592,7 +613,7 @@ module ActsAsPhocodable
592
613
  run_callbacks :phocode_hdr do
593
614
  Rails.logger.debug "trying to phocode for #{Phocoder.base_url} "
594
615
  Rails.logger.debug "callback url = #{callback_url}"
595
- response = Phocoder::Job.create(phocoder_hdr_params)
616
+ response = create_phocoder_job(phocoder_hdr_params)
596
617
  Rails.logger.debug "the response from phocode_hdr = #{response.body.to_json}"
597
618
  if ActsAsPhocodable.track_components
598
619
  job = self.encodable_jobs.new
@@ -631,7 +652,7 @@ module ActsAsPhocodable
631
652
  run_callbacks :phocode_hdrhtml do
632
653
  Rails.logger.debug "trying to phocode for #{Phocoder.base_url} "
633
654
  Rails.logger.debug "callback url = #{callback_url}"
634
- response = Phocoder::Job.create(phocoder_hdrhtml_params)
655
+ response = create_phocoder_job(phocoder_hdrhtml_params)
635
656
  Rails.logger.debug "the response from phocode_hdrhtml = #{response.body.to_json}"
636
657
  if ActsAsPhocodable.track_components
637
658
  job = self.encodable_jobs.new
@@ -671,7 +692,7 @@ module ActsAsPhocodable
671
692
  destroy_thumbnails
672
693
  Rails.logger.debug "trying to phocode for #{Phocoder.base_url} "
673
694
  Rails.logger.debug "callback url = #{callback_url}"
674
- response = Phocoder::Job.create(phocoder_tone_mapping_params)
695
+ response = create_phocoder_job(phocoder_tone_mapping_params)
675
696
  Rails.logger.debug "tone_mapping response = #{response.body.to_json}"
676
697
  #puts "tone_mapping response = #{response.body.to_json}"
677
698
  if ActsAsPhocodable.track_components
@@ -714,7 +735,7 @@ module ActsAsPhocodable
714
735
  destroy_thumbnails
715
736
  Rails.logger.debug "trying to phocode for #{Phocoder.base_url} "
716
737
  Rails.logger.debug "callback url = #{callback_url}"
717
- response = Phocoder::Job.create(phocoder_composite_params)
738
+ response = create_phocoder_job(phocoder_composite_params)
718
739
  Rails.logger.debug "composite response = #{response.body.to_json}"
719
740
  #puts "composite response = #{response.body.to_json}"
720
741
  if ActsAsPhocodable.track_components
@@ -745,5 +745,20 @@ describe ActsAsPhocodable do
745
745
  @iu.cloudfront_base_host.should == "http://asset0.myhost.com"
746
746
  end
747
747
  end
748
+
749
+ describe "create_phocoder_job" do
750
+ before(:each) do
751
+ @iu = ImageUpload.new(@attr)
752
+ end
753
+ it "should try to create a job" do
754
+ Phocoder::Job.should_receive(:create).and_return(mock)
755
+ @iu.create_phocoder_job({})
756
+ end
757
+ it "should try again if the first one fails" do
758
+ Phocoder::Job.should_receive(:create).and_raise("error")
759
+ Phocoder::Job.should_receive(:create).and_return(mock)
760
+ @iu.create_phocoder_job({})
761
+ end
762
+ end
748
763
 
749
764
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phocoder-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.51
4
+ version: 0.0.52
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-01 00:00:00.000000000 Z
12
+ date: 2013-01-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -425,7 +425,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
425
425
  version: '0'
426
426
  segments:
427
427
  - 0
428
- hash: 4328902982859700340
428
+ hash: 4213961976185896641
429
429
  required_rubygems_version: !ruby/object:Gem::Requirement
430
430
  none: false
431
431
  requirements:
@@ -434,7 +434,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
434
434
  version: '0'
435
435
  segments:
436
436
  - 0
437
- hash: 4328902982859700340
437
+ hash: 4213961976185896641
438
438
  requirements: []
439
439
  rubyforge_project:
440
440
  rubygems_version: 1.8.24