phocoder-rails 0.0.40 → 0.0.41

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1,4 +1,4 @@
1
- 0.0.40
1
+ 0.0.41
2
2
 
3
3
 
4
4
 
@@ -59,6 +59,23 @@ module ActsAsPhocodable
59
59
  mattr_accessor :config_file
60
60
  self.config_file = "config/phocodable.yml"
61
61
 
62
+ # The actual configuration parameters
63
+ mattr_accessor :config
64
+ self.config = nil
65
+
66
+ def self.phocodable_config
67
+ #puts "checking phocodable_config for #{self.config}"
68
+ self.read_phocodable_configuration if self.config.nil?
69
+ self.config
70
+ end
71
+
72
+ def self.read_phocodable_configuration
73
+
74
+ config_path = File.join(::Rails.root.to_s, ActsAsPhocodable.config_file)
75
+ puts "#{self.config} - looking for a config in #{config_path}"
76
+ self.config = YAML.load(ERB.new(File.read(config_path)).result)[::Rails.env.to_s].symbolize_keys
77
+ #self.apply_phocodable_configuration
78
+ end
62
79
 
63
80
  # The list of image content types that are considered web safe
64
81
  # These can be displayed directly, skipping processing if in offline mode
@@ -319,14 +336,16 @@ module ActsAsPhocodable
319
336
  end
320
337
 
321
338
 
322
-
323
339
  def read_phocodable_configuration
324
- config_path = File.join(::Rails.root.to_s, ActsAsPhocodable.config_file)
325
- puts "looking for a config in #{config_path}"
326
- self.phocodable_configuration = YAML.load(ERB.new(File.read(config_path)).result)[::Rails.env.to_s].symbolize_keys
340
+ #raise "This method is going away!"
341
+ #puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
342
+ #puts "This method is going away!"
343
+ #puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
344
+ self.phocodable_configuration = ActsAsPhocodable.phocodable_config
327
345
  self.apply_phocodable_configuration
328
346
  end
329
347
 
348
+
330
349
  def apply_phocodable_configuration
331
350
  if self.phocodable_configuration[:base_url]
332
351
  ActsAsPhocodable.base_url = phocodable_configuration[:base_url]
@@ -442,7 +461,7 @@ module ActsAsPhocodable
442
461
  def create_thumbnails_from_response(response_thumbs,job_id)
443
462
  new_thumbs = []
444
463
  response_thumbs.each do |thumb_params|
445
- puts "creating a thumb for #{thumb_params["label"]}"
464
+ #puts "creating a thumb for #{thumb_params["label"]}"
446
465
  # we do this the long way around just in case some of these
447
466
  # atts are attr_protected
448
467
  thumb = nil
@@ -472,7 +491,7 @@ module ActsAsPhocodable
472
491
  thumb.save
473
492
  new_thumbs << thumb
474
493
  Rails.logger.debug " thumb.errors = #{thumb.errors.to_json}"
475
- puts " thumb.errors = #{thumb.errors.to_json}"
494
+ #puts " thumb.errors = #{thumb.errors.to_json}"
476
495
  end
477
496
  new_thumbs
478
497
  end
@@ -493,9 +512,9 @@ module ActsAsPhocodable
493
512
  end
494
513
 
495
514
  def phocode(input_thumbs = self.parent_class.phocoder_thumbnails)
496
- puts " input_thumbs.count = #{input_thumbs.size}"
515
+ #puts " input_thumbs.count = #{input_thumbs.size}"
497
516
  input_thumbs = dedupe_input_thumbs(input_thumbs)
498
- puts " after dedupe input_thumbs.count = #{input_thumbs.size}"
517
+ #puts " after dedupe input_thumbs.count = #{input_thumbs.size}"
499
518
  #if self.thumbnails.count >= self.class.phocoder_thumbnails.size
500
519
  # raise "This item already has thumbnails!"
501
520
  # return
@@ -511,7 +530,7 @@ module ActsAsPhocodable
511
530
  Rails.logger.debug "callback url = #{callback_url}"
