kinetic_sdk 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. checksums.yaml +7 -0
  2. data/GettingStarted.md +64 -0
  3. data/README.md +383 -0
  4. data/bin/console +12 -0
  5. data/bin/setup +8 -0
  6. data/gems/kontena-websocket-client-0.1.1/Gemfile +4 -0
  7. data/gems/kontena-websocket-client-0.1.1/LICENSE +190 -0
  8. data/gems/kontena-websocket-client-0.1.1/README.md +138 -0
  9. data/gems/kontena-websocket-client-0.1.1/Rakefile +6 -0
  10. data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark-client.rb +45 -0
  11. data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark-em.rb +66 -0
  12. data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark.rb +161 -0
  13. data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark.sh +17 -0
  14. data/gems/kontena-websocket-client-0.1.1/benchmark/websocket-echo-server.go +207 -0
  15. data/gems/kontena-websocket-client-0.1.1/examples/websocket-echo-client.rb +80 -0
  16. data/gems/kontena-websocket-client-0.1.1/kontena-websocket-client.gemspec +24 -0
  17. data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/client/connection.rb +119 -0
  18. data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/client/version.rb +13 -0
  19. data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/client.rb +848 -0
  20. data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb +81 -0
  21. data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb +55 -0
  22. data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/openssl_patch.rb +10 -0
  23. data/gems/kontena-websocket-client-0.1.1/lib/kontena-websocket-client.rb +15 -0
  24. data/gems/mime-types-3.1/Code-of-Conduct.rdoc +74 -0
  25. data/gems/mime-types-3.1/Contributing.rdoc +130 -0
  26. data/gems/mime-types-3.1/History.rdoc +658 -0
  27. data/gems/mime-types-3.1/Licence.rdoc +25 -0
  28. data/gems/mime-types-3.1/Manifest.txt +31 -0
  29. data/gems/mime-types-3.1/README.rdoc +202 -0
  30. data/gems/mime-types-3.1/Rakefile +254 -0
  31. data/gems/mime-types-3.1/lib/mime/type/columnar.rb +55 -0
  32. data/gems/mime-types-3.1/lib/mime/type.rb +573 -0
  33. data/gems/mime-types-3.1/lib/mime/types/_columnar.rb +135 -0
  34. data/gems/mime-types-3.1/lib/mime/types/cache.rb +56 -0
  35. data/gems/mime-types-3.1/lib/mime/types/columnar.rb +1 -0
  36. data/gems/mime-types-3.1/lib/mime/types/container.rb +30 -0
  37. data/gems/mime-types-3.1/lib/mime/types/deprecations.rb +32 -0
  38. data/gems/mime-types-3.1/lib/mime/types/full.rb +17 -0
  39. data/gems/mime-types-3.1/lib/mime/types/loader.rb +148 -0
  40. data/gems/mime-types-3.1/lib/mime/types/logger.rb +37 -0
  41. data/gems/mime-types-3.1/lib/mime/types/registry.rb +81 -0
  42. data/gems/mime-types-3.1/lib/mime/types.rb +228 -0
  43. data/gems/mime-types-3.1/lib/mime-types.rb +1 -0
  44. data/gems/mime-types-3.1/test/bad-fixtures/malformed +9 -0
  45. data/gems/mime-types-3.1/test/fixture/json.json +1 -0
  46. data/gems/mime-types-3.1/test/fixture/old-data +9 -0
  47. data/gems/mime-types-3.1/test/fixture/yaml.yaml +55 -0
  48. data/gems/mime-types-3.1/test/minitest_helper.rb +13 -0
  49. data/gems/mime-types-3.1/test/test_mime_type.rb +603 -0
  50. data/gems/mime-types-3.1/test/test_mime_types.rb +161 -0
  51. data/gems/mime-types-3.1/test/test_mime_types_cache.rb +109 -0
  52. data/gems/mime-types-3.1/test/test_mime_types_class.rb +155 -0
  53. data/gems/mime-types-3.1/test/test_mime_types_lazy.rb +43 -0
  54. data/gems/mime-types-3.1/test/test_mime_types_loader.rb +32 -0
  55. data/gems/mime-types-data-3.2016.0521/Code-of-Conduct.md +75 -0
  56. data/gems/mime-types-data-3.2016.0521/Contributing.md +157 -0
  57. data/gems/mime-types-data-3.2016.0521/History.md +351 -0
  58. data/gems/mime-types-data-3.2016.0521/Licence.md +25 -0
  59. data/gems/mime-types-data-3.2016.0521/Manifest.txt +18 -0
  60. data/gems/mime-types-data-3.2016.0521/README.md +61 -0
  61. data/gems/mime-types-data-3.2016.0521/Rakefile +80 -0
  62. data/gems/mime-types-data-3.2016.0521/data/mime-types.json +1 -0
  63. data/gems/mime-types-data-3.2016.0521/data/mime.content_type.column +1964 -0
  64. data/gems/mime-types-data-3.2016.0521/data/mime.docs.column +1964 -0
  65. data/gems/mime-types-data-3.2016.0521/data/mime.encoding.column +1964 -0
  66. data/gems/mime-types-data-3.2016.0521/data/mime.flags.column +1964 -0
  67. data/gems/mime-types-data-3.2016.0521/data/mime.friendly.column +1964 -0
  68. data/gems/mime-types-data-3.2016.0521/data/mime.pext.column +1964 -0
  69. data/gems/mime-types-data-3.2016.0521/data/mime.use_instead.column +1964 -0
  70. data/gems/mime-types-data-3.2016.0521/data/mime.xrefs.column +1964 -0
  71. data/gems/mime-types-data-3.2016.0521/lib/mime/types/data.rb +21 -0
  72. data/gems/mime-types-data-3.2016.0521/lib/mime-types-data.rb +3 -0
  73. data/gems/multipart-post-2.0.0/Gemfile +14 -0
  74. data/gems/multipart-post-2.0.0/History.txt +60 -0
  75. data/gems/multipart-post-2.0.0/Manifest.txt +9 -0
  76. data/gems/multipart-post-2.0.0/README.md +77 -0
  77. data/gems/multipart-post-2.0.0/Rakefile +9 -0
  78. data/gems/multipart-post-2.0.0/lib/composite_io.rb +108 -0
  79. data/gems/multipart-post-2.0.0/lib/multipart_post.rb +9 -0
  80. data/gems/multipart-post-2.0.0/lib/multipartable.rb +29 -0
  81. data/gems/multipart-post-2.0.0/lib/net/http/post/multipart.rb +27 -0
  82. data/gems/multipart-post-2.0.0/lib/parts.rb +96 -0
  83. data/gems/multipart-post-2.0.0/multipart-post.gemspec +22 -0
  84. data/gems/multipart-post-2.0.0/test/multibyte.txt +1 -0
  85. data/gems/multipart-post-2.0.0/test/net/http/post/test_multipart.rb +110 -0
  86. data/gems/multipart-post-2.0.0/test/test_composite_io.rb +115 -0
  87. data/gems/multipart-post-2.0.0/test/test_parts.rb +86 -0
  88. data/gems/parallel-1.12.1/MIT-LICENSE.txt +20 -0
  89. data/gems/parallel-1.12.1/lib/parallel/processor_count.rb +93 -0
  90. data/gems/parallel-1.12.1/lib/parallel/version.rb +3 -0
  91. data/gems/parallel-1.12.1/lib/parallel.rb +500 -0
  92. data/gems/ruby-progressbar-1.9.0/LICENSE.txt +19 -0
  93. data/gems/ruby-progressbar-1.9.0/README.md +38 -0
  94. data/gems/ruby-progressbar-1.9.0/Rakefile +2 -0
  95. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/base.rb +183 -0
  96. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/calculators/length.rb +99 -0
  97. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/calculators/running_average.rb +9 -0
  98. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/bar.rb +96 -0
  99. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/percentage.rb +29 -0
  100. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/rate.rb +43 -0
  101. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/time.rb +107 -0
  102. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/title.rb +13 -0
  103. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components.rb +5 -0
  104. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/errors/invalid_progress_error.rb +4 -0
  105. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format/formatter.rb +27 -0
  106. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format/molecule.rb +59 -0
  107. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format/string.rb +36 -0
  108. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format.rb +3 -0
  109. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/output.rb +68 -0
  110. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/outputs/non_tty.rb +47 -0
  111. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/outputs/null.rb +33 -0
  112. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/outputs/tty.rb +32 -0
  113. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/progress.rb +118 -0
  114. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb +25 -0
  115. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements.rb +1 -0
  116. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/throttle.rb +25 -0
  117. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/time.rb +30 -0
  118. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/timer.rb +72 -0
  119. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/version.rb +3 -0
  120. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar.rb +18 -0
  121. data/gems/slugify-1.0.7/README +18 -0
  122. data/gems/slugify-1.0.7/lib/slugify.rb +1012 -0
  123. data/gems/slugify-1.0.7/lib/slugify_string.rb +11 -0
  124. data/gems/slugify-1.0.7/tests/slugify_test.rb +116 -0
  125. data/gems/slugify-1.0.7/tests/string_slugify_test.rb +23 -0
  126. data/gems/websocket-driver-0.6.5/CHANGELOG.md +123 -0
  127. data/gems/websocket-driver-0.6.5/LICENSE.md +22 -0
  128. data/gems/websocket-driver-0.6.5/README.md +369 -0
  129. data/gems/websocket-driver-0.6.5/examples/tcp_server.rb +28 -0
  130. data/gems/websocket-driver-0.6.5/ext/websocket-driver/Makefile +264 -0
  131. data/gems/websocket-driver-0.6.5/ext/websocket-driver/WebsocketMaskService.java +55 -0
  132. data/gems/websocket-driver-0.6.5/ext/websocket-driver/extconf.rb +4 -0
  133. data/gems/websocket-driver-0.6.5/ext/websocket-driver/websocket_mask.bundle +0 -0
  134. data/gems/websocket-driver-0.6.5/ext/websocket-driver/websocket_mask.c +41 -0
  135. data/gems/websocket-driver-0.6.5/ext/websocket-driver/websocket_mask.o +0 -0
  136. data/gems/websocket-driver-0.6.5/lib/websocket/driver/client.rb +140 -0
  137. data/gems/websocket-driver-0.6.5/lib/websocket/driver/draft75.rb +102 -0
  138. data/gems/websocket-driver-0.6.5/lib/websocket/driver/draft76.rb +96 -0
  139. data/gems/websocket-driver-0.6.5/lib/websocket/driver/event_emitter.rb +54 -0
  140. data/gems/websocket-driver-0.6.5/lib/websocket/driver/headers.rb +45 -0
  141. data/gems/websocket-driver-0.6.5/lib/websocket/driver/hybi/frame.rb +20 -0
  142. data/gems/websocket-driver-0.6.5/lib/websocket/driver/hybi/message.rb +31 -0
  143. data/gems/websocket-driver-0.6.5/lib/websocket/driver/hybi.rb +406 -0
  144. data/gems/websocket-driver-0.6.5/lib/websocket/driver/proxy.rb +68 -0
  145. data/gems/websocket-driver-0.6.5/lib/websocket/driver/server.rb +80 -0
  146. data/gems/websocket-driver-0.6.5/lib/websocket/driver/stream_reader.rb +55 -0
  147. data/gems/websocket-driver-0.6.5/lib/websocket/driver.rb +199 -0
  148. data/gems/websocket-driver-0.6.5/lib/websocket/http/headers.rb +112 -0
  149. data/gems/websocket-driver-0.6.5/lib/websocket/http/request.rb +45 -0
  150. data/gems/websocket-driver-0.6.5/lib/websocket/http/response.rb +29 -0
  151. data/gems/websocket-driver-0.6.5/lib/websocket/http.rb +15 -0
  152. data/gems/websocket-driver-0.6.5/lib/websocket/mask.rb +14 -0
  153. data/gems/websocket-driver-0.6.5/lib/websocket/websocket_mask.rb +2 -0
  154. data/gems/websocket-driver-0.6.5/lib/websocket_mask.bundle +0 -0
  155. data/gems/websocket-driver-0.6.5-java/CHANGELOG.md +123 -0
  156. data/gems/websocket-driver-0.6.5-java/LICENSE.md +22 -0
  157. data/gems/websocket-driver-0.6.5-java/README.md +369 -0
  158. data/gems/websocket-driver-0.6.5-java/examples/tcp_server.rb +28 -0
  159. data/gems/websocket-driver-0.6.5-java/ext/websocket-driver/WebsocketMaskService.java +55 -0
  160. data/gems/websocket-driver-0.6.5-java/ext/websocket-driver/extconf.rb +4 -0
  161. data/gems/websocket-driver-0.6.5-java/ext/websocket-driver/websocket_mask.c +41 -0
  162. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/client.rb +140 -0
  163. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/draft75.rb +102 -0
  164. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/draft76.rb +96 -0
  165. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/event_emitter.rb +54 -0
  166. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/headers.rb +45 -0
  167. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/hybi/frame.rb +20 -0
  168. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/hybi/message.rb +31 -0
  169. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/hybi.rb +406 -0
  170. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/proxy.rb +68 -0
  171. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/server.rb +80 -0
  172. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/stream_reader.rb +55 -0
  173. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver.rb +199 -0
  174. data/gems/websocket-driver-0.6.5-java/lib/websocket/http/headers.rb +112 -0
  175. data/gems/websocket-driver-0.6.5-java/lib/websocket/http/request.rb +45 -0
  176. data/gems/websocket-driver-0.6.5-java/lib/websocket/http/response.rb +29 -0
  177. data/gems/websocket-driver-0.6.5-java/lib/websocket/http.rb +15 -0
  178. data/gems/websocket-driver-0.6.5-java/lib/websocket/mask.rb +14 -0
  179. data/gems/websocket-driver-0.6.5-java/lib/websocket/websocket_mask.rb +2 -0
  180. data/gems/websocket-driver-0.6.5-java/lib/websocket_mask.jar +0 -0
  181. data/gems/websocket-extensions-0.1.3/CHANGELOG.md +15 -0
  182. data/gems/websocket-extensions-0.1.3/LICENSE.md +20 -0
  183. data/gems/websocket-extensions-0.1.3/README.md +313 -0
  184. data/gems/websocket-extensions-0.1.3/lib/websocket/extensions/parser.rb +111 -0
  185. data/gems/websocket-extensions-0.1.3/lib/websocket/extensions.rb +181 -0
  186. data/lib/kinetic-sdk.rb +1 -0
  187. data/lib/kinetic_sdk/bridgehub/bridgehub-sdk.rb +80 -0
  188. data/lib/kinetic_sdk/bridgehub/lib/access_keys.rb +67 -0
  189. data/lib/kinetic_sdk/bridgehub/lib/bridge.rb +69 -0
  190. data/lib/kinetic_sdk/discussions/discussions-sdk.rb +165 -0
  191. data/lib/kinetic_sdk/discussions/lib/discussions.rb +107 -0
  192. data/lib/kinetic_sdk/discussions/lib/invitations.rb +120 -0
  193. data/lib/kinetic_sdk/discussions/lib/messages.rb +190 -0
  194. data/lib/kinetic_sdk/discussions/lib/meta.rb +14 -0
  195. data/lib/kinetic_sdk/discussions/lib/participants.rb +64 -0
  196. data/lib/kinetic_sdk/discussions/lib/related_items.rb +54 -0
  197. data/lib/kinetic_sdk/discussions/lib/websockets.rb +96 -0
  198. data/lib/kinetic_sdk/filehub/filehub-sdk.rb +80 -0
  199. data/lib/kinetic_sdk/filehub/lib/access_keys.rb +67 -0
  200. data/lib/kinetic_sdk/filehub/lib/filestores.rb +67 -0
  201. data/lib/kinetic_sdk/request_ce/lib/attribute_definitions.rb +153 -0
  202. data/lib/kinetic_sdk/request_ce/lib/bridges.rb +66 -0
  203. data/lib/kinetic_sdk/request_ce/lib/categories.rb +34 -0
  204. data/lib/kinetic_sdk/request_ce/lib/datastore_form.rb +110 -0
  205. data/lib/kinetic_sdk/request_ce/lib/datastore_submissions.rb +157 -0
  206. data/lib/kinetic_sdk/request_ce/lib/form.rb +99 -0
  207. data/lib/kinetic_sdk/request_ce/lib/form_types.rb +51 -0
  208. data/lib/kinetic_sdk/request_ce/lib/jwt.rb +55 -0
  209. data/lib/kinetic_sdk/request_ce/lib/kapp.rb +93 -0
  210. data/lib/kinetic_sdk/request_ce/lib/meta.rb +14 -0
  211. data/lib/kinetic_sdk/request_ce/lib/oauth.rb +37 -0
  212. data/lib/kinetic_sdk/request_ce/lib/security_policy_definitions.rb +157 -0
  213. data/lib/kinetic_sdk/request_ce/lib/space.rb +89 -0
  214. data/lib/kinetic_sdk/request_ce/lib/submissions.rb +215 -0
  215. data/lib/kinetic_sdk/request_ce/lib/system_api.rb +69 -0
  216. data/lib/kinetic_sdk/request_ce/lib/teams.rb +113 -0
  217. data/lib/kinetic_sdk/request_ce/lib/users.rb +245 -0
  218. data/lib/kinetic_sdk/request_ce/lib/webhook_jobs.rb +142 -0
  219. data/lib/kinetic_sdk/request_ce/lib/webhooks.rb +192 -0
  220. data/lib/kinetic_sdk/request_ce/request-ce-sdk.rb +153 -0
  221. data/lib/kinetic_sdk/task/lib/access_keys.rb +94 -0
  222. data/lib/kinetic_sdk/task/lib/categories.rb +190 -0
  223. data/lib/kinetic_sdk/task/lib/config.rb +202 -0
  224. data/lib/kinetic_sdk/task/lib/engine.rb +42 -0
  225. data/lib/kinetic_sdk/task/lib/environment.rb +14 -0
  226. data/lib/kinetic_sdk/task/lib/errors.rb +165 -0
  227. data/lib/kinetic_sdk/task/lib/groups.rb +112 -0
  228. data/lib/kinetic_sdk/task/lib/handlers.rb +105 -0
  229. data/lib/kinetic_sdk/task/lib/health.rb +28 -0
  230. data/lib/kinetic_sdk/task/lib/license.rb +52 -0
  231. data/lib/kinetic_sdk/task/lib/policy_rules.rb +166 -0
  232. data/lib/kinetic_sdk/task/lib/setup.rb +56 -0
  233. data/lib/kinetic_sdk/task/lib/sources.rb +134 -0
  234. data/lib/kinetic_sdk/task/lib/tasks.rb +17 -0
  235. data/lib/kinetic_sdk/task/lib/trees.rb +274 -0
  236. data/lib/kinetic_sdk/task/lib/users.rb +75 -0
  237. data/lib/kinetic_sdk/task/task-sdk.rb +92 -0
  238. data/lib/kinetic_sdk/utils/kinetic-http-headers.rb +150 -0
  239. data/lib/kinetic_sdk/utils/kinetic-http-response.rb +75 -0
  240. data/lib/kinetic_sdk/utils/kinetic-http.rb +552 -0
  241. data/lib/kinetic_sdk/utils/logger.rb +70 -0
  242. data/lib/kinetic_sdk/utils/random.rb +30 -0
  243. data/lib/kinetic_sdk/version.rb +7 -0
  244. data/lib/kinetic_sdk.rb +57 -0
  245. metadata +414 -0
