garage_client 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rspec +1 -0
  4. data/CHANGELOG.md +40 -0
  5. data/Gemfile +8 -0
  6. data/Guardfile +7 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +196 -0
  9. data/Rakefile +8 -0
  10. data/garage_client.gemspec +36 -0
  11. data/gemfiles/Gemfile.faraday-0.8.x +4 -0
  12. data/lib/garage_client.rb +33 -0
  13. data/lib/garage_client/cachers/base.rb +44 -0
  14. data/lib/garage_client/client.rb +93 -0
  15. data/lib/garage_client/configuration.rb +51 -0
  16. data/lib/garage_client/error.rb +37 -0
  17. data/lib/garage_client/request.rb +38 -0
  18. data/lib/garage_client/request/json_encoded.rb +59 -0
  19. data/lib/garage_client/resource.rb +63 -0
  20. data/lib/garage_client/response.rb +123 -0
  21. data/lib/garage_client/response/cacheable.rb +27 -0
  22. data/lib/garage_client/response/raise_http_exception.rb +34 -0
  23. data/lib/garage_client/version.rb +3 -0
  24. data/spec/features/configuration_spec.rb +46 -0
  25. data/spec/fixtures/example.yaml +56 -0
  26. data/spec/fixtures/examples.yaml +60 -0
  27. data/spec/fixtures/examples_dictionary.yaml +60 -0
  28. data/spec/fixtures/examples_without_pagination.yaml +58 -0
  29. data/spec/garage_client/cacher_spec.rb +55 -0
  30. data/spec/garage_client/client_spec.rb +228 -0
  31. data/spec/garage_client/configuration_spec.rb +106 -0
  32. data/spec/garage_client/error_spec.rb +37 -0
  33. data/spec/garage_client/request/json_encoded_spec.rb +66 -0
  34. data/spec/garage_client/resource_spec.rb +102 -0
  35. data/spec/garage_client/response_spec.rb +450 -0
  36. data/spec/garage_client_spec.rb +48 -0
  37. data/spec/spec_helper.rb +56 -0
  38. metadata +275 -0
