typekit-client 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -3
  3. data/.travis.yml +4 -0
  4. data/.yardopts +6 -0
  5. data/CHANGELOG.md +12 -0
  6. data/Guardfile +21 -3
  7. data/README.md +253 -248
  8. data/bin/typekit-client +16 -16
  9. data/bin/typekit-publisher +6 -5
  10. data/lib/typekit.rb +6 -2
  11. data/lib/typekit/client.rb +66 -24
  12. data/lib/typekit/collection.rb +6 -11
  13. data/lib/typekit/collection/base.rb +40 -0
  14. data/lib/typekit/collection/serialization.rb +17 -0
  15. data/lib/typekit/converter.rb +26 -0
  16. data/lib/typekit/converter/boolean.rb +12 -0
  17. data/lib/typekit/converter/collection.rb +13 -0
  18. data/lib/typekit/converter/datetime.rb +12 -0
  19. data/lib/typekit/converter/element.rb +13 -0
  20. data/lib/typekit/converter/errors.rb +12 -0
  21. data/lib/typekit/converter/unknown.rb +13 -0
  22. data/lib/typekit/core.rb +8 -10
  23. data/lib/typekit/element.rb +27 -0
  24. data/lib/typekit/element/association.rb +63 -0
  25. data/lib/typekit/element/base.rb +61 -0
  26. data/lib/typekit/element/persistence.rb +61 -0
  27. data/lib/typekit/element/query.rb +25 -0
  28. data/lib/typekit/element/serialization.rb +17 -0
  29. data/lib/typekit/error.rb +23 -0
  30. data/lib/typekit/helper.rb +59 -10
  31. data/lib/typekit/record.rb +18 -22
  32. data/lib/typekit/record/family.rb +24 -1
  33. data/lib/typekit/record/kit.rb +29 -1
  34. data/lib/typekit/record/library.rb +4 -1
  35. data/lib/typekit/record/variation.rb +13 -1
  36. data/lib/typekit/version.rb +1 -1
  37. data/spec/feature/create_kit_spec.rb +52 -0
  38. data/spec/feature/delete_kit_spec.rb +33 -0
  39. data/spec/feature/index_kits_spec.rb +55 -0
  40. data/spec/feature/publish_kit_spec.rb +15 -0
  41. data/spec/feature/show_family_spec.rb +75 -0
  42. data/spec/feature/show_kit_spec.rb +56 -0
  43. data/spec/feature/show_library_spec.rb +29 -0
  44. data/spec/feature/show_variation_spec.rb +18 -0
  45. data/spec/feature/update_kit_spec.rb +88 -0
  46. data/spec/fixture/cassette/create_kits_bad.yml +16 -0
  47. data/spec/fixture/cassette/create_kits_ok.yml +16 -0
  48. data/spec/fixture/cassette/delete_kits_xxx_not_found.yml +13 -0
  49. data/spec/{cassettes → fixture/cassette}/delete_kits_xxx_ok.yml +0 -3
  50. data/spec/fixture/cassette/index_kits_show_kit_xxx_ok.yml +25 -0
  51. data/spec/{cassettes → fixture/cassette}/index_kits_unauthorized.yml +0 -3
  52. data/spec/{cassettes → fixture/cassette}/show_families_xxx_found.yml +0 -3
  53. data/spec/{cassettes → fixture/cassette}/show_families_xxx_ok.yml +0 -3
  54. data/spec/{cassettes → fixture/cassette}/show_families_xxx_yyy_ok.yml +0 -3
  55. data/spec/fixture/cassette/show_families_yyy_update_kits_xxx_families_ok.yml +35 -0
  56. data/spec/fixture/cassette/show_kits_xxx_families_yyy_show_family_yyy_ok.yml +45 -0
  57. data/spec/fixture/cassette/show_kits_xxx_not_found.yml +13 -0
  58. data/spec/fixture/cassette/show_kits_xxx_show_family_yyy_ok.yml +46 -0
  59. data/spec/{cassettes → fixture/cassette}/show_libraries_xxx_ok.yml +0 -3
  60. data/spec/fixture/cassette/update_kits_xxx_empty_families_ok.yml +16 -0
  61. data/spec/fixture/cassette/update_kits_xxx_families_ok.yml +18 -0
  62. data/spec/fixture/cassette/update_kits_xxx_families_variations_ok.yml +18 -0
  63. data/spec/fixture/cassette/update_kits_xxx_name_ok.yml +17 -0
  64. data/spec/fixture/cassette/update_kits_xxx_publish_ok.yml +16 -0
  65. data/spec/fixture/record/article.rb +11 -0
  66. data/spec/fixture/record/section.rb +10 -0
  67. data/spec/lib/typekit/collection_spec.rb +22 -0
  68. data/spec/{typekit/processing → lib/typekit}/converter_spec.rb +13 -13
  69. data/spec/lib/typekit/element/association_spec.rb +96 -0
  70. data/spec/lib/typekit/element/base_spec.rb +70 -0
  71. data/spec/lib/typekit/element/persistence_spec.rb +97 -0
  72. data/spec/lib/typekit/element/serialization_spec.rb +28 -0
  73. data/spec/lib/typekit/element_spec.rb +58 -0
  74. data/spec/{typekit → lib/typekit}/helper_spec.rb +6 -8
  75. data/spec/lib/typekit/record_spec.rb +57 -0
  76. data/spec/spec_helper.rb +10 -3
  77. data/spec/support/common_helper.rb +5 -0
  78. data/spec/support/record_helper.rb +38 -0
  79. data/typekit-client.gemspec +11 -4
  80. metadata +164 -58
  81. data/lib/typekit/processing.rb +0 -8
  82. data/lib/typekit/processing/converter.rb +0 -28
  83. data/lib/typekit/processing/converter/boolean.rb +0 -14
  84. data/lib/typekit/processing/converter/collection.rb +0 -18
  85. data/lib/typekit/processing/converter/datetime.rb +0 -14
  86. data/lib/typekit/processing/converter/errors.rb +0 -24
  87. data/lib/typekit/processing/converter/record.rb +0 -16
  88. data/lib/typekit/processing/converter/unknown.rb +0 -15
  89. data/lib/typekit/processing/translator.rb +0 -13
  90. data/lib/typekit/record/base.rb +0 -52
  91. data/spec/cassettes/index_kits_ok.yml +0 -16
  92. data/spec/cassettes/show_kits_xxx_families_yyy_ok.yml +0 -16
  93. data/spec/cassettes/show_kits_xxx_ok.yml +0 -17
  94. data/spec/features/client/delete_kit_spec.rb +0 -13
  95. data/spec/features/client/index_kits_spec.rb +0 -25
  96. data/spec/features/client/show_family_spec.rb +0 -47
  97. data/spec/features/client/show_kit_spec.rb +0 -18
  98. data/spec/features/client/show_library_spec.rb +0 -18
  99. data/spec/features/client/show_variation_spec.rb +0 -22
  100. data/spec/support/resource_helper.rb +0 -34
  101. data/spec/typekit/record/base_spec.rb +0 -85
  102. data/spec/typekit/record_spec.rb +0 -80