@@ -0,0 +1,55 @@
1
+ ---
2
+ - !ruby/object:MIME::Type
3
+ content-type: application/smil
4
+ encoding: 8bit
5
+ extensions:
6
+ - smi
7
+ - smil
8
+ obsolete: true
9
+ use-instead: application/smil+xml
10
+ registered: true
11
+ - !ruby/object:MIME::Type
12
+ content-type: audio/vnd.qcelp
13
+ encoding: base64
14
+ extensions:
15
+ - qcp
16
+ obsolete: true
17
+ use-instead: audio/QCELP
18
+ registered: true
19
+ - !ruby/object:MIME::Type
20
+ content-type: image/bmp
21
+ encoding: base64
22
+ extensions:
23
+ - bmp
24
+ obsolete: true
25
+ use-instead: image/x-bmp
26
+ registered: false
27
+ - !ruby/object:MIME::Type
28
+ content-type: application/acad
29
+ encoding: base64
30
+ registered: false
31
+ - !ruby/object:MIME::Type
32
+ content-type: audio/webm
33
+ encoding: base64
34
+ extensions:
35
+ - webm
36
+ registered: false
37
+ - !ruby/object:MIME::Type
38
+ content-type: image/pjpeg
39
+ docs: Fixes a bug with IE6 and progressive JPEGs
40
+ encoding: base64
41
+ registered: false
42
+ - !ruby/object:MIME::Type
43
+ content-type: application/1d-interleaved-parityfec
44
+ encoding: base64
45
+ registered: true
46
+ - !ruby/object:MIME::Type
47
+ content-type: audio/1d-interleaved-parityfec
48
+ encoding: base64
49
+ registered: true
50
+ - !ruby/object:MIME::Type
51
+ content-type: application/x-apple-diskimage
52
+ encoding: base64
53
+ extensions:
54
+ - dmg
55
+ registered: false
@@ -0,0 +1,13 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+
3
+ require 'mime/type'
4
+ require 'fileutils'
5
+
6
+ gem 'minitest'
7
+ require 'fivemat/minitest/autorun'
8
+ require 'minitest/focus'
9
+ require 'minitest/rg'
10
+ require 'minitest-bonus-assertions'
11
+ require 'minitest/hooks'
12
+
13
+ ENV['RUBY_MIME_TYPES_LAZY_LOAD'] = 'yes'
@@ -0,0 +1,603 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+
3
+ require 'mime/types'
4
+ require 'minitest_helper'
5
+
6
+ describe MIME::Type do
7
+ # it { fail }
8
+
9
+ def mime_type(content_type)
10
+ MIME::Type.new(content_type) { |mt| yield mt if block_given? }
11
+ end
12
+
13
+ let(:x_appl_x_zip) {
14
+ mime_type('x-appl/x-zip') { |t| t.extensions = %w(zip zp) }
15
+ }
16
+ let(:text_plain) { mime_type('text/plain') }
17
+ let(:text_html) { mime_type('text/html') }
18
+ let(:image_jpeg) { mime_type('image/jpeg') }
19
+ let(:application_javascript) {
20
+ mime_type('application/javascript') do |js|
21
+ js.friendly('en' => 'JavaScript')
22
+ js.xrefs = {
23
+ 'rfc' => %w(rfc4239 rfc4239),
24
+ 'template' => %w(application/javascript)
25
+ }
26
+ js.encoding = '8bit'
27
+ js.extensions = %w(js sj)
28
+ js.registered = true
29
+ end
30
+ }
31
+ let(:text_x_yaml) {
32
+ mime_type('text/x-yaml') do |yaml|
33
+ yaml.extensions = %w(yaml yml)
34
+ yaml.encoding = '8bit'
35
+ yaml.friendly('en' => 'YAML Structured Document')
36
+ end
37
+ }
38
+ let(:text_x_yaml_with_docs) {
39
+ text_x_yaml.dup.tap do |yaml|
40
+ yaml.docs = 'Test YAML'
41
+ end
42
+ }
43
+
44
+ describe '.simplified' do
45
+ it 'leaves normal types alone' do
46
+ assert_equal 'text/plain', MIME::Type.simplified('text/plain')
47
+ end
48
+
49
+ it 'does not remove x- prefixes by default' do
50
+ assert_equal 'application/x-msword',
51
+ MIME::Type.simplified('application/x-msword')
52
+ assert_equal 'x-xyz/abc', MIME::Type.simplified('x-xyz/abc')
53
+ end
54
+
55
+ it 'removes x- prefixes when requested' do
56
+ assert_equal 'application/msword',
57
+ MIME::Type.simplified('application/x-msword', remove_x_prefix: true)
58
+ assert_equal 'xyz/abc',
59
+ MIME::Type.simplified('x-xyz/abc', remove_x_prefix: true)
60
+ end
61
+
62
+ it 'lowercases mixed-case types' do
63
+ assert_equal 'text/vcard', MIME::Type.simplified('text/vCard')
64
+ end
65
+
66
+ it 'returns nil when the value provided is not a valid content type' do
67
+ assert_nil MIME::Type.simplified('text')
68
+ end
69
+ end
70
+
71
+ describe '.i18n_key' do
72
+ it 'converts text/plain to text.plain' do
73
+ assert_equal 'text.plain', MIME::Type.i18n_key('text/plain')
74
+ end
75
+
76
+ it 'does not remove x-prefixes' do
77
+ assert_equal 'application.x-msword',
78
+ MIME::Type.i18n_key('application/x-msword')
79
+ end
80
+
81
+ it 'converts text/vCard to text.vcard' do
82
+ assert_equal 'text.vcard', MIME::Type.i18n_key('text/vCard')
83
+ end
84
+
85
+ it 'returns nil when the value provided is not a valid content type' do
86
+ assert_nil MIME::Type.i18n_key('text')
87
+ end
88
+ end
89
+
90
+ describe '.new' do
91
+ it 'fails if an invalid content type is provided' do
92
+ exception = assert_raises MIME::Type::InvalidContentType do
93
+ MIME::Type.new('apps')
94
+ end
95
+ assert_equal 'Invalid Content-Type "apps"', exception.to_s
96
+ end
97
+
98
+ it 'creates a valid content type just from a string' do
99
+ type = MIME::Type.new('text/x-yaml')
100
+
101
+ assert_instance_of MIME::Type, type
102
+ assert_equal 'text/x-yaml', type.content_type
103
+ end
104
+
105
+ it 'yields the content type in a block' do
106
+ MIME::Type.new('text/x-yaml') do |type|
107
+ assert_instance_of MIME::Type, type
108
+ assert_equal 'text/x-yaml', type.content_type
109
+ end
110
+ end
111
+
112
+ it 'creates a valid content type from a hash' do
113
+ type = MIME::Type.new(
114
+ 'content-type' => 'text/x-yaml',
115
+ 'obsolete' => true
116
+ )
117
+ assert_instance_of MIME::Type, type
118
+ assert_equal 'text/x-yaml', type.content_type
119
+ assert type.obsolete?
120
+ end
121
+
122
+ it 'creates a valid content type from an array' do
123
+ type = MIME::Type.new(%w(text/x-yaml yaml yml yz))
124
+ assert_instance_of MIME::Type, type
125
+ assert_equal 'text/x-yaml', type.content_type
126
+ assert_equal %w(yaml yml yz), type.extensions
127
+ end
128
+ end
129
+
130
+ describe '#like?' do
131
+ it 'compares two MIME::Types on #simplified values without x- prefixes' do
132
+ assert text_plain.like?(text_plain)
133
+ refute text_plain.like?(text_html)
134
+ end
135
+
136
+ it 'compares MIME::Type against string without x- prefixes' do
137
+ assert text_plain.like?(text_plain.to_s)
138
+ refute text_plain.like?(text_html.to_s)
139
+ end
140
+ end
141
+
142
+ describe '#<=>' do
143
+ it 'correctly compares identical types' do
144
+ assert_equal text_plain, text_plain
145
+ end
146
+
147
+ it 'correctly compares equivalent types' do
148
+ right = mime_type('text/Plain')
149
+ refute_same text_plain, right
150
+ assert_equal text_plain, right
151
+ end
152
+
153
+ it 'correctly compares types that sort earlier' do
154
+ refute_equal text_html, text_plain
155
+ assert_operator text_html, :<, text_plain
156
+ end
157
+
158
+ it 'correctly compares types that sort later' do
159
+ refute_equal text_plain, text_html
160
+ assert_operator text_plain, :>, text_html
161
+ end
162
+
163
+ it 'correctly compares types against equivalent strings' do
164
+ assert_equal text_plain, 'text/plain'
165
+ end
166
+
167
+ it 'correctly compares types against strings that sort earlier' do
168
+ refute_equal text_html, 'text/plain'
169
+ assert_operator text_html, :<, 'text/plain'
170
+ end
171
+
172
+ it 'correctly compares types against strings that sort later' do
173
+ refute_equal text_plain, 'text/html'
174
+ assert_operator text_plain, :>, 'text/html'
175
+ end
176
+
177
+ it 'correctly compares against nil' do
178
+ refute_equal text_html, nil
179
+ assert_operator text_plain, :<, nil
180
+ end
181
+ end
182
+
183
+ describe '#ascii?' do
184
+ it 'defaults to true for text/* types' do
185
+ assert text_plain.ascii?
186
+ end
187
+
188
+ it 'defaults to false for non-text/* types' do
189
+ refute image_jpeg.ascii?
190
+ end
191
+ end
192
+
193
+ describe '#binary?' do
194
+ it 'defaults to false for text/* types' do
195
+ refute text_plain.binary?
196
+ end
197
+
198
+ it 'defaults to true for non-text/* types' do
199
+ assert image_jpeg.binary?
200
+ end
201
+ end
202
+
203
+ describe '#complete?' do
204
+ it 'is true when there are extensions' do
205
+ assert text_x_yaml.complete?
206
+ end
207
+
208
+ it 'is false when there are no extensions' do
209
+ refute mime_type('text/plain').complete?
210
+ end
211
+ end
212
+
213
+ describe '#content_type' do
214
+ it 'preserves the original case' do
215
+ assert_equal 'text/plain', text_plain.content_type
216
+ assert_equal 'text/vCard', mime_type('text/vCard').content_type
217
+ end
218
+
219
+ it 'does not remove x- prefixes' do
220
+ assert_equal 'x-appl/x-zip', x_appl_x_zip.content_type
221
+ end
222
+ end
223
+
224
+ describe '#default_encoding' do
225
+ it 'is quoted-printable for text/* types' do
226
+ assert_equal 'quoted-printable', text_plain.default_encoding
227
+ end
228
+
229
+ it 'is base64 for non-text/* types' do
230
+ assert_equal 'base64', image_jpeg.default_encoding
231
+ end
232
+ end
233
+
234
+ describe '#encoding, #encoding=' do
235
+ it 'returns #default_encoding if not set explicitly' do
236
+ assert_equal 'quoted-printable', text_plain.encoding
237
+ assert_equal 'base64', image_jpeg.encoding
238
+ end
239
+
240
+ it 'returns the set value when set' do
241
+ text_plain.encoding = '8bit'
242
+ assert_equal '8bit', text_plain.encoding
243
+ end
244
+
245
+ it 'resets to the default encoding when set to nil or :default' do
246
+ text_plain.encoding = '8bit'
247
+ text_plain.encoding = nil
248
+ assert_equal text_plain.default_encoding, text_plain.encoding
249
+ text_plain.encoding = :default
250
+ assert_equal text_plain.default_encoding, text_plain.encoding
251
+ end
252
+
253
+ it 'raises a MIME::Type::InvalidEncoding for an invalid encoding' do
254
+ exception = assert_raises MIME::Type::InvalidEncoding do
255
+ text_plain.encoding = 'binary'
256
+ end
257
+ assert_equal 'Invalid Encoding "binary"', exception.to_s
258
+ end
259
+ end
260
+
261
+ describe '#eql?' do
262
+ it 'is not true for a non-MIME::Type' do
263
+ refute text_plain.eql?('text/plain')
264
+ end
265
+
266
+ it 'is not true for a different MIME::Type' do
267
+ refute text_plain.eql?(image_jpeg)
268
+ end
269
+
270
+ it 'is true for an equivalent MIME::Type' do
271
+ assert text_plain, mime_type('text/Plain')
272
+ end
273
+ end
274
+
275
+ describe '#extensions, #extensions=' do
276
+ it 'returns an array of extensions' do
277
+ assert_equal %w(yaml yml), text_x_yaml.extensions
278
+ assert_equal %w(zip zp), x_appl_x_zip.extensions
279
+ end
280
+
281
+ it 'sets a single extension when provided a single value' do
282
+ text_x_yaml.extensions = 'yaml'
283
+ assert_equal %w(yaml), text_x_yaml.extensions
284
+ end
285
+
286
+ it 'deduplicates extensions' do
287
+ text_x_yaml.extensions = %w(yaml yaml)
288
+ assert_equal %w(yaml), text_x_yaml.extensions
289
+ end
290
+ end
291
+
292
+ describe '#add_extensions' do
293
+ it 'does not modify extensions when provided nil' do
294
+ text_x_yaml.add_extensions(nil)
295
+ assert_equal %w(yaml yml), text_x_yaml.extensions
296
+ end
297
+
298
+ it 'remains deduplicated with duplicate values' do
299
+ text_x_yaml.add_extensions('yaml')
300
+ assert_equal %w(yaml yml), text_x_yaml.extensions
301
+ text_x_yaml.add_extensions(%w(yaml yz))
302
+ assert_equal %w(yaml yml yz), text_x_yaml.extensions
303
+ end
304
+ end
305
+
306
+ describe '#priority_compare' do
307
+ def assert_priority_less(left, right)
308
+ assert_equal(-1, left.priority_compare(right))
309
+ end
310
+
311
+ def assert_priority_same(left, right)
312
+ assert_equal 0, left.priority_compare(right)
313
+ end
314
+
315
+ def assert_priority_more(left, right)
316
+ assert_equal 1, left.priority_compare(right)
317
+ end
318
+
319
+ def assert_priority(left, middle, right)
320
+ assert_priority_less left, right
321
+ assert_priority_same left, middle
322
+ assert_priority_more right, left
323
+ end
324
+
325
+ let(:text_1) { mime_type('text/1') }
326
+ let(:text_1p) { mime_type('text/1') }
327
+ let(:text_2) { mime_type('text/2') }
328
+
329
+ it 'sorts (1) based on the simplified type' do
330
+ assert_priority text_1, text_1p, text_2
331
+ end
332
+
333
+ it 'sorts (2) based on the registration state' do
334
+ text_1.registered = text_1p.registered = true
335
+ text_1b = mime_type(text_1) { |t| t.registered = false }
336
+
337
+ assert_priority text_1, text_1p, text_1b
338
+ end
339
+
340
+ it 'sorts (3) based on the completeness' do
341
+ text_1.extensions = text_1p.extensions = '1'
342
+ text_1b = mime_type(text_1) { |t| t.extensions = nil }
343
+
344
+ assert_priority text_1, text_1p, text_1b
345
+ end
346
+
347
+ it 'sorts (4) based on obsolete status' do
348
+ text_1.obsolete = text_1p.obsolete = false
349
+ text_1b = mime_type(text_1) { |t| t.obsolete = true }
350
+
351
+ assert_priority text_1, text_1p, text_1b
352
+ end
353
+
354
+ it 'sorts (5) based on the use-instead value' do
355
+ text_1.obsolete = text_1p.obsolete = true
356
+ text_1.use_instead = text_1p.use_instead = 'abc/xyz'
357
+ text_1b = mime_type(text_1) { |t| t.use_instead = nil }
358
+
359
+ assert_priority text_1, text_1p, text_1b
360
+
361
+ text_1b.use_instead = 'abc/zzz'
362
+
363
+ assert_priority text_1, text_1p, text_1b
364
+ end
365
+ end
366
+
367
+ describe '#raw_media_type' do
368
+ it 'extracts the media type as case-preserved' do
369
+ assert_equal 'Text', mime_type('Text/plain').raw_media_type
370
+ end
371
+
372
+ it 'does not remove x- prefixes' do
373
+ assert_equal('x-appl', x_appl_x_zip.raw_media_type)
374
+ end
375
+ end
376
+
377
+ describe '#media_type' do
378
+ it 'extracts the media type as lowercase' do
379
+ assert_equal 'text', text_plain.media_type
380
+ end
381
+
382
+ it 'does not remove x- prefixes' do
383
+ assert_equal('x-appl', x_appl_x_zip.media_type)
384
+ end
385
+ end
386
+
387
+ describe '#raw_media_type' do
388
+ it 'extracts the media type as case-preserved' do
389
+ assert_equal 'Text', mime_type('Text/plain').raw_media_type
390
+ end
391
+
392
+ it 'does not remove x- prefixes' do
393
+ assert_equal('x-appl', x_appl_x_zip.raw_media_type)
394
+ end
395
+ end
396
+
397
+ describe '#sub_type' do
398
+ it 'extracts the sub type as lowercase' do
399
+ assert_equal 'plain', text_plain.sub_type
400
+ end
401
+
402
+ it 'does not remove x- prefixes' do
403
+ assert_equal('x-zip', x_appl_x_zip.sub_type)
404
+ end
405
+ end
406
+
407
+ describe '#raw_sub_type' do
408
+ it 'extracts the sub type as case-preserved' do
409
+ assert_equal 'Plain', mime_type('text/Plain').raw_sub_type
410
+ end
411
+
412
+ it 'does not remove x- prefixes' do
413
+ assert_equal('x-zip', x_appl_x_zip.raw_sub_type)
414
+ end
415
+ end
416
+
417
+ describe '#to_h' do
418
+ let(:t) { mime_type('a/b') }
419
+
420
+ it 'has the required keys (content-type, registered, encoding)' do
421
+ assert_has_keys t.to_h, %w(content-type registered encoding)
422
+ end
423
+
424
+ it 'has the docs key if there are documents' do
425
+ assert_has_keys mime_type(t) { |v| v.docs = 'a' }.to_h, %w(docs)
426
+ end
427
+
428
+ it 'has the extensions key if set' do
429
+ assert_has_keys mime_type(t) { |v| v.extensions = 'a' }.to_h,
430
+ 'extensions'
431
+ end
432
+
433
+ it 'has the preferred-extension key if set' do
434
+ assert_has_keys mime_type(t) { |v| v.preferred_extension = 'a' }.to_h,
435
+ 'preferred-extension'
436
+ end
437
+
438
+ it 'has the obsolete key if set' do
439
+ assert_has_keys mime_type(t) { |v| v.obsolete = true }.to_h, 'obsolete'
440
+ end
441
+
442
+ it 'has the obsolete and use-instead keys if set' do
443
+ assert_has_keys mime_type(t) { |v|
444
+ v.obsolete = true
445
+ v.use_instead = 'c/d'
446
+ }.to_h, %w(obsolete use-instead)
447
+ end
448
+
449
+ it 'has the signature key if set' do
450
+ assert_has_keys mime_type(t) { |v| v.signature = true }.to_h, 'signature'
451
+ end
452
+ end
453
+
454
+ describe '#to_json' do
455
+ let(:expected) {
456
+ '{"content-type":"a/b","encoding":"base64","registered":false}'
457
+ }
458
+
459
+ it 'converts to JSON when requested' do
460
+ assert_equal expected, mime_type('a/b').to_json
461
+ end
462
+ end
463
+
464
+ describe '#to_s, #to_str' do
465
+ it 'represents itself as a string of the canonical content_type' do
466
+ assert_equal 'text/plain', "#{text_plain}"
467
+ end
468
+
469
+ it 'acts like a string of the canonical content_type for comparison' do
470
+ assert_equal text_plain, 'text/plain'
471
+ end
472
+
473
+ it 'acts like a string for other purposes' do
474
+ assert_equal 'stringy', 'text/plain'.sub(text_plain, 'stringy')
475
+ end
476
+ end
477
+
478
+ describe '#xrefs, #xrefs=' do
479
+ let(:expected) {
480
+ {
481
+ 'rfc' => Set[*%w(rfc1234 rfc5678)]
482
+ }
483
+ }
484
+
485
+ it 'returns the expected results' do
486
+ application_javascript.xrefs = {
487
+ 'rfc' => %w(rfc5678 rfc1234 rfc1234)
488
+ }
489
+
490
+ assert_equal expected, application_javascript.xrefs
491
+ end
492
+ end
493
+
494
+ describe '#xref_urls' do
495
+ let(:expected) {
496
+ [
497
+ 'http://www.iana.org/go/draft1',
498
+ 'http://www.iana.org/assignments/media-types/a/b',
499
+ 'http://www.iana.org/assignments/media-types/media-types.xhtml#p-1',
500
+ 'http://www.iana.org/go/rfc-1',
501
+ 'http://www.rfc-editor.org/errata_search.php?eid=err-1',
502
+ 'http://example.org',
503
+ 'text'
504
+ ]
505
+ }
506
+
507
+ let(:type) {
508
+ mime_type('a/b').tap do |t|
509
+ t.xrefs = {
510
+ 'draft' => [ 'RFC1' ],
511
+ 'template' => [ 'a/b' ],
512
+ 'person' => [ 'p-1' ],
513
+ 'rfc' => [ 'rfc-1' ],
514
+ 'rfc-errata' => [ 'err-1' ],
515
+ 'uri' => [ 'http://example.org' ],
516
+ 'text' => [ 'text' ]
517
+ }
518
+ end
519
+ }
520
+
521
+ it 'translates according to given rules' do
522
+ assert_equal expected, type.xref_urls
523
+ end
524
+ end
525
+
526
+ describe '#use_instead' do
527
+ it 'is nil unless the type is obsolete' do
528
+ assert_nil text_plain.use_instead
529
+ end
530
+
531
+ it 'is nil if not set and the type is obsolete' do
532
+ text_plain.obsolete = true
533
+ assert_nil text_plain.use_instead
534
+ end
535
+
536
+ it 'is a different type if set and the type is obsolete' do
537
+ text_plain.obsolete = true
538
+ text_plain.use_instead = 'text/html'
539
+ assert_equal 'text/html', text_plain.use_instead
540
+ end
541
+ end
542
+
543
+ describe '#preferred_extension, #preferred_extension=' do
544
+ it 'is nil when not set and there are no extensions' do
545
+ assert_nil text_plain.preferred_extension
546
+ end
547
+
548
+ it 'is the first extension when not set but there are extensions' do
549
+ assert_equal 'yaml', text_x_yaml.preferred_extension
550
+ end
551
+
552
+ it 'is the extension provided when set' do
553
+ text_x_yaml.preferred_extension = 'yml'
554
+ assert_equal 'yml', text_x_yaml.preferred_extension
555
+ end
556
+
557
+ it 'is adds the preferred extension if it does not exist' do
558
+ text_x_yaml.preferred_extension = 'yz'
559
+ assert_equal 'yz', text_x_yaml.preferred_extension
560
+ assert_includes text_x_yaml.extensions, 'yz'
561
+ end
562
+ end
563
+
564
+ describe '#friendly' do
565
+ it 'returns English by default' do
566
+ assert_equal 'YAML Structured Document', text_x_yaml.friendly
567
+ end
568
+
569
+ it 'returns English when requested' do
570
+ assert_equal 'YAML Structured Document', text_x_yaml.friendly('en')
571
+ assert_equal 'YAML Structured Document', text_x_yaml.friendly(:en)
572
+ end
573
+
574
+ it 'returns nothing for an unknown language' do
575
+ assert_nil text_x_yaml.friendly('zz')
576
+ end
577
+
578
+ it 'merges new values from an array parameter' do
579
+ expected = { 'en' => 'Text files' }
580
+ assert_equal expected, text_plain.friendly([ 'en', 'Text files' ])
581
+ expected.update('fr' => 'des fichiers texte')
582
+ assert_equal expected,
583
+ text_plain.friendly([ 'fr', 'des fichiers texte' ])
584
+ end
585
+
586
+ it 'merges new values from a hash parameter' do
587
+ expected = { 'en' => 'Text files' }
588
+ assert_equal expected, text_plain.friendly(expected)
589
+ french = { 'fr' => 'des fichiers texte' }
590
+ expected.update(french)
591
+ assert_equal expected, text_plain.friendly(french)
592
+ end
593
+
594
+ it 'raises an ArgumentError if an unknown value is provided' do
595
+ exception = assert_raises ArgumentError do
596
+ text_plain.friendly(1)
597
+ end
598
+
599
+ assert_equal 'Expected a language or translation set, not 1',
600
+ exception.message
601
+ end
602
+ end
603
+ end