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,161 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+
3
+ require 'mime/types'
4
+ require 'minitest_helper'
5
+
6
+ describe MIME::Types do
7
+ def mime_types
8
+ @mime_types ||= MIME::Types.new.tap do |mt|
9
+ mt.add MIME::Type.new(['text/plain', %w(txt)]),
10
+ MIME::Type.new(['image/jpeg', %w(jpg jpeg)]),
11
+ MIME::Type.new('application/x-wordperfect6.1'),
12
+ MIME::Type.new(
13
+ 'content-type' => 'application/x-www-form-urlencoded',
14
+ 'registered' => true
15
+ ),
16
+ MIME::Type.new(['application/x-gzip', %w(gz)]),
17
+ MIME::Type.new(
18
+ 'content-type' => 'application/gzip',
19
+ 'extensions' => 'gz',
20
+ 'registered' => true
21
+ )
22
+ end
23
+ end
24
+
25
+ describe 'is enumerable' do
26
+ it 'correctly uses an Enumerable method like #any?' do
27
+ assert mime_types.any? { |type| type.content_type == 'text/plain' }
28
+ end
29
+
30
+ it 'implements each with no parameters to return an Enumerator' do
31
+ assert_kind_of Enumerator, mime_types.each
32
+ assert_kind_of Enumerator, mime_types.map
33
+ end
34
+
35
+ it 'will create a lazy enumerator' do
36
+ assert_kind_of Enumerator::Lazy, mime_types.lazy
37
+ assert_kind_of Enumerator::Lazy, mime_types.map.lazy
38
+ end
39
+
40
+ it 'is countable with an enumerator' do
41
+ assert_equal 6, mime_types.each.count
42
+ assert_equal 6, mime_types.lazy.count
43
+ end
44
+ end
45
+
46
+ describe '#[]' do
47
+ it 'can be searched with a MIME::Type' do
48
+ text_plain = MIME::Type.new('text/plain')
49
+ assert_includes mime_types[text_plain], 'text/plain'
50
+ assert_equal 1, mime_types[text_plain].size
51
+ end
52
+
53
+ it 'can be searched with a regular expression' do
54
+ assert_includes mime_types[/plain$/], 'text/plain'
55
+ assert_equal 1, mime_types[/plain$/].size
56
+ end
57
+
58
+ it 'sorts by priority with multiple matches' do
59
+ assert_equal %w(application/gzip application/x-gzip), mime_types[/gzip$/]
60
+ assert_equal 2, mime_types[/gzip$/].size
61
+ end
62
+
63
+ it 'can be searched with a string' do
64
+ assert_includes mime_types['text/plain'], 'text/plain'
65
+ assert_equal 1, mime_types['text/plain'].size
66
+ end
67
+
68
+ it 'can be searched with the complete flag' do
69
+ assert_empty mime_types[
70
+ 'application/x-www-form-urlencoded',
71
+ complete: true
72
+ ]
73
+ assert_includes mime_types['text/plain', complete: true], 'text/plain'
74
+ assert_equal 1, mime_types['text/plain', complete: true].size
75
+ end
76
+
77
+ it 'can be searched with the registered flag' do
78
+ assert_empty mime_types['application/x-wordperfect6.1', registered: true]
79
+ refute_empty mime_types[
80
+ 'application/x-www-form-urlencoded',
81
+ registered: true
82
+ ]
83
+ refute_empty mime_types[/gzip/, registered: true]
84
+ refute_equal mime_types[/gzip/], mime_types[/gzip/, registered: true]
85
+ end
86
+ end
87
+
88
+ describe '#add' do
89
+ let(:eruby) { MIME::Type.new('application/x-eruby') }
90
+ let(:jinja) { MIME::Type.new('application/jinja2' )}
91
+
92
+ it 'successfully adds a new type' do
93
+ mime_types.add(eruby)
94
+ assert_equal mime_types['application/x-eruby'], [ eruby ]
95
+ end
96
+
97
+ it 'complains about adding a duplicate type' do
98
+ mime_types.add(eruby)
99
+ assert_output '', /is already registered as a variant/ do
100
+ mime_types.add(eruby)
101
+ end
102
+ assert_equal mime_types['application/x-eruby'], [eruby]
103
+ end
104
+
105
+ it 'does not complain about adding a duplicate type when quiet' do
106
+ mime_types.add(eruby)
107
+ assert_output '', '' do
108
+ mime_types.add(eruby, :silent)
109
+ end
110
+ assert_equal mime_types['application/x-eruby'], [ eruby ]
111
+ end
112
+
113
+ it 'successfully adds from an array' do
114
+ mime_types.add([ eruby, jinja ])
115
+ assert_equal mime_types['application/x-eruby'], [ eruby ]
116
+ assert_equal mime_types['application/jinja2'], [ jinja ]
117
+ end
118
+
119
+ it 'successfully adds from another MIME::Types' do
120
+ mt = MIME::Types.new
121
+ mt.add(mime_types)
122
+ assert_equal mime_types.count, mt.count
123
+
124
+ mime_types.each do |type|
125
+ assert_equal mt[type.content_type], [ type ]
126
+ end
127
+ end
128
+ end
129
+
130
+ describe '#type_for' do
131
+ it 'finds all types for a given extension' do
132
+ assert_equal %w(application/gzip application/x-gzip),
133
+ mime_types.type_for('gz')
134
+ end
135
+
136
+ it 'separates the extension from filenames' do
137
+ assert_equal %w(image/jpeg), mime_types.of(['foo.jpeg', 'bar.jpeg'])
138
+ end
139
+
140
+ it 'finds multiple extensions' do
141
+ assert_equal %w(image/jpeg text/plain),
142
+ mime_types.type_for(%w(foo.txt foo.jpeg))
143
+ end
144
+
145
+ it 'does not find unknown extensions' do
146
+ assert_empty mime_types.type_for('zzz')
147
+ end
148
+
149
+ it 'modifying type extensions causes reindexing' do
150
+ plain_text = mime_types['text/plain'].first
151
+ plain_text.add_extensions('xtxt')
152
+ assert_includes mime_types.type_for('xtxt'), 'text/plain'
153
+ end
154
+ end
155
+
156
+ describe '#count' do
157
+ it 'can count the number of types inside' do
158
+ assert_equal 6, mime_types.count
159
+ end
160
+ end
161
+ end
@@ -0,0 +1,109 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+
3
+ require 'mime/types'
4
+ require 'minitest_helper'
5
+
6
+ describe MIME::Types::Cache do
7
+ include Minitest::Hooks
8
+
9
+ MUTEX = Mutex.new
10
+
11
+ def around
12
+ require 'fileutils'
13
+
14
+ MUTEX.synchronize do
15
+ @cache_file = File.expand_path('../cache.tst', __FILE__)
16
+ ENV['RUBY_MIME_TYPES_CACHE'] = @cache_file
17
+ clear_cache_file
18
+
19
+ super
20
+
21
+ clear_cache_file
22
+ ENV.delete('RUBY_MIME_TYPES_CACHE')
23
+ end
24
+ end
25
+
26
+ def reset_mime_types
27
+ MIME::Types.instance_variable_set(:@__types__, nil)
28
+ MIME::Types.send(:load_default_mime_types)
29
+ end
30
+
31
+ def clear_cache_file
32
+ FileUtils.rm @cache_file if File.exist? @cache_file
33
+ end
34
+
35
+ describe '.load' do
36
+ it 'does not use cache when RUBY_MIME_TYPES_CACHE is unset' do
37
+ ENV.delete('RUBY_MIME_TYPES_CACHE')
38
+ assert_equal(nil, MIME::Types::Cache.load)
39
+ end
40
+
41
+ it 'does not use cache when missing' do
42
+ assert_equal(nil, MIME::Types::Cache.load)
43
+ end
44
+
45
+ it 'outputs an error when there is an invalid version' do
46
+ v = MIME::Types::Data::VERSION
47
+ MIME::Types::Data.send(:remove_const, :VERSION)
48
+ MIME::Types::Data.const_set(:VERSION, '0.0')
49
+ MIME::Types::Cache.save
50
+ MIME::Types::Data.send(:remove_const, :VERSION)
51
+ MIME::Types::Data.const_set(:VERSION, v)
52
+ MIME::Types.instance_variable_set(:@__types__, nil)
53
+ assert_output '', /MIME::Types cache: invalid version/ do
54
+ MIME::Types['text/html']
55
+ end
56
+ end
57
+
58
+ it 'outputs an error when there is a marshal file incompatibility' do
59
+ MIME::Types::Cache.save
60
+ data = File.binread(@cache_file).reverse
61
+ File.open(@cache_file, 'wb') { |f| f.write(data) }
62
+ MIME::Types.instance_variable_set(:@__types__, nil)
63
+ assert_output '', /incompatible marshal file format/ do
64
+ MIME::Types['text/html']
65
+ end
66
+ end
67
+ end
68
+
69
+ describe '.save' do
70
+ it 'does not create cache when RUBY_MIME_TYPES_CACHE is unset' do
71
+ ENV.delete('RUBY_MIME_TYPES_CACHE')
72
+ assert_equal(nil, MIME::Types::Cache.save)
73
+ end
74
+
75
+ it 'creates the cache ' do
76
+ assert_equal(false, File.exist?(@cache_file))
77
+ MIME::Types::Cache.save
78
+ assert_equal(true, File.exist?(@cache_file))
79
+ end
80
+
81
+ it 'uses the cache' do
82
+ MIME::Types['text/html'].first.add_extensions('hex')
83
+ MIME::Types::Cache.save
84
+ MIME::Types.instance_variable_set(:@__types__, nil)
85
+
86
+ assert_includes MIME::Types['text/html'].first.extensions, 'hex'
87
+
88
+ reset_mime_types
89
+ end
90
+ end
91
+ end
92
+
93
+ describe MIME::Types::Container do
94
+ it 'marshals and unmarshals correctly' do
95
+ container = MIME::Types::Container.new
96
+ container['xyz'] << 'abc'
97
+
98
+ # default proc should return Set[]
99
+ assert_equal(Set[], container['abc'])
100
+ assert_equal(Set['abc'], container['xyz'])
101
+
102
+ marshalled = Marshal.dump(container)
103
+ loaded_container = Marshal.load(marshalled)
104
+
105
+ # default proc should still return Set[]
106
+ assert_equal(Set[], loaded_container['abc'])
107
+ assert_equal(Set['abc'], container['xyz'])
108
+ end
109
+ end
@@ -0,0 +1,155 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+
3
+ require 'mime/types'
4
+ require 'minitest_helper'
5
+
6
+ describe MIME::Types, 'registry' do
7
+ def setup
8
+ MIME::Types.send(:load_default_mime_types)
9
+ end
10
+
11
+ describe 'is enumerable' do
12
+ it 'correctly uses an Enumerable method like #any?' do
13
+ assert MIME::Types.any? { |type| type.content_type == 'text/plain' }
14
+ end
15
+
16
+ it 'implements each with no parameters to return an Enumerator' do
17
+ assert_kind_of Enumerator, MIME::Types.each
18
+ assert_kind_of Enumerator, MIME::Types.map
19
+ end
20
+
21
+ it 'will create a lazy enumerator' do
22
+ assert_kind_of Enumerator::Lazy, MIME::Types.lazy
23
+ assert_kind_of Enumerator::Lazy, MIME::Types.map.lazy
24
+ end
25
+
26
+ it 'is countable with an enumerator' do
27
+ assert MIME::Types.each.count > 999
28
+ assert MIME::Types.lazy.count > 999
29
+ end
30
+ end
31
+
32
+ describe '.[]' do
33
+ it 'can be searched with a MIME::Type' do
34
+ text_plain = MIME::Type.new('text/plain')
35
+ assert_includes MIME::Types[text_plain], 'text/plain'
36
+ assert_equal 1, MIME::Types[text_plain].size
37
+ end
38
+
39
+ it 'can be searched with a regular expression' do
40
+ assert_includes MIME::Types[/plain$/], 'text/plain'
41
+ assert_equal 1, MIME::Types[/plain$/].size
42
+ end
43
+
44
+ it 'sorts by priority with multiple matches' do
45
+ assert_equal %w(application/gzip application/x-gzip multipart/x-gzip),
46
+ MIME::Types[/gzip$/]
47
+ assert_equal 3, MIME::Types[/gzip$/].size
48
+ end
49
+
50
+ it 'can be searched with a string' do
51
+ assert_includes MIME::Types['text/plain'], 'text/plain'
52
+ assert_equal 1, MIME::Types['text/plain'].size
53
+ end
54
+
55
+ it 'can be searched with the complete flag' do
56
+ assert_empty MIME::Types[
57
+ 'application/x-www-form-urlencoded',
58
+ complete: true
59
+ ]
60
+ assert_includes MIME::Types['text/plain', complete: true], 'text/plain'
61
+ assert_equal 1, MIME::Types['text/plain', complete: true].size
62
+ end
63
+
64
+ it 'can be searched with the registered flag' do
65
+ assert_empty MIME::Types['application/x-wordperfect6.1', registered: true]
66
+ refute_empty MIME::Types[
67
+ 'application/x-www-form-urlencoded',
68
+ registered: true
69
+ ]
70
+ refute_empty MIME::Types[/gzip/, registered: true]
71
+ refute_equal MIME::Types[/gzip/], MIME::Types[/gzip/, registered: true]
72
+ end
73
+ end
74
+
75
+ describe '.type_for' do
76
+ it 'finds all types for a given extension' do
77
+ assert_equal %w(application/gzip application/x-gzip),
78
+ MIME::Types.type_for('gz')
79
+ end
80
+
81
+ it 'separates the extension from filenames' do
82
+ assert_equal %w(image/jpeg), MIME::Types.of(['foo.jpeg', 'bar.jpeg'])
83
+ end
84
+
85
+ it 'finds multiple extensions' do
86
+ assert_equal %w(image/jpeg text/plain),
87
+ MIME::Types.type_for(%w(foo.txt foo.jpeg))
88
+ end
89
+
90
+ it 'does not find unknown extensions' do
91
+ assert_empty MIME::Types.type_for('zzz')
92
+ end
93
+
94
+ it 'modifying type extensions causes reindexing' do
95
+ plain_text = MIME::Types['text/plain'].first
96
+ plain_text.add_extensions('xtxt')
97
+ assert_includes MIME::Types.type_for('xtxt'), 'text/plain'
98
+ end
99
+ end
100
+
101
+ describe '.count' do
102
+ it 'can count the number of types inside' do
103
+ assert MIME::Types.count > 999
104
+ end
105
+ end
106
+
107
+ describe '.add' do
108
+ def setup
109
+ MIME::Types.instance_variable_set(:@__types__, nil)
110
+ MIME::Types.send(:load_default_mime_types)
111
+ end
112
+
113
+ let(:eruby) { MIME::Type.new('application/x-eruby') }
114
+ let(:jinja) { MIME::Type.new('application/jinja2' )}
115
+
116
+ it 'successfully adds a new type' do
117
+ MIME::Types.add(eruby)
118
+ assert_equal MIME::Types['application/x-eruby'], [ eruby ]
119
+ end
120
+
121
+ it 'complains about adding a duplicate type' do
122
+ MIME::Types.add(eruby)
123
+ assert_output '', /is already registered as a variant/ do
124
+ MIME::Types.add(eruby)
125
+ end
126
+ assert_equal MIME::Types['application/x-eruby'], [eruby]
127
+ end
128
+
129
+ it 'does not complain about adding a duplicate type when quiet' do
130
+ MIME::Types.add(eruby)
131
+ assert_silent do
132
+ MIME::Types.add(eruby, :silent)
133
+ end
134
+ assert_equal MIME::Types['application/x-eruby'], [ eruby ]
135
+ end
136
+
137
+ it 'successfully adds from an array' do
138
+ MIME::Types.add([ eruby, jinja ])
139
+ assert_equal MIME::Types['application/x-eruby'], [ eruby ]
140
+ assert_equal MIME::Types['application/jinja2'], [ jinja ]
141
+ end
142
+
143
+ it 'successfully adds from another MIME::Types' do
144
+ old_count = MIME::Types.count
145
+
146
+ mt = MIME::Types.new
147
+ mt.add(eruby)
148
+
149
+ MIME::Types.add(mt)
150
+ assert_equal old_count + 1, MIME::Types.count
151
+
152
+ assert_equal MIME::Types[eruby.content_type], [ eruby ]
153
+ end
154
+ end
155
+ end
@@ -0,0 +1,43 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+
3
+ require 'mime/types'
4
+ require 'minitest_helper'
5
+
6
+ describe MIME::Types, 'lazy loading' do
7
+ def setup
8
+ ENV['RUBY_MIME_TYPES_LAZY_LOAD'] = 'true'
9
+ end
10
+
11
+ def teardown
12
+ reset_mime_types
13
+ ENV.delete('RUBY_MIME_TYPES_LAZY_LOAD')
14
+ end
15
+
16
+ def reset_mime_types
17
+ MIME::Types.instance_variable_set(:@__types__, nil)
18
+ MIME::Types.send(:load_default_mime_types)
19
+ end
20
+
21
+ describe '.lazy_load?' do
22
+ it 'is true when RUBY_MIME_TYPES_LAZY_LOAD is set' do
23
+ assert_equal true, MIME::Types.send(:lazy_load?)
24
+ end
25
+
26
+ it 'is nil when RUBY_MIME_TYPES_LAZY_LOAD is unset' do
27
+ ENV['RUBY_MIME_TYPES_LAZY_LOAD'] = nil
28
+ assert_equal nil, MIME::Types.send(:lazy_load?)
29
+ end
30
+
31
+ it 'is false when RUBY_MIME_TYPES_LAZY_LOAD is false' do
32
+ ENV['RUBY_MIME_TYPES_LAZY_LOAD'] = 'false'
33
+ assert_equal false, MIME::Types.send(:lazy_load?)
34
+ end
35
+ end
36
+
37
+ it 'loads lazily when RUBY_MIME_TYPES_LAZY_LOAD is set' do
38
+ MIME::Types.instance_variable_set(:@__types__, nil)
39
+ assert_nil MIME::Types.instance_variable_get(:@__types__)
40
+ refute_nil MIME::Types['text/html'].first
41
+ refute_nil MIME::Types.instance_variable_get(:@__types__)
42
+ end
43
+ end
@@ -0,0 +1,32 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+
3
+ require 'mime/types'
4
+ require 'minitest_helper'
5
+
6
+ describe MIME::Types::Loader do
7
+ def setup
8
+ @path = File.expand_path('../fixture', __FILE__)
9
+ @loader = MIME::Types::Loader.new(@path)
10
+ @bad_path = File.expand_path('../bad-fixtures', __FILE__)
11
+ end
12
+
13
+ def assert_correctly_loaded(types)
14
+ assert_includes(types, 'application/1d-interleaved-parityfec')
15
+ assert_equal(%w(webm), types['audio/webm'].first.extensions)
16
+ refute(types['audio/webm'].first.registered?)
17
+
18
+ assert_equal('Fixes a bug with IE6 and progressive JPEGs',
19
+ types['image/pjpeg'].first.docs)
20
+
21
+ assert(types['audio/vnd.qcelp'].first.obsolete?)
22
+ assert_equal('audio/QCELP', types['audio/vnd.qcelp'].first.use_instead)
23
+ end
24
+
25
+ it 'loads YAML files correctly' do
26
+ assert_correctly_loaded @loader.load_yaml
27
+ end
28
+
29
+ it 'loads JSON files correctly' do
30
+ assert_correctly_loaded @loader.load_json
31
+ end
32
+ end
@@ -0,0 +1,75 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age,
8
+ body size, disability, ethnicity, gender identity and expression, level of
9
+ experience, nationality, personal appearance, race, religion, or sexual
10
+ identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an
52
+ appointed representative at an online or offline event. Representation of a
53
+ project may be further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an
62
+ incident. Further details of specific enforcement policies may be posted
63
+ separately.
64
+
65
+ Project maintainers who do not follow or enforce the Code of Conduct in good
66
+ faith may face temporary or permanent repercussions as determined by other
67
+ members of the project's leadership.
68
+
69
+ ## Attribution
70
+
71
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
72
+ available at [http://contributor-covenant.org/version/1/4][version]
73
+
74
+ [homepage]: http://contributor-covenant.org
75
+ [version]: http://contributor-covenant.org/version/1/4/