@@ -0,0 +1,16 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://typekit.com/api/v1/json/kits
6
+ body:
7
+ encoding: UTF-8
8
+ string: name=Megakit
9
+ response:
10
+ status:
11
+ code: 400
12
+ message: Bad Request
13
+ body:
14
+ encoding: UTF-8
15
+ string: '{"errors":["Missing ''domains'' parameter"]}'
16
+ recorded_at: Tue, 29 Jul 2014 00:00:00 GMT
@@ -0,0 +1,16 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://typekit.com/api/v1/json/kits
6
+ body:
7
+ encoding: UTF-8
8
+ string: name=Megakit&domains=localhost
9
+ response:
10
+ status:
11
+ code: 200
12
+ message: OK
13
+ body:
14
+ encoding: UTF-8
15
+ string: '{"kit":{"id":"xxx","name":"Megakit","analytics":false,"badge":true,"domains":["localhost"],"families":[]}}'
16
+ recorded_at: Mon, 16 Jun 2014 00:00:00 GMT
@@ -0,0 +1,13 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: https://typekit.com/api/v1/json/kits/xxx
6
+ response:
7
+ status:
8
+ code: 404
9
+ message: Not Found
10
+ body:
11
+ encoding: UTF-8
12
+ string: '{"errors":["Not Found"]}'
13
+ recorded_at: Thu, 12 Jun 2014 00:00:00 GMT
@@ -7,9 +7,6 @@ http_interactions:
7
7
  status:
8
8
  code: 200
9
9
  message: OK
10
- headers:
11
- Status:
12
- - 200 OK
13
10
  body:
14
11
  encoding: UTF-8
15
12
  string: '{"ok":true}'
@@ -0,0 +1,25 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://typekit.com/api/v1/json/kits
6
+ response:
7
+ status:
8
+ code: 200
9
+ message: OK
10
+ body:
11
+ encoding: UTF-8
12
+ string: '{"kits":[{"id":"xxx","link":"/api/v1/json/kits/xxx"},{"id":"yyy","link":"/api/v1/json/kits/yyy"},{"id":"zzz","link":"/api/v1/json/kits/zzz"}]}'
13
+ recorded_at: Mon, 21 Jul 2014 00:00:00 GMT
14
+ - request:
15
+ method: get
16
+ uri: https://typekit.com/api/v1/json/kits/xxx
17
+ response:
18
+ status:
19
+ code: 200
20
+ message: OK
21
+ body:
22
+ encoding: UTF-8
23
+ string: '{"kit":{"id":"xxx","name":"Megakit","analytics":false,"badge":false,"domains":["localhost"],"families":[{"id":"vcsm","name":"Proxima
24
+ Nova","slug":"proxima-nova","css_names":["proxima-nova"],"css_stack":"\"proxima-nova\",sans-serif","subset":"default","variations":["n1","n3","n4"]},{"id":"vybr","name":"Calluna","slug":"calluna","css_names":["calluna"],"css_stack":"\"calluna\",serif","subset":"default","variations":["n4","i4"]}]}}'
25
+ recorded_at: Mon, 21 Jul 2014 00:00:00 GMT
@@ -7,9 +7,6 @@ http_interactions:
7
7
  status:
8
8
  code: 401
9
9
  message: Unauthorized
10
- headers:
11
- Status:
12
- - 401 Unauthorized
13
10
  body:
14
11
  encoding: UTF-8
15
12
  string: '{"errors":["Not authorized"]}'
@@ -7,9 +7,6 @@ http_interactions:
7
7
  status:
8
8
  code: 302
9
9
  message: Found
10
- headers:
11
- Status:
12
- - 302 Found
13
10
  body:
14
11
  encoding: UTF-8
15
12
  string: '{"family":{"id":"vybr","link":"/api/v1/json/families/vybr"}}'
@@ -7,9 +7,6 @@ http_interactions:
7
7
  status:
8
8
  code: 200
9
9
  message: OK
10
- headers:
11
- Status:
12
- - 200 OK
13
10
  body:
14
11
  encoding: UTF-8
15
12
  string: '{"family":{"id":"vybr","name":"Calluna","slug":"calluna","web_link":"http://typekit.com/fonts/calluna","browse_info":{"capitals":["uppercase-lowercase"],"classification":["serif"],"contrast":["regular"],"language":["ca","cs","de","en","es","fr","it","mt","nl","pl","pt","sl","sv"],"number_style":["lowercase"],"recommended_for":["paragraphs"],"weight":["heavy","regular"],"width":["regular"],"x_height":["regular"]},"css_stack":"serif","description":"Calluna
@@ -7,9 +7,6 @@ http_interactions:
7
7
  status:
8
8
  code: 200
9
9
  message: OK
10
- headers:
11
- Status:
12
- - 200 OK
13
10
  body:
14
11
  encoding: UTF-8
15
12
  string: '{"variation":{"id":"vcsm:i9","name":"Proxima Nova Black Italic","family":{"id":"vcsm","link":"/api/v1/json/families/vcsm","name":"Proxima
