Skip to content
Browse files

convert readme to markdown

  • Loading branch information...
1 parent 703f2cb commit 101c55f10b5995d40141be3b35a78fe5dd947cc6 @technoweenie technoweenie committed
Showing with 85 additions and 90 deletions.
  1. +84 −0 README.md
  2. +0 −84 README.rdoc
  3. +1 −6 faraday.gemspec
View
84 README.md
@@ -0,0 +1,84 @@
+# faraday
+
+Modular HTTP client library using middleware heavily inspired by Rack.
+
+This mess is gonna get raw, like sushi. So, haters to the left.
+
+## Usage
+
+ conn = Faraday::Connection.new(:url => 'http://sushi.com') do |builder|
+ builder.use Faraday::Request::Yajl # convert body to json with Yajl lib
+ builder.use Faraday::Adapter::Logger # log the request somewhere?
+ builder.use Faraday::Adapter::Typhoeus # make http request with typhoeus
+ builder.use Faraday::Response::Yajl # # parse body with yajl
+
+ # or use shortcuts
+ builder.request :yajl # Faraday::Request::Yajl
+ builder.adapter :logger # Faraday::Adapter::Logger
+ builder.adapter :typhoeus # Faraday::Adapter::Typhoeus
+ builder.response :yajl # Faraday::Response::Yajl
+ end
+
+ resp1 = conn.get '/nigiri/sake.json'
+ resp2 = conn.post do |req|
+ req.url "/nigiri.json", :page => 2
+ req[:content_type] = 'application/json'
+ req.body = {:name => 'Unagi'}
+ end
+
+ # If you're ready to roll with just the bare minimum (net/http):
+ resp1 = Faraday.get 'http://sushi.com/nigiri/sake.json'
+
+## Testing
+
+ # It's possible to define stubbed request outside a test adapter block.
+ stubs = Faraday::Test::Stubs.new do |stub|
+ stub.get('/tamago') { [200, {}, 'egg'] }
+ end
+
+ # You can pass stubbed request to the test adapter or define them in a block
+ # or a combination of the two.
+ test = Faraday::Connection.new do |builder|
+ builder.adapter :test, stubs do |stub|
+ stub.get('/ebi') {[ 200, {}, 'shrimp' ]}
+ end
+ end
+
+ # It's also possible to stub additional requests after the connection has
+ # been initialized. This is useful for testing.
+ stubs.get('/uni') {[ 200, {}, 'urchin' ]}
+
+ resp = test.get '/tamago'
+ resp.body # => 'egg'
+ resp = test.get '/ebi'
+ resp.body # => 'shrimp'
+ resp = test.get '/uni'
+ resp.body # => 'urchin'
+ resp = test.get '/else' #=> raises "no such stub" error
+
+ # If you like, you can treat your stubs as mocks by verifying that all of
+ # the stubbed calls were made. NOTE that this feature is still fairly
+ # experimental: It will not verify the order or count of any stub, only that
+ # it was called once during the course of the test.
+ stubs.verify_stubbed_calls
+
+## TODO
+
+* support streaming requests/responses
+* better stubbing API
+* Support timeouts
+* Add curb, em-http, fast_http
+
+## Note on Patches/Pull Requests
+
+* Fork the project.
+* Make your feature addition or bug fix.
+* Add tests for it. This is important so I don't break it in a
+ future version unintentionally.
+* Commit, do not mess with rakefile, version, or history.
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
+* Send me a pull request. Bonus points for topic branches.
+
+## Copyright
+
+Copyright (c) 2009-2010 rick, hobson. See LICENSE for details.
View
84 README.rdoc
@@ -1,84 +0,0 @@
-= faraday
-
-Modular HTTP client library using middleware heavily inspired by Rack.
-
-This mess is gonna get raw, like sushi. So, haters to the left.
-
-== Usage
-
- conn = Faraday::Connection.new(:url => 'http://sushi.com') do |builder|
- builder.use Faraday::Request::Yajl # convert body to json with Yajl lib
- builder.use Faraday::Adapter::Logger # log the request somewhere?
- builder.use Faraday::Adapter::Typhoeus # make http request with typhoeus
- builder.use Faraday::Response::Yajl # # parse body with yajl
-
- # or use shortcuts
- builder.request :yajl # Faraday::Request::Yajl
- builder.adapter :logger # Faraday::Adapter::Logger
- builder.adapter :typhoeus # Faraday::Adapter::Typhoeus
- builder.response :yajl # Faraday::Response::Yajl
- end
-
- resp1 = conn.get '/nigiri/sake.json'
- resp2 = conn.post do |req|
- req.url "/nigiri.json", :page => 2
- req[:content_type] = 'application/json'
- req.body = {:name => 'Unagi'}
- end
-
- # If you're ready to roll with just the bare minimum (net/http):
- resp1 = Faraday.get 'http://sushi.com/nigiri/sake.json'
-
-== Testing
-
- # It's possible to define stubbed request outside a test adapter block.
- stubs = Faraday::Test::Stubs.new do |stub|
- stub.get('/tamago') { [200, {}, 'egg'] }
- end
-
- # You can pass stubbed request to the test adapter or define them in a block
- # or a combination of the two.
- test = Faraday::Connection.new do |builder|
- builder.adapter :test, stubs do |stub|
- stub.get('/ebi') {[ 200, {}, 'shrimp' ]}
- end
- end
-
- # It's also possible to stub additional requests after the connection has
- # been initialized. This is useful for testing.
- stubs.get('/uni') {[ 200, {}, 'urchin' ]}
-
- resp = test.get '/tamago'
- resp.body # => 'egg'
- resp = test.get '/ebi'
- resp.body # => 'shrimp'
- resp = test.get '/uni'
- resp.body # => 'urchin'
- resp = test.get '/else' #=> raises "no such stub" error
-
- # If you like, you can treat your stubs as mocks by verifying that all of
- # the stubbed calls were made. NOTE that this feature is still fairly
- # experimental: It will not verify the order or count of any stub, only that
- # it was called once during the course of the test.
- stubs.verify_stubbed_calls
-
-== TODO
-
-* support streaming requests/responses
-* better stubbing API
-* Support timeouts
-* Add curb, em-http, fast_http
-
-== Note on Patches/Pull Requests
-
-* Fork the project.
-* Make your feature addition or bug fix.
-* Add tests for it. This is important so I don't break it in a
- future version unintentionally.
-* Commit, do not mess with rakefile, version, or history.
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-* Send me a pull request. Bonus points for topic branches.
-
-== Copyright
-
-Copyright (c) 2009-2010 rick, hobson. See LICENSE for details.
View
7 faraday.gemspec
@@ -33,11 +33,6 @@ Gem::Specification.new do |s|
## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
s.require_paths = %w[lib]
- ## Specify any RDoc options here. You'll want to add your README and
- ## LICENSE files to the extra_rdoc_files list.
- s.rdoc_options = ["--charset=UTF-8"]
- s.extra_rdoc_files = %w[README LICENSE]
-
s.add_development_dependency('rake', ['~> 0.8.7'])
s.add_development_dependency('sinatra', ['~> 1.0.0'])
s.add_runtime_dependency('addressable', ['~> 2.1.1'])
@@ -52,7 +47,7 @@ Gem::Specification.new do |s|
Gemfile
Gemfile.lock
LICENSE
- README.rdoc
+ README.md
Rakefile
faraday.gemspec
lib/faraday.rb

0 comments on commit 101c55f

Please sign in to comment.
Something went wrong with that request. Please try again.