phocoder-rails 0.0.56 → 0.0.57

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.56
1
+ 0.0.57
2
2
 
3
3
 
4
4
 
@@ -411,10 +411,14 @@ module ActsAsPhocodable
411
411
  end
412
412
 
413
413
  def establish_aws_connection
414
- AWS::S3::Base.establish_connection!(
415
- :access_key_id => ActsAsPhocodable.s3_access_key_id,
416
- :secret_access_key => ActsAsPhocodable.s3_secret_access_key
417
- )
414
+ AWS.config({
415
+ :access_key_id => ActsAsPhocodable.s3_access_key_id,
416
+ :secret_access_key => ActsAsPhocodable.s3_secret_access_key
417
+ })
418
+ # AWS::S3::Base.establish_connection!(
419
+ # :access_key_id => ActsAsPhocodable.s3_access_key_id,
420
+ # :secret_access_key => ActsAsPhocodable.s3_secret_access_key
421
+ # )
418
422
  end
419
423
 
420
424
 
@@ -1224,22 +1228,38 @@ module ActsAsPhocodable
1224
1228
  "#{cloudfront_base_host}/#{s3_key}"
1225
1229
  end
1226
1230
 
1231
+ def unused_s3_demo_stuff
1232
+ s3 = AWS::S3.new
1233
+ key,bucket = get_s3_key_and_bucket
1234
+ obj = s3.buckets[bucket].objects[key]
1235
+ obj.write(Pathname.new(tmpFile),{:acl=>:public_read,"Cache-Control"=>'max-age=315360000'})
1236
+ end
1237
+
1238
+ def s3
1239
+ @s3 ||= AWS::S3.new
1240
+ end
1241
+
1242
+ def s3_obj
1243
+ s3.buckets[s3_bucket_name].objects[s3_key]
1244
+ end
1245
+
1227
1246
  def save_s3_file
1228
1247
  #I don't think we need this return check anymore.
1229
1248
  #return if !@saved_a_new_file
1230
1249
  #@saved_a_new_file = false
1231
- AWS::S3::S3Object.store(
1232
- s3_key,
1233
- open(local_path),
1234
- s3_bucket_name,
1235
- :access => :public_read,
1236
- "Cache-Control" => 'max-age=315360000'
1237
- )
1250
+ #AWS::S3::S3Object.store(
1251
+ #s3_key,
1252
+ #open(local_path),
1253
+ #s3_bucket_name,
1254
+ #:access => :public_read,
1255
+ #"Cache-Control" => 'max-age=315360000'
1256
+ #)
1257
+ s3_obj.write(Pathname.new(local_path),{:acl=>:public_read,"Cache-Control"=>'max-age=315360000'})
1238
1258
  self.encodable_status = "s3"
1239
1259
  self.save
1240
- obj_data = AWS::S3::S3Object.find(s3_key,s3_bucket_name)
1260
+ #obj_data = AWS::S3::S3Object.find(s3_key,s3_bucket_name)
1241
1261
  Rails.logger.debug "----------------------------------------------------------------------------------------------------"
1242
- if obj_data.size == file_size # it made it into s3 safely
1262
+ if s3_obj.content_length == file_size # it made it into s3 safely
1243
1263
  Rails.logger.debug " we are about to remove local file!"
1244
1264
  remove_local_file
1245
1265
  else
@@ -1254,8 +1274,9 @@ module ActsAsPhocodable
1254
1274
  def remove_s3_file
1255
1275
  #puts "trying to delete #{s3_key} #{s3_bucket_name}"
1256
1276
  #if ActsAsPhocodable.storeage_mode == "s3"
1257
- AWS::S3::S3Object.delete s3_key, s3_bucket_name
1277
+ #AWS::S3::S3Object.delete s3_key, s3_bucket_name
1258
1278
  #end
1279
+ s3_obj.delete
1259
1280
  rescue Exception => e
1260
1281
  #this probably means that the file never made it to S3
1261
1282
  end
@@ -21,7 +21,8 @@ Gem::Specification.new do |gem|
21
21
  gem.add_dependency 'phocoder-rb'
22
22
  gem.add_dependency 'zencoder'
23
23
  gem.add_dependency "mimetype-fu", "~> 0.1.2"#, :require => 'mimetype_fu'