@@ -0,0 +1,48 @@
1
+ require "spec_helper"
2
+
3
+ describe GarageClient do
4
+ describe ".adapter" do
5
+ it "returns configuration.adapter" do
6
+ described_class.adapter.should == described_class.configuration.adapter
7
+ end
8
+ end
9
+
10
+ describe ".endpoint" do
11
+ it "returns configuration.endpoint" do
12
+ described_class.endpoint.should == described_class.configuration.endpoint
13
+ end
14
+ end
15
+
16
+ describe ".headers" do
17
+ it "returns configuration.headers" do
18
+ described_class.headers.should == described_class.configuration.headers
19
+ end
20
+ end
21
+
22
+ describe ".default_headers" do
23
+ it "returns configuration.headers" do
24
+ described_class.headers.should == described_class.configuration.headers
25
+ end
26
+ end
27
+
28
+ describe ".path_prefix" do
29
+ it "returns configuration.path_prefix" do
30
+ described_class.path_prefix.should == described_class.configuration.path_prefix
31
+ end
32
+ end
33
+
34
+ describe ".verbose" do
35
+ it "returns configuration.verbose" do
36
+ described_class.verbose.should == described_class.configuration.verbose
37
+ end
38
+ end
39
+
40
+ describe ".configure" do
41
+ it "executes given block with configuration object" do
42
+ described_class.configure do |configuration|
43
+ configuration.headers = { "Host" => "example.com" }
44
+ end
45
+ described_class.headers.should == { "Host" => "example.com" }
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'pry'
3
+ require 'uri'
4
+ require 'rspec'
5
+ require 'webmock/rspec'
6
+
7
+ if ENV["COVERAGE"]
8
+ require 'simplecov'
9
+ SimpleCov.start do
10
+ if ENV["RUN_CI"]
11
+ # Only with mri_19
12
+ require 'simplecov-rcov'
13
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
14
+ end
15
+ end
16
+ end
17
+
18
+ require 'garage_client'
19
+
20
+ GarageClient.configure do |c|
21
+ c.path_prefix = ''
22
+ c.endpoint = "https://garage.example.com"
23
+ end
24
+
25
+ # This workaround is strictly for stubbing purpose.
26
+ def make_endpoint(path)
27
+ /^(http|https):\/\//.match(path) ? path : URI.join(GarageClient.endpoint, path).to_s
28
+ end
29
+
30
+ def stub_get(path)
31
+ stub_request(:get, make_endpoint(path))
32
+ end
33
+
34
+ def stub_post(path)
35
+ stub_request(:post, make_endpoint(path))
36
+ end
37
+
38
+ def stub_put(path)
39
+ stub_request(:put, make_endpoint(path))
40
+ end
41
+
42
+ def stub_delete(path)
43
+ stub_request(:delete, make_endpoint(path))
44
+ end
45
+
46
+ def fixture(file)
47
+ prefix = File.expand_path('../fixtures', __FILE__)
48
+ path = File.join(prefix, file)
49
+ HashWithIndifferentAccess.new(YAML.load_file(path))
50
+ end
51
+
52
+ RSpec.configure do |config|
53
+ config.expect_with :rspec do |c|
54
+ c.syntax = [:should, :expect]
55
+ end
56
+ end
metadata ADDED
@@ -0,0 +1,275 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: garage_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Cookpad Inc.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.8.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday_middleware
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
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: hashie
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.2.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.2.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: link_header
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
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: mime-types
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.16'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.16'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 0.9.2
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 0.9.2
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
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
+ - !ruby/object:Gem::Dependency
126
+ name: json
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: guard-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: webmock
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: pry
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: simplecov
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 0.7.1
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: 0.7.1
195
+ description: Ruby client library for the Garage API
196
+ email:
197
+ - kaihatsu@cookpad.com
198
+ executables: []
199
+ extensions: []
200
+ extra_rdoc_files: []
201
+ files:
202
+ - ".gitignore"
203
+ - ".rspec"
204
+ - CHANGELOG.md
205
+ - Gemfile
206
+ - Guardfile
207
+ - LICENSE.txt
208
+ - README.md
209
+ - Rakefile
210
+ - garage_client.gemspec
211
+ - gemfiles/Gemfile.faraday-0.8.x
212
+ - lib/garage_client.rb
213
+ - lib/garage_client/cachers/base.rb
214
+ - lib/garage_client/client.rb
215
+ - lib/garage_client/configuration.rb
216
+ - lib/garage_client/error.rb
217
+ - lib/garage_client/request.rb
218
+ - lib/garage_client/request/json_encoded.rb
219
+ - lib/garage_client/resource.rb
220
+ - lib/garage_client/response.rb
221
+ - lib/garage_client/response/cacheable.rb
222
+ - lib/garage_client/response/raise_http_exception.rb
223
+ - lib/garage_client/version.rb
224
+ - spec/features/configuration_spec.rb
225
+ - spec/fixtures/example.yaml
226
+ - spec/fixtures/examples.yaml
227
+ - spec/fixtures/examples_dictionary.yaml
228
+ - spec/fixtures/examples_without_pagination.yaml
229
+ - spec/garage_client/cacher_spec.rb
230
+ - spec/garage_client/client_spec.rb
231
+ - spec/garage_client/configuration_spec.rb
232
+ - spec/garage_client/error_spec.rb
233
+ - spec/garage_client/request/json_encoded_spec.rb
234
+ - spec/garage_client/resource_spec.rb
235
+ - spec/garage_client/response_spec.rb
236
+ - spec/garage_client_spec.rb
237
+ - spec/spec_helper.rb
238
+ homepage: https://github.com/cookpad/garage_client
239
+ licenses: []
240
+ metadata: {}
241
+ post_install_message:
242
+ rdoc_options: []
243
+ require_paths:
244
+ - lib
245
+ required_ruby_version: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - ">="
248
+ - !ruby/object:Gem::Version
249
+ version: '0'
250
+ required_rubygems_version: !ruby/object:Gem::Requirement
251
+ requirements:
252
+ - - ">="
253
+ - !ruby/object:Gem::Version
254
+ version: '0'
255
+ requirements: []
256
+ rubyforge_project:
257
+ rubygems_version: 2.2.2
258
+ signing_key:
259
+ specification_version: 4
260
+ summary: Ruby client library for the Garage API
261
+ test_files:
262
+ - spec/features/configuration_spec.rb
263
+ - spec/fixtures/example.yaml
264
+ - spec/fixtures/examples.yaml
265
+ - spec/fixtures/examples_dictionary.yaml
266
+ - spec/fixtures/examples_without_pagination.yaml
267
+ - spec/garage_client/cacher_spec.rb
268
+ - spec/garage_client/client_spec.rb
269
+ - spec/garage_client/configuration_spec.rb
270
+ - spec/garage_client/error_spec.rb
271
+ - spec/garage_client/request/json_encoded_spec.rb
272
+ - spec/garage_client/resource_spec.rb
273
+ - spec/garage_client/response_spec.rb
274
+ - spec/garage_client_spec.rb
275
+ - spec/spec_helper.rb