kinetic_sdk 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MIME
4
+ class Types
5
+ module Data
6
+ VERSION = '3.2016.0521'
7
+
8
+ # The path that will be used for loading the MIME::Types data. The
9
+ # default location is __FILE__/../../../../data, which is where the data
10
+ # lives in the gem installation of the mime-types-data library.
11
+ #
12
+ # The MIME::Types::Loader will load all JSON or columnar files contained
13
+ # in this path.
14
+ #
15
+ # System maintainer note: this is the constant to change when packaging
16
+ # mime-types for your system. It is recommended that the path be
17
+ # something like /usr/share/ruby/mime-types/.
18
+ PATH = File.expand_path('../../../../data', __FILE__)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mime/types/data'
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ platforms :mri_19 do
5
+ gem 'ruby-debug19'
6
+ end
7
+
8
+ platforms :mri_18 do
9
+ gem 'ruby-debug'
10
+ end
11
+
12
+ group :development, :test do
13
+ gem 'rake'
14
+ end
@@ -0,0 +1,60 @@
1
+ === 2.0.0 / 2013-12-21
2
+
3
+ - Drop Ruby 1.8 compatibility
4
+ - GH #21: Fix FilePart length calculation for Ruby 1.9 when filename contains
5
+ multibyte characters (hexfet)
6
+ - GH #20: Ensure upload responds to both #content_type and #original_filename
7
+ (Steven Davidovitz)
8
+ - GH #31: Support setting headers on any part of the request (Socrates Vicente)
9
+ - GH #30: Support array values for params (Gustav Ernberg)
10
+ - GH #32: Fix respond_to? signature (Leo Cassarani)
11
+ - GH #33: Update README to markdown (Jagtesh Chadha)
12
+ - GH #35: Improved handling of array-type parameters (Steffen Grunwald)
13
+
14
+ === 1.2.0 / 2013-02-25
15
+
16
+ - #25: Ruby 2 compatibility (thanks mislav)
17
+
18
+ === 1.1.5 / 2012-02-12
19
+
20
+ - Fix length/bytesize of parts in 1.9 (#7, #14) (Jason Moore)
21
+ - Allow CompositeIO objects to be re-read by rewinding, like other IO
22
+ objects. (Luke Redpath)
23
+
24
+ === 1.1.4 / 2011-11-23
25
+
26
+ - Non-functional changes in release (switch to Bundler gem tasks)
27
+
28
+ === 1.1.3 / 2011-07-25
29
+
30
+ - More configurable header specification for parts (Gerrit Riessen)
31
+
32
+ === 1.1.2 / 2011-05-24
33
+
34
+ - Fix CRLF file part miscalculation (Johannes Wagener)
35
+ - Fix Epilogue CRLF issue (suggestion by Neil Spring)
36
+
37
+ === 1.1.1 / 2011-05-13
38
+
39
+ - GH# 9: Fixed Ruby 1.9.2 StringIO bug (thanks Alex Koppel)
40
+
41
+ === 1.1.0 / 2011-01-11
42
+
43
+ - API CHANGE: UploadIO.convert! removed in favor of UploadIO.new
44
+ (Jeff Hodges)
45
+
46
+ === 1.0.1 / 2010-04-27
47
+
48
+ - Doc updates, make gemspec based on more modern Rubygems
49
+
50
+ === 1.0 / 2009-02-12
51
+
52
+ - Many fixes from mlooney, seems to work now. Putting the 0.9 seal of
53
+ approval on it.
54
+
55
+ === 0.1 / 2008-08-12
56
+
57
+ * 1 major enhancement
58
+
59
+ * Birthday!
60
+
@@ -0,0 +1,9 @@
1
+ lib/composite_io.rb
2
+ lib/multipartable.rb
3
+ lib/parts.rb
4
+ lib/net/http/post/multipart.rb
5
+ Manifest.txt
6
+ Rakefile
7
+ README.txt
8
+ test/test_composite_io.rb
9
+ test/net/http/post/test_multipart.rb
@@ -0,0 +1,77 @@
1
+ ## multipart-post
2
+
3
+ * http://github.com/nicksieger/multipart-post
4
+
5
+ ![build status](https://travis-ci.org/nicksieger/multipart-post.png)
6
+
7
+ #### DESCRIPTION:
8
+
9
+ Adds a streamy multipart form post capability to Net::HTTP. Also
10
+ supports other methods besides POST.
11
+
12
+ #### FEATURES/PROBLEMS:
13
+
14
+ * Appears to actually work. A good feature to have.
15
+ * Encapsulates posting of file/binary parts and name/value parameter parts, similar to
16
+ most browsers' file upload forms.
17
+ * Provides an UploadIO helper class to prepare IO objects for inclusion in the params
18
+ hash of the multipart post object.
19
+
20
+ #### SYNOPSIS:
21
+
22
+ require 'net/http/post/multipart'
23
+
24
+ url = URI.parse('http://www.example.com/upload')
25
+ File.open("./image.jpg") do |jpg|
26
+ req = Net::HTTP::Post::Multipart.new url.path,
27
+ "file" => UploadIO.new(jpg, "image/jpeg", "image.jpg")
28
+ res = Net::HTTP.start(url.host, url.port) do |http|
29
+ http.request(req)
30
+ end
31
+ end
32
+
33
+ To post multiple files or attachments, simply include multiple parameters with
34
+ UploadIO values:
35
+
36
+ require 'net/http/post/multipart'
37
+
38
+ url = URI.parse('http://www.example.com/upload')
39
+ req = Net::HTTP::Post::Multipart.new url.path,
40
+ "file1" => UploadIO.new(File.new("./image.jpg"), "image/jpeg", "image.jpg"),
41
+ "file2" => UploadIO.new(File.new("./image2.jpg"), "image/jpeg", "image2.jpg")
42
+ res = Net::HTTP.start(url.host, url.port) do |http|
43
+ http.request(req)
44
+ end
45
+
46
+ #### REQUIREMENTS:
47
+
48
+ None
49
+
50
+ #### INSTALL:
51
+
52
+ gem install multipart-post
53
+
54
+ #### LICENSE:
55
+
56
+ (The MIT License)
57
+
58
+ Copyright (c) 2007-2013 Nick Sieger <nick@nicksieger.com>
59
+
60
+ Permission is hereby granted, free of charge, to any person obtaining
61
+ a copy of this software and associated documentation files (the
62
+ 'Software'), to deal in the Software without restriction, including
63
+ without limitation the rights to use, copy, modify, merge, publish,
64
+ distribute, sublicense, and/or sell copies of the Software, and to
65
+ permit persons to whom the Software is furnished to do so, subject to
66
+ the following conditions:
67
+
68
+ The above copyright notice and this permission notice shall be
69
+ included in all copies or substantial portions of the Software.
70
+
71
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
72
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
73
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
74
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
75
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
76
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
77
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :default => :test
4
+
5
+ require 'rake/testtask'
6
+ Rake::TestTask.new do |t|
7
+ t.libs << "test"
8
+ t.test_files = FileList['test/**/test*.rb']
9
+ end
@@ -0,0 +1,108 @@
1
+ #--
2
+ # Copyright (c) 2007-2012 Nick Sieger.
3
+ # See the file README.txt included with the distribution for
4
+ # software license details.
5
+ #++
6
+
7
+ # Concatenate together multiple IO objects into a single, composite IO object
8
+ # for purposes of reading as a single stream.
9
+ #
10
+ # Usage:
11
+ #
12
+ # crio = CompositeReadIO.new(StringIO.new('one'), StringIO.new('two'), StringIO.new('three'))
13
+ # puts crio.read # => "onetwothree"
14
+ #
15
+ class CompositeReadIO
16
+ # Create a new composite-read IO from the arguments, all of which should
17
+ # respond to #read in a manner consistent with IO.
18
+ def initialize(*ios)
19
+ @ios = ios.flatten
20
+ @index = 0
21
+ end
22
+
23
+ # Read from IOs in order until `length` bytes have been received.
24
+ def read(length = nil, outbuf = nil)
25
+ got_result = false
26
+ outbuf = outbuf ? outbuf.replace("") : ""
27
+
28
+ while io = current_io
29
+ if result = io.read(length)
30
+ got_result ||= !result.nil?
31
+ result.force_encoding("BINARY") if result.respond_to?(:force_encoding)
32
+ outbuf << result
33
+ length -= result.length if length
34
+ break if length == 0
35
+ end
36
+ advance_io
37
+ end
38
+ (!got_result && length) ? nil : outbuf
39
+ end
40
+
41
+ def rewind
42
+ @ios.each { |io| io.rewind }
43
+ @index = 0
44
+ end
45
+
46
+ private
47
+
48
+ def current_io
49
+ @ios[@index]
50
+ end
51
+
52
+ def advance_io
53
+ @index += 1
54
+ end
55
+ end
56
+
57
+ # Convenience methods for dealing with files and IO that are to be uploaded.
58
+ class UploadIO
59
+ # Create an upload IO suitable for including in the params hash of a
60
+ # Net::HTTP::Post::Multipart.
61
+ #
62
+ # Can take two forms. The first accepts a filename and content type, and
63
+ # opens the file for reading (to be closed by finalizer).
64
+ #
65
+ # The second accepts an already-open IO, but also requires a third argument,
66
+ # the filename from which it was opened (particularly useful/recommended if
67
+ # uploading directly from a form in a framework, which often save the file to
68
+ # an arbitrarily named RackMultipart file in /tmp).
69
+ #
70
+ # Usage:
71
+ #
72
+ # UploadIO.new("file.txt", "text/plain")
73
+ # UploadIO.new(file_io, "text/plain", "file.txt")
74
+ #
75
+ attr_reader :content_type, :original_filename, :local_path, :io, :opts
76
+
77
+ def initialize(filename_or_io, content_type, filename = nil, opts = {})
78
+ io = filename_or_io
79
+ local_path = ""
80
+ if io.respond_to? :read
81
+ # in Ruby 1.9.2, StringIOs no longer respond to path
82
+ # (since they respond to :length, so we don't need their local path, see parts.rb:41)
83
+ local_path = filename_or_io.respond_to?(:path) ? filename_or_io.path : "local.path"
84
+ else
85
+ io = File.open(filename_or_io)
86
+ local_path = filename_or_io
87
+ end
88
+ filename ||= local_path
89
+
90
+ @content_type = content_type
91
+ @original_filename = File.basename(filename)
92
+ @local_path = local_path
93
+ @io = io
94
+ @opts = opts
95
+ end
96
+
97
+ def self.convert!(io, content_type, original_filename, local_path)
98
+ raise ArgumentError, "convert! has been removed. You must now wrap IOs using:\nUploadIO.new(filename_or_io, content_type, filename=nil)\nPlease update your code."
99
+ end
100
+
101
+ def method_missing(*args)
102
+ @io.send(*args)
103
+ end
104
+
105
+ def respond_to?(meth, include_all = false)
106
+ @io.respond_to?(meth, include_all) || super(meth, include_all)
107
+ end
108
+ end
@@ -0,0 +1,9 @@
1
+ #--
2
+ # Copyright (c) 2007-2013 Nick Sieger.
3
+ # See the file README.txt included with the distribution for
4
+ # software license details.
5
+ #++
6
+
7
+ module MultipartPost
8
+ VERSION = "2.0.0"
9
+ end
@@ -0,0 +1,29 @@
1
+ #--
2
+ # Copyright (c) 2007-2013 Nick Sieger.
3
+ # See the file README.txt included with the distribution for
4
+ # software license details.
5
+ #++
6
+
7
+ require 'parts'
8
+ module Multipartable
9
+ DEFAULT_BOUNDARY = "-----------RubyMultipartPost"
10
+ def initialize(path, params, headers={}, boundary = DEFAULT_BOUNDARY)
11
+ headers = headers.clone # don't want to modify the original variable
12
+ parts_headers = headers.delete(:parts) || {}
13
+ super(path, headers)
14
+ parts = params.map do |k,v|
15
+ case v
16
+ when Array
17
+ v.map {|item| Parts::Part.new(boundary, k, item, parts_headers[k]) }
18
+ else
19
+ Parts::Part.new(boundary, k, v, parts_headers[k])
20
+ end
21
+ end.flatten
22
+ parts << Parts::EpiloguePart.new(boundary)
23
+ ios = parts.map {|p| p.to_io }
24
+ self.set_content_type(headers["Content-Type"] || "multipart/form-data",
25
+ { "boundary" => boundary })
26
+ self.content_length = parts.inject(0) {|sum,i| sum + i.length }
27
+ self.body_stream = CompositeReadIO.new(*ios)
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ #--
2
+ # Copyright (c) 2007-2012 Nick Sieger.
3
+ # See the file README.txt included with the distribution for
4
+ # software license details.
5
+ #++
6
+
7
+ require 'net/http'
8
+ require 'stringio'
9
+ require 'cgi'
10
+ require 'composite_io'
11
+ require 'multipartable'
12
+ require 'parts'
13
+
14
+ module Net #:nodoc:
15
+ class HTTP #:nodoc:
16
+ class Put
17
+ class Multipart < Put
18
+ include Multipartable
19
+ end
20
+ end
21
+ class Post #:nodoc:
22
+ class Multipart < Post
23
+ include Multipartable
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,96 @@
1
+ #--
2
+ # Copyright (c) 2007-2013 Nick Sieger.
3
+ # See the file README.txt included with the distribution for
4
+ # software license details.
5
+ #++
6
+
7
+ module Parts
8
+ module Part #:nodoc:
9
+ def self.new(boundary, name, value, headers = {})
10
+ headers ||= {} # avoid nil values
11
+ if file?(value)
12
+ FilePart.new(boundary, name, value, headers)
13
+ else
14
+ ParamPart.new(boundary, name, value, headers)
15
+ end
16
+ end
17
+
18
+ def self.file?(value)
19
+ value.respond_to?(:content_type) && value.respond_to?(:original_filename)
20
+ end
21
+
22
+ def length
23
+ @part.length
24
+ end
25
+
26
+ def to_io
27
+ @io
28
+ end
29
+ end
30
+
31
+ class ParamPart
32
+ include Part
33
+ def initialize(boundary, name, value, headers = {})
34
+ @part = build_part(boundary, name, value, headers)
35
+ @io = StringIO.new(@part)
36
+ end
37
+
38
+ def length
39
+ @part.bytesize
40
+ end
41
+
42
+ def build_part(boundary, name, value, headers = {})
43
+ part = ''
44
+ part << "--#{boundary}\r\n"
45
+ part << "Content-Disposition: form-data; name=\"#{name.to_s}\"\r\n"
46
+ part << "Content-Type: #{headers["Content-Type"]}\r\n" if headers["Content-Type"]
47
+ part << "\r\n"
48
+ part << "#{value}\r\n"
49
+ end
50
+ end
51
+
52
+ # Represents a part to be filled from file IO.
53
+ class FilePart
54
+ include Part
55
+ attr_reader :length
56
+ def initialize(boundary, name, io, headers = {})
57
+ file_length = io.respond_to?(:length) ? io.length : File.size(io.local_path)
58
+ @head = build_head(boundary, name, io.original_filename, io.content_type, file_length,
59
+ io.respond_to?(:opts) ? io.opts.merge(headers) : headers)
60
+ @foot = "\r\n"
61
+ @length = @head.bytesize + file_length + @foot.length
62
+ @io = CompositeReadIO.new(StringIO.new(@head), io, StringIO.new(@foot))
63
+ end
64
+
65
+ def build_head(boundary, name, filename, type, content_len, opts = {}, headers = {})
66
+ trans_encoding = opts["Content-Transfer-Encoding"] || "binary"
67
+ content_disposition = opts["Content-Disposition"] || "form-data"
68
+
69
+ part = ''
70
+ part << "--#{boundary}\r\n"
71
+ part << "Content-Disposition: #{content_disposition}; name=\"#{name.to_s}\"; filename=\"#{filename}\"\r\n"
72
+ part << "Content-Length: #{content_len}\r\n"
73
+ if content_id = opts["Content-ID"]
74
+ part << "Content-ID: #{content_id}\r\n"
75
+ end
76
+
77
+ if headers["Content-Type"] != nil
78
+ part << "Content-Type: " + headers["Content-Type"] + "\r\n"
79
+ else
80
+ part << "Content-Type: #{type}\r\n"
81
+ end
82
+
83
+ part << "Content-Transfer-Encoding: #{trans_encoding}\r\n"
84
+ part << "\r\n"
85
+ end
86
+ end
87
+
88
+ # Represents the epilogue or closing boundary.
89
+ class EpiloguePart
90
+ include Part
91
+ def initialize(boundary)
92
+ @part = "--#{boundary}--\r\n\r\n"
93
+ @io = StringIO.new(@part)
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "multipart_post"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "multipart-post"
7
+ s.version = MultipartPost::VERSION
8
+ s.authors = ["Nick Sieger"]
9
+ s.email = ["nick@nicksieger.com"]
10
+ s.homepage = "https://github.com/nicksieger/multipart-post"
11
+ s.summary = %q{A multipart form post accessory for Net::HTTP.}
12
+ s.license = "MIT"
13
+ s.description = %q{Use with Net::HTTP to do multipart form posts. IO values that have #content_type, #original_filename, and #local_path will be posted as a binary file.}
14
+
15
+ s.rubyforge_project = "caldersphere"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.rdoc_options = ["--main", "README.md", "-SHN", "-f", "darkfish"]
21
+ s.require_paths = ["lib"]
22
+ end
@@ -0,0 +1 @@
1
+ ファイル
@@ -0,0 +1,110 @@
1
+ #--
2
+ # Copyright (c) 2007-2013 Nick Sieger.
3
+ # See the file README.txt included with the distribution for
4
+ # software license details.
5
+ #++
6
+
7
+ require 'net/http/post/multipart'
8
+ require 'test/unit'
9
+
10
+ class Net::HTTP::Post::MultiPartTest < Test::Unit::TestCase
11
+ TEMP_FILE = "temp.txt"
12
+
13
+ HTTPPost = Struct.new("HTTPPost", :content_length, :body_stream, :content_type)
14
+ HTTPPost.module_eval do
15
+ def set_content_type(type, params = {})
16
+ self.content_type = type + params.map{|k,v|"; #{k}=#{v}"}.join('')
17
+ end
18
+ end
19
+
20
+ def teardown
21
+ File.delete(TEMP_FILE) rescue nil
22
+ end
23
+
24
+ def test_form_multipart_body
25
+ File.open(TEMP_FILE, "w") {|f| f << "1234567890"}
26
+ @io = File.open(TEMP_FILE)
27
+ @io = UploadIO.new @io, "text/plain", TEMP_FILE
28
+ assert_results Net::HTTP::Post::Multipart.new("/foo/bar", :foo => 'bar', :file => @io)
29
+ end
30
+ def test_form_multipart_body_put
31
+ File.open(TEMP_FILE, "w") {|f| f << "1234567890"}
32
+ @io = File.open(TEMP_FILE)
33
+ @io = UploadIO.new @io, "text/plain", TEMP_FILE
34
+ assert_results Net::HTTP::Put::Multipart.new("/foo/bar", :foo => 'bar', :file => @io)
35
+ end
36
+
37
+ def test_form_multipart_body_with_stringio
38
+ @io = StringIO.new("1234567890")
39
+ @io = UploadIO.new @io, "text/plain", TEMP_FILE
40
+ assert_results Net::HTTP::Post::Multipart.new("/foo/bar", :foo => 'bar', :file => @io)
41
+ end
42
+
43
+ def test_form_multiparty_body_with_parts_headers
44
+ @io = StringIO.new("1234567890")
45
+ @io = UploadIO.new @io, "text/plain", TEMP_FILE
46
+ parts = { :text => 'bar', :file => @io }
47
+ headers = {
48
+ :parts => {
49
+ :text => { "Content-Type" => "part/type" },
50
+ :file => { "Content-Transfer-Encoding" => "part-encoding" }
51
+ }
52
+ }
53
+
54
+ request = Net::HTTP::Post::Multipart.new("/foo/bar", parts, headers)
55
+ assert_results request
56
+ assert_additional_headers_added(request, headers[:parts])
57
+ end
58
+
59
+ def test_form_multipart_body_with_array_value
60
+ File.open(TEMP_FILE, "w") {|f| f << "1234567890"}
61
+ @io = File.open(TEMP_FILE)
62
+ @io = UploadIO.new @io, "text/plain", TEMP_FILE
63
+ params = {:foo => ['bar', 'quux'], :file => @io}
64
+ headers = { :parts => {
65
+ :foo => { "Content-Type" => "application/json; charset=UTF-8" } } }
66
+ post = Net::HTTP::Post::Multipart.new("/foo/bar", params, headers,
67
+ Net::HTTP::Post::Multipart::DEFAULT_BOUNDARY)
68
+
69
+ assert post.content_length && post.content_length > 0
70
+ assert post.body_stream
71
+
72
+ body = post.body_stream.read
73
+ assert_equal 2, body.lines.grep(/name="foo"/).length
74
+ assert body =~ /Content-Type: application\/json; charset=UTF-8/, body
75
+ end
76
+
77
+ def test_form_multipart_body_with_arrayparam
78
+ File.open(TEMP_FILE, "w") {|f| f << "1234567890"}
79
+ @io = File.open(TEMP_FILE)
80
+ @io = UploadIO.new @io, "text/plain", TEMP_FILE
81
+ assert_results Net::HTTP::Post::Multipart.new("/foo/bar", :multivalueParam => ['bar','bah'], :file => @io)
82
+ end
83
+
84
+ def assert_results(post)
85
+ assert post.content_length && post.content_length > 0
86
+ assert post.body_stream
87
+ assert_equal "multipart/form-data; boundary=#{Multipartable::DEFAULT_BOUNDARY}", post['content-type']
88
+ body = post.body_stream.read
89
+ boundary_regex = Regexp.quote Multipartable::DEFAULT_BOUNDARY
90
+ assert body =~ /1234567890/
91
+ # ensure there is at least one boundary
92
+ assert body =~ /^--#{boundary_regex}\r\n/
93
+ # ensure there is an epilogue
94
+ assert body =~ /^--#{boundary_regex}--\r\n/
95
+ assert body =~ /text\/plain/
96
+ if (body =~ /multivalueParam/)
97
+ assert_equal 2, body.scan(/^.*multivalueParam.*$/).size
98
+ end
99
+ end
100
+
101
+ def assert_additional_headers_added(post, parts_headers)
102
+ post.body_stream.rewind
103
+ body = post.body_stream.read
104
+ parts_headers.each do |part, headers|
105
+ headers.each do |k,v|
106
+ assert body =~ /#{k}: #{v}/
107
+ end
108
+ end
109
+ end
110
+ end