512
531
  response = Phocoder::Job.create(phocoder_params(input_thumbs))
513
532
  Rails.logger.debug "the phocode response = #{response.to_json}" if Rails.env != "test"
514
- puts "the phocode response = #{response.to_json}" if Rails.env != "test"
533
+ #puts "the phocode response = #{response.to_json}" if Rails.env != "test"
515
534
  job = self.encodable_jobs.new
516
535
  job.phocoder_input_id = response.body["job"]["inputs"].first["id"]
517
536
  job.phocoder_job_id = response.body["job"]["id"]
@@ -521,7 +540,7 @@ module ActsAsPhocodable
521
540
  self.save #false need to do save(false) here if we're calling phocode on after_save
522
541
  response_thumbs = response.body["job"]["thumbnails"]
523
542
  Rails.logger.debug "trying to decode #{response_thumbs.size} response_thumbs = #{response_thumbs.to_json}"
524
- puts "trying to decode #{response_thumbs.size} response_thumbs = #{response_thumbs.to_json}"
543
+ #puts "trying to decode #{response_thumbs.size} response_thumbs = #{response_thumbs.to_json}"
525
544
  create_thumbnails_from_response(response_thumbs,response.body["job"]["id"])
526
545
  end
527
546
 
@@ -595,7 +614,7 @@ module ActsAsPhocodable
595
614
  Rails.logger.debug "callback url = #{callback_url}"
596
615
  response = Phocoder::Job.create(phocoder_tone_mapping_params)
597
616
  Rails.logger.debug "tone_mapping response = #{response.body.to_json}"
598
- puts "tone_mapping response = #{response.body.to_json}"
617
+ #puts "tone_mapping response = #{response.body.to_json}"
599
618
  job = self.encodable_jobs.new
600
619
  job.phocoder_output_id = response.body["job"]["tone_mapping"]["id"]
601
620
  job.phocoder_job_id = response.body["job"]["id"]
@@ -626,7 +645,7 @@ module ActsAsPhocodable
626
645
  Rails.logger.debug "callback url = #{callback_url}"
627
646
  response = Phocoder::Job.create(phocoder_composite_params)
628
647
  Rails.logger.debug "composite response = #{response.body.to_json}"
629
- puts "composite response = #{response.body.to_json}"
648
+ #puts "composite response = #{response.body.to_json}"
630
649
  job = self.encodable_jobs.new
631
650
  job.phocoder_output_id = response.body["job"]["composite"]["id"]
632
651
  job.phocoder_job_id = response.body["job"]["id"]
@@ -636,7 +655,7 @@ module ActsAsPhocodable
636
655
  self.save #false need to do save(false) here if we're calling phocode on after_save
637
656
  response_thumbs = response.body["job"]["thumbnails"]
638
657
  Rails.logger.debug "trying to decode #{response_thumbs.size} response_thumbs = #{response_thumbs.to_json}"
639
- puts "trying to decode #{response_thumbs.size} response_thumbs = #{response_thumbs.to_json}"
658
+ #puts "trying to decode #{response_thumbs.size} response_thumbs = #{response_thumbs.to_json}"
640
659
  create_thumbnails_from_response(response_thumbs,response.body["job"]["id"])
641
660
  end
642
661
  end
@@ -670,7 +689,7 @@ module ActsAsPhocodable
670
689
  self.thumbnails << thumb
671
690
  thumb.encodable_status = "zencoding"
672
691
  thumb.save
673
- puts " thumb.errors = #{thumb.errors.to_json}"
692
+ #puts " thumb.errors = #{thumb.errors.to_json}"
674
693
  end
675
694
 
676
695
  self.save
@@ -826,7 +845,7 @@ module ActsAsPhocodable
826
845
  end
827
846
 
828
847
  def phocodable_config
829
- puts "looking for config!"
848
+ #puts "looking for config!"
830
849
  self.class.config
831
850
  end
832
851
 