@@ -0,0 +1,35 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://typekit.com/api/v1/json/families/gkmg
6
+ response:
7
+ status:
8
+ code: 200
9
+ message: OK
10
+ body:
11
+ encoding: US-ASCII
12
+ string: ! '{"family":{"id":"gkmg","name":"Droid Sans","slug":"droid-sans","web_link":"http://typekit.com/fonts/droid-sans","browse_info":{"capitals":["uppercase-lowercase"],"classification":["sans-serif"],"contrast":["regular"],"language":["ca","cs","de","en","es","fr","it","mt","nl","pl","pt","ru","sl","sv"],"number_style":["uppercase"],"recommended_for":["paragraphs"],"weight":["regular"],"width":["regular"],"x_height":["high"]},"css_stack":"sans-serif","description":null,"foundry":{"name":"Google
13
+ Android","slug":"google-android"},"libraries":[{"id":"trial","link":"/api/v1/json/libraries/trial","name":"Trial
14
+ Library"},{"id":"personal","link":"/api/v1/json/libraries/personal","name":"Personal
15
+ Library"},{"id":"full","link":"/api/v1/json/libraries/full","name":"Full Library"},{"id":"enterprise","link":"/api/v1/json/libraries/enterprise","name":"Enterprise
16
+ Library"}],"variations":[{"id":"gkmg:n4","link":"/api/v1/json/families/gkmg/n4","name":"Droid
17
+ Sans Regular","fvd":"n4"},{"id":"gkmg:n7","link":"/api/v1/json/families/gkmg/n7","name":"Droid
18
+ Sans Bold","fvd":"n7"}]}}'
19
+ recorded_at: Thu, 24 Jul 2014 00:00:00 GMT
20
+ - request:
21
+ method: post
22
+ uri: https://typekit.com/api/v1/json/kits/xxx
23
+ body:
24
+ encoding: UTF-8
25
+ string: id=xxx&name=Megakit&analytics=false&badge=true&domains[]=localhost&families[0][id]=vqgt&families[0][subset]=all&families[0][variations][]=n4&families[1][id]=gkmg&families[1][variations][]=n4&families[1][variations][]=n7
26
+ response:
27
+ status:
28
+ code: 200
29
+ message: OK
30
+ body:
31
+ encoding: US-ASCII
32
+ string: ! '{"kit":{"id":"xxx","name":"Megakit","analytics":false,"domains":["localhost"],"families":[{"id":"gkmg","name":"Droid
33
+ Sans","slug":"droid-sans","css_names":["droid-sans-1","droid-sans-2"],"css_stack":"\"droid-sans-1\",\"droid-sans-2\",sans-serif","subset":"default","variations":["n4","n7"]},{"id":"vqgt","name":"Droid
34
+ Sans Mono","slug":"droid-sans-mono","css_names":["droid-sans-mono-1","droid-sans-mono-2"],"css_stack":"\"droid-sans-mono-1\",\"droid-sans-mono-2\",sans-serif","subset":"all","variations":["n4"]}]}}'
35
+ recorded_at: Thu, 24 Jul 2014 00:00:00 GMT
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://typekit.com/api/v1/json/kits/xxx/families/yyy
6
+ response:
7
+ status:
8
+ code: 200
9
+ message: OK
10
+ body:
11
+ encoding: UTF-8
12
+ string: '{"family":{"id":"vcsm","name":"Proxima Nova","slug":"proxima-nova","css_names":["proxima-nova"],"css_stack":"\"proxima-nova\",sans-serif","subset":"default","variations":["n1","n3","n4"]}}'
13
+ recorded_at: Wed, 23 Jul 2014 00:00:00 GMT
14
+ - request:
15
+ method: get
16
+ uri: https://typekit.com/api/v1/json/families/vcsm
17
+ response:
18
+ status:
19
+ code: 200
20
+ message: OK
21
+ body:
22
+ encoding: UTF-8
23
+ string: '{"family":{"id":"vcsm","name":"Proxima Nova","slug":"proxima-nova","web_link":"http://typekit.com/fonts/proxima-nova","browse_info":{"capitals":["uppercase-lowercase"],"classification":["sans-serif"],"contrast":["low"],"language":["ca","cs","de","en","es","fr","it","mt","nl","pl","pt","ru","sl","sv"],"number_style":["uppercase"],"recommended_for":["headings","paragraphs"],"weight":["heavy","light","regular"],"width":["regular"],"x_height":["high"]},"css_stack":"sans-serif","description":"Proxima
24
+ Nova (2005) is a complete reworking of Proxima Sans (1994). The original six
25
+ fonts (three weights with italics) have been expanded to 42 full-featured
26
+ OpenType fonts.\r\nProxima Nova straddles the gap between typefaces like Futura
27
+ and Akzidenz Grotesk. The result is a hybrid combining humanistic proportions
28
+ with a somewhat geometric appearance.","foundry":{"name":"Mark Simonson Studio","slug":"mark-simonson-studio"},"libraries":[{"id":"full","link":"/api/v1/json/libraries/full","name":"Full
29
+ Library"},{"id":"enterprise","link":"/api/v1/json/libraries/enterprise","name":"Enterprise
30
+ Library"}],"variations":[{"id":"vcsm:n1","link":"/api/v1/json/families/vcsm/n1","name":"Proxima
31
+ Nova Thin","fvd":"n1"},{"id":"vcsm:i1","link":"/api/v1/json/families/vcsm/i1","name":"Proxima
32
+ Nova Thin Italic","fvd":"i1"},{"id":"vcsm:n3","link":"/api/v1/json/families/vcsm/n3","name":"Proxima
33
+ Nova Light","fvd":"n3"},{"id":"vcsm:i3","link":"/api/v1/json/families/vcsm/i3","name":"Proxima
34
+ Nova Light Italic","fvd":"i3"},{"id":"vcsm:n4","link":"/api/v1/json/families/vcsm/n4","name":"Proxima
35
+ Nova Regular","fvd":"n4"},{"id":"vcsm:i4","link":"/api/v1/json/families/vcsm/i4","name":"Proxima
36
+ Nova Regular Italic","fvd":"i4"},{"id":"vcsm:n6","link":"/api/v1/json/families/vcsm/n6","name":"Proxima
37
+ Nova Semibold","fvd":"n6"},{"id":"vcsm:i6","link":"/api/v1/json/families/vcsm/i6","name":"Proxima
38
+ Nova Semibold Italic","fvd":"i6"},{"id":"vcsm:n7","link":"/api/v1/json/families/vcsm/n7","name":"Proxima
39
+ Nova Bold","fvd":"n7"},{"id":"vcsm:i7","link":"/api/v1/json/families/vcsm/i7","name":"Proxima
40
+ Nova Bold Italic","fvd":"i7"},{"id":"vcsm:n8","link":"/api/v1/json/families/vcsm/n8","name":"Proxima
41
+ Nova Extrabold","fvd":"n8"},{"id":"vcsm:i8","link":"/api/v1/json/families/vcsm/i8","name":"Proxima
42
+ Nova Extrabold Italic","fvd":"i8"},{"id":"vcsm:n9","link":"/api/v1/json/families/vcsm/n9","name":"Proxima
43
+ Nova Black","fvd":"n9"},{"id":"vcsm:i9","link":"/api/v1/json/families/vcsm/i9","name":"Proxima
44
+ Nova Black Italic","fvd":"i9"}]}}'
45
+ recorded_at: Wed, 23 Jul 2014 00:00:00 GMT
@@ -0,0 +1,13 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://typekit.com/api/v1/json/kits/xxx
6
+ response:
7
+ status:
8
+ code: 404
9
+ message: Not Found
10
+ body:
11
+ encoding: UTF-8
12
+ string: '{"errors":["Not Found"]}'
13
+ recorded_at: Tue, 17 Jun 2014 00:00:00 GMT
@@ -0,0 +1,46 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://typekit.com/api/v1/json/kits/xxx
6
+ response:
7
+ status:
8
+ code: 200
9
+ message: OK
10
+ body:
11
+ encoding: UTF-8
12
+ string: '{"kit":{"id":"xxx","name":"Megakit","analytics":false,"badge":false,"domains":["localhost"],"families":[{"id":"vcsm","name":"Proxima
13
+ Nova","slug":"proxima-nova","css_names":["proxima-nova"],"css_stack":"\"proxima-nova\",sans-serif","subset":"default","variations":["n1","n3","n4"]},{"id":"vybr","name":"Calluna","slug":"calluna","css_names":["calluna"],"css_stack":"\"calluna\",serif","subset":"default","variations":["n4","i4"]}]}}'
14
+ recorded_at: Wed, 23 Jul 2014 00:00:00 GMT
15
+ - request:
16
+ method: get
17
+ uri: https://typekit.com/api/v1/json/families/vcsm
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ body:
23
+ encoding: UTF-8
24
+ string: '{"family":{"id":"vcsm","name":"Proxima Nova","slug":"proxima-nova","web_link":"http://typekit.com/fonts/proxima-nova","browse_info":{"capitals":["uppercase-lowercase"],"classification":["sans-serif"],"contrast":["low"],"language":["ca","cs","de","en","es","fr","it","mt","nl","pl","pt","ru","sl","sv"],"number_style":["uppercase"],"recommended_for":["headings","paragraphs"],"weight":["heavy","light","regular"],"width":["regular"],"x_height":["high"]},"css_stack":"sans-serif","description":"Proxima
25
+ Nova (2005) is a complete reworking of Proxima Sans (1994). The original six
26
+ fonts (three weights with italics) have been expanded to 42 full-featured
27
+ OpenType fonts.\r\nProxima Nova straddles the gap between typefaces like Futura
28
+ and Akzidenz Grotesk. The result is a hybrid combining humanistic proportions
29
+ with a somewhat geometric appearance.","foundry":{"name":"Mark Simonson Studio","slug":"mark-simonson-studio"},"libraries":[{"id":"full","link":"/api/v1/json/libraries/full","name":"Full
30
+ Library"},{"id":"enterprise","link":"/api/v1/json/libraries/enterprise","name":"Enterprise
31
+ Library"}],"variations":[{"id":"vcsm:n1","link":"/api/v1/json/families/vcsm/n1","name":"Proxima
32
+ Nova Thin","fvd":"n1"},{"id":"vcsm:i1","link":"/api/v1/json/families/vcsm/i1","name":"Proxima
33
+ Nova Thin Italic","fvd":"i1"},{"id":"vcsm:n3","link":"/api/v1/json/families/vcsm/n3","name":"Proxima
34
+ Nova Light","fvd":"n3"},{"id":"vcsm:i3","link":"/api/v1/json/families/vcsm/i3","name":"Proxima
35
+ Nova Light Italic","fvd":"i3"},{"id":"vcsm:n4","link":"/api/v1/json/families/vcsm/n4","name":"Proxima
36
+ Nova Regular","fvd":"n4"},{"id":"vcsm:i4","link":"/api/v1/json/families/vcsm/i4","name":"Proxima
37
+ Nova Regular Italic","fvd":"i4"},{"id":"vcsm:n6","link":"/api/v1/json/families/vcsm/n6","name":"Proxima
38
+ Nova Semibold","fvd":"n6"},{"id":"vcsm:i6","link":"/api/v1/json/families/vcsm/i6","name":"Proxima
39
+ Nova Semibold Italic","fvd":"i6"},{"id":"vcsm:n7","link":"/api/v1/json/families/vcsm/n7","name":"Proxima
40
+ Nova Bold","fvd":"n7"},{"id":"vcsm:i7","link":"/api/v1/json/families/vcsm/i7","name":"Proxima
41
+ Nova Bold Italic","fvd":"i7"},{"id":"vcsm:n8","link":"/api/v1/json/families/vcsm/n8","name":"Proxima
42
+ Nova Extrabold","fvd":"n8"},{"id":"vcsm:i8","link":"/api/v1/json/families/vcsm/i8","name":"Proxima
43
+ Nova Extrabold Italic","fvd":"i8"},{"id":"vcsm:n9","link":"/api/v1/json/families/vcsm/n9","name":"Proxima
44
+ Nova Black","fvd":"n9"},{"id":"vcsm:i9","link":"/api/v1/json/families/vcsm/i9","name":"Proxima
45
+ Nova Black Italic","fvd":"i9"}]}}'
46
+ recorded_at: Wed, 23 Jul 2014 00:00:00 GMT
@@ -7,9 +7,6 @@ http_interactions:
7
7
  status:
