bits_service_client 0.2.2.pre.3 → 0.2.2.pre.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +159 -0
- data/Gemfile +1 -0
- data/Guardfile +5 -0
- data/README.md +15 -0
- data/Rakefile +4 -1
- data/bits_service_client.gemspec +20 -16
- data/lib/bits_service_client/blob.rb +4 -2
- data/lib/bits_service_client/client.rb +25 -8
- data/lib/bits_service_client/errors.rb +1 -0
- data/lib/bits_service_client/logging_http_client.rb +1 -1
- data/lib/bits_service_client/resource_pool.rb +1 -0
- data/lib/bits_service_client/version.rb +2 -1
- data/lib/bits_service_client.rb +6 -5
- metadata +46 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0afab030e8087f4633b60c3a2a9b425abec6fd75
|
4
|
+
data.tar.gz: 043730165351c7c7937a9dd995403157e16d8a52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d3139a75921c1a57c9205cca2f012f4d74006dad95cdbece06b60f7d6486459f00c647ee7288a894e99d218a2a8096d90f3fee77c88eb1cdfb9e58c6c148d50
|
7
|
+
data.tar.gz: f20904efc5f39267e1b402ac442e649eb1177d64e9f69f953e79ad7536dbc84543ac30e759d746249f087a7290fbbbf4abd2f3497eafa38f85b789ee35538108
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.3
|
3
|
+
Include:
|
4
|
+
- '**/Gemfile'
|
5
|
+
- '**/Rakefile'
|
6
|
+
- '*.gemspec'
|
7
|
+
Exclude:
|
8
|
+
- vendor/**/*
|
9
|
+
- db/migrations/**/*
|
10
|
+
|
11
|
+
Lint/AmbiguousRegexpLiteral:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Lint/HandleExceptions:
|
15
|
+
Enabled: true
|
16
|
+
|
17
|
+
Lint/UnusedBlockArgument:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Lint/UnusedMethodArgument:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
Metrics/AbcSize:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
Metrics/ClassLength:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
Metrics/CyclomaticComplexity:
|
30
|
+
Max: 12
|
31
|
+
|
32
|
+
Metrics/LineLength:
|
33
|
+
Max: 180
|
34
|
+
|
35
|
+
Metrics/MethodLength:
|
36
|
+
Max: 60
|
37
|
+
|
38
|
+
Metrics/ModuleLength:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
Metrics/ParameterLists:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
Metrics/PerceivedComplexity:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
Performance/Casecmp:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
Performance/Sample:
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
Style/Alias:
|
54
|
+
EnforcedStyle: prefer_alias_method
|
55
|
+
|
56
|
+
Style/AlignParameters:
|
57
|
+
Enabled: false
|
58
|
+
|
59
|
+
Style/BlockDelimiters:
|
60
|
+
Enabled: false
|
61
|
+
|
62
|
+
Style/BracesAroundHashParameters:
|
63
|
+
Enabled: false
|
64
|
+
|
65
|
+
Style/ClassAndModuleChildren:
|
66
|
+
Enabled: false
|
67
|
+
|
68
|
+
Style/ClosingParenthesisIndentation:
|
69
|
+
Enabled: false
|
70
|
+
|
71
|
+
Style/Documentation:
|
72
|
+
Enabled: false
|
73
|
+
|
74
|
+
Style/DotPosition:
|
75
|
+
EnforcedStyle: trailing
|
76
|
+
|
77
|
+
Style/DoubleNegation:
|
78
|
+
Enabled: false
|
79
|
+
|
80
|
+
Style/EachWithObject:
|
81
|
+
Enabled: false
|
82
|
+
|
83
|
+
Style/FormatString:
|
84
|
+
EnforcedStyle: sprintf
|
85
|
+
|
86
|
+
Style/GuardClause:
|
87
|
+
Enabled: false
|
88
|
+
|
89
|
+
Style/IfUnlessModifier:
|
90
|
+
Enabled: false
|
91
|
+
|
92
|
+
Style/IndentArray:
|
93
|
+
EnforcedStyle: consistent
|
94
|
+
|
95
|
+
Style/IndentHash:
|
96
|
+
Enabled: false
|
97
|
+
|
98
|
+
Style/Lambda:
|
99
|
+
Enabled: false
|
100
|
+
|
101
|
+
Style/MultilineBlockChain:
|
102
|
+
Enabled: false
|
103
|
+
|
104
|
+
Style/MultilineBlockLayout:
|
105
|
+
Enabled: false
|
106
|
+
|
107
|
+
Style/MultilineOperationIndentation:
|
108
|
+
Enabled: false
|
109
|
+
|
110
|
+
Style/NegatedIf:
|
111
|
+
Enabled: false
|
112
|
+
|
113
|
+
Style/Next:
|
114
|
+
Enabled: false
|
115
|
+
|
116
|
+
Style/NumericLiterals:
|
117
|
+
Enabled: false
|
118
|
+
|
119
|
+
Style/PredicateName:
|
120
|
+
Enabled: false
|
121
|
+
|
122
|
+
Style/RaiseArgs:
|
123
|
+
EnforcedStyle: compact
|
124
|
+
|
125
|
+
Style/RedundantSelf:
|
126
|
+
Enabled: false
|
127
|
+
|
128
|
+
Style/RescueModifier:
|
129
|
+
Enabled: false
|
130
|
+
|
131
|
+
Style/SignalException:
|
132
|
+
Enabled: false
|
133
|
+
|
134
|
+
Style/SingleLineBlockParams:
|
135
|
+
Enabled: false
|
136
|
+
|
137
|
+
Style/SpaceAroundEqualsInParameterDefault:
|
138
|
+
EnforcedStyle: no_space
|
139
|
+
|
140
|
+
Style/StructInheritance:
|
141
|
+
Enabled: false
|
142
|
+
|
143
|
+
Style/TrailingCommaInArguments:
|
144
|
+
Enabled: false
|
145
|
+
|
146
|
+
Style/TrailingCommaInLiteral:
|
147
|
+
Enabled: false
|
148
|
+
|
149
|
+
Style/TrailingUnderscoreVariable:
|
150
|
+
Enabled: false
|
151
|
+
|
152
|
+
Style/TrivialAccessors:
|
153
|
+
Enabled: false
|
154
|
+
|
155
|
+
Style/WordArray:
|
156
|
+
Enabled: false
|
157
|
+
|
158
|
+
Style/ZeroLengthPredicate:
|
159
|
+
Enabled: false
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -16,3 +16,8 @@ guard :rspec, cmd: 'bundle exec rspec' do
|
|
16
16
|
watch(%r{^lib/bits_service_client/client.rb$}){|m| "spec/unit/bits_service_client/bits_service_client_spec.rb"}
|
17
17
|
watch('spec/spec_helper.rb') { 'spec' }
|
18
18
|
end
|
19
|
+
|
20
|
+
guard :rubocop do
|
21
|
+
watch(%r{.+\.rb$})
|
22
|
+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
23
|
+
end
|
data/README.md
CHANGED
@@ -4,9 +4,24 @@ Ruby client for [bits-service](https://github.com/cloudfoundry-incubator/bits-se
|
|
4
4
|
|
5
5
|
# Changelog
|
6
6
|
|
7
|
+
* 0.2.1:
|
8
|
+
- Update list of authors
|
9
|
+
|
7
10
|
* 0.2.0:
|
8
11
|
- Add `vcap_request_id` to `BitsService::Client` and `BitsService::ResourcePool`
|
9
12
|
- Add `request_timeout_in_seconds` to `BitsService::ResourcePool`
|
10
13
|
- Move unit tests from CloudController to this gem
|
11
14
|
|
12
15
|
* 0.1.0: Initial version
|
16
|
+
|
17
|
+
# Bump
|
18
|
+
|
19
|
+
The gem is automatically built and published to [rubygems.org](https://rubygems.org/gems/bits_service_client) in the [flintstone](https://flintstone.ci.cf-app.com) CI pipeline.
|
20
|
+
|
21
|
+
In order to release a new version of the gem, the following steps should be taken:
|
22
|
+
|
23
|
+
1. Update the change log above
|
24
|
+
1. Update [`version.rb`](lib/bits_service_client/version.rb) with the new version
|
25
|
+
1. Check in the changes and push them to `origin`.
|
26
|
+
|
27
|
+
The pipeline will pick up the changes and will, if `version.rb` has changed, tag the release in git and publish the new version of the gem.
|
data/Rakefile
CHANGED
data/bits_service_client.gemspec
CHANGED
@@ -1,32 +1,36 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'bits_service_client/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'bits_service_client'
|
8
9
|
spec.version = BitsServiceClient::VERSION
|
9
10
|
spec.authors = ['Rizwan Reza', 'Steffen Uhlig', 'Peter Goetz']
|
10
|
-
spec.email = [
|
11
|
+
spec.email = ['rizwanreza@gmail.com', 'steffen.uhlig@de.ibm.com', 'peter.gtz@gmail.com']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.homepage =
|
13
|
+
spec.summary = 'Bits Services client for Cloud Foundry'
|
14
|
+
spec.homepage = 'https://github.com/cloudfoundry-incubator/bits-service-client'
|
14
15
|
|
15
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
-
spec.require_paths = [
|
17
|
+
spec.require_paths = ['lib']
|
17
18
|
|
18
|
-
spec.add_dependency
|
19
|
-
spec.add_dependency
|
19
|
+
spec.add_dependency 'steno'
|
20
|
+
spec.add_dependency 'activesupport'
|
20
21
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
25
|
+
spec.add_development_dependency 'webmock', '= 1.20.4'
|
26
|
+
spec.add_development_dependency 'multipart-post'
|
27
|
+
spec.add_development_dependency 'rack-test'
|
28
|
+
spec.add_development_dependency 'guard'
|
29
|
+
spec.add_development_dependency 'guard-bundler'
|
30
|
+
spec.add_development_dependency 'guard-rspec'
|
30
31
|
spec.add_development_dependency 'terminal-notifier-guard'
|
31
32
|
spec.add_development_dependency 'terminal-notifier'
|
33
|
+
spec.add_development_dependency 'rb-readline'
|
34
|
+
spec.add_development_dependency 'rubocop'
|
35
|
+
spec.add_development_dependency 'guard-rubocop'
|
32
36
|
end
|
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module BitsService
|
2
3
|
class Blob
|
3
|
-
attr_reader :guid, :public_download_url, :internal_download_url
|
4
|
+
attr_reader :guid, :public_download_url, :internal_download_url, :public_upload_url
|
4
5
|
|
5
|
-
def initialize(guid:, public_download_url:, internal_download_url:)
|
6
|
+
def initialize(guid:, public_download_url:, internal_download_url:, public_upload_url:)
|
6
7
|
@guid = guid
|
7
8
|
@public_download_url = public_download_url
|
8
9
|
@internal_download_url = internal_download_url
|
10
|
+
@public_upload_url = public_upload_url
|
9
11
|
end
|
10
12
|
|
11
13
|
def attributes(*_)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'active_support/inflector'
|
2
3
|
require 'bits_service_client/logging_http_client'
|
3
4
|
|
@@ -44,6 +45,11 @@ module BitsService
|
|
44
45
|
FileUtils.mkdir_p(File.dirname(destination_path))
|
45
46
|
File.open(destination_path, 'wb') do |file|
|
46
47
|
response = @private_http_client.get(resource_path(source_key), @vcap_request_id)
|
48
|
+
|
49
|
+
if response.code == '302'
|
50
|
+
response = Net::HTTP.get_response(URI(response['location']))
|
51
|
+
end
|
52
|
+
|
47
53
|
validate_response_code!(200, response)
|
48
54
|
file.write(response.body)
|
49
55
|
file.chmod(mode) if mode
|
@@ -66,20 +72,31 @@ module BitsService
|
|
66
72
|
end
|
67
73
|
|
68
74
|
def blob(key)
|
69
|
-
response = @private_http_client.get('/sign' + resource_path(key), @vcap_request_id, {username: @username, password: @password})
|
70
|
-
validate_response_code!([200, 302], response)
|
71
|
-
|
72
|
-
response.tap do |response|
|
73
|
-
response.body = response['location'] if response.code.to_i == 302
|
74
|
-
end
|
75
|
-
|
76
75
|
Blob.new(
|
77
76
|
guid: key,
|
78
|
-
public_download_url:
|
77
|
+
public_download_url: signed_url(key),
|
78
|
+
public_upload_url: signed_url(key, verb: 'put'),
|
79
79
|
internal_download_url: generate_private_url(key)
|
80
80
|
)
|
81
81
|
end
|
82
82
|
|
83
|
+
def signed_url(key, verb: nil)
|
84
|
+
query = if verb.nil?
|
85
|
+
''
|
86
|
+
else
|
87
|
+
"?verb=#{verb}"
|
88
|
+
end
|
89
|
+
|
90
|
+
response = @private_http_client.get("/sign#{resource_path(key)}#{query}", @vcap_request_id, { username: @username, password: @password })
|
91
|
+
validate_response_code!([200, 302], response)
|
92
|
+
|
93
|
+
response.tap do |result|
|
94
|
+
result.body = result['location'] if result.code.to_i == 302
|
95
|
+
end
|
96
|
+
|
97
|
+
response.body
|
98
|
+
end
|
99
|
+
|
83
100
|
def delete_blob(blob)
|
84
101
|
delete(blob.guid)
|
85
102
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module BitsService
|
2
3
|
class LoggingHttpClient
|
3
4
|
def initialize(http_client)
|
@@ -40,6 +41,5 @@ module BitsService
|
|
40
41
|
@logger.info('Response', { code: response.code, vcap_request_id: vcap_request_id })
|
41
42
|
end
|
42
43
|
end
|
43
|
-
|
44
44
|
end
|
45
45
|
end
|
data/lib/bits_service_client.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'json'
|
2
3
|
require 'net/http/post/multipart'
|
3
4
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
5
|
+
require 'bits_service_client/version'
|
6
|
+
require 'bits_service_client/blob'
|
7
|
+
require 'bits_service_client/errors'
|
8
|
+
require 'bits_service_client/client'
|
9
|
+
require 'bits_service_client/resource_pool'
|
9
10
|
|
10
11
|
module BitsService
|
11
12
|
BlobstoreError = Class.new(StandardError)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bits_service_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.2.pre.
|
4
|
+
version: 0.2.2.pre.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rizwan Reza
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-12-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: steno
|
@@ -194,6 +194,48 @@ dependencies:
|
|
194
194
|
- - ">="
|
195
195
|
- !ruby/object:Gem::Version
|
196
196
|
version: '0'
|
197
|
+
- !ruby/object:Gem::Dependency
|
198
|
+
name: rb-readline
|
199
|
+
requirement: !ruby/object:Gem::Requirement
|
200
|
+
requirements:
|
201
|
+
- - ">="
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
version: '0'
|
204
|
+
type: :development
|
205
|
+
prerelease: false
|
206
|
+
version_requirements: !ruby/object:Gem::Requirement
|
207
|
+
requirements:
|
208
|
+
- - ">="
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: '0'
|
211
|
+
- !ruby/object:Gem::Dependency
|
212
|
+
name: rubocop
|
213
|
+
requirement: !ruby/object:Gem::Requirement
|
214
|
+
requirements:
|
215
|
+
- - ">="
|
216
|
+
- !ruby/object:Gem::Version
|
217
|
+
version: '0'
|
218
|
+
type: :development
|
219
|
+
prerelease: false
|
220
|
+
version_requirements: !ruby/object:Gem::Requirement
|
221
|
+
requirements:
|
222
|
+
- - ">="
|
223
|
+
- !ruby/object:Gem::Version
|
224
|
+
version: '0'
|
225
|
+
- !ruby/object:Gem::Dependency
|
226
|
+
name: guard-rubocop
|
227
|
+
requirement: !ruby/object:Gem::Requirement
|
228
|
+
requirements:
|
229
|
+
- - ">="
|
230
|
+
- !ruby/object:Gem::Version
|
231
|
+
version: '0'
|
232
|
+
type: :development
|
233
|
+
prerelease: false
|
234
|
+
version_requirements: !ruby/object:Gem::Requirement
|
235
|
+
requirements:
|
236
|
+
- - ">="
|
237
|
+
- !ruby/object:Gem::Version
|
238
|
+
version: '0'
|
197
239
|
description:
|
198
240
|
email:
|
199
241
|
- rizwanreza@gmail.com
|
@@ -205,6 +247,7 @@ extra_rdoc_files: []
|
|
205
247
|
files:
|
206
248
|
- ".gitignore"
|
207
249
|
- ".rspec"
|
250
|
+
- ".rubocop.yml"
|
208
251
|
- Gemfile
|
209
252
|
- Guardfile
|
210
253
|
- README.md
|
@@ -217,7 +260,7 @@ files:
|
|
217
260
|
- lib/bits_service_client/logging_http_client.rb
|
218
261
|
- lib/bits_service_client/resource_pool.rb
|
219
262
|
- lib/bits_service_client/version.rb
|
220
|
-
homepage:
|
263
|
+
homepage: https://github.com/cloudfoundry-incubator/bits-service-client
|
221
264
|
licenses: []
|
222
265
|
metadata: {}
|
223
266
|
post_install_message:
|