@@ -845,7 +864,7 @@ module ActsAsPhocodable
845
864
 
846
865
  def destroy_thumbnails
847
866
  if self.class.phocoder_thumbnails.size == 0 and self.class.zencoder_videos.size == 0
848
- puts "we're skipping destory_thumbnails since we don't do any processing "
867
+ #puts "we're skipping destory_thumbnails since we don't do any processing "
849
868
  return
850
869
  end
851
870
  #puts "calling destory thumbnails for #{self.thumbnails.count} - #{self.thumbnails.size}"
@@ -870,7 +889,7 @@ module ActsAsPhocodable
870
889
  end
871
890
  if thumbnail_name.blank? and thumbnail_hash_or_name.is_a?(Hash)
872
891
  thumbnail_name = "#{thumbnail_hash_or_name[:width]}x#{thumbnail_hash_or_name[:height]}"
873
- puts "thumbnail_name = #{thumbnail_name}"
892
+ #puts "thumbnail_name = #{thumbnail_name}"
874
893
  thumbnail_hash_or_name[:label] = thumbnail_name
875
894
  end
876
895
  thumb = thumbnails.find_by_thumbnail(thumbnail_name)
@@ -924,7 +943,7 @@ module ActsAsPhocodable
924
943
 
925
944
  def save_local_file
926
945
  return if @saved_file.blank?
927
- puts "saving the local file!!!!!!"
946
+ #puts "saving the local file!!!!!!"
928
947
  Rails.logger.debug "==================================================================================================="
929
948
  Rails.logger.debug "about to save the local file"
930
949
  run_callbacks :file_saved do
@@ -946,10 +965,10 @@ module ActsAsPhocodable
946
965
  if ActsAsPhocodable.storeage_mode == "s3" and ActsAsPhocodable.processing_mode == "spawn"
947
966
  spawn do # :method => :thread # <-- I think that should be set at the config/environment level
948
967
  Rails.logger.debug "------------beginning of spawn block"
949
- puts "------------beginning of spawn block"
968
+ #puts "------------beginning of spawn block"
950
969
  self.save_s3_file
951
970
  Rails.logger.debug "------------end of spawn block"
952
- puts "------------end of spawn block"
971
+ #puts "------------end of spawn block"
953
972
  end
954
973
  end
955
974
  if ActsAsPhocodable.storeage_mode == "local" and ActsAsPhocodable.processing_mode == "automatic"
@@ -1017,7 +1036,7 @@ module ActsAsPhocodable
1017
1036
  # This should generate a fully qualified http://something-something
1018
1037
  # type of a reference. Depending on storeage_mode/base_url settings.
1019
1038
  def public_url
1020
- puts "our base_url = #{base_url} and our local_url = #{local_url}"
1039
+ #puts "our base_url = #{base_url} and our local_url = #{local_url}"
1021
1040
  if ActsAsPhocodable.storeage_mode == "local" or ActsAsPhocodable.storeage_mode == "offline"
1022
1041
  base_url + local_url
1023
1042
  else
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{phocoder-rails}
8
- s.version = "0.0.39"
8
+ s.version = "0.0.41"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Jeremy Green}]
12
- s.date = %q{2012-02-15}
12
+ s.date = %q{2012-03-24}
13
13
  s.description = %q{Rails engine for easy integration with phocoder.com}