24
- gem.add_dependency 'aws-s3'#, :require => 'aws/s3'
24
+ #gem.add_dependency 'aws-s3'#, :require => 'aws/s3'
25
+ gem.add_dependency "aws-sdk", "~> 1.8.3.1"
25
26
  gem.add_dependency "spawn"#, :git => 'git://github.com/tra/spawn', :branch => "edge"
26
27
 
27
28
  gem.add_development_dependency "sqlite3"
@@ -29,8 +30,8 @@ Gem::Specification.new do |gem|
29
30
  gem.add_development_dependency "webrat"
30
31
  gem.add_development_dependency "capybara", ">= 0.3.9"
31
32
  gem.add_development_dependency "sqlite3-ruby"#, :require => "sqlite3"
32
- gem.add_development_dependency 'rspec', '2.4.0'
33
- gem.add_development_dependency 'rspec-rails', '2.4.1'
33
+ #gem.add_development_dependency 'rspec', '2.4.0'
34
+ gem.add_development_dependency 'rspec-rails', '2.13.0'
34
35
  gem.add_development_dependency 'autotest', '4.4.4'
35
36
  gem.add_development_dependency 'redgreen', '1.2.2'
36
37
  gem.add_development_dependency "webmock"
@@ -65,6 +65,9 @@ describe ActsAsPhocodable do
65
65
  }
66
66
  ActsAsPhocodable.track_jobs = true
67
67
  ActsAsPhocodable.track_components = false
68
+
69
+ @obj = mock(AWS::S3::S3Object)
70
+ AWS::S3.any_instance.stub_chain(:buckets,:[],:objects,:[]){ @obj }
68
71
  end
69
72
 
70
73
 
@@ -644,7 +647,7 @@ describe ActsAsPhocodable do
644
647
  it "in delayed s3 mode it should save the file to an AWS S3 storage location, call phocoder, then destroy" do
645
648
  ActsAsPhocodable.storeage_mode = "s3"
646
649
  ActsAsPhocodable.processing_mode = "delayed"
647
- ImageUpload.establish_aws_connection
650
+ #ImageUpload.establish_aws_connection
648
651
 
649
652
  iu = ImageUpload.new(@attr)
