s3repo 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circle-ruby +3 -0
- data/.prospectus +21 -7
- data/.rubocop.yml +5 -2
- data/Gemfile +0 -1
- data/README.md +1 -1
- data/Rakefile +1 -2
- data/bin/s3repo +31 -8
- data/circle.yml +7 -4
- data/lib/s3repo.rb +2 -0
- data/lib/s3repo/base.rb +4 -8
- data/lib/s3repo/cache.rb +13 -10
- data/lib/s3repo/client.rb +21 -8
- data/lib/s3repo/metadata.rb +12 -24
- data/lib/s3repo/repo.rb +17 -15
- data/lib/s3repo/signer.rb +17 -0
- data/lib/s3repo/templates.rb +52 -0
- data/lib/s3repo/version.rb +2 -1
- data/s3repo.gemspec +12 -9
- data/spec/spec_helper.rb +3 -0
- metadata +48 -27
- data/spec/fixtures/cassettes/cache.yml +0 -547
- data/spec/fixtures/cassettes/etag_cache.yml +0 -590
- data/spec/fixtures/cassettes/nil_cache.yml +0 -46
- data/spec/s3repo/base_spec.rb +0 -71
- data/spec/s3repo/cache_spec.rb +0 -48
@@ -1,46 +0,0 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
4
|
-
method: get
|
5
|
-
uri: https://amylum.s3.amazonaws.com/nonexistent-file
|
6
|
-
body:
|
7
|
-
encoding: ASCII-8BIT
|
8
|
-
string: ''
|
9
|
-
headers:
|
10
|
-
Content-Type:
|
11
|
-
- ''
|
12
|
-
Accept-Encoding:
|
13
|
-
- ''
|
14
|
-
User-Agent:
|
15
|
-
- aws-sdk-ruby2/2.1.29 ruby/2.2.3 x86_64-darwin15
|
16
|
-
Date:
|
17
|
-
- Tue, 20 Oct 2015 04:09:17 GMT
|
18
|
-
Content-Length:
|
19
|
-
- '0'
|
20
|
-
Accept:
|
21
|
-
- "*/*"
|
22
|
-
response:
|
23
|
-
status:
|
24
|
-
code: 404
|
25
|
-
message: Not Found
|
26
|
-
headers:
|
27
|
-
X-Amz-Request-Id:
|
28
|
-
- 9912CC9008F75725
|
29
|
-
X-Amz-Id-2:
|
30
|
-
- hCk6ZeuNM8sfiCQjllSr+M79BFlQ2x1/iv1osCzYXo1nlUiqjRNMWnlz6EfmTPJQ
|
31
|
-
Content-Type:
|
32
|
-
- application/xml
|
33
|
-
Transfer-Encoding:
|
34
|
-
- chunked
|
35
|
-
Date:
|
36
|
-
- Tue, 20 Oct 2015 04:09:17 GMT
|
37
|
-
Server:
|
38
|
-
- AmazonS3
|
39
|
-
body:
|
40
|
-
encoding: UTF-8
|
41
|
-
string: |-
|
42
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
43
|
-
<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>nonexistent-file</Key><RequestId>9912CC9008F75725</RequestId><HostId>hCk6ZeuNM8sfiCQjllSr+M79BFlQ2x1/iv1osCzYXo1nlUiqjRNMWnlz6EfmTPJQ</HostId></Error>
|
44
|
-
http_version:
|
45
|
-
recorded_at: Tue, 20 Oct 2015 04:09:18 GMT
|
46
|
-
recorded_with: VCR 2.9.3
|
data/spec/s3repo/base_spec.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe S3Repo::Base do
|
4
|
-
it 'accepts a parameter hash' do
|
5
|
-
expect(S3Repo::Base.new({})).to be_an_instance_of S3Repo::Base
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'has a private run method' do
|
9
|
-
expect(subject.respond_to?(:run)).to be_falsey
|
10
|
-
end
|
11
|
-
it 'runs commands and returns their output' do
|
12
|
-
expect(subject.send(:run, 'echo winner')).to eql "winner\n"
|
13
|
-
end
|
14
|
-
it 'raises if the run fails' do
|
15
|
-
expect { subject.send(:run, 'false') }.to raise_exception RuntimeError
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'has a private bucket param' do
|
19
|
-
expect(subject.respond_to?(:bucket)).to be_falsey
|
20
|
-
end
|
21
|
-
describe 'provided bucket param' do
|
22
|
-
it 'uses bucket from option' do
|
23
|
-
expect(S3Repo::Base.new(bucket: 'foo').send(:bucket)).to eql 'foo'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
describe 'bucket set in ENV' do
|
27
|
-
it 'uses bucket from ENV' do
|
28
|
-
ClimateControl.modify S3_BUCKET: 'bar' do
|
29
|
-
expect(S3Repo::Base.new.send(:bucket)).to eql 'bar'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
describe 'no bucket set' do
|
34
|
-
it 'raises an error' do
|
35
|
-
expect { S3Repo::Base.new.send(:bucket) }.to raise_exception RuntimeError
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'has a private client method' do
|
40
|
-
expect(subject.respond_to?(:client)).to be_falsey
|
41
|
-
end
|
42
|
-
describe 'a provided client' do
|
43
|
-
it 'reuses the client' do
|
44
|
-
expect(S3Repo::Base.new(client: 'foo').send(:client)).to eql 'foo'
|
45
|
-
end
|
46
|
-
end
|
47
|
-
describe 'no provided client' do
|
48
|
-
it 'creates the client' do
|
49
|
-
ClimateControl.modify AWS_REGION: 'us-east-1' do
|
50
|
-
base = S3Repo::Base.new(bucket: 'foo')
|
51
|
-
expect(base.send(:client)).to be_an_instance_of S3Repo::Client
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'has a private file_cache method' do
|
57
|
-
expect(subject.respond_to?(:file_cache)).to be_falsey
|
58
|
-
end
|
59
|
-
describe 'a provided file_cache' do
|
60
|
-
it 'reuses the file_cache' do
|
61
|
-
base = S3Repo::Base.new(client: 'bar', file_cache: 'foo')
|
62
|
-
expect(base.send(:file_cache)).to eql 'foo'
|
63
|
-
end
|
64
|
-
end
|
65
|
-
describe 'no provided file_cache' do
|
66
|
-
it 'creates the file_cache' do
|
67
|
-
base = S3Repo::Base.new(client: 'foo')
|
68
|
-
expect(base.send(:file_cache)).to be_an_instance_of S3Repo::Cache
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
data/spec/s3repo/cache_spec.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe S3Repo::Cache do
|
4
|
-
it 'serves a file', vcr: { cassette_name: 'cache' } do
|
5
|
-
with_auth do
|
6
|
-
resp = S3Repo::Cache.new.serve('repo.db')
|
7
|
-
expect(resp).to be_an_instance_of String
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
context 'by default' do
|
12
|
-
it 'tries to cache the file', vcr: { cassette_name: 'cache' } do
|
13
|
-
with_auth do
|
14
|
-
cache = S3Repo::Cache.new
|
15
|
-
cache.serve('repo.db')
|
16
|
-
expect { cache.serve('repo.db') }.to raise_exception(
|
17
|
-
VCR::Errors::UnhandledHTTPRequestError
|
18
|
-
)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
it 'checks etag for caching', vcr: { cassette_name: 'etag_cache' } do
|
22
|
-
with_auth do
|
23
|
-
cache = S3Repo::Cache.new
|
24
|
-
res = (1..2).map do
|
25
|
-
cache.serve('repo.db')
|
26
|
-
cache.send(:etags)['repo.db']
|
27
|
-
end
|
28
|
-
expect(res.first).to eql res.last
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
context 'with refresh = false' do
|
33
|
-
it 'caches the file', vcr: { cassette_name: 'cache' } do
|
34
|
-
with_auth do
|
35
|
-
cache = S3Repo::Cache.new
|
36
|
-
cache.serve('repo.db')
|
37
|
-
expect(cache.serve('repo.db', false)).to be_an_instance_of String
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'returns nil if key does not exist', vcr: { cassette_name: 'nil_cache' } do
|
43
|
-
with_auth do
|
44
|
-
cache = S3Repo::Cache.new
|
45
|
-
expect(cache.serve('nonexistent-file')).to be_nil
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|