8
8
  code: 200
9
9
  message: OK
10
- headers:
11
- Status:
12
- - 200 OK
13
10
  body:
14
11
  encoding: UTF-8
15
12
  string: '{"library":{"id":"trial","link":"/api/v1/json/libraries/trial","name":"Trial
@@ -0,0 +1,16 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://typekit.com/api/v1/json/kits/xxx
6
+ body:
7
+ encoding: UTF-8
8
+ string: id=xxx&name=Megakit&analytics=false&badge=true&domains[]=localhost&families=
9
+ response:
10
+ status:
11
+ code: 200
12
+ message: OK
13
+ body:
14
+ encoding: US-ASCII
15
+ string: ! '{"kit":{"id":"xxx","name":"Megakit","analytics":false,"domains":["localhost"],"families":[]}}'
16
+ recorded_at: Thu, 24 Jul 2014 00:00:00 GMT
@@ -0,0 +1,18 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://typekit.com/api/v1/json/kits/xxx
6
+ body:
7
+ encoding: UTF-8
8
+ string: id=xxx&name=Megakit&analytics=false&badge=true&domains[]=localhost&families[0][id]=vqgt&families[0][subset]=all&families[0][variations][]=n4&families[1][id]=gkmg
9
+ response:
10
+ status:
11
+ code: 200
12
+ message: OK
13
+ body:
14
+ encoding: US-ASCII
15
+ string: ! '{"kit":{"id":"xxx","name":"Megakit","analytics":false,"badge":true,"domains":["localhost"],"families":[{"id":"gkmg","name":"Droid
16
+ Sans","slug":"droid-sans","css_names":["droid-sans-1","droid-sans-2"],"css_stack":"\"droid-sans-1\",\"droid-sans-2\",sans-serif","subset":"default","variations":["n4","n7"]},{"id":"vqgt","name":"Droid
17
+ Sans Mono","slug":"droid-sans-mono","css_names":["droid-sans-mono-1","droid-sans-mono-2"],"css_stack":"\"droid-sans-mono-1\",\"droid-sans-mono-2\",sans-serif","subset":"all","variations":["n4"]}]}}'
18
+ recorded_at: Thu, 24 Jul 2014 00:00:00 GMT
@@ -0,0 +1,18 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://typekit.com/api/v1/json/kits/xxx
6
+ body:
7
+ encoding: UTF-8
8
+ string: id=xxx&name=Megakit&analytics=false&badge=true&domains[]=localhost&families[0][id]=vqgt&families[0][subset]=all&families[0][variations][]=n4&families[1][id]=gkmg&families[1][variations][]=n4
9
+ response:
10
+ status:
11
+ code: 200
12
+ message: OK
13
+ body:
14
+ encoding: US-ASCII
15
+ string: ! '{"kit":{"id":"xxx","name":"Megakit","analytics":false,"domains":["localhost"],"families":[{"id":"gkmg","name":"Droid
16
+ Sans","slug":"droid-sans","css_names":["droid-sans-1","droid-sans-2"],"css_stack":"\"droid-sans-1\",\"droid-sans-2\",sans-serif","subset":"default","variations":["n4"]},{"id":"vqgt","name":"Droid
17
+ Sans Mono","slug":"droid-sans-mono","css_names":["droid-sans-mono-1","droid-sans-mono-2"],"css_stack":"\"droid-sans-mono-1\",\"droid-sans-mono-2\",sans-serif","subset":"all","variations":["n4"]}]}}'
18
+ recorded_at: Thu, 24 Jul 2014 00:00:00 GMT
@@ -0,0 +1,17 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://typekit.com/api/v1/json/kits/xxx
6
+ body:
7
+ encoding: UTF-8
8
+ string: id=xxx&name=Ultrakit&analytics=false&badge=true&domains[]=localhost&families[0][id]=vqgt&families[0][subset]=all&families[0][variations][]=n4
9
+ response:
10
+ status:
11
+ code: 200
12
+ message: OK
13
+ body:
14
+ encoding: US-ASCII
15
+ string: ! '{"kit":{"id":"xxx","name":"Ultrakit","analytics":false,"badge":true,"domains":["localhost"],"families":[{"id":"vqgt","name":"Droid
16
+ Sans Mono","slug":"droid-sans-mono","css_names":["droid-sans-mono-1","droid-sans-mono-2"],"css_stack":"\"droid-sans-mono-1\",\"droid-sans-mono-2\",sans-serif","subset":"all","variations":["n4"]}]}}'
17
+ recorded_at: Thu, 24 Jul 2014 00:00:00 GMT
@@ -0,0 +1,16 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://typekit.com/api/v1/json/kits/xxx/publish
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ response:
10
+ status:
11
+ code: 200
12
+ message: OK
13
+ body:
14
+ encoding: UTF-8
15
+ string: '{"published":"2014-07-29T13:32:22Z"}'
16
+ recorded_at: Tue, 29 Jul 2014 00:00:00 GMT
@@ -0,0 +1,11 @@
1
+ module Fixture
2
+ module Record
3
+ class Article < Typekit::Element::Base
4
+ include Typekit::Element::Association
5
+ include Typekit::Element::Persistence
6
+ include Typekit::Element::Serialization
7
+
8
+ has_many :sections
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ module Fixture
2
+ module Record
3
+ class Section < Typekit::Element::Base
4
+ include Typekit::Element::Association
5
+ include Typekit::Element::Serialization
6
+
7
+ belongs_to :article
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+ require 'fixture/record/article'
3
+
4
+ RSpec.describe Typekit::Collection do
5
+ let(:article_class) { Fixture::Record::Article }
6
+
7
+ describe '.build' do
8
+ subject { described_module.build(:articles, [{ id: 4 }, { id: 2 }]) }
9
+
10
+ it 'creates a Collection' do
11
+ expect(subject).to be_an_instance_of(described_module::Base)
12
+ end
13
+
14
+ describe 'the Collection' do
15
+ it 'contains Elements' do
16
+ subject.each do |element|
17
+ expect(element).to be_an_instance_of(article_class)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,50 +1,50 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe Typekit::Processing::Converter do
3
+ RSpec.describe Typekit::Converter do
4
4
  def create(name)