14
14
  s.email = %q{jagthedrummer@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -95,8 +95,7 @@ describe ActsAsPhocodable do
95
95
  ActsAsPhocodable.base_url = "http://new-domain.com"
96
96
  ActsAsPhocodable.base_url.should == "http://new-domain.com"
97
97
  end
98
-
99
-
98
+
100
99
  it "should default to the normal config file" do
101
100
  ActsAsPhocodable.config_file.should == "config/phocodable.yml"
102
101
  end
@@ -108,15 +107,20 @@ describe ActsAsPhocodable do
108
107
  ActsAsPhocodable.config_file = "config/phocodable.yml"
109
108
  ActsAsPhocodable.config_file.should == "config/phocodable.yml"
110
109
  end
111
-
112
-
110
+
113
111
  it "should read the config file" do
114
112
  ActsAsPhocodable.config_file == "config/phocodable.yml"
115
- iu = ImageUpload.new
116
- iu.phocodable_config.should_not be_nil
113
+ ActsAsPhocodable.config = nil
114
+ ActsAsPhocodable.config.should be_nil
115
+
116
+ ActsAsPhocodable.read_phocodable_configuration
117
+ ActsAsPhocodable.config.should_not be_nil
118
+ ActsAsPhocodable.config.to_json.should_not == "{}"
119
+ #iu = ImageUpload.new
120
+ #iu.phocodable_config.should_not be_nil
117
121
  end
118
-
119
-
122
+
123
+
120
124
  it "should read actual configs" do
121
125
  ActsAsPhocodable.config_file == "config/phocodable.yml"
122
126
  iu = ImageUpload.new()
@@ -147,8 +151,7 @@ describe ActsAsPhocodable do
147
151
  atts[:aspect_mode].should == "crop"
148
152
  end
149
153
  end
150
-
151
-
154
+
152
155
  it "should create phocoder params based on the acts_as_phocodable :thumbnail options" do
153
156
  iu = ImageUpload.new(@attr)
154
157
  phorams = iu.phocoder_params
@@ -171,7 +174,7 @@ describe ActsAsPhocodable do
171
174
  it "should create zencooder params based on the acts_as_phocodable :videos options" do
172
175
  iu = ImageUpload.new(@vid_attr)
173
176
  zenrams = iu.zencoder_params
174
- puts zenrams.to_json
177
+ #puts zenrams.to_json
175
178
  zenrams.should_not be_nil
176
179
  zenrams[:input].should == iu.public_url
177
180
  zenrams[:outputs].size.should == 2
@@ -187,7 +190,7 @@ describe ActsAsPhocodable do
187
190
  ActsAsPhocodable.storeage_mode = "s3"
188
191
  iu = ImageUpload.new(@vid_attr)
189
192
  zenrams = iu.zencoder_params
190
- puts zenrams.to_json
193
+ #puts zenrams.to_json
191
194
  zenrams.should_not be_nil
192
195
  zenrams[:input].should == iu.public_url
193
196
  zenrams[:outputs].size.should == 2
@@ -501,7 +504,7 @@ describe ActsAsPhocodable do
501
504
 
502
505
  #iu.reload #make sure it knows aobut the thumbnail
503
506
  iu.destroy
504
- puts "ImageUpload.first = #{ImageUpload.first.to_json}"
507
+ #puts "ImageUpload.first = #{ImageUpload.first.to_json}"
505
508
  ImageUpload.count.should == 0
506
509
  File.exists?(expected_local_path).should_not be_true
507
510
  end
@@ -558,7 +561,7 @@ describe ActsAsPhocodable do
558
561
 
559
562
  thumb.reload
560
563
  #expected_local_path = File.expand_path(File.join(File.dirname(File.expand_path(__FILE__)),'..','dummy','public','ImageUpload',iu.id.to_s,thumb.filename))
561
- puts "thumb.local_path = #{thumb.local_path} - #{thumb.id}"
564
+ #puts "thumb.local_path = #{thumb.local_path} - #{thumb.id}"
562
565
  File.exists?(thumb.local_path).should be_true
563
566
  thumb.width.should == 10
564
567
  thumb.height.should == 20
@@ -607,7 +610,7 @@ describe ActsAsPhocodable do
607
610
  ActsAsPhocodable.storeage_mode = "s3"
608
611
  ActsAsPhocodable.processing_mode = "automatic"
609
612
  ImageUpload.establish_aws_connection
610
- puts "======================================="
613
+ #puts "======================================="
611
614
  iu = ImageUpload.new(@attr)
612
615
  Phocoder::Job.stub!(:create).and_return(mock(Phocoder::Response,:body=>{
613
616
  "job"=>{
@@ -623,8 +626,8 @@ describe ActsAsPhocodable do
623
626
  AWS::S3::S3Object.should_receive(:find).and_return( mock(:size => 19494) )
624
627
  #now store in S3 + phocode
625
628
  iu.save
626
- puts "======================================="
627
- puts iu.thumbnails.to_json
629
+ #puts "======================================="
630
+ #puts iu.thumbnails.to_json
628
631
  iu.thumbnails.size.should == 1
629
632
 
630
633
  iu.destroy
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phocoder-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 79
5
- prerelease: false
4
+ hash: 77
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 40
10
- segments_generated: true
11
- version: 0.0.40
9
+ - 41
10
+ version: 0.0.41
12
11
  platform: ruby
13
12
  authors:
14
13
  - Jeremy Green
@@ -16,11 +15,11 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2012-03-16 00:00:00 -05:00
20
- default_executable:
18
+ date: 2012-03-24 00:00:00 Z
21
19
  dependencies:
22
20
  - !ruby/object:Gem::Dependency
23
- requirement: &id001 !ruby/object:Gem::Requirement
21
+ name: rails
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
23
  none: false
25
24
  requirements:
26
25
  - - ">="
@@ -30,14 +29,13 @@ dependencies:
30
29
  - 3
31
30
  - 0
32
31
  - 0
33
- segments_generated: true
34
32
  version: 3.0.0
35
- type: :runtime
36
- name: rails
37
33
  prerelease: false
38
- version_requirements: *id001
34
+ requirement: *id001
35
+ type: :runtime
39
36
  - !ruby/object:Gem::Dependency
40
- requirement: &id002 !ruby/object:Gem::Requirement
37
+ name: phocoder-rb
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
41
39
  none: false
42
40
  requirements:
43
41
  - - ">="
@@ -45,14 +43,13 @@ dependencies:
45
43
  hash: 3
46
44
  segments:
47
45
  - 0
48
- segments_generated: true
49
46
  version: "0"
50
- type: :runtime
51
- name: phocoder-rb
52
47
  prerelease: false
53
- version_requirements: *id002
48
+ requirement: *id002
49
+ type: :runtime
54
50
  - !ruby/object:Gem::Dependency
55
- requirement: &id003 !ruby/object:Gem::Requirement
51
+ name: zencoder
52
+ version_requirements: &id003 !ruby/object:Gem::Requirement
56
53
  none: false
57
54
  requirements:
58
55
  - - ">="
@@ -60,14 +57,13 @@ dependencies:
60
57
  hash: 3
61
58
  segments:
62
59
  - 0
63
- segments_generated: true
64
60
  version: "0"
65
- type: :runtime
66
- name: zencoder
67
61
  prerelease: false
68
- version_requirements: *id003
62
+ requirement: *id003
63
+ type: :runtime
69
64
  - !ruby/object:Gem::Dependency
70
- requirement: &id004 !ruby/object:Gem::Requirement
65
+ name: aws-s3
66
+ version_requirements: &id004 !ruby/object:Gem::Requirement
71
67
  none: false
72
68
  requirements:
73
69
  - - ">="
@@ -75,14 +71,13 @@ dependencies:
75
71
  hash: 3
76
72
  segments:
77
73
  - 0
78
- segments_generated: true
79
74
  version: "0"
80
- type: :runtime
81
- name: aws-s3
82
75
  prerelease: false
83
- version_requirements: *id004
76
+ requirement: *id004
77
+ type: :runtime
84
78
  - !ruby/object:Gem::Dependency
85
- requirement: &id005 !ruby/object:Gem::Requirement
79
+ name: spawn
80
+ version_requirements: &id005 !ruby/object:Gem::Requirement
86
81
  none: false
87
82
  requirements:
88
83
  - - ">="
@@ -90,14 +85,13 @@ dependencies:
90
85
  hash: 3
91
86
  segments:
92
87
  - 0
93
- segments_generated: true
94
88
  version: "0"
95
- type: :runtime
96
- name: spawn
97
89
  prerelease: false
98
- version_requirements: *id005
90
+ requirement: *id005
91
+ type: :runtime
99
92
  - !ruby/object:Gem::Dependency
100
- requirement: &id006 !ruby/object:Gem::Requirement
93
+ name: rspec-rails
94
+ version_requirements: &id006 !ruby/object:Gem::Requirement
101
95
  none: false
102
96
  requirements:
103
97
  - - "="
@@ -107,14 +101,13 @@ dependencies:
107
101
  - 2
108
102
  - 4
109
103
  - 1
110
- segments_generated: true
111
104
  version: 2.4.1
112
- type: :development
113
- name: rspec-rails
114
105
  prerelease: false
115
- version_requirements: *id006
106
+ requirement: *id006
107
+ type: :development
116
108
  - !ruby/object:Gem::Dependency
117
- requirement: &id007 !ruby/object:Gem::Requirement
109
+ name: bundler
110
+ version_requirements: &id007 !ruby/object:Gem::Requirement
118
111
  none: false
119
112
  requirements:
120
113
  - - ~>
@@ -124,14 +117,13 @@ dependencies:
124
117
  - 1
125
118
  - 0
126
119
  - 0
127
- segments_generated: true
128
120
  version: 1.0.0
129
- type: :development
130
- name: bundler
131
121
  prerelease: false
132
- version_requirements: *id007
122
+ requirement: *id007
123
+ type: :development
133
124
  - !ruby/object:Gem::Dependency
134
- requirement: &id008 !ruby/object:Gem::Requirement
125
+ name: jeweler
126
+ version_requirements: &id008 !ruby/object:Gem::Requirement
135
127
  none: false
136
128
  requirements:
137
129
  - - ~>
@@ -141,14 +133,13 @@ dependencies:
141
133
  - 1
142
134
  - 5
143
135
  - 1
144
- segments_generated: true
145
136
  version: 1.5.1
146
- type: :development
147
- name: jeweler
148
137
  prerelease: false
149
- version_requirements: *id008
138
+ requirement: *id008
139
+ type: :development
150
140
  - !ruby/object:Gem::Dependency
151
- requirement: &id009 !ruby/object:Gem::Requirement
141
+ name: rcov
142
+ version_requirements: &id009 !ruby/object:Gem::Requirement
152
143
  none: false
153
144
  requirements:
154
145
  - - ">="
@@ -156,12 +147,10 @@ dependencies:
156
147
  hash: 3
157
148
  segments:
158
149
  - 0
159
- segments_generated: true
160
150
  version: "0"
161
- type: :development
162
- name: rcov
163
151
  prerelease: false
164
- version_requirements: *id009
152
+ requirement: *id009
153
+ type: :development
165
154
  description: Rails engine for easy integration with phocoder.com
166
155
  email: jagthedrummer@gmail.com
167
156
  executables: []
@@ -287,7 +276,6 @@ files:
287
276
  - spec/phocoder_rails_spec.rb
288
277
  - spec/routing/phocoder_routing_spec.rb
289
278
  - spec/spec_helper.rb
290
- has_rdoc: true
291
279
  homepage: http://github.com/jagthedrummer/phocoder-rails
292
280
  licenses:
293
281
  - MIT
@@ -304,7 +292,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
304
292
  hash: 3
305
293
  segments:
306
294
  - 0
307
- segments_generated: true
308
295
  version: "0"
309
296
  required_rubygems_version: !ruby/object:Gem::Requirement
310
297
  none: false
@@ -314,12 +301,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
314
301
  hash: 3
315
302
  segments:
316
303
  - 0
317
- segments_generated: true
318
304
  version: "0"
319
305
  requirements: []
320
306
 
321
307
  rubyforge_project:
322
- rubygems_version: 1.3.7
308
+ rubygems_version: 1.8.5
323
309
  signing_key:
324
310
  specification_version: 3
325
311
  summary: Rails engine for easy integration with phocoder.com