pyramid_scheme 0.2.0 → 0.2.1

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 "aws-s3", ">= 0.5.1"
16
+ gem.add_dependency "right_aws", ">= 1.10.0"
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.0
1
+ 0.2.1
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
 
4
4
  require 'configatron'
5
- require 'aws/s3'
5
+ require 'right_aws'
6
6
 
7
7
  require 'pyramid_scheme/required_configuration_not_found'
8
8
 
@@ -1,3 +1,4 @@
1
+ require "ruby-debug"
1
2
  module PyramidScheme
2
3
  module IndexProvider
3
4
  class S3 < PyramidScheme::IndexProvider::Base
@@ -13,35 +14,34 @@ module PyramidScheme
13
14
  ]
14
15
  end
15
16
 
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]
17
+ def connection
18
+ @connection ||= RightAws::S3.new(
19
+ PyramidScheme.configuration[:access_key],
20
+ PyramidScheme.configuration[:secret_access_key]
20
21
  )
21
22
  end
22
23
 
24
+ def bucket
25
+ @bucket ||= RightAws::S3::Bucket.create(
26
+ connection, PyramidScheme.configuration[:bucket])
27
+ end
23
28
  end
24
29
 
25
30
  def initialize(options = {})
26
31
  super
27
- self.class.establish_connection!
28
32
  end
29
33
 
30
34
  def process_index
31
35
  server_copy
32
36
  end
33
-
37
+
34
38
  def provide_client_with_index
35
39
  Configuration::INDEX_FILE_EXTENSIONS.each do |ext|
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."))
40
+ self.class.bucket.keys('prefix'=> @configuration[:prefix]).each do |obj|
41
+ new_filename = File.basename(obj.name.gsub(@configuration[:prefix], '').gsub(/\./, ".new."))
40
42
  destined_path = File.join(@configuration[:client_destination_path], new_filename)
41
43
  File.open(destined_path, 'w') do |file|
42
- AWS::S3::S3Object.stream(obj.key, @configuration[:bucket]) do |chunk|
43
- file.write chunk
44
- end
44
+ file.write obj.data
45
45
  end
46
46
  end
47
47
  end
@@ -55,10 +55,9 @@ 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
- AWS::S3::S3Object.store("#{@configuration[:prefix]}/#{File.basename(f)}",
59
- File.open(f),
60
- @configuration[:bucket]
61
- )
58
+ key = RightAws::S3::Key.create(self.class.bucket,
59
+ "#{@configuration[:prefix]}/#{File.basename(f)}")
60
+ key.put(File.read(f))
62
61
  end
63
62
  end
64
63
 
@@ -1,27 +1,28 @@
1
1
  module PyramidScheme
2
2
  module Lock
3
3
  class S3 < PyramidScheme::Lock::Base
4
+ attr_reader :bucket
5
+
4
6
  def initialize
5
- PyramidScheme::IndexProvider::S3.establish_connection!
7
+ @bucket = PyramidScheme::IndexProvider::S3.bucket
6
8
  end
7
9
 
8
10
  def exists?
9
- AWS::S3::S3Object.exists?(key_name, bucket)
11
+ key = RightAws::S3::Key.create(bucket, key_name)
12
+ key.exists?
10
13
  end
11
14
 
12
15
  def create
13
- AWS::S3::S3Object.store(key_name, "", bucket)
16
+ key = RightAws::S3::Key.create(bucket, key_name)
17
+ key.put("")
14
18
  end
15
19
 
16
20
  def destroy
17
- AWS::S3::S3Object.delete(key_name, bucket)
21
+ key = RightAws::S3::Key.create(bucket, key_name)
22
+ key.delete
18
23
  end
19
24
 
20
25
  protected
21
- def bucket
22
- PyramidScheme.configuration[:bucket]
23
- end
24
-
25
26
  def key_name
26
27
  "#{PyramidScheme.configuration[:prefix]}/#{PyramidScheme.configuration[:lock_file_name]}"
27
28
  end
@@ -43,8 +43,9 @@ describe "S3 index provider" do
43
43
  @provider.process_index
44
44
 
45
45
  @filenames.each do |f|
46
- AWS::S3::S3Object.exists?("#{PyramidScheme.configuration[:prefix]}/#{@filename}",
47
- PyramidScheme.configuration[:bucket])
46
+ key = RightAws::S3::Key.create(PyramidScheme::IndexProvider::S3.bucket,
47
+ "#{PyramidScheme.configuration[:prefix]}/#{f}")
48
+ key.exists?.should be_true
48
49
  end
49
50
  end
50
51
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
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-08 00:00:00 -05:00
17
+ date: 2010-03-09 00:00:00 -05: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: aws-s3
47
+ name: right_aws
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
- - 0
55
- - 5
56
54
  - 1
57
- version: 0.5.1
55
+ - 10
56
+ - 0
57
+ version: 1.10.0
58
58
  type: :runtime
59
59
  version_requirements: *id003
60
60
  - !ruby/object:Gem::Dependency