benschwarz-smoke 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. data/Rakefile +6 -0
  2. data/VERSION.yml +1 -1
  3. metadata +65 -196
  4. data/Gemfile +0 -10
  5. data/bin/edit_json.rb +0 -3
  6. data/bin/restclient +0 -3
  7. data/vendor/gems/cache/crack-0.1.1.gem +0 -0
  8. data/vendor/gems/cache/fakeweb-1.2.5.gem +0 -0
  9. data/vendor/gems/cache/json-1.1.3.gem +0 -0
  10. data/vendor/gems/cache/rest-client-1.0.1.gem +0 -0
  11. data/vendor/gems/cache/simple-rss-1.2.gem +0 -0
  12. data/vendor/gems/cache/wycats-moneta-0.6.0.gem +0 -0
  13. data/vendor/gems/environment.rb +0 -83
  14. data/vendor/gems/gems/crack-0.1.1/LICENSE +0 -20
  15. data/vendor/gems/gems/crack-0.1.1/README.rdoc +0 -22
  16. data/vendor/gems/gems/crack-0.1.1/VERSION.yml +0 -4
  17. data/vendor/gems/gems/crack-0.1.1/lib/crack.rb +0 -7
  18. data/vendor/gems/gems/crack-0.1.1/lib/crack/core_extensions.rb +0 -126
  19. data/vendor/gems/gems/crack-0.1.1/lib/crack/json.rb +0 -66
  20. data/vendor/gems/gems/crack-0.1.1/lib/crack/xml.rb +0 -211
  21. data/vendor/gems/gems/crack-0.1.1/test/crack_test.rb +0 -4
  22. data/vendor/gems/gems/crack-0.1.1/test/json_test.rb +0 -42
  23. data/vendor/gems/gems/crack-0.1.1/test/test_helper.rb +0 -12
  24. data/vendor/gems/gems/crack-0.1.1/test/xml_test.rb +0 -451
  25. data/vendor/gems/gems/fakeweb-1.2.5/CHANGELOG +0 -163
  26. data/vendor/gems/gems/fakeweb-1.2.5/LICENSE.txt +0 -281
  27. data/vendor/gems/gems/fakeweb-1.2.5/README.rdoc +0 -193
  28. data/vendor/gems/gems/fakeweb-1.2.5/Rakefile +0 -76
  29. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web.rb +0 -172
  30. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/ext/net_http.rb +0 -71
  31. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/registry.rb +0 -103
  32. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/responder.rb +0 -113
  33. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/response.rb +0 -10
  34. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/stub_socket.rb +0 -15
  35. data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/utility.rb +0 -22
  36. data/vendor/gems/gems/fakeweb-1.2.5/lib/fakeweb.rb +0 -2
  37. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_from_curl +0 -12
  38. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_with_transfer_encoding +0 -17
  39. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_without_transfer_encoding +0 -11
  40. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/test_example.txt +0 -1
  41. data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/test_txt_file +0 -3
  42. data/vendor/gems/gems/fakeweb-1.2.5/test/test_allow_net_connect.rb +0 -85
  43. data/vendor/gems/gems/fakeweb-1.2.5/test/test_deprecations.rb +0 -54
  44. data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_authentication.rb +0 -92
  45. data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_web.rb +0 -518
  46. data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_web_open_uri.rb +0 -58
  47. data/vendor/gems/gems/fakeweb-1.2.5/test/test_helper.rb +0 -74
  48. data/vendor/gems/gems/fakeweb-1.2.5/test/test_missing_open_uri.rb +0 -25
  49. data/vendor/gems/gems/fakeweb-1.2.5/test/test_precedence.rb +0 -51
  50. data/vendor/gems/gems/fakeweb-1.2.5/test/test_query_string.rb +0 -45
  51. data/vendor/gems/gems/fakeweb-1.2.5/test/test_regexes.rb +0 -103
  52. data/vendor/gems/gems/fakeweb-1.2.5/test/test_response_headers.rb +0 -67
  53. data/vendor/gems/gems/fakeweb-1.2.5/test/test_trailing_slashes.rb +0 -53
  54. data/vendor/gems/gems/fakeweb-1.2.5/test/test_utility.rb +0 -70
  55. data/vendor/gems/gems/json-1.1.3/CHANGES +0 -93
  56. data/vendor/gems/gems/json-1.1.3/GPL +0 -340
  57. data/vendor/gems/gems/json-1.1.3/README +0 -78
  58. data/vendor/gems/gems/json-1.1.3/RUBY +0 -58
  59. data/vendor/gems/gems/json-1.1.3/Rakefile +0 -309
  60. data/vendor/gems/gems/json-1.1.3/TODO +0 -1
  61. data/vendor/gems/gems/json-1.1.3/VERSION +0 -1
  62. data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark.txt +0 -133
  63. data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_generator.rb +0 -48
  64. data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_parser.rb +0 -26
  65. data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_rails.rb +0 -26
  66. data/vendor/gems/gems/json-1.1.3/bin/edit_json.rb +0 -10
  67. data/vendor/gems/gems/json-1.1.3/bin/prettify_json.rb +0 -76
  68. data/vendor/gems/gems/json-1.1.3/data/example.json +0 -1
  69. data/vendor/gems/gems/json-1.1.3/data/index.html +0 -38
  70. data/vendor/gems/gems/json-1.1.3/data/prototype.js +0 -4184
  71. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator.bundle +0 -0
  72. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/Makefile +0 -150
  73. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/extconf.rb +0 -9
  74. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.bundle +0 -0
  75. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.c +0 -875
  76. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.o +0 -0
  77. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.c +0 -182
  78. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.h +0 -53
  79. data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.o +0 -0
  80. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser.bundle +0 -0
  81. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/Makefile +0 -150
  82. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/extconf.rb +0 -9
  83. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.bundle +0 -0
  84. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.c +0 -1758
  85. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.o +0 -0
  86. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.rl +0 -638
  87. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.c +0 -154
  88. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.h +0 -58
  89. data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.o +0 -0
  90. data/vendor/gems/gems/json-1.1.3/install.rb +0 -26
  91. data/vendor/gems/gems/json-1.1.3/lib/json.rb +0 -235
  92. data/vendor/gems/gems/json-1.1.3/lib/json/Array.xpm +0 -21
  93. data/vendor/gems/gems/json-1.1.3/lib/json/FalseClass.xpm +0 -21
  94. data/vendor/gems/gems/json-1.1.3/lib/json/Hash.xpm +0 -21
  95. data/vendor/gems/gems/json-1.1.3/lib/json/Key.xpm +0 -73
  96. data/vendor/gems/gems/json-1.1.3/lib/json/NilClass.xpm +0 -21
  97. data/vendor/gems/gems/json-1.1.3/lib/json/Numeric.xpm +0 -28
  98. data/vendor/gems/gems/json-1.1.3/lib/json/String.xpm +0 -96
  99. data/vendor/gems/gems/json-1.1.3/lib/json/TrueClass.xpm +0 -21
  100. data/vendor/gems/gems/json-1.1.3/lib/json/add/core.rb +0 -135
  101. data/vendor/gems/gems/json-1.1.3/lib/json/add/rails.rb +0 -58
  102. data/vendor/gems/gems/json-1.1.3/lib/json/common.rb +0 -354
  103. data/vendor/gems/gems/json-1.1.3/lib/json/editor.rb +0 -1362
  104. data/vendor/gems/gems/json-1.1.3/lib/json/ext.rb +0 -13
  105. data/vendor/gems/gems/json-1.1.3/lib/json/json.xpm +0 -1499
  106. data/vendor/gems/gems/json-1.1.3/lib/json/pure.rb +0 -75
  107. data/vendor/gems/gems/json-1.1.3/lib/json/pure/generator.rb +0 -394
  108. data/vendor/gems/gems/json-1.1.3/lib/json/pure/parser.rb +0 -259
  109. data/vendor/gems/gems/json-1.1.3/lib/json/version.rb +0 -9
  110. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail1.json +0 -1
  111. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail10.json +0 -1
  112. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail11.json +0 -1
  113. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail12.json +0 -1
  114. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail13.json +0 -1
  115. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail14.json +0 -1
  116. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail18.json +0 -1
  117. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail19.json +0 -1
  118. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail2.json +0 -1
  119. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail20.json +0 -1
  120. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail21.json +0 -1
  121. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail22.json +0 -1
  122. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail23.json +0 -1
  123. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail24.json +0 -1
  124. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail25.json +0 -1
  125. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail27.json +0 -2
  126. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail28.json +0 -2
  127. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail3.json +0 -1
  128. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail4.json +0 -1
  129. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail5.json +0 -1
  130. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail6.json +0 -1
  131. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail7.json +0 -1
  132. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail8.json +0 -1
  133. data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail9.json +0 -1
  134. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass1.json +0 -56
  135. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass15.json +0 -1
  136. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass16.json +0 -1
  137. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass17.json +0 -1
  138. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass2.json +0 -1
  139. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass26.json +0 -1
  140. data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass3.json +0 -6
  141. data/vendor/gems/gems/json-1.1.3/tests/runner.rb +0 -25
  142. data/vendor/gems/gems/json-1.1.3/tests/test_json.rb +0 -293
  143. data/vendor/gems/gems/json-1.1.3/tests/test_json_addition.rb +0 -161
  144. data/vendor/gems/gems/json-1.1.3/tests/test_json_fixtures.rb +0 -30
  145. data/vendor/gems/gems/json-1.1.3/tests/test_json_generate.rb +0 -100
  146. data/vendor/gems/gems/json-1.1.3/tests/test_json_rails.rb +0 -118
  147. data/vendor/gems/gems/json-1.1.3/tests/test_json_unicode.rb +0 -61
  148. data/vendor/gems/gems/json-1.1.3/tools/fuzz.rb +0 -140
  149. data/vendor/gems/gems/json-1.1.3/tools/server.rb +0 -62
  150. data/vendor/gems/gems/rest-client-1.0.1/README.rdoc +0 -151
  151. data/vendor/gems/gems/rest-client-1.0.1/Rakefile +0 -85
  152. data/vendor/gems/gems/rest-client-1.0.1/bin/restclient +0 -87
  153. data/vendor/gems/gems/rest-client-1.0.1/lib/rest_client.rb +0 -2
  154. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient.rb +0 -93
  155. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/exceptions.rb +0 -84
  156. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/mixin/response.rb +0 -43
  157. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/raw_response.rb +0 -30
  158. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/request.rb +0 -236
  159. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/resource.rb +0 -146
  160. data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/response.rb +0 -20
  161. data/vendor/gems/gems/rest-client-1.0.1/spec/base.rb +0 -4
  162. data/vendor/gems/gems/rest-client-1.0.1/spec/exceptions_spec.rb +0 -54
  163. data/vendor/gems/gems/rest-client-1.0.1/spec/mixin/response_spec.rb +0 -46
  164. data/vendor/gems/gems/rest-client-1.0.1/spec/raw_response_spec.rb +0 -17
  165. data/vendor/gems/gems/rest-client-1.0.1/spec/request_spec.rb +0 -462
  166. data/vendor/gems/gems/rest-client-1.0.1/spec/resource_spec.rb +0 -75
  167. data/vendor/gems/gems/rest-client-1.0.1/spec/response_spec.rb +0 -16
  168. data/vendor/gems/gems/rest-client-1.0.1/spec/restclient_spec.rb +0 -53
  169. data/vendor/gems/gems/simple-rss-1.2/LICENSE +0 -429
  170. data/vendor/gems/gems/simple-rss-1.2/README +0 -43
  171. data/vendor/gems/gems/simple-rss-1.2/Rakefile +0 -212
  172. data/vendor/gems/gems/simple-rss-1.2/lib/simple-rss.rb +0 -149
  173. data/vendor/gems/gems/simple-rss-1.2/test/base/base_test.rb +0 -51
  174. data/vendor/gems/gems/simple-rss-1.2/test/data/atom.xml +0 -45
  175. data/vendor/gems/gems/simple-rss-1.2/test/data/not-rss.xml +0 -8
  176. data/vendor/gems/gems/simple-rss-1.2/test/data/rss09.rdf +0 -79
  177. data/vendor/gems/gems/simple-rss-1.2/test/data/rss20.xml +0 -818
  178. data/vendor/gems/gems/simple-rss-1.2/test/test_helper.rb +0 -4
  179. data/vendor/gems/gems/wycats-moneta-0.6.0/LICENSE +0 -20
  180. data/vendor/gems/gems/wycats-moneta-0.6.0/README +0 -50
  181. data/vendor/gems/gems/wycats-moneta-0.6.0/Rakefile +0 -60
  182. data/vendor/gems/gems/wycats-moneta-0.6.0/TODO +0 -4
  183. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta.rb +0 -76
  184. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/datamapper.rb +0 -117
  185. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/file.rb +0 -91
  186. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/memcache.rb +0 -52
  187. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/memory.rb +0 -11
  188. data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/xattr.rb +0 -58
  189. data/vendor/gems/specifications/crack-0.1.1.gemspec +0 -29
  190. data/vendor/gems/specifications/fakeweb-1.2.5.gemspec +0 -34
  191. data/vendor/gems/specifications/json-1.1.3.gemspec +0 -33
  192. data/vendor/gems/specifications/rest-client-1.0.1.gemspec +0 -30
  193. data/vendor/gems/specifications/simple-rss-1.2.gemspec +0 -27
  194. data/vendor/gems/specifications/wycats-moneta-0.6.0.gemspec +0 -29