5
- Typekit::Processing::Converter.build(name)
5
+ Typekit::Converter.build(name)
6
6
  end
7
7
 
8
8
  let(:request) { double(code: 200) }
9
9
 
10
10
  describe '.build#process' do
11
11
  %w{family kit library}.each do |name|
12
- it "maps '#{ name }' to a Record" do
12
+ it "maps '#{name}' to a Element" do
13
13
  result = create(name).process(request, {})
14
- expect(result).to be_kind_of(Typekit::Record::Base)
14
+ expect(result).to be_kind_of(Typekit::Element::Base)
15
15
  end
16
16
  end
17
17
 
18
18
  %w{families kits libraries}.each do |name|
19
- it "maps '#{ name }' to an array of Records" do
20
- result = create(name).process(request, [ {} ])
21
- result.each { |r| expect(r).to be_kind_of(Typekit::Record::Base) }
19
+ it "maps '#{name}' to an array of Elements" do
20
+ result = create(name).process(request, [{}])
21
+ result.each { |r| expect(r).to be_kind_of(Typekit::Element::Base) }
22
22
  end
23
23
  end
24
24
 
25
25
  %w{ok}.each do |name|
26
- it "maps '#{ name }' to a boolean" do
26
+ it "maps '#{name}' to a boolean" do
27
27
  result = create(name).process(request, true)
28
28
  expect(result).to be_kind_of(::TrueClass)
29
29
  end
30
30
  end
31
31
 
32
32
  %w{published}.each do |name|
33
- it "maps '#{ name }' to a datetime" do
33
+ it "maps '#{name}' to a datetime" do
34
34
  result = create(name).process(request, '2010-05-20T21:15:31Z')
35
35
  expect(result).to be_kind_of(::DateTime)
36
36
  end
37
37
  end
38
38
 
39
- [ nil, 'errors' ].each do |name|
40
- it "raises an exception for '#{ name }'" do
39
+ [nil, 'errors'].each do |name|
40
+ it "raises an exception for '#{name}'" do
41
41
  expect { create(name).process(request, nil) }.to \
42
- raise_error(Typekit::Processing::Error)
42
+ raise_error(Typekit::ServerError)
43
43
  end
44
44
  end
45
45
 
46
46
  %w{kittens puppies}.each do |name|
47
- it "returns unknowns like '#{ name }' as they are" do
47
+ it "returns unknowns like '#{name}' as they are" do
48
48
  result = create(name).process(request, 42)
49
49
  expect(result).to eq(name => 42)
50
50
  end