typekit-client 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +6 -0
  4. data/CHANGELOG.md +9 -5
  5. data/Guardfile +7 -0
  6. data/README.md +160 -131
  7. data/bin/typekit +21 -8
  8. data/lib/typekit/client.rb +5 -5
  9. data/lib/typekit/configuration/base.rb +1 -1
  10. data/lib/typekit/configuration/default.rb +9 -5
  11. data/lib/typekit/connection/dispatcher.rb +2 -2
  12. data/lib/typekit/connection/request.rb +5 -2
  13. data/lib/typekit/connection/response.rb +4 -8
  14. data/lib/typekit/helper.rb +22 -0
  15. data/lib/typekit/processing/converter/boolean.rb +11 -0
  16. data/lib/typekit/processing/converter/datetime.rb +11 -0
  17. data/lib/typekit/processing/converter/errors.rb +22 -0
  18. data/lib/typekit/processing/converter/record.rb +15 -0
  19. data/lib/typekit/processing/converter/records.rb +18 -0
  20. data/lib/typekit/processing/converter/unknown.rb +14 -0
  21. data/lib/typekit/processing/converter.rb +32 -0
  22. data/lib/typekit/processing/parser/json.rb +15 -0
  23. data/lib/typekit/processing/parser/yaml.rb +15 -0
  24. data/lib/typekit/processing/parser.rb +14 -0
  25. data/lib/typekit/processing/translator.rb +16 -0
  26. data/lib/typekit/processing.rb +9 -0
  27. data/lib/typekit/record/base.rb +30 -0
  28. data/lib/typekit/record/family.rb +7 -0
  29. data/lib/typekit/record/kit.rb +7 -0
  30. data/lib/typekit/record/library.rb +7 -0
  31. data/lib/typekit/record/variation.rb +8 -0
  32. data/lib/typekit/record.rb +35 -0
  33. data/lib/typekit/routing/{map.rb → mapper.rb} +1 -1
  34. data/lib/typekit/routing/node/base.rb +1 -0
  35. data/lib/typekit/routing.rb +1 -1
  36. data/lib/typekit/version.rb +1 -1
  37. data/lib/typekit.rb +4 -4
  38. data/spec/cassettes/delete_kits_xxx_ok.yml +16 -0
  39. data/spec/typekit/client_spec.rb +11 -3
  40. data/spec/typekit/configuration_spec.rb +20 -4
  41. data/spec/typekit/connection/dispatcher_spec.rb +4 -4
  42. data/spec/typekit/connection/response_spec.rb +18 -0
  43. data/spec/typekit/helper_spec.rb +34 -0
  44. data/spec/typekit/processing/converter_spec.rb +54 -0
  45. data/spec/typekit/processing/parser_spec.rb +23 -0
  46. data/spec/typekit/record/base_spec.rb +33 -0
  47. data/spec/typekit/record_spec.rb +48 -0
  48. data/spec/typekit/routing/mapper_spec.rb +177 -0
  49. data/spec/typekit/routing/node_spec.rb +31 -10
  50. data/typekit-client.gemspec +2 -1
  51. metadata +53 -13
  52. data/lib/typekit/parser/json.rb +0 -13
  53. data/lib/typekit/parser/yaml.rb +0 -13
  54. data/lib/typekit/parser.rb +0 -14
  55. data/lib/typekit/processor.rb +0 -38
  56. data/spec/typekit/processor_spec.rb +0 -34
  57. data/spec/typekit/routing/map_spec.rb +0 -106
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c787138c7a90aa58f94a0f9cfd0080aeac67440d
4
- data.tar.gz: 24df2e9aa560fb343e385198510af8c235afa72e
3
+ metadata.gz: 88f79a82bec7c431919822610e0b780faaa7c5aa
4
+ data.tar.gz: 13dff8c0ffb2cd4df92f76cb89574e11ef8644e4
5
5
  SHA512:
6
- metadata.gz: 6adc44648829ecd93949689f00765376f61a9d8f7b6b3cd5e5976220dabb229c7a359ed26c12e8c9f46b7095fa928010d1732a32b88744131701cbebb688b2f9
7
- data.tar.gz: 5adb42620a3c05627243b0e834ab12249a56cc62f48c0afe9ed5c87135f9ddc2a4fa03a206b3bc0d2106819027e701b75b0470d15194eea72eef06cf617d4235
6
+ metadata.gz: 568ade996d80ad36f2af3d374f4ef71cc0cebf6d56b7c2be718277967def5b82fd65fded286d5d21fde117f7251439809c809a05b25db6441ec092a7fca55b91
7
+ data.tar.gz: f0644585301a5fe1b8ee6384f6076c603c4265747e0dc390330c201d5d3d0c003a4d7f5c53da2a4c78f01bfb807a4f66b109df6674084890ac1b33bdf3d66a34
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .DS_Store
3
3
  Gemfile.lock
4
4
  *.gem
5
+ *.swo
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ branches:
5
+ only:
6
+ - master
data/CHANGELOG.md CHANGED
@@ -1,7 +1,11 @@
1
- ## Typekit 0.0.2 (May 28, 2014)
2
- * Renamed the gem into `typekit-client` (still `require 'typekit'`).
3
- * Rewrote the whole library (refactoring, preparing for new features).
4
- * Implemented a DSL for describing the resources provided by Typekit.
5
- * Introduced a client-side verification of user requests.
1
+ ## Typekit Client (master)
2
+ * Object-restful mapping (families, kits, etc. got proper classes).
3
+ * Command history and tab completion in the CLI.
4
+
5
+ ## Typekit Client 0.0.2 (May 28, 2014)
6
+ * New name for the gem (still `require 'typekit'`).
7
+ * Basic DSL for describing RESTful resources.
8
+ * Client-side verification of user requests.
9
+ * Refactoring, preparing for new features.
6
10
 
7
11
  ## Typekit 0.0.1 (May 16, 2014)