@@ -1,62 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $KCODE='UTF8'
4
- require 'webrick'
5
- include WEBrick
6
- $:.unshift 'ext'
7
- $:.unshift 'lib'
8
- require 'json'
9
-
10
- class JSONServlet < HTTPServlet::AbstractServlet
11
- @@count = 1
12
-
13
- def do_GET(req, res)
14
- obj = {
15
- "TIME" => Time.now.strftime("%FT%T"),
16
- "foo" => "Bär",
17
- "bar" => "© ≠ €!",
18
- 'a' => 2,
19
- 'b' => 3.141,
20
- 'COUNT' => @@count += 1,
21
- 'c' => 'c',
22
- 'd' => [ 1, "b", 3.14 ],
23
- 'e' => { 'foo' => 'bar' },
24
- 'g' => "松本行弘",
25
- 'h' => 1000.0,
26
- 'i' => 0.001,
27
- 'j' => "\xf0\xa0\x80\x81",
28
- }
29
- res.body = JSON.generate obj
30
- res['Content-Type'] = "application/json"
31
- end
32
- end
33
-
34
- def create_server(err, dir, port)
35
- dir = File.expand_path(dir)
36
- err.puts "Surf to:", "http://#{Socket.gethostname}:#{port}"
37
-
38
- s = HTTPServer.new(
39
- :Port => port,
40
- :DocumentRoot => dir,
41
- :Logger => WEBrick::Log.new(err),
42
- :AccessLog => [
43
- [ err, WEBrick::AccessLog::COMMON_LOG_FORMAT ],
44
- [ err, WEBrick::AccessLog::REFERER_LOG_FORMAT ],
45
- [ err, WEBrick::AccessLog::AGENT_LOG_FORMAT ]
46
- ]
47
- )
48
- s.mount("/json", JSONServlet)
49
- s
50
- end
51
-
52
- default_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'data'))
53
- dir = ARGV.shift || default_dir
54
- port = (ARGV.shift || 6666).to_i
55
- s = create_server(STDERR, dir, 6666)
56
- t = Thread.new { s.start }
57
- trap(:INT) do
58
- s.shutdown
59
- t.join
60
- exit
61
- end
62
- sleep
@@ -1,151 +0,0 @@
1
- = REST Client -- simple DSL for accessing REST resources
2
-
3
- A simple REST client for Ruby, inspired by the Sinatra's microframework style
4
- of specifying actions: get, put, post, delete.
5
-
6
- == Usage: Raw URL
7
-
8
- require 'rest_client'
9
-
10
- RestClient.get 'http://example.com/resource'
11
- RestClient.get 'https://user:password@example.com/private/resource'
12
-
13
- RestClient.post 'http://example.com/resource', :param1 => 'one', :nested => { :param2 => 'two' }
14
-
15
- RestClient.delete 'http://example.com/resource'
16
-
17
- See RestClient module docs for details.
18
-
19
- == Usage: ActiveResource-Style
20
-
21
- resource = RestClient::Resource.new 'http://example.com/resource'
22
- resource.get
23
-
24
- private_resource = RestClient::Resource.new 'https://example.com/private/resource', :user => 'adam', :password => 'secret', :timeout => 20, :open_timeout => 5
25
- private_resource.put File.read('pic.jpg'), :content_type => 'image/jpg'
26
-
27
- See RestClient::Resource module docs for details.
28
-
29
- == Usage: Resource Nesting
30
-
31
- site = RestClient::Resource.new('http://example.com')
32
- site['posts/1/comments'].post 'Good article.', :content_type => 'text/plain'
33
-
34
- See RestClient::Resource docs for details.
35
-
36
- == Shell
37
-
38
- The restclient shell command gives an IRB session with RestClient already loaded:
39
-
40
- $ restclient
41
- >> RestClient.get 'http://example.com'
42
-
43
- Specify a URL argument for get/post/put/delete on that resource:
44
-
45
- $ restclient http://example.com
46
- >> put '/resource', 'data'
47
-
48
- Add a user and password for authenticated resources:
49
-
50
- $ restclient https://example.com user pass
51
- >> delete '/private/resource'
52
-
53
- Create ~/.restclient for named sessions:
54
-
55
- sinatra:
56
- url: http://localhost:4567
57
- rack:
58
- url: http://localhost:9292
59
- private_site:
60
- url: http://example.com
61
- username: user
62
- password: pass
63
-
64
- Then invoke:
65
-
66
- $ restclient private_site
67
-
68
- Use as a one-off, curl-style:
69
-
70
- $ restclient get http://example.com/resource > output_body
71
-
72
- $ restclient put http://example.com/resource < input_body
73
-
74
- == Logging
75
-
76
- Write calls to a log filename (can also be "stdout" or "stderr"):
77
-
78
- RestClient.log = '/tmp/restclient.log'
79
-
80
- Or set an environment variable to avoid modifying the code:
81
-
82
- $ RESTCLIENT_LOG=stdout path/to/my/program
83
-
84
- Either produces logs like this:
85
-
86
- RestClient.get "http://some/resource"
87
- # => 200 OK | text/html 250 bytes
88
- RestClient.put "http://some/resource", "payload"
89
- # => 401 Unauthorized | application/xml 340 bytes
90
-
91
- Note that these logs are valid Ruby, so you can paste them into the restclient
92
- shell or a script to replay your sequence of rest calls.
93
-
94
- == Proxy
95
-
96
- All calls to RestClient, including Resources, will use the proxy specified by
97
- RestClient.proxy:
98
-
99
- RestClient.proxy = "http://proxy.example.com/"
100
- RestClient.get "http://some/resource"
101
- # => response from some/resource as proxied through proxy.example.com
102
-
103
- Often the proxy url is set in an environment variable, so you can do this to
104
- use whatever proxy the system is configured to use:
105
-
106
- RestClient.proxy = ENV['http_proxy']
107
-
108
- == Cookies
109
-
110
- Request and Response objects know about HTTP cookies, and will automatically
111
- extract and set headers for them as needed:
112
-
113
- response = RestClient.get 'http://example.com/action_which_sets_session_id'
114
- response.cookies
115
- # => {"_applicatioN_session_id" => "1234"}
116
-
117
- response2 = RestClient.post(
118
- 'http://localhost:3000/',
119
- {:param1 => "foo"},
120
- {:cookies => {:session_id => "1234"}}
121
- )
122
- # ...response body
123
-
124
- == SSL Client Certificates
125
-
126
- RestClient::Resource.new(
127
- 'https://example.com',
128
- :ssl_client_cert => OpenSSL::X509::Certificate.new(File.read("cert.pem")),
129
- :ssl_client_key => OpenSSL::PKey::RSA.new(File.read("key.pem"), "passphrase, if any"),
130
- :ssl_ca_file => "ca_certificate.pem",
131
- :verify_ssl => OpenSSL::SSL::VERIFY_PEER
132
- ).get
133
-
134
- Self-signed certificates can be generated with the openssl command-line tool.
135
-
136
- == Meta
137
-
138
- Written by Adam Wiggins (adam at heroku dot com)
139
-
140
- Patches contributed by: Chris Anderson, Greg Borenstein, Ardekantur, Pedro
141
- Belo, Rafael Souza, Rick Olson, Aman Gupta, Blake Mizerany, Brian Donovan, Ivan
142
- Makfinsky, Marc-André Cournoyer, Coda Hale, Tetsuo Watanabe, Dusty Doris,
143
- Lennon Day-Reynolds, James Edward Gray II, Cyril Rohr, Juan Alvarez, and Adam
144
- Jacob, and Paul Dlug
145
-
146
- Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
147
-
148
- http://rest-client.heroku.com
149
-
150
- http://github.com/adamwiggins/rest-client
151
-
@@ -1,85 +0,0 @@
1
- require 'rake'
2
- require 'spec/rake/spectask'
3
-
4
- desc "Run all specs"
5
- Spec::Rake::SpecTask.new('spec') do |t|
6
- t.spec_opts = ['--colour --format progress --loadby mtime --reverse']
7
- t.spec_files = FileList['spec/*_spec.rb']
8
- end
9
-
10
- desc "Print specdocs"
11
- Spec::Rake::SpecTask.new(:doc) do |t|
12
- t.spec_opts = ["--format", "specdoc", "--dry-run"]
13
- t.spec_files = FileList['spec/*_spec.rb']
14
- end
15
-
16
- desc "Run all examples with RCov"
17
- Spec::Rake::SpecTask.new('rcov') do |t|
18
- t.spec_files = FileList['spec/*_spec.rb']
19
- t.rcov = true
20
- t.rcov_opts = ['--exclude', 'examples']
21
- end
22
-
23
- task :default => :spec
24
-
25
- ######################################################
26
-
27
- require 'rake'
28
- require 'rake/testtask'
29
- require 'rake/clean'
30
- require 'rake/gempackagetask'
31
- require 'rake/rdoctask'
32
- require 'fileutils'
33
-
34
- version = "1.0.1"
35
- name = "rest-client"
36
-
37
- spec = Gem::Specification.new do |s|
38
- s.name = name
39
- s.version = version
40
- s.summary = "Simple REST client for Ruby, inspired by microframework syntax for specifying actions."
41
- s.description = "A simple REST client for Ruby, inspired by the Sinatra microframework style of specifying actions: get, put, post, delete."
42
- s.author = "Adam Wiggins"
43
- s.email = "adam@heroku.com"
44
- s.homepage = "http://rest-client.heroku.com/"
45
- s.rubyforge_project = "rest-client"
46
-
47
- s.platform = Gem::Platform::RUBY
48
- s.has_rdoc = true
49
-
50
- s.files = %w(Rakefile README.rdoc) + Dir.glob("{lib,spec}/**/*")
51
- s.executables = ['restclient']
52
-
53
- s.require_path = "lib"
54
- end
55
-
56
- Rake::GemPackageTask.new(spec) do |p|
57
- p.need_tar = true if RUBY_PLATFORM !~ /mswin/
58
- end
59
-
60
- task :install => [ :package ] do
61
- sh %{sudo gem install pkg/#{name}-#{version}.gem}
62
- end
63
-
64
- task :uninstall => [ :clean ] do
65
- sh %{sudo gem uninstall #{name}}
66
- end
67
-
68
- Rake::TestTask.new do |t|
69
- t.libs << "spec"
70
- t.test_files = FileList['spec/*_spec.rb']
71
- t.verbose = true
72
- end
73
-
74
- Rake::RDocTask.new do |t|
75
- t.rdoc_dir = 'rdoc'
76
- t.title = "rest-client, fetch RESTful resources effortlessly"
77
- t.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
78
- t.options << '--charset' << 'utf-8'
79
- t.rdoc_files.include('README.rdoc')
80
- t.rdoc_files.include('lib/restclient.rb')
81
- t.rdoc_files.include('lib/restclient/*.rb')
82
- end
83
-
84
- CLEAN.include [ 'pkg', '*.gem', '.config' ]
85
-
@@ -1,87 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $:.unshift File.dirname(__FILE__) + "/../lib"
4
- require 'restclient'
5
-
6
- require "yaml"
7
-
8
- def usage(why = nil)
9
- puts "failed for reason: #{why}" if why
10
- puts "usage: restclient [get|put|post|delete] url|name [username] [password]"
11
- puts " The verb is optional, if you leave it off you'll get an interactive shell."
12
- puts " put and post both take the input body on stdin."
13
- exit(1)
14
- end
15
-
16
- if %w(get put post delete).include? ARGV.first
17
- @verb = ARGV.shift
18
- else
19
- @verb = nil
20
- end
21
-
22
- @url = ARGV.shift || 'http://localhost:4567'
23
-
24
- config = YAML.load(File.read(ENV['HOME'] + "/.restclient")) rescue {}
25
-
26
- @url, @username, @password = if c = config[@url]
27
- [c['url'], c['username'], c['password']]
28
- else
29
- [@url, *ARGV]
30
- end
31
-
32
- usage("invalid url '#{@url}") unless @url =~ /^https?/
33
- usage("too few args") unless ARGV.size < 3
34
-
35
- def r
36
- @r ||= RestClient::Resource.new(@url, @username, @password)
37
- end
38
-
39
- r # force rc to load
40
-
41
- if @verb
42
- begin
43
- if %w(put post).include? @verb
44
- puts r.send(@verb, STDIN.read)
45
- else
46
- puts r.send(@verb)
47
- end
48
- exit 0
49
- rescue RestClient::Exception => e
50
- puts e.response.body if e.respond_to? :response
51
- raise
52
- end
53
- end
54
-
55
- %w(get post put delete).each do |m|
56
- eval <<-end_eval
57
- def #{m}(path, *args, &b)
58
- r[path].#{m}(*args, &b)
59
- end
60
- end_eval
61
- end
62
-
63
- def method_missing(s, *args, &b)
64
- super unless r.respond_to?(s)
65
- begin
66
- r.send(s, *args, &b)
67
- rescue RestClient::RequestFailed => e
68
- print STDERR, e.response.body
69
- raise e
70
- end
71
- end
72
-
73
- require 'irb'
74
- require 'irb/completion'
75
-
76
- if File.exists? ".irbrc"
77
- ENV['IRBRC'] = ".irbrc"
78
- end
79
-
80
- if File.exists?(rcfile = "~/.restclientrc")
81
- load(rcfile)
82
- end
83
-
84
- ARGV.clear
85
-
86
- IRB.start
87
- exit!
@@ -1,2 +0,0 @@
1
- # This file exists for backward compatbility with require 'rest_client'
2
- require File.dirname(__FILE__) + '/restclient'
@@ -1,93 +0,0 @@
1
- require 'uri'
2
- require 'net/https'
3
- require 'zlib'
4
- require 'stringio'
5
-
6
- require File.dirname(__FILE__) + '/restclient/request'
7
- require File.dirname(__FILE__) + '/restclient/mixin/response'
8
- require File.dirname(__FILE__) + '/restclient/response'
9
- require File.dirname(__FILE__) + '/restclient/raw_response'
10
- require File.dirname(__FILE__) + '/restclient/resource'
11
- require File.dirname(__FILE__) + '/restclient/exceptions'
12
-
13
- # This module's static methods are the entry point for using the REST client.
14
- #
15
- # # GET
16
- # xml = RestClient.get 'http://example.com/resource'
17
- # jpg = RestClient.get 'http://example.com/resource', :accept => 'image/jpg'
18
- #
19
- # # authentication and SSL
20
- # RestClient.get 'https://user:password@example.com/private/resource'
21
- #
22
- # # POST or PUT with a hash sends parameters as a urlencoded form body
23
- # RestClient.post 'http://example.com/resource', :param1 => 'one'
24
- #
25
- # # nest hash parameters
26
- # RestClient.post 'http://example.com/resource', :nested => { :param1 => 'one' }
27
- #
28
- # # POST and PUT with raw payloads
29
- # RestClient.post 'http://example.com/resource', 'the post body', :content_type => 'text/plain'
30
- # RestClient.post 'http://example.com/resource.xml', xml_doc
31
- # RestClient.put 'http://example.com/resource.pdf', File.read('my.pdf'), :content_type => 'application/pdf'
32
- #
33
- # # DELETE
34
- # RestClient.delete 'http://example.com/resource'
35
- #
36
- # # retreive the response http code and headers
37
- # res = RestClient.get 'http://example.com/some.jpg'
38
- # res.code # => 200
39
- # res.headers[:content_type] # => 'image/jpg'
40
- #
41
- # # HEAD
42
- # RestClient.head('http://example.com').headers
43
- #
44
- # To use with a proxy, just set RestClient.proxy to the proper http proxy:
45
- #
46
- # RestClient.proxy = "http://proxy.example.com/"
47
- #
48
- # Or inherit the proxy from the environment:
49
- #
50
- # RestClient.proxy = ENV['http_proxy']
51
- #
52
- # For live tests of RestClient, try using http://rest-test.heroku.com, which echoes back information about the rest call:
53
- #
54
- # >> RestClient.put 'http://rest-test.heroku.com/resource', :foo => 'baz'
55
- # => "PUT http://rest-test.heroku.com/resource with a 7 byte payload, content type application/x-www-form-urlencoded {\"foo\"=>\"baz\"}"
56
- #
57
- module RestClient
58
- def self.get(url, headers={})
59
- Request.execute(:method => :get, :url => url, :headers => headers)
60
- end
61
-
62
- def self.post(url, payload, headers={})
63
- Request.execute(:method => :post, :url => url, :payload => payload, :headers => headers)
64
- end
65
-
66
- def self.put(url, payload, headers={})
67
- Request.execute(:method => :put, :url => url, :payload => payload, :headers => headers)
68
- end
69
-
70
- def self.delete(url, headers={})
71
- Request.execute(:method => :delete, :url => url, :headers => headers)
72
- end
73
-
74
- def self.head(url, headers={})
75
- Request.execute(:method => :head, :url => url, :headers => headers)
76
- end
77
-
78
- class << self
79
- attr_accessor :proxy
80
- end
81
-
82
- # Print log of RestClient calls. Value can be stdout, stderr, or a filename.
83
- # You can also configure logging by the environment variable RESTCLIENT_LOG.
84
- def self.log=(log)
85
- @@log = log
86
- end
87
-
88
- def self.log # :nodoc:
89
- return ENV['RESTCLIENT_LOG'] if ENV['RESTCLIENT_LOG']
90
- return @@log if defined? @@log
91
- nil
92
- end
93
- end