mercadopago-custom-checkout 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (308) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.gs/bin/rake +23 -0
  4. data/.gs/cache/faraday-0.9.2.gem +0 -0
  5. data/.gs/cache/minitest-5.9.0.gem +0 -0
  6. data/.gs/cache/multi_json-1.12.1.gem +0 -0
  7. data/.gs/cache/multipart-post-2.0.0.gem +0 -0
  8. data/.gs/cache/rake-10.5.0.gem +0 -0
  9. data/.gs/gems/faraday-0.9.2/LICENSE.md +20 -0
  10. data/.gs/gems/faraday-0.9.2/README.md +245 -0
  11. data/.gs/gems/faraday-0.9.2/lib/faraday.rb +268 -0
  12. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter.rb +46 -0
  13. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/em_http.rb +237 -0
  14. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/em_http_ssl_patch.rb +56 -0
  15. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/em_synchrony.rb +100 -0
  16. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/em_synchrony/parallel_manager.rb +66 -0
  17. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/excon.rb +81 -0
  18. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/httpclient.rb +117 -0
  19. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb +130 -0
  20. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/net_http_persistent.rb +49 -0
  21. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/patron.rb +78 -0
  22. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/rack.rb +58 -0
  23. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/test.rb +162 -0
  24. data/.gs/gems/faraday-0.9.2/lib/faraday/adapter/typhoeus.rb +123 -0
  25. data/.gs/gems/faraday-0.9.2/lib/faraday/autoload.rb +84 -0
  26. data/.gs/gems/faraday-0.9.2/lib/faraday/connection.rb +437 -0
  27. data/.gs/gems/faraday-0.9.2/lib/faraday/error.rb +53 -0
  28. data/.gs/gems/faraday-0.9.2/lib/faraday/middleware.rb +37 -0
  29. data/.gs/gems/faraday-0.9.2/lib/faraday/options.rb +359 -0
  30. data/.gs/gems/faraday-0.9.2/lib/faraday/parameters.rb +197 -0
  31. data/.gs/gems/faraday-0.9.2/lib/faraday/rack_builder.rb +213 -0
  32. data/.gs/gems/faraday-0.9.2/lib/faraday/request.rb +92 -0
  33. data/.gs/gems/faraday-0.9.2/lib/faraday/request/authorization.rb +42 -0
  34. data/.gs/gems/faraday-0.9.2/lib/faraday/request/basic_authentication.rb +13 -0
  35. data/.gs/gems/faraday-0.9.2/lib/faraday/request/instrumentation.rb +36 -0
  36. data/.gs/gems/faraday-0.9.2/lib/faraday/request/multipart.rb +63 -0
  37. data/.gs/gems/faraday-0.9.2/lib/faraday/request/retry.rb +154 -0
  38. data/.gs/gems/faraday-0.9.2/lib/faraday/request/token_authentication.rb +15 -0
  39. data/.gs/gems/faraday-0.9.2/lib/faraday/request/url_encoded.rb +36 -0
  40. data/.gs/gems/faraday-0.9.2/lib/faraday/response.rb +93 -0
  41. data/.gs/gems/faraday-0.9.2/lib/faraday/response/logger.rb +59 -0
  42. data/.gs/gems/faraday-0.9.2/lib/faraday/response/raise_error.rb +21 -0
  43. data/.gs/gems/faraday-0.9.2/lib/faraday/upload_io.rb +67 -0
  44. data/.gs/gems/faraday-0.9.2/lib/faraday/utils.rb +309 -0
  45. data/.gs/gems/minitest-5.9.0/.autotest +34 -0
  46. data/.gs/gems/minitest-5.9.0/History.rdoc +1176 -0
  47. data/.gs/gems/minitest-5.9.0/Manifest.txt +26 -0
  48. data/.gs/gems/minitest-5.9.0/README.rdoc +656 -0
  49. data/.gs/gems/minitest-5.9.0/Rakefile +72 -0
  50. data/.gs/gems/minitest-5.9.0/design_rationale.rb +52 -0
  51. data/.gs/gems/minitest-5.9.0/lib/hoe/minitest.rb +26 -0
  52. data/.gs/gems/minitest-5.9.0/lib/minitest.rb +815 -0
  53. data/.gs/gems/minitest-5.9.0/lib/minitest/assertions.rb +674 -0
  54. data/.gs/gems/minitest-5.9.0/lib/minitest/autorun.rb +13 -0
  55. data/.gs/gems/minitest-5.9.0/lib/minitest/benchmark.rb +424 -0
  56. data/.gs/gems/minitest-5.9.0/lib/minitest/expectations.rb +284 -0
  57. data/.gs/gems/minitest-5.9.0/lib/minitest/hell.rb +17 -0
  58. data/.gs/gems/minitest-5.9.0/lib/minitest/mock.rb +232 -0
  59. data/.gs/gems/minitest-5.9.0/lib/minitest/parallel.rb +69 -0
  60. data/.gs/gems/minitest-5.9.0/lib/minitest/pride.rb +4 -0
  61. data/.gs/gems/minitest-5.9.0/lib/minitest/pride_plugin.rb +142 -0
  62. data/.gs/gems/minitest-5.9.0/lib/minitest/spec.rb +331 -0
  63. data/.gs/gems/minitest-5.9.0/lib/minitest/test.rb +284 -0
  64. data/.gs/gems/minitest-5.9.0/lib/minitest/unit.rb +45 -0
  65. data/.gs/gems/minitest-5.9.0/test/minitest/metametameta.rb +90 -0
  66. data/.gs/gems/minitest-5.9.0/test/minitest/test_minitest_benchmark.rb +137 -0
  67. data/.gs/gems/minitest-5.9.0/test/minitest/test_minitest_mock.rb +512 -0
  68. data/.gs/gems/minitest-5.9.0/test/minitest/test_minitest_reporter.rb +281 -0
  69. data/.gs/gems/minitest-5.9.0/test/minitest/test_minitest_spec.rb +967 -0
  70. data/.gs/gems/minitest-5.9.0/test/minitest/test_minitest_test.rb +1983 -0
  71. data/.gs/gems/multi_json-1.12.1/CHANGELOG.md +245 -0
  72. data/.gs/gems/multi_json-1.12.1/CONTRIBUTING.md +46 -0
  73. data/.gs/gems/multi_json-1.12.1/LICENSE.md +20 -0
  74. data/.gs/gems/multi_json-1.12.1/README.md +121 -0
  75. data/.gs/gems/multi_json-1.12.1/lib/multi_json.rb +161 -0
  76. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapter.rb +49 -0
  77. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapter_error.rb +15 -0
  78. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/gson.rb +20 -0
  79. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/jr_jackson.rb +25 -0
  80. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/json_common.rb +23 -0
  81. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/json_gem.rb +11 -0
  82. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/json_pure.rb +11 -0
  83. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/nsjsonserialization.rb +32 -0
  84. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/oj.rb +25 -0
  85. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/ok_json.rb +23 -0
  86. data/.gs/gems/multi_json-1.12.1/lib/multi_json/adapters/yajl.rb +19 -0
  87. data/.gs/gems/multi_json-1.12.1/lib/multi_json/convertible_hash_keys.rb +43 -0
  88. data/.gs/gems/multi_json-1.12.1/lib/multi_json/options.rb +39 -0
  89. data/.gs/gems/multi_json-1.12.1/lib/multi_json/options_cache.rb +29 -0
  90. data/.gs/gems/multi_json-1.12.1/lib/multi_json/parse_error.rb +17 -0
  91. data/.gs/gems/multi_json-1.12.1/lib/multi_json/vendor/okjson.rb +606 -0
  92. data/.gs/gems/multi_json-1.12.1/lib/multi_json/version.rb +17 -0
  93. data/.gs/gems/multi_json-1.12.1/multi_json.gemspec +20 -0
  94. data/.gs/gems/multipart-post-2.0.0/.gitignore +6 -0
  95. data/.gs/gems/multipart-post-2.0.0/.travis.yml +7 -0
  96. data/.gs/gems/multipart-post-2.0.0/Gemfile +14 -0
  97. data/.gs/gems/multipart-post-2.0.0/History.txt +60 -0
  98. data/.gs/gems/multipart-post-2.0.0/Manifest.txt +9 -0
  99. data/.gs/gems/multipart-post-2.0.0/README.md +77 -0
  100. data/.gs/gems/multipart-post-2.0.0/Rakefile +9 -0
  101. data/.gs/gems/multipart-post-2.0.0/lib/composite_io.rb +108 -0
  102. data/.gs/gems/multipart-post-2.0.0/lib/multipart_post.rb +9 -0
  103. data/.gs/gems/multipart-post-2.0.0/lib/multipartable.rb +29 -0
  104. data/.gs/gems/multipart-post-2.0.0/lib/net/http/post/multipart.rb +27 -0
  105. data/.gs/gems/multipart-post-2.0.0/lib/parts.rb +96 -0
  106. data/.gs/gems/multipart-post-2.0.0/multipart-post.gemspec +22 -0
  107. data/.gs/gems/multipart-post-2.0.0/test/multibyte.txt +1 -0
  108. data/.gs/gems/multipart-post-2.0.0/test/net/http/post/test_multipart.rb +110 -0
  109. data/.gs/gems/multipart-post-2.0.0/test/test_composite_io.rb +115 -0
  110. data/.gs/gems/multipart-post-2.0.0/test/test_parts.rb +86 -0
  111. data/.gs/gems/rake-10.5.0/.autotest +7 -0
  112. data/.gs/gems/rake-10.5.0/.rubocop.yml +27 -0
  113. data/.gs/gems/rake-10.5.0/.togglerc +7 -0
  114. data/.gs/gems/rake-10.5.0/CONTRIBUTING.rdoc +38 -0
  115. data/.gs/gems/rake-10.5.0/History.rdoc +659 -0
  116. data/.gs/gems/rake-10.5.0/MIT-LICENSE +21 -0
  117. data/.gs/gems/rake-10.5.0/Manifest.txt +166 -0
  118. data/.gs/gems/rake-10.5.0/README.rdoc +139 -0
  119. data/.gs/gems/rake-10.5.0/Rakefile +81 -0
  120. data/.gs/gems/rake-10.5.0/bin/rake +33 -0
  121. data/.gs/gems/rake-10.5.0/doc/command_line_usage.rdoc +158 -0
  122. data/.gs/gems/rake-10.5.0/doc/example/Rakefile1 +38 -0
  123. data/.gs/gems/rake-10.5.0/doc/example/Rakefile2 +35 -0
  124. data/.gs/gems/rake-10.5.0/doc/example/a.c +6 -0
  125. data/.gs/gems/rake-10.5.0/doc/example/b.c +6 -0
  126. data/.gs/gems/rake-10.5.0/doc/example/main.c +11 -0
  127. data/.gs/gems/rake-10.5.0/doc/glossary.rdoc +42 -0
  128. data/.gs/gems/rake-10.5.0/doc/jamis.rb +591 -0
  129. data/.gs/gems/rake-10.5.0/doc/proto_rake.rdoc +127 -0
  130. data/.gs/gems/rake-10.5.0/doc/rake.1 +141 -0
  131. data/.gs/gems/rake-10.5.0/doc/rakefile.rdoc +624 -0
  132. data/.gs/gems/rake-10.5.0/doc/rational.rdoc +151 -0
  133. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.4.14.rdoc +23 -0
  134. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.4.15.rdoc +35 -0
  135. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.5.0.rdoc +53 -0
  136. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.5.3.rdoc +78 -0
  137. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.5.4.rdoc +46 -0
  138. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.6.0.rdoc +141 -0
  139. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.7.0.rdoc +119 -0
  140. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.7.1.rdoc +59 -0
  141. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.7.2.rdoc +121 -0
  142. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.7.3.rdoc +47 -0
  143. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.8.0.rdoc +114 -0
  144. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.8.2.rdoc +165 -0
  145. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.8.3.rdoc +112 -0
  146. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.8.4.rdoc +147 -0
  147. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.8.5.rdoc +53 -0
  148. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.8.6.rdoc +37 -0
  149. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.8.7.rdoc +55 -0
  150. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.9.0.rdoc +112 -0
  151. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.9.1.rdoc +52 -0
  152. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.9.2.2.rdoc +55 -0
  153. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.9.2.rdoc +49 -0
  154. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.9.3.rdoc +102 -0
  155. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.9.4.rdoc +60 -0
  156. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.9.5.rdoc +55 -0
  157. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-0.9.6.rdoc +64 -0
  158. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-10.0.0.rdoc +178 -0
  159. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-10.0.1.rdoc +58 -0
  160. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-10.0.2.rdoc +53 -0
  161. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-10.0.3.rdoc +191 -0
  162. data/.gs/gems/rake-10.5.0/doc/release_notes/rake-10.1.0.rdoc +61 -0
  163. data/.gs/gems/rake-10.5.0/lib/rake.rb +79 -0
  164. data/.gs/gems/rake-10.5.0/lib/rake/alt_system.rb +110 -0
  165. data/.gs/gems/rake-10.5.0/lib/rake/application.rb +790 -0
  166. data/.gs/gems/rake-10.5.0/lib/rake/backtrace.rb +23 -0
  167. data/.gs/gems/rake-10.5.0/lib/rake/clean.rb +76 -0
  168. data/.gs/gems/rake-10.5.0/lib/rake/cloneable.rb +16 -0
  169. data/.gs/gems/rake-10.5.0/lib/rake/contrib/.document +1 -0
  170. data/.gs/gems/rake-10.5.0/lib/rake/contrib/compositepublisher.rb +21 -0
  171. data/.gs/gems/rake-10.5.0/lib/rake/contrib/ftptools.rb +137 -0
  172. data/.gs/gems/rake-10.5.0/lib/rake/contrib/publisher.rb +81 -0
  173. data/.gs/gems/rake-10.5.0/lib/rake/contrib/rubyforgepublisher.rb +18 -0
  174. data/.gs/gems/rake-10.5.0/lib/rake/contrib/sshpublisher.rb +61 -0
  175. data/.gs/gems/rake-10.5.0/lib/rake/contrib/sys.rb +4 -0
  176. data/.gs/gems/rake-10.5.0/lib/rake/cpu_counter.rb +125 -0
  177. data/.gs/gems/rake-10.5.0/lib/rake/default_loader.rb +14 -0
  178. data/.gs/gems/rake-10.5.0/lib/rake/dsl_definition.rb +201 -0
  179. data/.gs/gems/rake-10.5.0/lib/rake/early_time.rb +21 -0
  180. data/.gs/gems/rake-10.5.0/lib/rake/ext/core.rb +25 -0
  181. data/.gs/gems/rake-10.5.0/lib/rake/ext/module.rb +2 -0
  182. data/.gs/gems/rake-10.5.0/lib/rake/ext/pathname.rb +25 -0
  183. data/.gs/gems/rake-10.5.0/lib/rake/ext/string.rb +175 -0
  184. data/.gs/gems/rake-10.5.0/lib/rake/ext/time.rb +18 -0
  185. data/.gs/gems/rake-10.5.0/lib/rake/file_creation_task.rb +24 -0
  186. data/.gs/gems/rake-10.5.0/lib/rake/file_list.rb +428 -0
  187. data/.gs/gems/rake-10.5.0/lib/rake/file_task.rb +46 -0
  188. data/.gs/gems/rake-10.5.0/lib/rake/file_utils.rb +128 -0
  189. data/.gs/gems/rake-10.5.0/lib/rake/file_utils_ext.rb +144 -0
  190. data/.gs/gems/rake-10.5.0/lib/rake/gempackagetask.rb +4 -0
  191. data/.gs/gems/rake-10.5.0/lib/rake/invocation_chain.rb +56 -0
  192. data/.gs/gems/rake-10.5.0/lib/rake/invocation_exception_mixin.rb +16 -0
  193. data/.gs/gems/rake-10.5.0/lib/rake/late_time.rb +17 -0
  194. data/.gs/gems/rake-10.5.0/lib/rake/linked_list.rb +103 -0
  195. data/.gs/gems/rake-10.5.0/lib/rake/loaders/makefile.rb +53 -0
  196. data/.gs/gems/rake-10.5.0/lib/rake/multi_task.rb +13 -0
  197. data/.gs/gems/rake-10.5.0/lib/rake/name_space.rb +38 -0
  198. data/.gs/gems/rake-10.5.0/lib/rake/packagetask.rb +199 -0
  199. data/.gs/gems/rake-10.5.0/lib/rake/pathmap.rb +3 -0
  200. data/.gs/gems/rake-10.5.0/lib/rake/phony.rb +15 -0
  201. data/.gs/gems/rake-10.5.0/lib/rake/private_reader.rb +20 -0
  202. data/.gs/gems/rake-10.5.0/lib/rake/promise.rb +99 -0
  203. data/.gs/gems/rake-10.5.0/lib/rake/pseudo_status.rb +29 -0
  204. data/.gs/gems/rake-10.5.0/lib/rake/rake_module.rb +38 -0
  205. data/.gs/gems/rake-10.5.0/lib/rake/rake_test_loader.rb +22 -0
  206. data/.gs/gems/rake-10.5.0/lib/rake/rdoctask.rb +4 -0
  207. data/.gs/gems/rake-10.5.0/lib/rake/ruby182_test_unit_fix.rb +29 -0
  208. data/.gs/gems/rake-10.5.0/lib/rake/rule_recursion_overflow_error.rb +20 -0
  209. data/.gs/gems/rake-10.5.0/lib/rake/runtest.rb +27 -0
  210. data/.gs/gems/rake-10.5.0/lib/rake/scope.rb +42 -0
  211. data/.gs/gems/rake-10.5.0/lib/rake/task.rb +383 -0
  212. data/.gs/gems/rake-10.5.0/lib/rake/task_argument_error.rb +7 -0
  213. data/.gs/gems/rake-10.5.0/lib/rake/task_arguments.rb +98 -0
  214. data/.gs/gems/rake-10.5.0/lib/rake/task_manager.rb +307 -0
  215. data/.gs/gems/rake-10.5.0/lib/rake/tasklib.rb +24 -0
  216. data/.gs/gems/rake-10.5.0/lib/rake/testtask.rb +213 -0
  217. data/.gs/gems/rake-10.5.0/lib/rake/thread_history_display.rb +48 -0
  218. data/.gs/gems/rake-10.5.0/lib/rake/thread_pool.rb +164 -0
  219. data/.gs/gems/rake-10.5.0/lib/rake/trace_output.rb +22 -0
  220. data/.gs/gems/rake-10.5.0/lib/rake/version.rb +7 -0
  221. data/.gs/gems/rake-10.5.0/lib/rake/win32.rb +56 -0
  222. data/.gs/gems/rake-10.5.0/rakelib/publish.rake +20 -0
  223. data/.gs/gems/rake-10.5.0/rakelib/test_times.rake +25 -0
  224. data/.gs/gems/rake-10.5.0/test/file_creation.rb +34 -0
  225. data/.gs/gems/rake-10.5.0/test/helper.rb +129 -0
  226. data/.gs/gems/rake-10.5.0/test/support/rakefile_definitions.rb +478 -0
  227. data/.gs/gems/rake-10.5.0/test/support/ruby_runner.rb +34 -0
  228. data/.gs/gems/rake-10.5.0/test/test_private_reader.rb +42 -0
  229. data/.gs/gems/rake-10.5.0/test/test_rake.rb +40 -0
  230. data/.gs/gems/rake-10.5.0/test/test_rake_application.rb +643 -0
  231. data/.gs/gems/rake-10.5.0/test/test_rake_application_options.rb +468 -0
  232. data/.gs/gems/rake-10.5.0/test/test_rake_backtrace.rb +119 -0
  233. data/.gs/gems/rake-10.5.0/test/test_rake_clean.rb +61 -0
  234. data/.gs/gems/rake-10.5.0/test/test_rake_cpu_counter.rb +68 -0
  235. data/.gs/gems/rake-10.5.0/test/test_rake_definitions.rb +84 -0
  236. data/.gs/gems/rake-10.5.0/test/test_rake_directory_task.rb +76 -0
  237. data/.gs/gems/rake-10.5.0/test/test_rake_dsl.rb +40 -0
  238. data/.gs/gems/rake-10.5.0/test/test_rake_early_time.rb +31 -0
  239. data/.gs/gems/rake-10.5.0/test/test_rake_extension.rb +59 -0
  240. data/.gs/gems/rake-10.5.0/test/test_rake_file_creation_task.rb +56 -0
  241. data/.gs/gems/rake-10.5.0/test/test_rake_file_list.rb +670 -0
  242. data/.gs/gems/rake-10.5.0/test/test_rake_file_list_path_map.rb +8 -0
  243. data/.gs/gems/rake-10.5.0/test/test_rake_file_task.rb +197 -0
  244. data/.gs/gems/rake-10.5.0/test/test_rake_file_utils.rb +314 -0
  245. data/.gs/gems/rake-10.5.0/test/test_rake_ftp_file.rb +74 -0
  246. data/.gs/gems/rake-10.5.0/test/test_rake_functional.rb +482 -0
  247. data/.gs/gems/rake-10.5.0/test/test_rake_invocation_chain.rb +64 -0
  248. data/.gs/gems/rake-10.5.0/test/test_rake_late_time.rb +18 -0
  249. data/.gs/gems/rake-10.5.0/test/test_rake_linked_list.rb +84 -0
  250. data/.gs/gems/rake-10.5.0/test/test_rake_makefile_loader.rb +46 -0
  251. data/.gs/gems/rake-10.5.0/test/test_rake_multi_task.rb +64 -0
  252. data/.gs/gems/rake-10.5.0/test/test_rake_name_space.rb +57 -0
  253. data/.gs/gems/rake-10.5.0/test/test_rake_package_task.rb +79 -0
  254. data/.gs/gems/rake-10.5.0/test/test_rake_path_map.rb +168 -0
  255. data/.gs/gems/rake-10.5.0/test/test_rake_path_map_explode.rb +34 -0
  256. data/.gs/gems/rake-10.5.0/test/test_rake_path_map_partial.rb +18 -0
  257. data/.gs/gems/rake-10.5.0/test/test_rake_pathname_extensions.rb +15 -0
  258. data/.gs/gems/rake-10.5.0/test/test_rake_pseudo_status.rb +21 -0
  259. data/.gs/gems/rake-10.5.0/test/test_rake_rake_test_loader.rb +20 -0
  260. data/.gs/gems/rake-10.5.0/test/test_rake_reduce_compat.rb +26 -0
  261. data/.gs/gems/rake-10.5.0/test/test_rake_require.rb +40 -0
  262. data/.gs/gems/rake-10.5.0/test/test_rake_rules.rb +388 -0
  263. data/.gs/gems/rake-10.5.0/test/test_rake_scope.rb +44 -0
  264. data/.gs/gems/rake-10.5.0/test/test_rake_task.rb +393 -0
  265. data/.gs/gems/rake-10.5.0/test/test_rake_task_argument_parsing.rb +119 -0
  266. data/.gs/gems/rake-10.5.0/test/test_rake_task_arguments.rb +127 -0
  267. data/.gs/gems/rake-10.5.0/test/test_rake_task_lib.rb +9 -0
  268. data/.gs/gems/rake-10.5.0/test/test_rake_task_manager.rb +178 -0
  269. data/.gs/gems/rake-10.5.0/test/test_rake_task_manager_argument_resolution.rb +19 -0
  270. data/.gs/gems/rake-10.5.0/test/test_rake_task_with_arguments.rb +172 -0
  271. data/.gs/gems/rake-10.5.0/test/test_rake_test_task.rb +146 -0
  272. data/.gs/gems/rake-10.5.0/test/test_rake_thread_pool.rb +145 -0
  273. data/.gs/gems/rake-10.5.0/test/test_rake_top_level_functions.rb +71 -0
  274. data/.gs/gems/rake-10.5.0/test/test_rake_win32.rb +72 -0
  275. data/.gs/gems/rake-10.5.0/test/test_thread_history_display.rb +101 -0
  276. data/.gs/gems/rake-10.5.0/test/test_trace_output.rb +52 -0
  277. data/.gs/specifications/faraday-0.9.2.gemspec +31 -0
  278. data/.gs/specifications/minitest-5.9.0.gemspec +39 -0
  279. data/.gs/specifications/multi_json-1.12.1.gemspec +33 -0
  280. data/.gs/specifications/multipart-post-2.0.0.gemspec +22 -0
  281. data/.gs/specifications/rake-10.5.0.gemspec +43 -0
  282. data/.rubocop.yml +36 -0
  283. data/.ruby-version +1 -0
  284. data/.travis.yml +7 -0
  285. data/CODE_OF_CONDUCT.md +49 -0
  286. data/Gemfile +10 -0
  287. data/LICENSE.txt +21 -0
  288. data/README.md +35 -0
  289. data/Rakefile +38 -0
  290. data/bin/console +14 -0
  291. data/bin/setup +8 -0
  292. data/lib/mercadopago/core/client.rb +70 -0
  293. data/lib/mercadopago/core/endpoints.rb +134 -0
  294. data/lib/mercadopago/core/errors.rb +6 -0
  295. data/lib/mercadopago/core/gateway.rb +84 -0
  296. data/lib/mercadopago/custom_checkout.rb +29 -0
  297. data/lib/mercadopago/custom_checkout/account.rb +162 -0
  298. data/lib/mercadopago/custom_checkout/card_issuer.rb +20 -0
  299. data/lib/mercadopago/custom_checkout/card_token.rb +57 -0
  300. data/lib/mercadopago/custom_checkout/customer.rb +84 -0
  301. data/lib/mercadopago/custom_checkout/errors.rb +6 -0
  302. data/lib/mercadopago/custom_checkout/identification_type.rb +19 -0
  303. data/lib/mercadopago/custom_checkout/payment_method.rb +42 -0
  304. data/lib/mercadopago/custom_checkout/payments.rb +24 -0
  305. data/lib/mercadopago/custom_checkout/resource.rb +14 -0
  306. data/lib/mercadopago/custom_checkout/version.rb +5 -0
  307. data/mercadopago-custom-checkout.gemspec +30 -0
  308. metadata +455 -0