650
653
  Phocoder::Job.stub!(:create).and_return(mock(Phocoder::Response,:body=>{
@@ -660,9 +663,10 @@ describe ActsAsPhocodable do
660
663
  # No thumbnail should be created yet
661
664
  iu.thumbnails.size.should == 0
662
665
  # Mock the AWS reqeust for storing
663
- AWS::S3::S3Object.should_receive(:store).and_return(nil)
666
+ @obj.should_receive(:write).and_return(nil)
667
+ @obj.should_receive(:content_length).and_return(19494)
664
668
  # Mock the AWS request for checking file size
665
- AWS::S3::S3Object.should_receive(:find).and_return( mock(:size => 19494) )
669
+ #AWS::S3::S3Object.should_receive(:find).and_return( mock(:size => 19494) )
666
670
 
667
671
  iu.save_s3_file
668
672
  # Now we should have a thumb
@@ -670,7 +674,7 @@ describe ActsAsPhocodable do
670
674
  #puts iu.thumbnails.map{|t| t.thumbnail }.to_json
671
675
  iu.thumbnails.size.should == 2
672
676
  # Mock the AWS reqeust for deleting the file and it's thumbnail
673
- AWS::S3::S3Object.should_receive(:delete).exactly(3).times.and_return(nil)
677
+ @obj.should_receive(:delete).exactly(3).times.and_return(nil)
674
678
  iu.destroy
675
679
  end
676
680
 
@@ -678,7 +682,7 @@ describe ActsAsPhocodable do
678
682
  it "in automatic s3 mode it should save the file to an AWS S3 storage location, call phocoder, then destroy" do
679
683
  ActsAsPhocodable.storeage_mode = "s3"
680
684
  ActsAsPhocodable.processing_mode = "automatic"
681
- ImageUpload.establish_aws_connection
685
+ #ImageUpload.establish_aws_connection
682
686
  #puts "======================================="
683
687
  iu = ImageUpload.new(@attr)
684
688
  Phocoder::Job.stub!(:create).and_return(mock(Phocoder::Response,:body=>{
@@ -690,9 +694,9 @@ describe ActsAsPhocodable do
690
694
  }))
691
695
 
692
696
  # Mock the AWS reqeust for storing
693
- AWS::S3::S3Object.should_receive(:store).and_return(nil)
697
+ @obj.should_receive(:write).and_return(nil)
694
698
  # Mock the AWS request for checking file size
695
- AWS::S3::S3Object.should_receive(:find).and_return( mock(:size => 19494) )
699
+ @obj.should_receive(:content_length).and_return( 19494 )
696
700
  #now store in S3 + phocode
697
701
  iu.save
698
702
  #puts "======================================="
@@ -709,7 +713,7 @@ describe ActsAsPhocodable do
709
713
  # Hopefully...
710
714
  ActsAsPhocodable.storeage_mode = "s3"
711
715
  ActsAsPhocodable.processing_mode = "spawn"
712
- ImageUpload.establish_aws_connection
716
+ #ImageUpload.establish_aws_connection
713
717
 
714
718
  iu = ImageUpload.new(@attr)
715
719
  Phocoder::Job.stub!(:create).and_return(mock(Phocoder::Response,:body=>{
@@ -721,9 +725,9 @@ describe ActsAsPhocodable do
721
725
  }))
722
726
 
723
727
  # Mock the AWS reqeust for storing
724
- AWS::S3::S3Object.should_receive(:store).and_return(nil)
728
+ @obj.should_receive(:write).and_return(nil)
725
729
  # Mock the AWS request for checking file size
726
- AWS::S3::S3Object.should_receive(:find).and_return( mock(:size => 19494) )
730
+ @obj.should_receive(:content_length).and_return( 19494 )
727
731
 
728
732
  #now store in S3 + phocode
729
733
  iu.save
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.56
4
+ version: 0.0.57
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-02-09 00:00:00.000000000 Z
12
+ date: 2013-03-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -76,21 +76,21 @@ dependencies:
76
76
  - !ruby/object:Gem::Version
77
77
  version: 0.1.2
78
78
  - !ruby/object:Gem::Dependency
79
- name: aws-s3
79
+ name: aws-sdk
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
83
- - - ! '>='
83
+ - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: '0'
85
+ version: 1.8.3.1
86
86
  type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
- - - ! '>='
91
+ - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: '0'
93
+ version: 1.8.3.1
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: spawn
96
96
  requirement: !ruby/object:Gem::Requirement
@@ -187,22 +187,6 @@ dependencies:
187
187
  - - ! '>='
188
188
  - !ruby/object:Gem::Version
189
189
  version: '0'
190
- - !ruby/object:Gem::Dependency
191
- name: rspec
192
- requirement: !ruby/object:Gem::Requirement
193
- none: false
194
- requirements:
195
- - - '='
196
- - !ruby/object:Gem::Version
197
- version: 2.4.0
198
- type: :development
199
- prerelease: false
200
- version_requirements: !ruby/object:Gem::Requirement
201
- none: false
202
- requirements:
203
- - - '='
204
- - !ruby/object:Gem::Version
205
- version: 2.4.0
206
190
  - !ruby/object:Gem::Dependency
207
191
  name: rspec-rails
208
192
  requirement: !ruby/object:Gem::Requirement
@@ -210,7 +194,7 @@ dependencies:
210
194
  requirements:
211
195
  - - '='
212
196
  - !ruby/object:Gem::Version
213
- version: 2.4.1
197
+ version: 2.13.0
214
198
  type: :development
215
199
  prerelease: false
216
200
  version_requirements: !ruby/object:Gem::Requirement
@@ -218,7 +202,7 @@ dependencies:
218
202
  requirements:
219
203
  - - '='
220
204
  - !ruby/object:Gem::Version
221
- version: 2.4.1
205
+ version: 2.13.0
222
206
  - !ruby/object:Gem::Dependency
223
207
  name: autotest
224
208
  requirement: !ruby/object:Gem::Requirement
@@ -425,7 +409,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
425
409
  version: '0'
426
410
  segments:
427
411
  - 0
428
- hash: -3998073261859968829
412
+ hash: -832447145253874651
429
413
  required_rubygems_version: !ruby/object:Gem::Requirement
430
414
  none: false
431
415
  requirements:
@@ -434,7 +418,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
434
418
  version: '0'
435
419
  segments:
436
420
  - 0
437
- hash: -3998073261859968829
421
+ hash: -832447145253874651
438
422
  requirements: []
439
423
  rubyforge_project:
440
424
  rubygems_version: 1.8.24