pyramid_scheme 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ begin
13
13
  gem.authors = ["Dan Pickett"]
14
14
  gem.add_dependency "rake", ">= 0.8.7"
15
15
  gem.add_dependency "configatron"
16
- gem.add_dependency "right_aws", ">= 1.10.0"
16
+ gem.add_dependency "aws-s3", ">= 0.5.1"
17
17
  gem.add_development_dependency "rspec", ">= 1.2.9"
18
18
  gem.add_development_dependency "yard", ">= 0"
19
19
  gem.add_development_dependency "mocha", "0.9.8"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
 
4
4
  require 'configatron'
5
- require 'right_aws'
5
+ require 'aws/s3'
6
6
 
7
7
  require 'pyramid_scheme/required_configuration_not_found'
8
8
 
@@ -1,4 +1,3 @@
1
- require "ruby-debug"
2
1
  module PyramidScheme
3
2
  module IndexProvider
4
3
  class S3 < PyramidScheme::IndexProvider::Base
@@ -14,34 +13,35 @@ module PyramidScheme
14
13
  ]
15
14
  end
16
15
 
17
- def connection
18
- @connection ||= RightAws::S3.new(
19
- PyramidScheme.configuration[:access_key],
20
- PyramidScheme.configuration[:secret_access_key]
16
+ def establish_connection!
17
+ @connection ||= AWS::S3::Base.establish_connection!(
18
+ :access_key_id => PyramidScheme.configuration[:access_key],
19
+ :secret_access_key => PyramidScheme.configuration[:secret_access_key]
21
20
  )
22
21
  end
23
22
 
24
- def bucket
25
- @bucket ||= RightAws::S3::Bucket.create(
26
- connection, PyramidScheme.configuration[:bucket])
27
- end
28
23
  end
29
24
 
30
25
  def initialize(options = {})
31
26
  super
27
+ self.class.establish_connection!
32
28
  end
33
29
 
34
30
  def process_index
35
31
  server_copy
36
32
  end
37
-
33
+
38
34
  def provide_client_with_index
39
35
  Configuration::INDEX_FILE_EXTENSIONS.each do |ext|
40
- self.class.bucket.keys('prefix'=> @configuration[:prefix] + "/").each do |obj|
41
- new_filename = File.basename(obj.name.gsub(@configuration[:prefix] + "/", '').gsub(/\./, ".new."))
36
+ AWS::S3::Bucket.objects(@configuration[:bucket],
37
+ :prefix => @configuration[:prefix]).each do |obj|
38
+
39
+ new_filename = File.basename(obj.key.gsub(@configuration[:prefix], '').gsub(/\./, ".new."))
42
40
  destined_path = File.join(@configuration[:client_destination_path], new_filename)
43
41
  File.open(destined_path, 'w') do |file|
44
- file.write obj.data
42
+ AWS::S3::S3Object.stream(obj.key, @configuration[:bucket]) do |chunk|
43
+ file.write chunk
44
+ end
45
45
  end
46
46
  end
47
47
  end
@@ -55,9 +55,10 @@ module PyramidScheme
55
55
  def server_copy
56
56
  Configuration::INDEX_FILE_EXTENSIONS.each do |ext|
57
57
  Dir[File.join(@configuration[:server_source_path], "*#{ext}")].each do |f|
58
- key = RightAws::S3::Key.create(self.class.bucket,
59
- "#{@configuration[:prefix]}/#{File.basename(f)}")
60
- key.put(File.read(f))
58
+ AWS::S3::S3Object.store("#{@configuration[:prefix]}/#{File.basename(f)}",
59
+ File.open(f),
60
+ @configuration[:bucket]
61
+ )
61
62
  end
62
63
  end
63
64
 
@@ -1,28 +1,27 @@
1
1
  module PyramidScheme
2
2
  module Lock
3
3
  class S3 < PyramidScheme::Lock::Base
4
- attr_reader :bucket
5
-
6
4
  def initialize
7
- @bucket = PyramidScheme::IndexProvider::S3.bucket
5
+ PyramidScheme::IndexProvider::S3.establish_connection!
8
6
  end
9
7
 
10
8
  def exists?
11
- key = RightAws::S3::Key.create(bucket, key_name)
12
- key.exists?
9
+ AWS::S3::S3Object.exists?(key_name, bucket)
13
10
  end
14
11
 
15
12
  def create
16
- key = RightAws::S3::Key.create(bucket, key_name)
17
- key.put("")
13
+ AWS::S3::S3Object.store(key_name, "", bucket)
18
14
  end
19
15
 
20
16
  def destroy
21
- key = RightAws::S3::Key.create(bucket, key_name)
22
- key.delete
17
+ AWS::S3::S3Object.delete(key_name, bucket)
23
18
  end
24
19
 
25
20
  protected
21
+ def bucket
22
+ PyramidScheme.configuration[:bucket]
23
+ end
24
+
26
25
  def key_name
27
26
  "#{PyramidScheme.configuration[:prefix]}/#{PyramidScheme.configuration[:lock_file_name]}"
28
27
  end
@@ -43,9 +43,8 @@ describe "S3 index provider" do
43
43
  @provider.process_index
44
44
 
45
45
  @filenames.each do |f|
46
- key = RightAws::S3::Key.create(PyramidScheme::IndexProvider::S3.bucket,
47
- "#{PyramidScheme.configuration[:prefix]}/#{f}")
48
- key.exists?.should be_true
46
+ AWS::S3::S3Object.exists?("#{PyramidScheme.configuration[:prefix]}/#{@filename}",
47
+ PyramidScheme.configuration[:bucket])
49
48
  end
50
49
  end
51
50
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 2
9
- version: 0.2.2
8
+ - 3
9
+ version: 0.2.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Dan Pickett
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-09 00:00:00 -05:00
17
+ date: 2010-03-22 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -44,17 +44,17 @@ dependencies:
44
44
  type: :runtime
45
45
  version_requirements: *id002
46
46
  - !ruby/object:Gem::Dependency
47
- name: right_aws
47
+ name: aws-s3
48
48
  prerelease: false
49
49
  requirement: &id003 !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  segments:
54
- - 1
55
- - 10
56
54
  - 0
57
- version: 1.10.0
55
+ - 5
56
+ - 1
57
+ version: 0.5.1
58
58
  type: :runtime
59
59
  version_requirements: *id003
60
60
  - !ruby/object:Gem::Dependency