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 +1 -1
- data/VERSION +1 -1
- data/lib/pyramid_scheme.rb +1 -1
- data/lib/pyramid_scheme/index_provider/s3.rb +17 -16
- data/lib/pyramid_scheme/lock/s3.rb +8 -9
- data/spec/integrations/s3_spec.rb +2 -3
- metadata +7 -7
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 "
|
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.
|
1
|
+
0.2.3
|
data/lib/pyramid_scheme.rb
CHANGED
@@ -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
|
18
|
-
@connection ||=
|
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
|
-
|
41
|
-
|
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
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
5
|
+
PyramidScheme::IndexProvider::S3.establish_connection!
|
8
6
|
end
|
9
7
|
|
10
8
|
def exists?
|
11
|
-
|
12
|
-
key.exists?
|
9
|
+
AWS::S3::S3Object.exists?(key_name, bucket)
|
13
10
|
end
|
14
11
|
|
15
12
|
def create
|
16
|
-
|
17
|
-
key.put("")
|
13
|
+
AWS::S3::S3Object.store(key_name, "", bucket)
|
18
14
|
end
|
19
15
|
|
20
16
|
def destroy
|
21
|
-
|
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
|
-
|
47
|
-
|
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
|
-
-
|
9
|
-
version: 0.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-
|
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:
|
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
|
-
|
55
|
+
- 5
|
56
|
+
- 1
|
57
|
+
version: 0.5.1
|
58
58
|
type: :runtime
|
59
59
|
version_requirements: *id003
|
60
60
|
- !ruby/object:Gem::Dependency
|