data/Guardfile ADDED
@@ -0,0 +1,7 @@
1
+ guard :rspec do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch('spec/spec_helper.rb') { 'spec' }
4
+ watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
5
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{ m[1] }_spec.rb" }
6
+ watch(%r{^lib/(.*\.rb)$}) { |m| "spec/#{ File.dirname(m[1]) }" }
7
+ end
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Typekit Client
1
+ # Typekit Client [![Gem Version](https://badge.fury.io/rb/typekit-client.svg)](http://badge.fury.io/rb/typekit-client) [![Build Status](https://travis-ci.org/IvanUkhov/typekit-client.svg?branch=master)](https://travis-ci.org/IvanUkhov/typekit-client)
2
2
  A Ruby library for accessing the [Typekit API](https://typekit.com/docs/api).
3
3
 
4
4
  ## Installation
@@ -55,41 +55,56 @@ The arguments are as follows:
55
55
 
56
56
  `perform` has an alias for each of the actions: `index(*path, parameters = {})`,
57
57
  `show(*path, parameters = {})`, `create(*path, parameters = {})`, and so on.
58
- The result of a method call is returned as a hash, and its content is exactly
59
- what the Typekit API sends back to `client`. The only exception is when
60
- the API returns an error, in which case an appropriate exception is being
61
- raised.
62
-
63
- Before sending the actual request to the Typekit API, the library checks
58
+ Before sending the actual request to the Typekit API, `perform` checks
64
59
  whether the resource given by `*path` makes sense and, if it does, whether
65
60
  `action` can be performed on that resource. So, if you receive an exception,
66
- check out the [API reference](https://typekit.com/docs/api/).
61
+ check the [API reference](https://typekit.com/docs/api/).
67
62
 
68
63
  Now, let us have a look at some typical use cases. For clarity, the code
69
64
  below makes use of the following auxiliary function:
70
65
  ```ruby
71
66
  def p(data)
72
67
  puts JSON.pretty_generate(data)
68
+ rescue JSON::GeneratorError
69
+ puts data.inspect
73
70
  end
74
71
  ```
75
72
 
76
73
  ### Show all kits
77
74
  Code:
78
75
  ```ruby
79
- p client.index(:kits)
76
+ p kits = client.index(:kits)
77
+ p kits.map(&:class)
78
+ p kits.first.attributes
79
+ p kits.first.link
80
80
  ```
81
81
 
82
82
  Output:
83
83
  ```json
84
+ [
85
+ {
86
+ "id": "bas4cfe",
87
+ "link": "/api/v1/json/kits/bas4cfe"
88
+ },
89
+ {
90
+ "id": "sfh6bkj",
91
+ "link": "/api/v1/json/kits/sfh6bkj"
92
+ },
93
+ {
94
+ "id": "kof8zcn",
95
+ "link": "/api/v1/json/kits/kof8zcn"
96
+ }
97
+ ]
98
+ [
99
+ "Typekit::Record::Kit",
100
+ "Typekit::Record::Kit",
101
+ "Typekit::Record::Kit"
102
+ ]
84
103
  {
85
- "kits": [
86
- {
87
- "id": "bas4cfe",
88
- "link": "/api/v1/json/kits/bas4cfe"
89
- },
90
- ...
91
- ]
104
+ "id": "bas4cfe",
105
+ "link": "/api/v1/json/kits/bas4cfe"
92
106
  }
107
+ "/api/v1/json/kits/bas4cfe"
93
108
  ```
94
109
 
95
110
  ### Show the description of a variant of a font family
@@ -101,19 +116,17 @@ p client.show(:families, 'vcsm', 'i9')
101
116
  Output:
102
117
  ```json
103
118
  {
104
- "variation": {
105
- "id": "vcsm:i9",
106
- "name": "Proxima Nova Black Italic",
107
- "family": {
108
- "id": "vcsm",
109
- "link": "/api/v1/json/families/vcsm",
110
- "name": "Proxima Nova"
111
- },
112
- "font_style": "italic",
113
- "font_variant": "normal",
114
- "font_weight": "900",
115
- ...
116
- }
119
+ "id": "vcsm:i9",
120
+ "name": "Proxima Nova Black Italic",
121
+ "family": {
122
+ "id": "vcsm",
123
+ "link": "/api/v1/json/families/vcsm",
124
+ "name": "Proxima Nova"
125
+ },
126
+ "font_style": "italic",
127
+ "font_variant": "normal",
128
+ "font_weight": "900",
129
+ ...
117
130
  }
118
131
  ```
119
132
 
@@ -126,30 +139,28 @@ p client.show(:libraries, 'trial', page: 10, per_page: 5)
126
139
  Output:
127
140
  ```json
128
141
  {
129
- "library": {
130
- "id": "trial",
131
- "link": "/api/v1/json/libraries/trial",
132
- "name": "Trial Library",
133
- "families": [
134
- {
135
- "id": "qnhl",
136
- "link": "/api/v1/json/families/qnhl",
137
- "name": "Caliban Std"
138
- },
139
- {
140
- "id": "vybr",
141
- "link": "/api/v1/json/families/vybr",
142
- "name": "Calluna"
143
- },
144
- ...
145
- ],
146
- "pagination": {
147
- "count": 261,
148
- "on": "families",
149
- "page": 10,
150
- "page_count": 53,
151
- "per_page": 5
152
- }
142
+ "id": "trial",
143
+ "link": "/api/v1/json/libraries/trial",
144
+ "name": "Trial Library",
145
+ "families": [
146
+ {
147
+ "id": "qnhl",
148
+ "link": "/api/v1/json/families/qnhl",
149
+ "name": "Caliban Std"
150
+ },
151
+ {
152
+ "id": "vybr",
153
+ "link": "/api/v1/json/families/vybr",
154
+ "name": "Calluna"
155
+ },
156
+ ...
157
+ ],
158
+ "pagination": {
159
+ "count": 261,
160
+ "on": "families",
161
+ "page": 10,
162
+ "page_count": 53,
163
+ "per_page": 5
153
164
  }
154
165
  }
155
166
  ```
@@ -157,115 +168,137 @@ Output:
157
168
  ### Create a new kit
158
169
  Code:
159
170
  ```ruby
160
- p result = client.create(:kits, name: 'Megakit', domains: 'localhost')
161
- kit_id = result['kit']['id']
171
+ p kit = client.create(:kits, name: 'Megakit', domains: 'localhost')
162
172
  ```
163
173
 
164
174
  Output:
165
175
  ```json
166
176
  {
167
- "kit": {
168
- "id": "izw0qiq",
169
- "name": "Megakit",
170
- "analytics": false,
171
- "badge": true,
172
- "domains": [
173
- "localhost"
174
- ],
175
- "families": [
176
-
177
- ]
178
- }
177
+ "id": "izw0qiq",
178
+ "name": "Megakit",
179
+ "analytics": false,
180
+ "badge": true,
181
+ "domains": [
182
+ "localhost"
183
+ ],
184
+ "families": [
185
+
186
+ ]
179
187
  }
180
188
  ```
181
189
 
182
190
  ### Disable the badge of a kit
183
191
  Code:
184
192
  ```ruby
185
- p client.update(:kits, kit_id, badge: false)
193
+ p client.update(:kits, kit.id, badge: false)
186
194
  ```
187
195
 
188
196
  Output:
189
197
  ```json
190
198
  {
191
- "kit": {
192
- "id": "izw0qiq",
193
- "name": "Megakit",
194
- "analytics": false,
195
- "badge": false,
196
- "domains": [
197
- "localhost"
198
- ],
199
- "families": [
200
-
201
- ]
202
- }
199
+ "id": "izw0qiq",
200
+ "name": "Megakit",
201
+ "analytics": false,
202
+ "badge": false,
203
+ "domains": [
204
+ "localhost"
205
+ ],
206
+ "families": [
207
+
208
+ ]
203
209
  }
204
210
  ```
205
211
 
206
212
  ### Look up the id of a font family by its slug
207
213
  Code:
208
214
  ```ruby
209
- p result = client.show(:families, 'proxima-nova')
210
- family_id = result['family']['id']
215
+ p family = client.show(:families, 'proxima-nova')
211
216
  ```
212
217
 
213
218
  Output:
214
219
  ```json
215
220
  {
216
- "family": {
217
- "id": "vcsm",
218
- "link": "/api/v1/json/families/vcsm"
219
- }
221
+ "id": "vcsm",
222
+ "link": "/api/v1/json/families/vcsm"
220
223
  }
221
224
  ```
222
225
 
223
226
  ### Add a font family into a kit
224
227
  Code:
225
228
  ```ruby
226
- p client.update(:kits, kit_id, families: { "0" => { id: family_id } })
229
+ p client.update(:kits, kit.id, families: { "0" => { id: family.id } })
227
230
  ```
228
231
 
229
232
  Output:
230
233
  ```json
231
234
  {
232
- "kit": {
233
- "id": "nys8sny",
234
- "name": "Megakit",
235
- "analytics": false,
236
- "badge": false,
237
- "domains": [
238
- "localhost"
239
- ],
240
- "families": [
241
- {
242
- "id": "vcsm",
243
- "name": "Proxima Nova",
244
- "slug": "proxima-nova",
245
- "css_names": [
246
- "proxima-nova-1",
247
- "proxima-nova-2"
248
- ],
249
- ...
250
- }
251
- ]
252
- }
235
+ "id": "nys8sny",
236
+ "name": "Megakit",
237
+ "analytics": false,
238
+ "badge": false,
239
+ "domains": [
240
+ "localhost"
241
+ ],
242
+ "families": [
243
+ {
244
+ "id": "vcsm",
245
+ "name": "Proxima Nova",
246
+ "slug": "proxima-nova",
247
+ "css_names": [
248
+ "proxima-nova-1",
249
+ "proxima-nova-2"
250
+ ],
251
+ ...
252
+ }
253
+ ]
253
254
  }
254
255
  ```
255
256
 
256
- ### Delete a kit
257
- Command:
257
+ ### Publish a kit
258
+ Code:
258
259
  ```ruby
259
- p client.delete(:kits, kit_id)
260
+ p client.update(:kits, kit.id, :publish)
260
261
  ```
261
262
 
262
263
  Output:
263
- ```json
264
+ ```
265
+ #<DateTime: 2014-05-31T06:45:29+00:00 ((2456809j,24329s,0n),+0s,2299161j)>
266
+ ```
267
+
268
+ ### Show the description of a published kit
269
+ Code:
270
+ ```ruby
271
+ p client.show(:kits, kit.id, :published)
272
+ ```
273
+
274
+ Output:
275
+ ```
264
276
  {
265
- "ok": true
277
+ "id": "vzt4lrg",
278
+ "name": "Megakit",
279
+ "analytics": false,
280
+ "badge": false,
281
+ "domains": [
282
+ "localhost"
283
+ ],
284
+ "families": [
285
+ ...
286
+ ],
287
+ "published": "2014-05-31T06:45:29Z"
266
288
  }
267
289
  ```
268
290
 
291
+ ### Delete a kit
292
+ Command:
293
+ ```ruby
294
+ p client.delete(:kits, kit.id)
295
+ ```
296
+
297
+ Output:
298
+ ```
299
+ true
300
+ ```
301
+
269
302
  ## Command-line Interface (CLI)
270
303
  There is a simple CLI provided in order to demonstrate the usage of the
271
304
  library and to give the ability to perform basic operations without writing
@@ -294,15 +327,13 @@ The tool has two modes: normal and interactive. If `command` is provided,
294
327
  the tool executes only that particular command and terminates:
295
328
  ```
296
329
  $ typekit -t $tk_token index kits
297
- {
298
- "kits": [
299
- {
300
- "id": "bas4cfe",
301
- "link": "/api/v1/json/kits/bas4cfe"
302
- },
303
- ...
304
- ]
305
- }
330
+ [
331
+ {
332
+ "id": "bas4cfe",
333
+ "link": "/api/v1/json/kits/bas4cfe"
334
+ },
335
+ ...
336
+ ]
306
337
  $
307
338
  ```
308
339
 
@@ -327,15 +358,13 @@ Examples:
327
358
  update kits bas4cfe { "name": "Ultrakit" }
328
359
  delete kits bas4cfe
329
360
  > index kits
330
- {
331
- "kits": [
332
- {
333
- "id": "bas4cfe",
334
- "link": "/api/v1/json/kits/bas4cfe"
335
- },
336
- ...
337
- ]
338
- }
361
+ [
362
+ {
363
+ "id": "bas4cfe",
364
+ "link": "/api/v1/json/kits/bas4cfe"
365
+ },
366
+ ...
367
+ ]
339
368
  > exit
340
369
  Bye.
341
370
  $
data/bin/typekit CHANGED
@@ -3,10 +3,14 @@
3
3
  $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
4
4
 
5
5
  require 'typekit'
6
+ require 'readline'
6
7
  require 'optparse'
7
8
  require 'json'
8
9
 
9
10
  class Controller
11
+ ACTIONS = %w{index show create update delete}
12
+ KEYWORDS = %w{families kits libraries published publish}
13
+
10
14
  def initialize(**options)
11
15
  @client = Typekit::Client.new(**options)
12
16
  end
@@ -22,7 +26,7 @@ class Controller
22
26
  puts <<-HELP
23
27
  Usage: <action> <resource> [parameters]
24
28
 
25
- <action> show, create, update, or delete
29
+ <action> index, show, create, update, or delete
26
30
  <resource> a list separated by whitespaces
27
31
  [parameters] a JSON-encoded hash (optional)
28
32
 
@@ -41,6 +45,8 @@ HELP
41
45
 
42
46
  def print(output)
43
47
  puts JSON.pretty_generate(output)
48
+ rescue JSON::GeneratorError
49
+ puts output.to_s # neither hash nor array
44
50
  end
45
51
 
46
52
  def parse(command)
@@ -50,12 +56,8 @@ HELP
50
56
  action, path = chunks[0], chunks[1..-1]
51
57
 
52
58
  raise 'Missing action name' if action.nil?
53
- raise 'Invalid action name' unless action =~ /^\w+$/
54
-
59
+ raise 'Invalid action name' unless ACTIONS.include?(action)
55
60
  raise 'Missing resource name' if path.empty?
56
- unless path.all?{ |chunk| chunk =~ /^[-\w\d]+$/ }
57
- raise 'Invalid resource name'
58
- end
59
61
 
60
62
  [ action, path, parameters ]
61
63
  end
@@ -123,11 +125,22 @@ end
123
125
 
124
126
  puts %{Type 'help' for help and 'exit' to exit.}
125
127
 
128
+ COMMANDS = Controller::ACTIONS + Controller::KEYWORDS + %w{help exit}
129
+ Readline.completion_proc = proc do |input|
130
+ COMMANDS.grep(/^#{ Regexp.escape(input) }/)
131
+ end
132
+
126
133
  loop do
127
134
  begin
128
- print '> '
129
- command = $stdin.gets.strip
135
+ command = Readline.readline('> ', true)
136
+ if command.nil? # ^D
137
+ puts
138
+ next
139
+ end
140
+
141
+ command.strip!
130
142
  next if command.empty?
143
+
131
144
  case command
132
145
  when 'exit'
133
146
  break
@@ -4,16 +4,16 @@ module Typekit
4
4
  class Client
5
5
  extend Forwardable
6
6
 
7
- def_delegators :@config, :map, :dispatcher, :processor
8
- private def_delegator :dispatcher, :deliver
9
- private def_delegator :processor, :process
7
+ def_delegators :@config, :mapper, :dispatcher, :translator
8
+ private def_delegator :dispatcher, :process, :dispatch
9
+ private def_delegator :translator, :process, :translate
10
10
 
11
11
  def initialize(config: :default, **options)
12
12
  @config = Configuration.build(config, **options)
13
13
  end
14
14
 
15
15
  def perform(*arguments)
16
- process(deliver(trace(*arguments)))
16
+ translate(dispatch(trace(*arguments)))
17
17
  end
18
18
 
19
19
  Typekit.actions.each do |action|
@@ -32,7 +32,7 @@ module Typekit
32
32
  def trace(*arguments)
33
33
  action, path, parameters = prepare(*arguments)
34
34
  request = Connection::Request.new(action: action, parameters: parameters)
35
- map.trace(request, path)
35
+ mapper.trace(request, path)
36
36
  end
37
37
  end
38
38
  end
@@ -9,7 +9,7 @@ module Typekit
9
9
  @token = token
10
10
  end
11
11
 
12
- [ :map, :dispatcher, :processor ].each do |component|
12
+ [ :mapper, :dispatcher, :translator ].each do |component|
13
13
  class_eval <<-METHOD, __FILE__, __LINE__ + 1
14
14
  def #{ component }
15
15
  @#{ component } ||= build_#{ component }
@@ -3,9 +3,9 @@ module Typekit
3
3
  class Default < Base
4
4
  private
5
5
 
6
- def build_map
7
- context = [ Typekit.address, "v#{ version }", format ]
8
- Routing::Map.new do
6
+ def build_mapper
7
+ context = build_context
8
+ Routing::Mapper.new do
9
9
  scope context do
10
10
  resources :families, only: :show do
11
11
  show ':variant', on: :member
@@ -26,8 +26,12 @@ module Typekit
26
26
  Connection::Dispatcher.new(adaptor: :standard, token: token)
27
27
  end
28
28
 
29
- def build_processor
30
- Processor.new(format: format)
29
+ def build_translator
30
+ Processing::Translator.new(format: format)
31
+ end
32
+
33
+ def build_context
34
+ [ Typekit.address, "v#{ version }", format ]
31
35
  end
32
36
  end
33
37
  end
@@ -6,11 +6,11 @@ module Typekit
6
6
  @adaptor = Adaptor.build(adaptor)
7
7
  end
8
8
 
9
- def deliver(request)
9
+ def process(request)
10
10
  method = Helper.translate_action(request.action)
11
11
  code, _, body = @adaptor.process(method, request.address,
12
12
  request.parameters, 'X-Typekit-Token' => @token)
13
- Response.new(code: code.to_i, content: body)
13
+ Response.new(code: code.to_i, body: body)
14
14
  end
15
15
  end
16
16
  end
@@ -5,7 +5,7 @@ module Typekit
5
5
  class Request
6
6
  extend Forwardable
7
7
 
8
- attr_reader :action, :parameters, :path
8
+ attr_reader :action, :parameters, :path, :node
9
9
  def_delegators :@path, :<<
10
10
 
11
11
  def initialize(action:, parameters: {})
@@ -15,9 +15,12 @@ module Typekit
15
15
  end
16
16
 
17
17
  def address
18
- # TODO: cache?
19
18
  @path.map(&:to_s).join('/')
20
19
  end
20
+
21
+ def sign(node)
22
+ @node = node
23
+ end
21
24
  end
22
25
  end
23
26
  end
@@ -1,19 +1,15 @@
1
1
  module Typekit
2
2
  module Connection
3
3
  class Response
4
- attr_reader :code, :content
4
+ attr_reader :code, :body
5
5
 
6
- def initialize(code:, content:)
6
+ def initialize(code:, body:)
7
7
  @code = code
8
- @content = content
8
+ @body = body
9
9
  end
10
10
 
11
11
  def success?
12
- @code == 200
13
- end
14
-
15
- def redirect?
16
- @code == 302
12
+ [ 200, 302 ].include?(@code)
17
13
  end
18
14
  end
19
15
  end