s3repo 0.3.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.prospectus +11 -0
- data/CHANGELOG.md +4 -0
- data/README.md +62 -3
- data/bin/s3repo +2 -2
- data/circle.yml +8 -0
- data/lib/s3repo/cache.rb +7 -2
- data/lib/s3repo/client.rb +1 -1
- data/lib/s3repo/repo.rb +11 -9
- data/lib/s3repo/version.rb +2 -1
- data/s3repo.gemspec +8 -5
- data/spec/fixtures/cassettes/cache.yml +547 -0
- data/spec/fixtures/cassettes/etag_cache.yml +590 -0
- data/spec/fixtures/cassettes/nil_cache.yml +46 -0
- data/spec/s3repo/base_spec.rb +71 -0
- data/spec/s3repo/cache_spec.rb +48 -0
- data/spec/s3repo_spec.rb +8 -0
- data/spec/spec_helper.rb +29 -6
- metadata +69 -15
- data/.travis.yml +0 -14
@@ -0,0 +1,71 @@
|
|
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
|
@@ -0,0 +1,48 @@
|
|
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
|
data/spec/s3repo_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,33 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
|
4
|
-
SimpleCov.formatter =
|
5
|
-
SimpleCov.start do
|
6
|
-
|
1
|
+
if ENV['CI'] == 'true'
|
2
|
+
require 'simplecov'
|
3
|
+
require 'codecov'
|
4
|
+
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
5
|
+
SimpleCov.start do
|
6
|
+
add_filter '/spec/'
|
7
|
+
end
|
7
8
|
end
|
8
9
|
|
9
10
|
require 'rspec'
|
10
11
|
require 's3repo'
|
12
|
+
|
13
|
+
require 'vcr'
|
14
|
+
VCR.configure do |c|
|
15
|
+
c.cassette_library_dir = 'spec/fixtures/cassettes'
|
16
|
+
c.hook_into :webmock
|
17
|
+
c.configure_rspec_metadata!
|
18
|
+
c.before_record do |i|
|
19
|
+
i.request.headers.delete 'Authorization'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'climate_control'
|
24
|
+
AUTH_OPTS = {
|
25
|
+
S3_BUCKET: 'amylum',
|
26
|
+
AWS_REGION: 'us-east-1',
|
27
|
+
AWS_SECRET_ACCESS_KEY: 'accesskey',
|
28
|
+
AWS_ACCESS_KEY_ID: 'sekritkey'
|
29
|
+
}.freeze
|
30
|
+
def with_auth(&block)
|
31
|
+
opts = AUTH_OPTS.dup.map { |k, v| [k, ENV.fetch("REAL_#{k}", v)] }
|
32
|
+
ClimateControl.modify(Hash[opts], &block)
|
33
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3repo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Les Aker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mercenary
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.2.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
40
|
+
version: 2.2.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: basiccache
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,56 +58,56 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.36.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.36.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 10.
|
75
|
+
version: 10.5.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 10.
|
82
|
+
version: 10.5.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: codecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.1.1
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.1.1
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 3.
|
103
|
+
version: 3.4.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 3.
|
110
|
+
version: 3.4.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: fuubar
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +122,48 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 2.0.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: webmock
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.22.0
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.22.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: vcr
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 3.0.0
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 3.0.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: climate_control
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.0.3
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.0.3
|
125
167
|
description: Simple library for interacting with Archlinux repos in S3
|
126
168
|
email: me@lesaker.org
|
127
169
|
executables:
|
@@ -130,14 +172,16 @@ extensions: []
|
|
130
172
|
extra_rdoc_files: []
|
131
173
|
files:
|
132
174
|
- ".gitignore"
|
175
|
+
- ".prospectus"
|
133
176
|
- ".rspec"
|
134
177
|
- ".rubocop.yml"
|
135
|
-
-
|
178
|
+
- CHANGELOG.md
|
136
179
|
- Gemfile
|
137
180
|
- LICENSE
|
138
181
|
- README.md
|
139
182
|
- Rakefile
|
140
183
|
- bin/s3repo
|
184
|
+
- circle.yml
|
141
185
|
- lib/s3repo.rb
|
142
186
|
- lib/s3repo/base.rb
|
143
187
|
- lib/s3repo/cache.rb
|
@@ -146,6 +190,11 @@ files:
|
|
146
190
|
- lib/s3repo/repo.rb
|
147
191
|
- lib/s3repo/version.rb
|
148
192
|
- s3repo.gemspec
|
193
|
+
- spec/fixtures/cassettes/cache.yml
|
194
|
+
- spec/fixtures/cassettes/etag_cache.yml
|
195
|
+
- spec/fixtures/cassettes/nil_cache.yml
|
196
|
+
- spec/s3repo/base_spec.rb
|
197
|
+
- spec/s3repo/cache_spec.rb
|
149
198
|
- spec/s3repo_spec.rb
|
150
199
|
- spec/spec_helper.rb
|
151
200
|
homepage: https://github.com/amylum/s3repo
|
@@ -168,10 +217,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
217
|
version: '0'
|
169
218
|
requirements: []
|
170
219
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.
|
220
|
+
rubygems_version: 2.5.1
|
172
221
|
signing_key:
|
173
222
|
specification_version: 4
|
174
223
|
summary: S3 Archlinux repo library
|
175
224
|
test_files:
|
225
|
+
- spec/fixtures/cassettes/cache.yml
|
226
|
+
- spec/fixtures/cassettes/etag_cache.yml
|
227
|
+
- spec/fixtures/cassettes/nil_cache.yml
|
228
|
+
- spec/s3repo/base_spec.rb
|
229
|
+
- spec/s3repo/cache_spec.rb
|
176
230
|
- spec/s3repo_spec.rb
|
177
231
|
- spec/spec_helper.rb
|
data/.travis.yml
DELETED