@@ -0,0 +1,58 @@
1
+ module Faraday
2
+ class Adapter
3
+ # Sends requests to a Rack app.
4
+ #
5
+ # Examples
6
+ #
7
+ # class MyRackApp
8
+ # def call(env)
9
+ # [200, {'Content-Type' => 'text/html'}, ["hello world"]]
10
+ # end
11
+ # end
12
+ #
13
+ # Faraday.new do |conn|
14
+ # conn.adapter :rack, MyRackApp.new
15
+ # end
16
+ class Rack < Faraday::Adapter
17
+ dependency 'rack/test'
18
+
19
+ # not prefixed with "HTTP_"
20
+ SPECIAL_HEADERS = %w[ CONTENT_LENGTH CONTENT_TYPE ]
21
+
22
+ def initialize(faraday_app, rack_app)
23
+ super(faraday_app)
24
+ mock_session = ::Rack::MockSession.new(rack_app)
25
+ @session = ::Rack::Test::Session.new(mock_session)
26
+ end
27
+
28
+ def call(env)
29
+ super
30
+ rack_env = {
31
+ :method => env[:method],
32
+ :input => env[:body].respond_to?(:read) ? env[:body].read : env[:body],
33
+ 'rack.url_scheme' => env[:url].scheme
34
+ }
35
+
36
+ env[:request_headers].each do |name, value|
37
+ name = name.upcase.tr('-', '_')
38
+ name = "HTTP_#{name}" unless SPECIAL_HEADERS.include? name
39
+ rack_env[name] = value
40
+ end if env[:request_headers]
41
+
42
+ timeout = env[:request][:timeout] || env[:request][:open_timeout]
43
+ response = if timeout
44
+ Timer.timeout(timeout, Faraday::Error::TimeoutError) { execute_request(env, rack_env) }
45
+ else
46
+ execute_request(env, rack_env)
47
+ end
48
+
49
+ save_response(env, response.status, response.body, response.headers)
50
+ @app.call env
51
+ end
52
+
53
+ def execute_request(env, rack_env)
54
+ @session.request(env[:url].to_s, rack_env)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,162 @@
1
+ module Faraday
2
+ class Adapter
3
+ # test = Faraday::Connection.new do
4
+ # use Faraday::Adapter::Test do |stub|
5
+ # stub.get '/nigiri/sake.json' do
6
+ # [200, {}, 'hi world']
7
+ # end
8
+ # end
9
+ # end
10
+ #
11
+ # resp = test.get '/nigiri/sake.json'
12
+ # resp.body # => 'hi world'
13
+ #
14
+ class Test < Faraday::Adapter
15
+ attr_accessor :stubs
16
+
17
+ class Stubs
18
+ class NotFound < StandardError
19
+ end
20
+
21
+ def initialize
22
+ # {:get => [Stub, Stub]}
23
+ @stack, @consumed = {}, {}
24
+ yield(self) if block_given?
25
+ end
26
+
27
+ def empty?
28
+ @stack.empty?
29
+ end
30
+
31
+ def match(request_method, path, headers, body)
32
+ return false if !@stack.key?(request_method)
33
+ stack = @stack[request_method]
34
+ consumed = (@consumed[request_method] ||= [])
35
+
36
+ if stub = matches?(stack, path, headers, body)
37
+ consumed << stack.delete(stub)
38
+ stub
39
+ else
40
+ matches?(consumed, path, headers, body)
41
+ end
42
+ end
43
+
44
+ def get(path, headers = {}, &block)
45
+ new_stub(:get, path, headers, &block)
46
+ end
47
+
48
+ def head(path, headers = {}, &block)
49
+ new_stub(:head, path, headers, &block)
50
+ end
51
+
52
+ def post(path, body=nil, headers = {}, &block)
53
+ new_stub(:post, path, headers, body, &block)
54
+ end
55
+
56
+ def put(path, body=nil, headers = {}, &block)
57
+ new_stub(:put, path, headers, body, &block)
58
+ end
59
+
60
+ def patch(path, body=nil, headers = {}, &block)
61
+ new_stub(:patch, path, headers, body, &block)
62
+ end
63
+
64
+ def delete(path, headers = {}, &block)
65
+ new_stub(:delete, path, headers, &block)
66
+ end
67
+
68
+ def options(path, headers = {}, &block)
69
+ new_stub(:options, path, headers, &block)
70
+ end
71
+
72
+ # Raises an error if any of the stubbed calls have not been made.
73
+ def verify_stubbed_calls
74
+ failed_stubs = []
75
+ @stack.each do |method, stubs|
76
+ unless stubs.size == 0
77
+ failed_stubs.concat(stubs.map {|stub|
78
+ "Expected #{method} #{stub}."
79
+ })
80
+ end
81
+ end
82
+ raise failed_stubs.join(" ") unless failed_stubs.size == 0
83
+ end
84
+
85
+ protected
86
+
87
+ def new_stub(request_method, path, headers = {}, body=nil, &block)
88
+ normalized_path = Faraday::Utils.normalize_path(path)
89
+ (@stack[request_method] ||= []) << Stub.new(normalized_path, headers, body, block)
90
+ end
91
+
92
+ def matches?(stack, path, headers, body)
93
+ stack.detect { |stub| stub.matches?(path, headers, body) }
94
+ end
95
+ end
96
+
97
+ class Stub < Struct.new(:path, :params, :headers, :body, :block)
98
+ def initialize(full, headers, body, block)
99
+ path, query = full.split('?')
100
+ params = query ?
101
+ Faraday::Utils.parse_nested_query(query) :
102
+ {}
103
+ super(path, params, headers, body, block)
104
+ end
105
+
106
+ def matches?(request_uri, request_headers, request_body)
107
+ request_path, request_query = request_uri.split('?')
108
+ request_params = request_query ?
109
+ Faraday::Utils.parse_nested_query(request_query) :
110
+ {}
111
+ request_path == path &&
112
+ params_match?(request_params) &&
113
+ (body.to_s.size.zero? || request_body == body) &&
114
+ headers_match?(request_headers)
115
+ end
116
+
117
+ def params_match?(request_params)
118
+ params.keys.all? do |key|
119
+ request_params[key] == params[key]
120
+ end
121
+ end
122
+
123
+ def headers_match?(request_headers)
124
+ headers.keys.all? do |key|
125
+ request_headers[key] == headers[key]
126
+ end
127
+ end
128
+
129
+ def to_s
130
+ "#{path} #{body}"
131
+ end
132
+ end
133
+
134
+ def initialize(app, stubs=nil, &block)
135
+ super(app)
136
+ @stubs = stubs || Stubs.new
137
+ configure(&block) if block
138
+ end
139
+
140
+ def configure
141
+ yield(stubs)
142
+ end
143
+
144
+ def call(env)
145
+ super
146
+ normalized_path = Faraday::Utils.normalize_path(env[:url])
147
+ params_encoder = env.request.params_encoder || Faraday::Utils.default_params_encoder
148
+
149
+ if stub = stubs.match(env[:method], normalized_path, env.request_headers, env[:body])
150
+ env[:params] = (query = env[:url].query) ?
151
+ params_encoder.decode(query) :
152
+ {}
153
+ status, headers, body = stub.block.call(env)
154
+ save_response(env, status, body, headers)
155
+ else
156
+ raise Stubs::NotFound, "no stubbed request for #{env[:method]} #{normalized_path} #{env[:body]}"
157
+ end
158
+ @app.call(env)
159
+ end
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,123 @@
1
+ module Faraday
2
+ class Adapter
3
+ class Typhoeus < Faraday::Adapter
4
+ self.supports_parallel = true
5
+
6
+ def self.setup_parallel_manager(options = {})
7
+ options.empty? ? ::Typhoeus::Hydra.hydra : ::Typhoeus::Hydra.new(options)
8
+ end
9
+
10
+ dependency 'typhoeus'
11
+
12
+ def call(env)
13
+ super
14
+ perform_request env
15
+ @app.call env
16
+ end
17
+
18
+ def perform_request(env)
19
+ read_body env
20
+
21
+ hydra = env[:parallel_manager] || self.class.setup_parallel_manager
22
+ hydra.queue request(env)
23
+ hydra.run unless parallel?(env)
24
+ rescue Errno::ECONNREFUSED
25
+ raise Error::ConnectionFailed, $!
26
+ end
27
+
28
+ # TODO: support streaming requests
29
+ def read_body(env)
30
+ env[:body] = env[:body].read if env[:body].respond_to? :read
31
+ end
32
+
33
+ def request(env)
34
+ method = env[:method]
35
+ # For some reason, prevents Typhoeus from using "100-continue".
36
+ # We want this because Webrick 1.3.1 can't seem to handle it w/ PUT.
37
+ method = method.to_s.upcase if method == :put
38
+
39
+ req = ::Typhoeus::Request.new env[:url].to_s,
40
+ :method => method,
41
+ :body => env[:body],
42
+ :headers => env[:request_headers],
43
+ :disable_ssl_peer_verification => (env[:ssl] && env[:ssl].disable?)
44
+
45
+ configure_ssl req, env
46
+ configure_proxy req, env
47
+ configure_timeout req, env
48
+ configure_socket req, env
49
+
50
+ req.on_complete do |resp|
51
+ if resp.timed_out?
52
+ if parallel?(env)
53
+ # TODO: error callback in async mode
54
+ else
55
+ raise Faraday::Error::TimeoutError, "request timed out"
56
+ end
57
+ end
58
+
59
+ case resp.curl_return_code
60
+ when 0
61
+ # everything OK
62
+ when 7
63
+ raise Error::ConnectionFailed, resp.curl_error_message
64
+ when 60
65
+ raise Faraday::SSLError, resp.curl_error_message
66
+ else
67
+ raise Error::ClientError, resp.curl_error_message
68
+ end
69
+
70
+ save_response(env, resp.code, resp.body) do |response_headers|
71
+ response_headers.parse resp.headers
72
+ end
73
+ # in async mode, :response is initialized at this point
74
+ env[:response].finish(env) if parallel?(env)
75
+ end
76
+
77
+ req
78
+ end
79
+
80
+ def configure_ssl(req, env)
81
+ ssl = env[:ssl]
82
+
83
+ req.ssl_version = ssl[:version] if ssl[:version]
84
+ req.ssl_cert = ssl[:client_cert] if ssl[:client_cert]
85
+ req.ssl_key = ssl[:client_key] if ssl[:client_key]
86
+ req.ssl_cacert = ssl[:ca_file] if ssl[:ca_file]
87
+ req.ssl_capath = ssl[:ca_path] if ssl[:ca_path]
88
+ end
89
+
90
+ def configure_proxy(req, env)
91
+ proxy = request_options(env)[:proxy]
92
+ return unless proxy
93
+
94
+ req.proxy = "#{proxy[:uri].host}:#{proxy[:uri].port}"
95
+
96
+ if proxy[:user] && proxy[:password]
97
+ req.proxy_username = proxy[:user]
98
+ req.proxy_password = proxy[:password]
99
+ end
100
+ end
101
+
102
+ def configure_timeout(req, env)
103
+ env_req = request_options(env)
104
+ req.timeout = req.connect_timeout = (env_req[:timeout] * 1000) if env_req[:timeout]
105
+ req.connect_timeout = (env_req[:open_timeout] * 1000) if env_req[:open_timeout]
106
+ end
107
+
108
+ def configure_socket(req, env)
109
+ if bind = request_options(env)[:bind]
110
+ req.interface = bind[:host]
111
+ end
112
+ end
113
+
114
+ def request_options(env)
115
+ env[:request]
116
+ end
117
+
118
+ def parallel?(env)
119
+ !!env[:parallel_manager]
120
+ end
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,84 @@
1
+ module Faraday
2
+ # Internal: Adds the ability for other modules to manage autoloadable
3
+ # constants.
4
+ module AutoloadHelper
5
+ # Internal: Registers the constants to be auto loaded.
6
+ #
7
+ # prefix - The String require prefix. If the path is inside Faraday, then
8
+ # it will be prefixed with the root path of this loaded Faraday
9
+ # version.
10
+ # options - Hash of Symbol => String library names.
11
+ #
12
+ # Examples.
13
+ #
14
+ # Faraday.autoload_all 'faraday/foo',
15
+ # :Bar => 'bar'
16
+ #
17
+ # # requires faraday/foo/bar to load Faraday::Bar.
18
+ # Faraday::Bar
19
+ #
20
+ #
21
+ # Returns nothing.
22
+ def autoload_all(prefix, options)
23
+ if prefix =~ /^faraday(\/|$)/i
24
+ prefix = File.join(Faraday.root_path, prefix)
25
+ end
26
+ options.each do |const_name, path|
27
+ autoload const_name, File.join(prefix, path)
28
+ end
29
+ end
30
+
31
+ # Internal: Loads each autoloaded constant. If thread safety is a concern,
32
+ # wrap this in a Mutex.
33
+ #
34
+ # Returns nothing.
35
+ def load_autoloaded_constants
36
+ constants.each do |const|
37
+ const_get(const) if autoload?(const)
38
+ end
39
+ end
40
+
41
+ # Internal: Filters the module's contents with those that have been already
42
+ # autoloaded.
43
+ #
44
+ # Returns an Array of Class/Module objects.
45
+ def all_loaded_constants
46
+ constants.map { |c| const_get(c) }.
47
+ select { |a| a.respond_to?(:loaded?) && a.loaded? }
48
+ end
49
+ end
50
+
51
+ class Adapter
52
+ extend AutoloadHelper
53
+ autoload_all 'faraday/adapter',
54
+ :NetHttp => 'net_http',
55
+ :NetHttpPersistent => 'net_http_persistent',
56
+ :Typhoeus => 'typhoeus',
57
+ :EMSynchrony => 'em_synchrony',
58
+ :EMHttp => 'em_http',
59
+ :Patron => 'patron',
60
+ :Excon => 'excon',
61
+ :Test => 'test',
62
+ :Rack => 'rack',
63
+ :HTTPClient => 'httpclient'
64
+ end
65
+
66
+ class Request
67
+ extend AutoloadHelper
68
+ autoload_all 'faraday/request',
69
+ :UrlEncoded => 'url_encoded',
70
+ :Multipart => 'multipart',
71
+ :Retry => 'retry',
72
+ :Authorization => 'authorization',
73
+ :BasicAuthentication => 'basic_authentication',
74
+ :TokenAuthentication => 'token_authentication',
75
+ :Instrumentation => 'instrumentation'
76
+ end
77
+
78
+ class Response
79
+ extend AutoloadHelper
80
+ autoload_all 'faraday/response',
81
+ :RaiseError => 'raise_error',
82
+ :Logger => 'logger'
83
+ end
84
+ end
@@ -0,0 +1,437 @@
1
+ module Faraday
2
+ # Public: Connection objects manage the default properties and the middleware
3
+ # stack for fulfilling an HTTP request.
4
+ #
5
+ # Examples
6
+ #
7
+ # conn = Faraday::Connection.new 'http://sushi.com'
8
+ #
9
+ # # GET http://sushi.com/nigiri
10
+ # conn.get 'nigiri'
11
+ # # => #<Faraday::Response>
12
+ #
13
+ class Connection
14
+ # A Set of allowed HTTP verbs.
15
+ METHODS = Set.new [:get, :post, :put, :delete, :head, :patch, :options]
16
+
17
+ # Public: Returns a Hash of URI query unencoded key/value pairs.
18
+ attr_reader :params
19
+
20
+ # Public: Returns a Hash of unencoded HTTP header key/value pairs.
21
+ attr_reader :headers
22
+
23
+ # Public: Returns a URI with the prefix used for all requests from this
24
+ # Connection. This includes a default host name, scheme, port, and path.
25
+ attr_reader :url_prefix
26
+
27
+ # Public: Returns the Faraday::Builder for this Connection.
28
+ attr_reader :builder
29
+
30
+ # Public: Returns a Hash of the request options.
31
+ attr_reader :options
32
+
33
+ # Public: Returns a Hash of the SSL options.
34
+ attr_reader :ssl
35
+
36
+ # Public: Returns the parallel manager for this Connection.
37
+ attr_reader :parallel_manager
38
+
39
+ # Public: Sets the default parallel manager for this connection.
40
+ attr_writer :default_parallel_manager
41
+
42
+ # Public: Initializes a new Faraday::Connection.
43
+ #
44
+ # url - URI or String base URL to use as a prefix for all
45
+ # requests (optional).
46
+ # options - Hash or Faraday::ConnectionOptions.
47
+ # :url - URI or String base URL (default: "http:/").
48
+ # :params - Hash of URI query unencoded key/value pairs.
49
+ # :headers - Hash of unencoded HTTP header key/value pairs.
50
+ # :request - Hash of request options.
51
+ # :ssl - Hash of SSL options.
52
+ # :proxy - URI, String or Hash of HTTP proxy options
53
+ # (default: "http_proxy" environment variable).
54
+ # :uri - URI or String
55
+ # :user - String (optional)
56
+ # :password - String (optional)
57
+ def initialize(url = nil, options = nil)
58
+ if url.is_a?(Hash)
59
+ options = ConnectionOptions.from(url)
60
+ url = options.url
61
+ else
62
+ options = ConnectionOptions.from(options)
63
+ end
64
+
65
+ @parallel_manager = nil
66
+ @headers = Utils::Headers.new
67
+ @params = Utils::ParamsHash.new
68
+ @options = options.request
69
+ @ssl = options.ssl
70
+ @default_parallel_manager = options.parallel_manager
71
+
72
+ @builder = options.builder || begin
73
+ # pass an empty block to Builder so it doesn't assume default middleware
74
+ options.new_builder(block_given? ? Proc.new { |b| } : nil)
75
+ end
76
+
77
+ self.url_prefix = url || 'http:/'
78
+
79
+ @params.update(options.params) if options.params
80
+ @headers.update(options.headers) if options.headers
81
+
82
+ @proxy = nil
83
+ proxy(options.fetch(:proxy) {
84
+ uri = ENV['http_proxy']
85
+ if uri && !uri.empty?
86
+ uri = 'http://' + uri if uri !~ /^http/i
87
+ uri
88
+ end
89
+ })
90
+
91
+ yield(self) if block_given?
92
+
93
+ @headers[:user_agent] ||= "Faraday v#{VERSION}"
94
+ end
95
+
96
+ # Public: Sets the Hash of URI query unencoded key/value pairs.
97
+ def params=(hash)
98
+ @params.replace hash
99
+ end
100
+
101
+ # Public: Sets the Hash of unencoded HTTP header key/value pairs.
102
+ def headers=(hash)
103
+ @headers.replace hash
104
+ end
105
+
106
+ extend Forwardable
107
+
108
+ def_delegators :builder, :build, :use, :request, :response, :adapter, :app
109
+
110
+ # Public: Makes an HTTP request without a body.
111
+ #
112
+ # url - The optional String base URL to use as a prefix for all
113
+ # requests. Can also be the options Hash.
114
+ # params - Hash of URI query unencoded key/value pairs.
115
+ # headers - Hash of unencoded HTTP header key/value pairs.
116
+ #
117
+ # Examples
118
+ #
119
+ # conn.get '/items', {:page => 1}, :accept => 'application/json'
120
+ # conn.head '/items/1'
121
+ #
122
+ # # ElasticSearch example sending a body with GET.
123
+ # conn.get '/twitter/tweet/_search' do |req|
124
+ # req.headers[:content_type] = 'application/json'
125
+ # req.params[:routing] = 'kimchy'
126
+ # req.body = JSON.generate(:query => {...})
127
+ # end
128
+ #
129
+ # Yields a Faraday::Response for further request customizations.
130
+ # Returns a Faraday::Response.
131
+ #
132
+ # Signature
133
+ #
134
+ # <verb>(url = nil, params = nil, headers = nil)
135
+ #
136
+ # verb - An HTTP verb: get, head, or delete.
137
+ %w[get head delete].each do |method|
138
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
139
+ def #{method}(url = nil, params = nil, headers = nil)
140
+ run_request(:#{method}, url, nil, headers) { |request|
141
+ request.params.update(params) if params
142
+ yield(request) if block_given?
143
+ }
144
+ end
145
+ RUBY
146
+ end
147
+
148
+ # Public: Makes an HTTP request with a body.
149
+ #
150
+ # url - The optional String base URL to use as a prefix for all
151
+ # requests. Can also be the options Hash.
152
+ # body - The String body for the request.
153
+ # headers - Hash of unencoded HTTP header key/value pairs.
154
+ #
155
+ # Examples
156
+ #
157
+ # conn.post '/items', data, :content_type => 'application/json'
158
+ #
159
+ # # Simple ElasticSearch indexing sample.
160
+ # conn.post '/twitter/tweet' do |req|
161
+ # req.headers[:content_type] = 'application/json'
162
+ # req.params[:routing] = 'kimchy'
163
+ # req.body = JSON.generate(:user => 'kimchy', ...)
164
+ # end
165
+ #
166
+ # Yields a Faraday::Response for further request customizations.
167
+ # Returns a Faraday::Response.
168
+ #
169
+ # Signature
170
+ #
171
+ # <verb>(url = nil, body = nil, headers = nil)
172
+ #
173
+ # verb - An HTTP verb: post, put, or patch.
174
+ %w[post put patch].each do |method|
175
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
176
+ def #{method}(url = nil, body = nil, headers = nil, &block)
177
+ run_request(:#{method}, url, body, headers, &block)
178
+ end
179
+ RUBY
180
+ end
181
+
182
+ # Public: Sets up the Authorization header with these credentials, encoded
183
+ # with base64.
184
+ #
185
+ # login - The authentication login.
186
+ # pass - The authentication password.
187
+ #
188
+ # Examples
189
+ #
190
+ # conn.basic_auth 'Aladdin', 'open sesame'
191
+ # conn.headers['Authorization']
192
+ # # => "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="
193
+ #
194
+ # Returns nothing.
195
+ def basic_auth(login, pass)
196
+ set_authorization_header(:basic_auth, login, pass)
197
+ end
198
+
199
+ # Public: Sets up the Authorization header with the given token.
200
+ #
201
+ # token - The String token.
202
+ # options - Optional Hash of extra token options.
203
+ #
204
+ # Examples
205
+ #
206
+ # conn.token_auth 'abcdef', :foo => 'bar'
207
+ # conn.headers['Authorization']
208
+ # # => "Token token=\"abcdef\",
209
+ # foo=\"bar\""
210
+ #
211
+ # Returns nothing.
212
+ def token_auth(token, options = nil)
213
+ set_authorization_header(:token_auth, token, options)
214
+ end
215
+
216
+ # Public: Sets up a custom Authorization header.
217
+ #
218
+ # type - The String authorization type.
219
+ # token - The String or Hash token. A String value is taken literally, and
220
+ # a Hash is encoded into comma separated key/value pairs.
221
+ #
222
+ # Examples
223
+ #
224
+ # conn.authorization :Bearer, 'mF_9.B5f-4.1JqM'
225
+ # conn.headers['Authorization']
226
+ # # => "Bearer mF_9.B5f-4.1JqM"
227
+ #
228
+ # conn.authorization :Token, :token => 'abcdef', :foo => 'bar'
229
+ # conn.headers['Authorization']
230
+ # # => "Token token=\"abcdef\",
231
+ # foo=\"bar\""
232
+ #
233
+ # Returns nothing.
234
+ def authorization(type, token)
235
+ set_authorization_header(:authorization, type, token)
236
+ end
237
+
238
+ # Internal: Traverse the middleware stack in search of a
239
+ # parallel-capable adapter.
240
+ #
241
+ # Yields in case of not found.
242
+ #
243
+ # Returns a parallel manager or nil if not found.
244
+ def default_parallel_manager
245
+ @default_parallel_manager ||= begin
246
+ handler = @builder.handlers.detect do |h|
247
+ h.klass.respond_to?(:supports_parallel?) and h.klass.supports_parallel?
248
+ end
249
+
250
+ if handler
251
+ handler.klass.setup_parallel_manager
252
+ elsif block_given?
253
+ yield
254
+ end
255
+ end
256
+ end
257
+
258
+ # Public: Determine if this Faraday::Connection can make parallel requests.
259
+ #
260
+ # Returns true or false.
261
+ def in_parallel?
262
+ !!@parallel_manager
263
+ end
264
+
265
+ # Public: Sets up the parallel manager to make a set of requests.
266
+ #
267
+ # manager - The parallel manager that this Connection's Adapter uses.
268
+ #
269
+ # Yields a block to execute multiple requests.
270
+ # Returns nothing.
271
+ def in_parallel(manager = nil)
272
+ @parallel_manager = manager || default_parallel_manager {
273
+ warn "Warning: `in_parallel` called but no parallel-capable adapter on Faraday stack"
274
+ warn caller[2,10].join("\n")
275
+ nil
276
+ }
277
+ yield
278
+ @parallel_manager && @parallel_manager.run
279
+ ensure
280
+ @parallel_manager = nil
281
+ end
282
+
283
+ # Public: Gets or Sets the Hash proxy options.
284
+ def proxy(arg = nil)
285
+ return @proxy if arg.nil?
286
+ @proxy = ProxyOptions.from(arg)
287
+ end
288
+
289
+ def_delegators :url_prefix, :scheme, :scheme=, :host, :host=, :port, :port=
290
+ def_delegator :url_prefix, :path, :path_prefix
291
+
292
+ # Public: Parses the giving url with URI and stores the individual
293
+ # components in this connection. These components serve as defaults for
294
+ # requests made by this connection.
295
+ #
296
+ # url - A String or URI.
297
+ #
298
+ # Examples
299
+ #
300
+ # conn = Faraday::Connection.new { ... }
301
+ # conn.url_prefix = "https://sushi.com/api"
302
+ # conn.scheme # => https
303
+ # conn.path_prefix # => "/api"
304
+ #
305
+ # conn.get("nigiri?page=2") # accesses https://sushi.com/api/nigiri
306
+ #
307
+ # Returns the parsed URI from teh given input..
308
+ def url_prefix=(url, encoder = nil)
309
+ uri = @url_prefix = Utils.URI(url)
310
+ self.path_prefix = uri.path
311
+
312
+ params.merge_query(uri.query, encoder)
313
+ uri.query = nil
314
+
315
+ with_uri_credentials(uri) do |user, password|
316
+ basic_auth user, password
317
+ uri.user = uri.password = nil
318
+ end
319
+
320
+ uri
321
+ end
322
+
323
+ # Public: Sets the path prefix and ensures that it always has a leading
324
+ # slash.
325
+ #
326
+ # value - A String.
327
+ #
328
+ # Returns the new String path prefix.
329
+ def path_prefix=(value)
330
+ url_prefix.path = if value
331
+ value = '/' + value unless value[0,1] == '/'
332
+ value
333
+ end
334
+ end
335
+
336
+ # Public: Takes a relative url for a request and combines it with the defaults
337
+ # set on the connection instance.
338
+ #
339
+ # conn = Faraday::Connection.new { ... }
340
+ # conn.url_prefix = "https://sushi.com/api?token=abc"
341
+ # conn.scheme # => https
342
+ # conn.path_prefix # => "/api"
343
+ #
344
+ # conn.build_url("nigiri?page=2") # => https://sushi.com/api/nigiri?token=abc&page=2
345
+ # conn.build_url("nigiri", :page => 2) # => https://sushi.com/api/nigiri?token=abc&page=2
346
+ #
347
+ def build_url(url = nil, extra_params = nil)
348
+ uri = build_exclusive_url(url)
349
+
350
+ query_values = params.dup.merge_query(uri.query, options.params_encoder)
351
+ query_values.update extra_params if extra_params
352
+ uri.query = query_values.empty? ? nil : query_values.to_query(options.params_encoder)
353
+
354
+ uri
355
+ end
356
+
357
+ # Builds and runs the Faraday::Request.
358
+ #
359
+ # method - The Symbol HTTP method.
360
+ # url - The String or URI to access.
361
+ # body - The String body
362
+ # headers - Hash of unencoded HTTP header key/value pairs.
363
+ #
364
+ # Returns a Faraday::Response.
365
+ def run_request(method, url, body, headers)
366
+ if !METHODS.include?(method)
367
+ raise ArgumentError, "unknown http method: #{method}"
368
+ end
369
+
370
+ request = build_request(method) do |req|
371
+ req.url(url) if url
372
+ req.headers.update(headers) if headers
373
+ req.body = body if body
374
+ yield(req) if block_given?
375
+ end
376
+
377
+ builder.build_response(self, request)
378
+ end
379
+
380
+ # Creates and configures the request object.
381
+ #
382
+ # Returns the new Request.
383
+ def build_request(method)
384
+ Request.create(method) do |req|
385
+ req.params = self.params.dup
386
+ req.headers = self.headers.dup
387
+ req.options = self.options.merge(:proxy => self.proxy)
388
+ yield(req) if block_given?
389
+ end
390
+ end
391
+
392
+ # Internal: Build an absolute URL based on url_prefix.
393
+ #
394
+ # url - A String or URI-like object
395
+ # params - A Faraday::Utils::ParamsHash to replace the query values
396
+ # of the resulting url (default: nil).
397
+ #
398
+ # Returns the resulting URI instance.
399
+ def build_exclusive_url(url = nil, params = nil, params_encoder = nil)
400
+ url = nil if url.respond_to?(:empty?) and url.empty?
401
+ base = url_prefix
402
+ if url and base.path and base.path !~ /\/$/
403
+ base = base.dup
404
+ base.path = base.path + '/' # ensure trailing slash
405
+ end
406
+ uri = url ? base + url : base
407
+ uri.query = params.to_query(params_encoder || options.params_encoder) if params
408
+ uri.query = nil if uri.query and uri.query.empty?
409
+ uri
410
+ end
411
+
412
+ # Internal: Creates a duplicate of this Faraday::Connection.
413
+ #
414
+ # Returns a Faraday::Connection.
415
+ def dup
416
+ self.class.new(build_exclusive_url,
417
+ :headers => headers.dup,
418
+ :params => params.dup,
419
+ :builder => builder.dup,
420
+ :ssl => ssl.dup,
421
+ :request => options.dup)
422
+ end
423
+
424
+ # Internal: Yields username and password extracted from a URI if they both exist.
425
+ def with_uri_credentials(uri)
426
+ if uri.user and uri.password
427
+ yield(Utils.unescape(uri.user), Utils.unescape(uri.password))
428
+ end
429
+ end
430
+
431
+ def set_authorization_header(header_type, *args)
432
+ header = Faraday::Request.lookup_middleware(header_type).
433
+ header(*args)
434
+ headers[Faraday::Request::Authorization::KEY] = header
435
+ end
436
+ end
437
+ end