garage_client 2.3.1 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/garage_client.gemspec +1 -0
- data/lib/garage_client/railtie.rb +17 -0
- data/lib/garage_client/version.rb +1 -1
- data/lib/garage_client.rb +7 -0
- data/spec/garage_client/railtie_spec.rb +40 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9f1a69ba91fc3ac307c8a3fee280e770afa9cb3
|
4
|
+
data.tar.gz: 97ec57d1cb62ce4eb891235aa793885e11a05838
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcce64de0d5f23fb06f9859ea1527c5da42dba01e970ea08225e5c148a774ecbecc874cbc1f4ae262f915c453f97acfa63cbc1dc8cf3dab359b887bcf94189da
|
7
|
+
data.tar.gz: c308b58aec27465cb8484252725aa5170d1cfe5ca5b6e263d2a034438e3b19bff1e5f3b2e4857397b7e2104a49b4f4664829a19e1de384fd0a915600ffa02a7c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -92,7 +92,7 @@ There are the following options:
|
|
92
92
|
|
93
93
|
- `adapter` - faraday adapter for http client (default: `:net_http`)
|
94
94
|
- `cacher` - take a cacher class in which caching logic is defined (default: nil)
|
95
|
-
- `name` - Client's application name, which is embedded in User-Agent by default (default: nil)
|
95
|
+
- `name` - Client's application name, which is embedded in User-Agent by default (default: nil. For Rails, `Rails.application.class.parent_name.underscore` is set by default.)
|
96
96
|
- `headers` - default http headers (default: `{ "Accept" => "application/json", "User-Agent" => "garage_client #{VERSION} #{name}" }`)
|
97
97
|
- `endpoint` - Garage application API endpoint (default: nil)
|
98
98
|
- `path_prefix` - API path prefix (default: `'/v1'`)
|
data/garage_client.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
|
25
25
|
s.add_dependency 'system_timer' if RUBY_VERSION < '1.9'
|
26
26
|
|
27
|
+
s.add_development_dependency "rails"
|
27
28
|
s.add_development_dependency "rake", ">= 0.9.2"
|
28
29
|
s.add_development_dependency "rspec"
|
29
30
|
s.add_development_dependency "json"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module GarageClient
|
2
|
+
class Railtie < ::Rails::Railtie
|
3
|
+
initializer :garage_client do |app|
|
4
|
+
RailsInitializer.set_default_name
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
module RailsInitializer
|
9
|
+
def self.set_default_name
|
10
|
+
unless GarageClient.configuration.options[:name]
|
11
|
+
GarageClient.configure do |c|
|
12
|
+
c.name = Rails.application.class.parent_name.underscore
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/garage_client.rb
CHANGED
@@ -15,6 +15,13 @@ require 'garage_client/response/raise_http_exception'
|
|
15
15
|
require 'garage_client/resource'
|
16
16
|
require 'garage_client/client'
|
17
17
|
|
18
|
+
begin
|
19
|
+
require 'rails'
|
20
|
+
rescue LoadError
|
21
|
+
else
|
22
|
+
require 'garage_client/railtie'
|
23
|
+
end
|
24
|
+
|
18
25
|
module GarageClient
|
19
26
|
class << self
|
20
27
|
GarageClient::Configuration.keys.each do |key|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
describe GarageClient::Railtie do
|
2
|
+
describe 'initializer' do
|
3
|
+
let(:parent_name) { 'Cookpad' }
|
4
|
+
|
5
|
+
before do
|
6
|
+
allow(Rails).to receive_message_chain(:application, :class, :parent_name).
|
7
|
+
and_return(parent_name)
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'when GarageClient.configuration.name is absent' do
|
11
|
+
before do
|
12
|
+
GarageClient.configuration.name = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'sets name by Rails.application.class.parent_name' do
|
16
|
+
expect {
|
17
|
+
GarageClient::RailsInitializer.set_default_name
|
18
|
+
}.to change {
|
19
|
+
GarageClient.configuration.options[:name]
|
20
|
+
}.from(nil).to(parent_name.underscore)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when GarageClient.configuration.name is present' do
|
25
|
+
let(:name) { 'cookpad2' }
|
26
|
+
|
27
|
+
before do
|
28
|
+
GarageClient.configuration.name = name
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'does not override name' do
|
32
|
+
expect {
|
33
|
+
GarageClient::RailsInitializer.set_default_name
|
34
|
+
}.to_not change {
|
35
|
+
GarageClient.configuration.options[:name]
|
36
|
+
}.from(name)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: garage_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cookpad Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rails
|
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'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -186,6 +200,7 @@ files:
|
|
186
200
|
- lib/garage_client/client.rb
|
187
201
|
- lib/garage_client/configuration.rb
|
188
202
|
- lib/garage_client/error.rb
|
203
|
+
- lib/garage_client/railtie.rb
|
189
204
|
- lib/garage_client/request.rb
|
190
205
|
- lib/garage_client/request/json_encoded.rb
|
191
206
|
- lib/garage_client/request/propagate_request_id.rb
|
@@ -205,6 +220,7 @@ files:
|
|
205
220
|
- spec/garage_client/client_spec.rb
|
206
221
|
- spec/garage_client/configuration_spec.rb
|
207
222
|
- spec/garage_client/error_spec.rb
|
223
|
+
- spec/garage_client/railtie_spec.rb
|
208
224
|
- spec/garage_client/request/json_encoded_spec.rb
|
209
225
|
- spec/garage_client/request/propagate_request_id_spec.rb
|
210
226
|
- spec/garage_client/resource_spec.rb
|
@@ -246,6 +262,7 @@ test_files:
|
|
246
262
|
- spec/garage_client/client_spec.rb
|
247
263
|
- spec/garage_client/configuration_spec.rb
|
248
264
|
- spec/garage_client/error_spec.rb
|
265
|
+
- spec/garage_client/railtie_spec.rb
|
249
266
|
- spec/garage_client/request/json_encoded_spec.rb
|
250
267
|
- spec/garage_client/request/propagate_request_id_spec.rb
|
251
268
|
- spec/garage_client/resource_spec.rb
|