targit 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +36 -0
- data/bin/targit +20 -7
- data/lib/targit.rb +1 -0
- data/lib/targit/asset.rb +8 -24
- data/lib/targit/client.rb +22 -0
- data/lib/targit/release.rb +6 -5
- data/lib/targit/version.rb +1 -1
- data/spec/examples/alpha +1 -0
- data/spec/examples/beta +1 -0
- data/spec/fixtures/cassettes/asset_autocreate_release.yml +272 -0
- data/spec/fixtures/cassettes/asset_existence_check_fail.yml +206 -0
- data/spec/fixtures/cassettes/asset_existence_check_pass.yml +206 -0
- data/spec/fixtures/cassettes/asset_metadata_absent.yml +209 -0
- data/spec/fixtures/cassettes/asset_metadata_present.yml +670 -0
- data/spec/fixtures/cassettes/asset_url_absent.yml +405 -0
- data/spec/fixtures/cassettes/asset_url_present.yml +674 -0
- data/spec/fixtures/cassettes/asset_without_release.yml +70 -0
- data/spec/fixtures/cassettes/block_existing_asset.yml +206 -0
- data/spec/fixtures/cassettes/create_new_asset.yml +674 -0
- data/spec/fixtures/cassettes/create_new_release.yml +205 -0
- data/spec/fixtures/cassettes/current_asset.yml +208 -0
- data/spec/fixtures/cassettes/current_io_asset.yml +70 -0
- data/spec/fixtures/cassettes/current_releases.yml +70 -0
- data/spec/fixtures/cassettes/delete_asset.yml +541 -0
- data/spec/fixtures/cassettes/no_release_found.yml +70 -0
- data/spec/fixtures/cassettes/release_object.yml +70 -0
- data/spec/fixtures/cassettes/replace_existing_asset.yml +867 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/targit/asset_spec.rb +212 -0
- data/spec/targit/release_spec.rb +40 -0
- data/spec/targit/version_spec.rb +9 -0
- data/spec/targit_spec.rb +17 -0
- data/targit.gemspec +2 -0
- metadata +78 -4
data/spec/spec_helper.rb
CHANGED
@@ -8,3 +8,21 @@ end
|
|
8
8
|
|
9
9
|
require 'rspec'
|
10
10
|
require 'targit'
|
11
|
+
|
12
|
+
unless File.exist? 'spec/.creds'
|
13
|
+
File.open('spec/.creds', 'w') do |fh|
|
14
|
+
fh << "---\ntargit: sekritkey\n"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'vcr'
|
19
|
+
VCR.configure do |c|
|
20
|
+
c.cassette_library_dir = 'spec/fixtures/cassettes'
|
21
|
+
c.hook_into :webmock
|
22
|
+
c.before_record do |i|
|
23
|
+
i.request.headers.delete 'Authorization'
|
24
|
+
%w(Etag X-Github-Request-Id X-Served-By).each do |header|
|
25
|
+
i.response.headers.delete header
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,212 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Targit do
|
4
|
+
describe Targit::Asset do
|
5
|
+
let(:asset) do
|
6
|
+
VCR.use_cassette('current_asset') do
|
7
|
+
Targit.new(
|
8
|
+
'spec/examples/alpha',
|
9
|
+
'akerl/targit',
|
10
|
+
'testing',
|
11
|
+
authfile: 'spec/.creds',
|
12
|
+
create: true
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
let(:io_asset) do
|
17
|
+
VCR.use_cassette('current_io_asset') do
|
18
|
+
fh = File.open('spec/examples/alpha')
|
19
|
+
Targit.new(
|
20
|
+
fh,
|
21
|
+
'akerl/targit',
|
22
|
+
'testing',
|
23
|
+
authfile: 'spec/.creds',
|
24
|
+
create: true
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'exposes the release object' do
|
30
|
+
expect(asset.release).to be_an_instance_of Targit::Release
|
31
|
+
end
|
32
|
+
it 'exposes the asset attribute' do
|
33
|
+
expect(asset.asset).to eql 'spec/examples/alpha'
|
34
|
+
end
|
35
|
+
it 'exposes the asset name' do
|
36
|
+
expect(asset.name).to eql 'alpha'
|
37
|
+
expect(io_asset.name).to eql 'alpha'
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'does not create a release by default' do
|
41
|
+
VCR.use_cassette('asset_without_release') do
|
42
|
+
expect do
|
43
|
+
Targit.new(
|
44
|
+
'spec/examples/beta',
|
45
|
+
'akerl/targit',
|
46
|
+
'more_testing',
|
47
|
+
authfile: 'spec/.creds'
|
48
|
+
)
|
49
|
+
end.to raise_error RuntimeError, /No release found/
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'can create a new release' do
|
54
|
+
VCR.use_cassette('asset_autocreate_release') do
|
55
|
+
expect do
|
56
|
+
Targit.new(
|
57
|
+
'spec/examples/beta',
|
58
|
+
'akerl/targit',
|
59
|
+
'more_testing',
|
60
|
+
authfile: 'spec/.creds'
|
61
|
+
)
|
62
|
+
end.to raise_error RuntimeError, /No release found/
|
63
|
+
asset = Targit.new(
|
64
|
+
'spec/examples/beta',
|
65
|
+
'akerl/targit',
|
66
|
+
'more_testing',
|
67
|
+
authfile: 'spec/.creds',
|
68
|
+
create: true
|
69
|
+
)
|
70
|
+
expect(asset.release).to be_an_instance_of Targit::Release
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#upload!' do
|
75
|
+
it 'uploads a release asset' do
|
76
|
+
VCR.use_cassette('create_new_asset') do
|
77
|
+
asset = Targit.new(
|
78
|
+
'spec/examples/beta',
|
79
|
+
'akerl/targit',
|
80
|
+
'testing',
|
81
|
+
authfile: 'spec/.creds'
|
82
|
+
)
|
83
|
+
expect { asset.url }.to raise_error RuntimeError, /URL not found/
|
84
|
+
asset.upload!
|
85
|
+
expect(asset.url).to eql 'https://github.com/akerl/targit/releases/download/testing/beta'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
it 'will fail to replace an existing asset by default' do
|
89
|
+
VCR.use_cassette('block_existing_asset') do
|
90
|
+
asset = Targit.new(
|
91
|
+
'spec/examples/beta',
|
92
|
+
'akerl/targit',
|
93
|
+
'testing',
|
94
|
+
authfile: 'spec/.creds'
|
95
|
+
)
|
96
|
+
expect { asset.upload! }.to raise_error RuntimeError, /already exists/
|
97
|
+
end
|
98
|
+
end
|
99
|
+
it 'can replace an existing asset' do
|
100
|
+
VCR.use_cassette('replace_existing_asset') do
|
101
|
+
asset = Targit.new(
|
102
|
+
'spec/examples/beta',
|
103
|
+
'akerl/targit',
|
104
|
+
'testing',
|
105
|
+
authfile: 'spec/.creds',
|
106
|
+
force: true
|
107
|
+
)
|
108
|
+
expect(asset.url).to eql 'https://github.com/akerl/targit/releases/download/testing/beta'
|
109
|
+
asset.upload!
|
110
|
+
expect(asset.url).to eql 'https://github.com/akerl/targit/releases/download/testing/beta'
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe '#already_exists?' do
|
116
|
+
it 'returns true if the asset is on GitHub' do
|
117
|
+
VCR.use_cassette('asset_existence_check_pass') do
|
118
|
+
asset = Targit.new(
|
119
|
+
'spec/examples/beta',
|
120
|
+
'akerl/targit',
|
121
|
+
'testing',
|
122
|
+
authfile: 'spec/.creds'
|
123
|
+
)
|
124
|
+
expect(asset.already_exists?).to be_truthy
|
125
|
+
end
|
126
|
+
end
|
127
|
+
it 'returns false if the asset is not on GitHub' do
|
128
|
+
VCR.use_cassette('asset_existence_check_fail') do
|
129
|
+
asset = Targit.new(
|
130
|
+
'spec/examples/charlie',
|
131
|
+
'akerl/targit',
|
132
|
+
'testing',
|
133
|
+
authfile: 'spec/.creds'
|
134
|
+
)
|
135
|
+
expect(asset.already_exists?).to be_falsey
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe '#delete!' do
|
141
|
+
it 'removes the asset from GitHub' do
|
142
|
+
VCR.use_cassette('delete_asset') do
|
143
|
+
asset = Targit.new(
|
144
|
+
'spec/examples/beta',
|
145
|
+
'akerl/targit',
|
146
|
+
'testing',
|
147
|
+
authfile: 'spec/.creds'
|
148
|
+
)
|
149
|
+
expect(asset.already_exists?).to be_truthy
|
150
|
+
asset.delete!
|
151
|
+
expect(asset.already_exists?).to be_falsey
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe '#github_data' do
|
157
|
+
it 'returns the GitHub metadata for this asset' do
|
158
|
+
VCR.use_cassette('asset_metadata_present') do
|
159
|
+
asset = Targit.new(
|
160
|
+
'spec/examples/beta',
|
161
|
+
'akerl/targit',
|
162
|
+
'meta_testing',
|
163
|
+
authfile: 'spec/.creds',
|
164
|
+
create: true
|
165
|
+
)
|
166
|
+
asset.upload!
|
167
|
+
expect(asset.github_data[:name]).to eql 'beta'
|
168
|
+
end
|
169
|
+
end
|
170
|
+
it 'returns nil if the asset is not on GitHub' do
|
171
|
+
VCR.use_cassette('asset_metadata_absent') do
|
172
|
+
asset = Targit.new(
|
173
|
+
'spec/examples/charlie',
|
174
|
+
'akerl/targit',
|
175
|
+
'testing',
|
176
|
+
authfile: 'spec/.creds'
|
177
|
+
)
|
178
|
+
expect(asset.github_data).to be_nil
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe '#url' do
|
184
|
+
it 'returns the download URL if the asset is on GitHub' do
|
185
|
+
VCR.use_cassette('asset_url_present') do
|
186
|
+
asset = Targit.new(
|
187
|
+
'spec/examples/beta',
|
188
|
+
'akerl/targit',
|
189
|
+
'testing',
|
190
|
+
authfile: 'spec/.creds',
|
191
|
+
force: true
|
192
|
+
)
|
193
|
+
asset.upload!
|
194
|
+
expect(asset.url).to eql 'https://github.com/akerl/targit/releases/download/testing/beta'
|
195
|
+
end
|
196
|
+
end
|
197
|
+
it 'raises if the asset is not on GitHub' do
|
198
|
+
VCR.use_cassette('asset_url_absent') do
|
199
|
+
asset = Targit.new(
|
200
|
+
'spec/examples/beta',
|
201
|
+
'akerl/targit',
|
202
|
+
'testing',
|
203
|
+
authfile: 'spec/.creds',
|
204
|
+
create: true
|
205
|
+
)
|
206
|
+
asset.delete!
|
207
|
+
expect { asset.url }.to raise_error RuntimeError, /URL not found/
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Targit do
|
4
|
+
describe Targit::Release do
|
5
|
+
let(:basic_release) do
|
6
|
+
VCR.use_cassette('release_object') do
|
7
|
+
Targit::Release.new 'akerl/targit', 'testing', authfile: 'spec/.creds'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'exposes the release object' do
|
12
|
+
expect(basic_release.data[:tag_name]).to eql 'testing'
|
13
|
+
end
|
14
|
+
it 'exposes the repo name' do
|
15
|
+
expect(basic_release.repo).to eql 'akerl/targit'
|
16
|
+
end
|
17
|
+
it 'exposes the tag name' do
|
18
|
+
expect(basic_release.tag).to eql 'testing'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'does not create a new release by default' do
|
22
|
+
VCR.use_cassette('no_release_found') do
|
23
|
+
expect do
|
24
|
+
Targit::Release.new(
|
25
|
+
'akerl/targit', 'new_release', authfile: 'spec/.creds'
|
26
|
+
)
|
27
|
+
end.to raise_error RuntimeError, /No release found/
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'creates the repo if called with :create = true' do
|
32
|
+
VCR.use_cassette('create_new_release') do
|
33
|
+
release = Targit::Release.new(
|
34
|
+
'akerl/targit', 'new_release', create: true, authfile: 'spec/.creds'
|
35
|
+
)
|
36
|
+
expect(release.repo).to eql 'akerl/targit'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/spec/targit_spec.rb
CHANGED
@@ -1 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Targit do
|
4
|
+
describe '#new' do
|
5
|
+
it 'creates Asset objects' do
|
6
|
+
VCR.use_cassette('current_releases') do
|
7
|
+
asset = Targit.new(
|
8
|
+
'spec/examples/alpha',
|
9
|
+
'akerl/targit',
|
10
|
+
'testing',
|
11
|
+
authfile: 'spec/.creds',
|
12
|
+
create: true
|
13
|
+
)
|
14
|
+
expect(asset).to be_an_instance_of Targit::Asset
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/targit.gemspec
CHANGED
@@ -27,4 +27,6 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_development_dependency 'coveralls', '~> 0.7.0'
|
28
28
|
s.add_development_dependency 'rspec', '~> 3.0.0'
|
29
29
|
s.add_development_dependency 'fuubar', '~> 2.0.0.rc1'
|
30
|
+
s.add_development_dependency 'webmock', '~> 1.18.0'
|
31
|
+
s.add_development_dependency 'vcr', '~> 2.9.2'
|
30
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: targit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.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: 2014-07-
|
11
|
+
date: 2014-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -136,6 +136,34 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 2.0.0.rc1
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: webmock
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 1.18.0
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 1.18.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: vcr
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 2.9.2
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 2.9.2
|
139
167
|
description: Manages GitHub release assets for pushing binaries and other large files
|
140
168
|
email: me@lesaker.org
|
141
169
|
executables:
|
@@ -154,9 +182,33 @@ files:
|
|
154
182
|
- bin/targit
|
155
183
|
- lib/targit.rb
|
156
184
|
- lib/targit/asset.rb
|
185
|
+
- lib/targit/client.rb
|
157
186
|
- lib/targit/release.rb
|
158
187
|
- lib/targit/version.rb
|
188
|
+
- spec/examples/alpha
|
189
|
+
- spec/examples/beta
|
190
|
+
- spec/fixtures/cassettes/asset_autocreate_release.yml
|
191
|
+
- spec/fixtures/cassettes/asset_existence_check_fail.yml
|
192
|
+
- spec/fixtures/cassettes/asset_existence_check_pass.yml
|
193
|
+
- spec/fixtures/cassettes/asset_metadata_absent.yml
|
194
|
+
- spec/fixtures/cassettes/asset_metadata_present.yml
|
195
|
+
- spec/fixtures/cassettes/asset_url_absent.yml
|
196
|
+
- spec/fixtures/cassettes/asset_url_present.yml
|
197
|
+
- spec/fixtures/cassettes/asset_without_release.yml
|
198
|
+
- spec/fixtures/cassettes/block_existing_asset.yml
|
199
|
+
- spec/fixtures/cassettes/create_new_asset.yml
|
200
|
+
- spec/fixtures/cassettes/create_new_release.yml
|
201
|
+
- spec/fixtures/cassettes/current_asset.yml
|
202
|
+
- spec/fixtures/cassettes/current_io_asset.yml
|
203
|
+
- spec/fixtures/cassettes/current_releases.yml
|
204
|
+
- spec/fixtures/cassettes/delete_asset.yml
|
205
|
+
- spec/fixtures/cassettes/no_release_found.yml
|
206
|
+
- spec/fixtures/cassettes/release_object.yml
|
207
|
+
- spec/fixtures/cassettes/replace_existing_asset.yml
|
159
208
|
- spec/spec_helper.rb
|
209
|
+
- spec/targit/asset_spec.rb
|
210
|
+
- spec/targit/release_spec.rb
|
211
|
+
- spec/targit/version_spec.rb
|
160
212
|
- spec/targit_spec.rb
|
161
213
|
- targit.gemspec
|
162
214
|
homepage: https://github.com/akerl/targit
|
@@ -179,11 +231,33 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
231
|
version: '0'
|
180
232
|
requirements: []
|
181
233
|
rubyforge_project:
|
182
|
-
rubygems_version: 2.
|
234
|
+
rubygems_version: 2.2.2
|
183
235
|
signing_key:
|
184
236
|
specification_version: 4
|
185
237
|
summary: Tool for adding GitHub release assets
|
186
238
|
test_files:
|
239
|
+
- spec/examples/alpha
|
240
|
+
- spec/examples/beta
|
241
|
+
- spec/fixtures/cassettes/asset_autocreate_release.yml
|
242
|
+
- spec/fixtures/cassettes/asset_existence_check_fail.yml
|
243
|
+
- spec/fixtures/cassettes/asset_existence_check_pass.yml
|
244
|
+
- spec/fixtures/cassettes/asset_metadata_absent.yml
|
245
|
+
- spec/fixtures/cassettes/asset_metadata_present.yml
|
246
|
+
- spec/fixtures/cassettes/asset_url_absent.yml
|
247
|
+
- spec/fixtures/cassettes/asset_url_present.yml
|
248
|
+
- spec/fixtures/cassettes/asset_without_release.yml
|
249
|
+
- spec/fixtures/cassettes/block_existing_asset.yml
|
250
|
+
- spec/fixtures/cassettes/create_new_asset.yml
|
251
|
+
- spec/fixtures/cassettes/create_new_release.yml
|
252
|
+
- spec/fixtures/cassettes/current_asset.yml
|
253
|
+
- spec/fixtures/cassettes/current_io_asset.yml
|
254
|
+
- spec/fixtures/cassettes/current_releases.yml
|
255
|
+
- spec/fixtures/cassettes/delete_asset.yml
|
256
|
+
- spec/fixtures/cassettes/no_release_found.yml
|
257
|
+
- spec/fixtures/cassettes/release_object.yml
|
258
|
+
- spec/fixtures/cassettes/replace_existing_asset.yml
|
187
259
|
- spec/spec_helper.rb
|
260
|
+
- spec/targit/asset_spec.rb
|
261
|
+
- spec/targit/release_spec.rb
|
262
|
+
- spec/targit/version_spec.rb
|
188
263
|
- spec/targit_spec.rb
|
189
|
-
has_rdoc:
|