dpl-bintray 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cddd0cf19cca0575252a19a50cf88d599ce64bc9
4
+ data.tar.gz: a03313e0b25aa0715180d224eef2fbf3cc9b4ff5
5
+ SHA512:
6
+ metadata.gz: a25a34024925c0484230428d56da872443b826dcf2209f18448b9d7120c9034e10d7a348b0571272750e05c2a8eb396f0e6fc6d7cf88d4359b04427dd8f8a39b
7
+ data.tar.gz: '085787918de2cbdd435b3646dd9a76e0d6a4cb8544c9727a68e4afbc398b01f14659702f076d6cd570133dba5509de996b69cf6521dfce54fae2654822f34c2f'
@@ -0,0 +1,3 @@
1
+ require './gemspec_helper'
2
+
3
+ gemspec_for 'bintray'
@@ -0,0 +1,501 @@
1
+ require 'json'
2
+ require 'net/http'
3
+ require "uri"
4
+ require 'find'
5
+
6
+ module DPL
7
+ class Provider
8
+ class Bintray < Provider
9
+ def check_auth
10
+ @user = option(:user)
11
+ @key = option(:key)
12
+ @url = option(:url)
13
+ end
14
+
15
+ def needs_key?
16
+ false
17
+ end
18
+
19
+ attr_accessor :test_mode
20
+ attr_reader :user
21
+ attr_reader :key
22
+ attr_reader :file
23
+ attr_reader :passphrase
24
+ attr_reader :url
25
+ attr_reader :dry_run
26
+ attr_reader :descriptor
27
+
28
+ def initialize(*args)
29
+ super(*args)
30
+ @test_mode = false
31
+
32
+ @file = options[:file]
33
+ @passphrase = options[:passphrase]
34
+ @dry_run = options[:dry_run]
35
+
36
+ if @url.nil?
37
+ @url = 'https://api.bintray.com'
38
+ end
39
+ if @dry_run.nil?
40
+ @dry_run = false
41
+ end
42
+ end
43
+
44
+ def read_descriptor
45
+ log "Reading descriptor file: #{file}"
46
+ @descriptor = JSON.parse(File.read(file))
47
+ end
48
+
49
+ def descriptor=(json)
50
+ @descriptor = JSON.parse(json)
51
+ end
52
+
53
+ def head_request(path)
54
+ url = URI.parse(self.url)
55
+ req = Net::HTTP::Head.new(path)
56
+ req.basic_auth user, key
57
+
58
+ sock = Net::HTTP.new(url.host, url.port)
59
+ sock.use_ssl = true
60
+ res = sock.start {|http| http.request(req) }
61
+
62
+ return res
63
+ end
64
+
65
+ def post_request(path, body)
66
+ req = Net::HTTP::Post.new(path)
67
+ req.add_field('Content-Type', 'application/json')
68
+ req.basic_auth user, key
69
+ if !body.nil?
70
+ req.body = body.to_json
71
+ end
72
+
73
+ url = URI.parse(self.url)
74
+ sock = Net::HTTP.new(url.host, url.port)
75
+ sock.use_ssl = true
76
+ res = sock.start {|http| http.request(req) }
77
+ return res
78
+ end
79
+
80
+ def put_file_request(local_file_path, upload_path, matrix_params)
81
+ url = URI.parse(self.url)
82
+
83
+ file = File.open(local_file_path, 'rb')
84
+ data = file.read()
85
+ http = Net::HTTP.new(url.host, url.port)
86
+ http.use_ssl = true
87
+
88
+ params = ''
89
+ if !matrix_params.nil?
90
+ matrix_params.each do |key, val|
91
+ params << ";#{key}=#{val}"
92
+ end
93
+ upload_path << params
94
+ end
95
+
96
+ request = Net::HTTP::Put.new("#{upload_path}")
97
+ request.basic_auth user, key
98
+ request.body = data
99
+
100
+ return http.request(request)
101
+ end
102
+
103
+ def upload_file(artifact)
104
+ log "Uploading file '#{artifact.local_path}' to #{artifact.upload_path}"
105
+
106
+ if dry_run
107
+ return
108
+ end
109
+
110
+ package = descriptor["package"]
111
+ version = descriptor["version"]
112
+ package_name = package["name"]
113
+ subject = package["subject"]
114
+ repo = package["repo"]
115
+ version_name = version["name"]
116
+
117
+ path = "/content/#{subject}/#{repo}/#{package_name}/#{version_name}/#{artifact.upload_path}"
118
+ res = put_file_request(artifact.local_path, path, artifact.matrix_params)
119
+ log_bintray_response(res)
120
+ end
121
+
122
+ def package_exists_path
123
+ package = descriptor["package"]
124
+ subject = package["subject"]
125
+ name = package["name"]
126
+ repo = package["repo"]
127
+ return "/packages/#{subject}/#{repo}/#{name}"
128
+ end
129
+
130
+ def package_exists?
131
+ path = package_exists_path
132
+ if !dry_run
133
+ res = head_request(path)
134
+ code = res.code.to_i
135
+ else
136
+ code = 404
137
+ end
138
+
139
+ if code == 404
140
+ return false
141
+ end
142
+ if code == 201 || code == 200
143
+ return true
144
+ end
145
+ name = descriptor["package"]["name"]
146
+ abort("Unexpected HTTP response code #{code} returned from Bintray while checking if package '#{name}' exists. " +
147
+ "Response message: #{res.message}")
148
+ end
149
+
150
+ def version_exists_path
151
+ package = descriptor["package"]
152
+ version = descriptor["version"]
153
+ package_name = package["name"]
154
+ subject = package["subject"]
155
+ repo = package["repo"]
156
+ version_name = version["name"]
157
+
158
+ return "/packages/#{subject}/#{repo}/#{package_name}/versions/#{version_name}"
159
+ end
160
+
161
+ def version_exists?
162
+ path = version_exists_path
163
+ if !dry_run
164
+ res = head_request(path)
165
+ code = res.code.to_i
166
+ else
167
+ code = 404
168
+ end
169
+
170
+ if code == 404
171
+ return false
172
+ end
173
+ if code == 201 || code == 200
174
+ return true
175
+ end
176
+ version_name = descriptor["version"]["name"]
177
+ abort("Unexpected HTTP response code #{code} returned from Bintray while checking if version '#{version_name}' exists. " +
178
+ "Response message: #{res.message}")
179
+ end
180
+
181
+ def create_package
182
+ package = descriptor["package"]
183
+ repo = package["repo"]
184
+ body = {}
185
+
186
+ add_to_map(body, package, "name")
187
+ add_to_map(body, package, "desc")
188
+ add_to_map(body, package, "licenses")
189
+ add_to_map(body, package, "labels")
190
+ add_to_map(body, package, "vcs_url")
191
+ add_to_map(body, package, "website_url")
192
+ add_to_map(body, package, "issue_tracker_url")
193
+ add_to_map(body, package, "public_download_numbers")
194
+ add_to_map(body, package, "public_stats")
195
+
196
+ subject = package["subject"]
197
+ package_name = package["name"]
198
+ log "Creating package '#{package_name}'..."
199
+
200
+ path = "/packages/#{subject}/#{repo}"
201
+ if !dry_run
202
+ res = post_request(path, body)
203
+ log_bintray_response(res)
204
+ code = res.code.to_i
205
+ else
206
+ code = 200
207
+ end
208
+
209
+ if !test_mode
210
+ if code == 201 || code == 200
211
+ add_package_attributes
212
+ end
213
+ end
214
+ RequestDetails.new(path, body)
215
+ end
216
+
217
+ def add_package_attributes
218
+ package = descriptor["package"]
219
+ repo = package["repo"]
220
+ subject = package["subject"]
221
+ package_name = package["name"]
222
+ attributes = package["attributes"]
223
+ path = nil
224
+ if !attributes.nil?
225
+ log "Adding attributes for package '#{package_name}'..."
226
+ path = "/packages/#{subject}/#{repo}/#{package_name}/attributes"
227
+ if !dry_run
228
+ res = post_request(path, attributes)
229
+ log_bintray_response(res)
230
+ end
231
+ end
232
+ RequestDetails.new(path, attributes)
233
+ end
234
+
235
+ def create_version
236
+ package = descriptor["package"]
237
+ version = descriptor["version"]
238
+ repo = package["repo"]
239
+ body = {}
240
+
241
+ add_to_map(body, version, "name")
242
+ add_to_map(body, version, "desc")
243
+ add_to_map(body, version, "released")
244
+ add_to_map(body, version, "vcs_tag")
245
+ add_to_map(body, version, "github_release_notes_file")
246
+ add_to_map(body, version, "github_use_tag_release_notes")
247
+ add_to_map(body, version, "attributes")
248
+
249
+ package_name = package["name"]
250
+ subject = package["subject"]
251
+ version_name = version["name"]
252
+ log "Creating version '#{version_name}'..."
253
+
254
+ path = "/packages/#{subject}/#{repo}/#{package_name}/versions"
255
+ if !dry_run
256
+ res = post_request(path, body)
257
+ log_bintray_response(res)
258
+ code = res.code.to_i
259
+ else
260
+ code = 200
261
+ end
262
+
263
+ if !test_mode
264
+ if code == 201 || code == 200
265
+ add_version_attributes
266
+ end
267
+ end
268
+ RequestDetails.new(path, body)
269
+ end
270
+
271
+ def add_version_attributes
272
+ package = descriptor["package"]
273
+ package_name = package["name"]
274
+ subject = package["subject"]
275
+ version = descriptor["version"]
276
+ version_name = version["name"]
277
+ repo = package["repo"]
278
+ attributes = version["attributes"]
279
+ path = nil
280
+ if !attributes.nil?
281
+ log "Adding attributes for version '#{version_name}'..."
282
+ path = "/packages/#{subject}/#{repo}/#{package_name}/versions/#{version_name}/attributes"
283
+ if !dry_run
284
+ res = post_request(path, attributes)
285
+ log_bintray_response(res)
286
+ end
287
+ end
288
+ RequestDetails.new(path, attributes)
289
+ end
290
+
291
+ def check_and_create_package
292
+ if !package_exists?
293
+ create_package
294
+ end
295
+ end
296
+
297
+ def check_and_create_version
298
+ if !version_exists?
299
+ create_version
300
+ end
301
+ end
302
+
303
+ def upload_files
304
+ files = files_to_upload
305
+
306
+ files.each do |key, artifact|
307
+ upload_file(artifact)
308
+ end
309
+ end
310
+
311
+ def publish_version
312
+ publish = descriptor["publish"]
313
+ if publish
314
+ package = descriptor["package"]
315
+ version = descriptor["version"]
316
+ repo = package["repo"]
317
+ package_name = package["name"]
318
+ subject = package["subject"]
319
+ version_name = version["name"]
320
+
321
+ log "Publishing version '#{version_name}' of package '#{package_name}'..."
322
+ path = "/content/#{subject}/#{repo}/#{package_name}/#{version_name}/publish"
323
+ if !dry_run
324
+ res = post_request(path, nil)
325
+ log_bintray_response(res)
326
+ end
327
+ end
328
+ RequestDetails.new(path, nil)
329
+ end
330
+
331
+ def gpg_sign_version
332
+ version = descriptor["version"]
333
+ gpg_sign = version["gpgSign"]
334
+ if gpg_sign
335
+ package = descriptor["package"]
336
+ repo = package["repo"]
337
+ package_name = package["name"]
338
+ subject = package["subject"]
339
+ version_name = version["name"]
340
+
341
+ body = nil
342
+ if !passphrase.nil?
343
+ log "Signing version with no passphrase..."
344
+ body = {}
345
+ body["passphrase"] = passphrase
346
+ else
347
+ log "Signing version with passphrase..."
348
+ end
349
+
350
+ path = "/gpg/#{subject}/#{repo}/#{package_name}/versions/#{version_name}"
351
+ if !dry_run
352
+ res = post_request(path, body)
353
+ log_bintray_response(res)
354
+ end
355
+ RequestDetails.new(path, body)
356
+ end
357
+ end
358
+
359
+ # Get the root path from which to start collecting files to be
360
+ # uploaded to Bintray.
361
+ def root_path(str)
362
+ index = str.index('(')
363
+ path = nil
364
+ if index.nil? || str.start_with?('(')
365
+ path = str
366
+ else
367
+ path = str[0, index]
368
+ end
369
+
370
+ if !test_mode && !File.exist?(path)
371
+ log "Warning: Path: #{path} does not exist."
372
+ return nil
373
+ end
374
+ return path
375
+ end
376
+
377
+ # Fills a map with Artifact objects which match
378
+ # the include pattern and do not match the exclude pattern.
379
+ # The artifacts are files collected from the file system.
380
+ def fill_files_map(map, include_pattern, exclude_pattern, upload_pattern, matrix_params)
381
+ # Get the root path from which to start collecting the files.
382
+ root_path = root_path(include_pattern)
383
+ if root_path.nil?
384
+ return
385
+ end
386
+
387
+ # Start scanning the root path recursively.
388
+ Find.find(root_path) do |path|
389
+ add_if_matches(map, path, include_pattern, exclude_pattern, upload_pattern, matrix_params)
390
+ end
391
+ end
392
+
393
+ def add_if_matches(map, path, include_pattern, exclude_pattern, upload_pattern, matrix_params)
394
+ res = path.match(/#{include_pattern}/)
395
+
396
+ # If the file matches the include pattern and it is not a directory.
397
+ # In case test_mode is set, we do not check if the file exists.
398
+ if !res.nil? && (test_mode || File.file?(path))
399
+ # If the file does not match the exclude pattern.
400
+ if exclude_pattern.nil? || exclude_pattern.empty? || !path.match(/#{exclude_pattern}/)
401
+ # Using the capturing groups in the include pattern, replace the $1, $2, ...
402
+ # in the upload pattern.
403
+ groups = res.captures
404
+ replaced_upload_pattern = upload_pattern
405
+ for i in 0..groups.size-1
406
+ replaced_upload_pattern = replaced_upload_pattern.gsub("$#{i+1}", groups[i])
407
+ end
408
+ map[path] = Artifact.new(path, replaced_upload_pattern, matrix_params)
409
+ end
410
+ end
411
+ end
412
+
413
+ # Returns a map containing Artifact objects.
414
+ # The map contains the files to be uploaded to Bintray.
415
+ def files_to_upload
416
+ upload_files = Hash.new()
417
+ files = descriptor["files"]
418
+ if files.nil?
419
+ return upload_files
420
+ end
421
+
422
+ files.each { |patterns|
423
+ fill_files_map(
424
+ upload_files,
425
+ patterns["includePattern"],
426
+ patterns["excludePattern"],
427
+ patterns["uploadPattern"],
428
+ patterns["matrixParams"])
429
+ }
430
+
431
+ return upload_files
432
+ end
433
+
434
+ def deploy
435
+ read_descriptor
436
+ check_and_create_package
437
+ check_and_create_version
438
+ upload_files
439
+ gpg_sign_version
440
+ publish_version
441
+ end
442
+
443
+ # Copies a key from one map to another, if the key exists there.
444
+ def add_to_map(to_map, from_map, key)
445
+ if !from_map[key].nil?
446
+ to_map[key] = from_map[key]
447
+ end
448
+ end
449
+
450
+ def log_bintray_response(res)
451
+ msg = ''
452
+ if !res.body.nil?
453
+ begin
454
+ response = JSON.parse(res.body)
455
+ msg = response["message"]
456
+ rescue
457
+ end
458
+ end
459
+
460
+ log "Bintray response: #{res.code.to_i} #{res.message}. #{msg}"
461
+ end
462
+
463
+ def log(msg)
464
+ puts "[Bintray Upload] #{msg}"
465
+ end
466
+
467
+ # This class represents an artifact (file) to be uploaded to Bintray.
468
+ class Artifact
469
+ def initialize(local_path, upload_path, matrix_params)
470
+ @local_path = local_path
471
+ @upload_path = upload_path
472
+ @matrix_params = matrix_params
473
+ end
474
+
475
+ def hash
476
+ return @localPath.hash
477
+ end
478
+
479
+ def eql?(other)
480
+ @localPath == other.local_path
481
+ end
482
+
483
+ attr_reader :local_path
484
+ attr_reader :upload_path
485
+ attr_reader :matrix_params
486
+ end
487
+
488
+ # Used to return the path and body of REST requests sent to Bintray.
489
+ # Used for testing.
490
+ class RequestDetails
491
+ def initialize(path, body)
492
+ @path = path
493
+ @body = body
494
+ end
495
+
496
+ attr_reader :path
497
+ attr_reader :body
498
+ end
499
+ end
500
+ end
501
+ end
@@ -0,0 +1,259 @@
1
+ require 'spec_helper'
2
+ require 'dpl/provider/bintray'
3
+
4
+ describe DPL::Provider::Bintray do
5
+
6
+ subject :provider do
7
+ described_class.new(DummyContext.new,
8
+ :user => 'user',
9
+ :key => 'key',
10
+ :file => 'file',
11
+ :dry_run => 'true')
12
+ end
13
+
14
+ subject :provider_with_passphrase do
15
+ described_class.new(DummyContext.new,
16
+ :user => 'user',
17
+ :key => 'key',
18
+ :file => 'file',
19
+ :dry_run => 'true',
20
+ :passphrase => 'passphrase')
21
+ end
22
+
23
+ describe "package_exists?" do
24
+ example do
25
+ descriptor = JSON.parse(descriptor_content)
26
+ package = descriptor["package"]
27
+ package_name = package["name"]
28
+ subject = package["subject"]
29
+ repo = package["repo"]
30
+
31
+ init_provider(provider)
32
+ expect(provider.package_exists_path).to eq("/packages/#{subject}/#{repo}/#{package_name}")
33
+ end
34
+ end
35
+
36
+ describe "version_exists?" do
37
+ example do
38
+ descriptor = JSON.parse(descriptor_content)
39
+ package = descriptor["package"]
40
+ package_name = package["name"]
41
+ subject = package["subject"]
42
+ repo = package["repo"]
43
+ version_name = descriptor["version"]["name"]
44
+
45
+ init_provider(provider)
46
+ expect(provider.version_exists_path).to eq("/packages/#{subject}/#{repo}/#{package_name}/versions/#{version_name}")
47
+ end
48
+ end
49
+
50
+ describe "create_package" do
51
+ example do
52
+ descriptor = JSON.parse(descriptor_content)
53
+ package = descriptor["package"]
54
+ subject = package["subject"]
55
+ repo = package["repo"]
56
+
57
+ init_provider(provider)
58
+ request_details = provider.create_package
59
+ expect(request_details.path).to eq("/packages/#{subject}/#{repo}")
60
+
61
+ body = {
62
+ 'name' => package["name"],
63
+ 'desc' => package["desc"],
64
+ 'licenses' => package["licenses"],
65
+ 'labels' => package["labels"],
66
+ 'vcs_url' => package["vcs_url"],
67
+ 'website_url' => package["website_url"],
68
+ 'issue_tracker_url' => package["issue_tracker_url"],
69
+ 'public_download_numbers' => package["public_download_numbers"],
70
+ 'public_stats' => package["public_stats"]
71
+ }
72
+ expect(request_details.body).to eq(body)
73
+ end
74
+ end
75
+
76
+ describe "create_version" do
77
+ example do
78
+ descriptor = JSON.parse(descriptor_content)
79
+ package = descriptor["package"]
80
+ package_name = package["name"]
81
+ subject = package["subject"]
82
+ repo = package["repo"]
83
+
84
+ init_provider(provider)
85
+ request_details = provider.create_version
86
+ expect(request_details.path).to eq("/packages/#{subject}/#{repo}/#{package_name}/versions")
87
+
88
+ version = descriptor["version"]
89
+ body = {
90
+ 'name' => version["name"],
91
+ 'desc' => version["desc"],
92
+ 'released' => version["released"],
93
+ 'vcs_tag' => version["vcs_tag"],
94
+ 'attributes' => version["attributes"]
95
+ }
96
+ expect(request_details.body).to eq(body)
97
+ end
98
+ end
99
+
100
+ describe "add_package_attributes" do
101
+ example do
102
+ descriptor = JSON.parse(descriptor_content)
103
+ package = descriptor["package"]
104
+ package_name = package["name"]
105
+ subject = package["subject"]
106
+ repo = package["repo"]
107
+
108
+ init_provider(provider)
109
+ request_details = provider.add_package_attributes
110
+ expect(request_details.path).to eq("/packages/#{subject}/#{repo}/#{package_name}/attributes")
111
+
112
+ body = package["attributes"]
113
+ expect(request_details.body).to eq(body)
114
+ end
115
+ end
116
+
117
+ describe "add_version_attributes" do
118
+ example do
119
+ descriptor = JSON.parse(descriptor_content)
120
+ package = descriptor["package"]
121
+ package_name = package["name"]
122
+ subject = package["subject"]
123
+ repo = package["repo"]
124
+ version_name = descriptor["version"]["name"]
125
+
126
+ init_provider(provider)
127
+ request_details = provider.add_version_attributes
128
+ expect(request_details.path).to eq("/packages/#{subject}/#{repo}/#{package_name}/versions/#{version_name}/attributes")
129
+
130
+ descriptor = JSON.parse(descriptor_content)
131
+ version = descriptor["version"]
132
+ body = version["attributes"]
133
+ expect(request_details.body).to eq(body)
134
+ end
135
+ end
136
+
137
+ describe "publish_version" do
138
+ example do
139
+ descriptor = JSON.parse(descriptor_content)
140
+ package = descriptor["package"]
141
+ package_name = package["name"]
142
+ subject = package["subject"]
143
+ repo = package["repo"]
144
+ version_name = descriptor["version"]["name"]
145
+
146
+ init_provider(provider)
147
+ request_details = provider.publish_version
148
+ expect(request_details.path).to eq("/content/#{subject}/#{repo}/#{package_name}/#{version_name}/publish")
149
+ end
150
+ end
151
+
152
+ describe "gpg_sign_version_without_passphrase" do
153
+ example do
154
+ descriptor = JSON.parse(descriptor_content)
155
+ package = descriptor["package"]
156
+ package_name = package["name"]
157
+ subject = package["subject"]
158
+ repo = package["repo"]
159
+ version_name = descriptor["version"]["name"]
160
+
161
+ init_provider(provider)
162
+ request_details = provider.gpg_sign_version
163
+ expect(request_details.path).to eq("/gpg/#{subject}/#{repo}/#{package_name}/versions/#{version_name}")
164
+ expect(request_details.body).to eq(nil)
165
+ end
166
+ end
167
+
168
+ describe "gpg_sign_version_with_passphrase" do
169
+ example do
170
+ descriptor = JSON.parse(descriptor_content)
171
+ package = descriptor["package"]
172
+ package_name = package["name"]
173
+ subject = package["subject"]
174
+ repo = package["repo"]
175
+ version_name = descriptor["version"]["name"]
176
+
177
+ init_provider(provider_with_passphrase)
178
+ request_details = provider_with_passphrase.gpg_sign_version
179
+ expect(request_details.path).to eq("/gpg/#{subject}/#{repo}/#{package_name}/versions/#{version_name}")
180
+
181
+ body = {
182
+ 'passphrase' => 'passphrase'
183
+ }
184
+ expect(request_details.body).to eq(body)
185
+ end
186
+ end
187
+
188
+ describe "upload_files" do
189
+ example do
190
+ init_provider(provider)
191
+ files_to_upload = Hash.new()
192
+ matrix_params = {
193
+ 'p1' => 'a',
194
+ 'p2' => 'b'
195
+ }
196
+
197
+ provider.add_if_matches(files_to_upload, 'build/files/a.gem', 'build/files/(.*.gem)', 'exclude', 'a/b/$1', nil)
198
+ provider.add_if_matches(files_to_upload, 'build/files/b.gem', 'build/files/(.*.gem)', nil, 'a/b/$1', matrix_params)
199
+ provider.add_if_matches(files_to_upload, 'build/files/c.gem', 'build/files/(.*.gem)', '.*files.*', 'a/b/$1', nil)
200
+ provider.add_if_matches(files_to_upload, 'build/files/c.txt', 'build/files/(.*.gem)', 'exclude', 'a/b/$1', nil)
201
+
202
+ expect(files_to_upload["build/files/a.gem"]).not_to eq(nil)
203
+ expect(files_to_upload["build/files/a.gem"].upload_path).to eq('a/b/a.gem')
204
+ expect(files_to_upload["build/files/a.gem"].matrix_params).to eq(nil)
205
+
206
+ expect(files_to_upload["build/files/b.gem"]).not_to eq(nil)
207
+ expect(files_to_upload["build/files/b.gem"].upload_path).to eq('a/b/b.gem')
208
+ expect(files_to_upload["build/files/b.gem"].matrix_params).to eq(matrix_params)
209
+
210
+ expect(files_to_upload["build/files/c.gem"]).to eq(nil)
211
+ expect(files_to_upload["build/files/c.txt"]).to eq(nil)
212
+ end
213
+ end
214
+
215
+ def init_provider(bintray)
216
+ bintray.descriptor=descriptor_content
217
+ bintray.test_mode = true
218
+ end
219
+
220
+ def descriptor_content
221
+ return """ {
222
+ \"package\": {
223
+ \"name\": \"auto-upload\",
224
+ \"repo\": \"myRepo\",
225
+ \"subject\": \"myBintrayUser\",
226
+ \"desc\": \"I was pushed completely automatically\",
227
+ \"website_url\": \"www.jfrog.com\",
228
+ \"issue_tracker_url\": \"https://github.com/bintray/bintray-client-java/issues\",
229
+ \"vcs_url\": \"https://github.com/bintray/bintray-client-java.git\",
230
+ \"github_use_tag_release_notes\": true,
231
+ \"github_release_notes_file\": \"RELEASE.txt\",
232
+ \"licenses\": [\"MIT\"],
233
+ \"labels\": [\"cool\", \"awesome\", \"gorilla\"],
234
+ \"public_download_numbers\": false,
235
+ \"public_stats\": false,
236
+ \"attributes\": [{\"name\": \"att1\", \"values\" : [\"val1\"], \"type\": \"string\"},
237
+ {\"name\": \"att2\", \"values\" : [1, 2.2, 4], \"type\": \"number\"},
238
+ {\"name\": \"att5\", \"values\" : [\"2014-12-28T19:43:37+0100\"], \"type\": \"date\"}]
239
+ },
240
+ \"version\": {
241
+ \"name\": \"0.5\",
242
+ \"desc\": \"This is a version\",
243
+ \"released\": \"2015-01-04\",
244
+ \"vcs_tag\": \"0.5\",
245
+ \"attributes\": [{\"name\": \"VerAtt1\", \"values\" : [\"VerVal1\"], \"type\": \"string\"},
246
+ {\"name\": \"VerAtt2\", \"values\" : [1, 3.3, 5], \"type\": \"number\"},
247
+ {\"name\": \"VerAtt3\", \"values\" : [\"2015-01-01T19:43:37+0100\"], \"type\": \"date\"}],
248
+ \"gpgSign\": true
249
+ },
250
+ \"files\":
251
+ [
252
+ {\"includePattern\": \"build/bin/(*.gem)\", \"excludePattern\": \".*/do-not-deploy/.*\", \"uploadPattern\": \"gems/$1\"},
253
+ {\"includePattern\": \"build/docs/(.*)\", \"uploadPattern\": \"docs/$1\"}
254
+ ],
255
+ \"publish\": true
256
+ }
257
+ """
258
+ end
259
+ end
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dpl-bintray
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Konstantin Haase
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-03-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dpl
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.9.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.9.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-its
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: json_pure
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: tins
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: highline
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: deploy tool abstraction for clients
126
+ email: konstantin.mailinglists@googlemail.com
127
+ executables: []
128
+ extensions: []
129
+ extra_rdoc_files: []
130
+ files:
131
+ - dpl-bintray.gemspec
132
+ - lib/dpl/provider/bintray.rb
133
+ - spec/provider/bintray_spec.rb
134
+ homepage: https://github.com/travis-ci/dpl
135
+ licenses:
136
+ - MIT
137
+ metadata: {}
138
+ post_install_message:
139
+ rdoc_options: []
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '2.2'
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ requirements: []
153
+ rubyforge_project:
154
+ rubygems_version: 2.6.13
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: deploy tool
158
+ test_files:
159
+ - spec/provider/bintray_spec.rb