faraday 0.6.0 → 0.8.0

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 (58) hide show
  1. data/Gemfile +22 -15
  2. data/{LICENSE → LICENSE.md} +1 -1
  3. data/README.md +216 -146
  4. data/Rakefile +14 -58
  5. data/config.ru +6 -0
  6. data/faraday.gemspec +31 -38
  7. data/lib/faraday/adapter/em_http.rb +204 -0
  8. data/lib/faraday/adapter/em_synchrony/parallel_manager.rb +66 -0
  9. data/lib/faraday/adapter/em_synchrony.rb +67 -16
  10. data/lib/faraday/adapter/excon.rb +1 -2
  11. data/lib/faraday/adapter/net_http.rb +82 -39
  12. data/lib/faraday/adapter/net_http_persistent.rb +37 -0
  13. data/lib/faraday/adapter/patron.rb +42 -8
  14. data/lib/faraday/adapter/rack.rb +59 -0
  15. data/lib/faraday/adapter/test.rb +49 -9
  16. data/lib/faraday/adapter/typhoeus.rb +70 -15
  17. data/lib/faraday/adapter.rb +41 -18
  18. data/lib/faraday/builder.rb +34 -16
  19. data/lib/faraday/connection.rb +177 -115
  20. data/lib/faraday/error.rb +4 -2
  21. data/lib/faraday/middleware.rb +18 -10
  22. data/lib/faraday/request/authorization.rb +40 -0
  23. data/lib/faraday/request/basic_authentication.rb +13 -0
  24. data/lib/faraday/request/multipart.rb +5 -6
  25. data/lib/faraday/request/retry.rb +21 -0
  26. data/lib/faraday/request/token_authentication.rb +15 -0
  27. data/lib/faraday/request/url_encoded.rb +1 -3
  28. data/lib/faraday/request.rb +48 -38
  29. data/lib/faraday/response/raise_error.rb +1 -1
  30. data/lib/faraday/response.rb +6 -5
  31. data/lib/faraday/upload_io.rb +1 -1
  32. data/lib/faraday/utils.rb +196 -29
  33. data/lib/faraday.rb +69 -13
  34. data/test/adapters/default_test.rb +14 -0
  35. data/test/adapters/em_http_test.rb +14 -0
  36. data/test/adapters/em_synchrony_test.rb +14 -0
  37. data/test/adapters/excon_test.rb +23 -0
  38. data/test/adapters/integration.rb +190 -0
  39. data/test/adapters/logger_test.rb +2 -2
  40. data/test/adapters/net_http_persistent_test.rb +11 -0
  41. data/test/adapters/net_http_test.rb +37 -21
  42. data/test/adapters/patron_test.rb +17 -0
  43. data/test/adapters/rack_test.rb +26 -0
  44. data/test/adapters/test_middleware_test.rb +28 -1
  45. data/test/adapters/typhoeus_test.rb +14 -0
  46. data/test/authentication_middleware_test.rb +65 -0
  47. data/test/connection_test.rb +211 -81
  48. data/test/env_test.rb +80 -31
  49. data/test/helper.rb +23 -13
  50. data/test/live_server.rb +38 -29
  51. data/test/middleware/retry_test.rb +25 -0
  52. data/test/middleware_stack_test.rb +85 -4
  53. data/test/request_middleware_test.rb +42 -19
  54. data/test/response_middleware_test.rb +30 -3
  55. metadata +104 -110
  56. data/lib/faraday/adapter/action_dispatch.rb +0 -30
  57. data/lib/faraday/request/json.rb +0 -31
  58. data/test/adapters/live_test.rb +0 -186
data/Gemfile CHANGED
@@ -1,19 +1,26 @@
1
- source "http://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- # Bundle gems for the local environment. Make sure to
4
- # put test-only gems in this group so their generators
5
- # and rake tasks are available in development mode:
6
- group :development, :test do
7
- gem 'patron', '~> 0.4', :platforms => :ruby
8
- gem 'sinatra', '~> 1.1'
9
- gem 'typhoeus', '~> 0.2', :platforms => :ruby
10
- gem 'excon', '~> 0.5.8'
11
- gem 'em-http-request', '~> 0.3', :require => 'em-http', :platforms => :ruby
12
- gem 'em-synchrony', '~> 0.2', :require => ['em-synchrony', 'em-synchrony/em-http'], :platforms => :ruby_19
13
- gem 'webmock'
14
- # ActiveSupport::JSON will be used in ruby 1.8 and Yajl in 1.9; this is to test against both adapters
15
- gem 'activesupport', '~> 2.3.8', :require => nil, :platforms => [:ruby_18, :jruby]
16
- gem 'yajl-ruby', :require => 'yajl', :platforms => :ruby_19
3
+ group :development do
4
+ gem 'sinatra', '~> 1.2'
5
+ end
6
+
7
+ group :test do
8
+ gem 'em-http-request', '~> 1.0', :require => 'em-http'
9
+ gem 'em-synchrony', '~> 1.0', :require => ['em-synchrony', 'em-synchrony/em-http'], :platforms => :ruby_19
10
+ gem 'excon', '~> 0.6'
11
+ gem 'net-http-persistent', '~> 2.5', :require => false
12
+ gem 'leftright', '~> 0.9', :require => false
13
+ gem 'rack-test', '~> 0.6', :require => 'rack/test'
14
+ end
15
+
16
+ platforms :ruby do
17
+ gem 'patron', '~> 0.4', '> 0.4.1'
18
+ gem 'typhoeus', '~> 0.3', '> 0.3.2'
19
+ end
20
+
21
+ platforms :jruby do
22
+ gem 'jruby-openssl', '~> 0.7'
23
+ gem 'ffi-ncurses', '~> 0.3'
17
24
  end
18
25
 
19
26
  gemspec
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009-* rick olson, zack hobson
1
+ Copyright (c) 2009 rick olson, zack hobson
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,166 +1,236 @@
1
- # faraday
2
-
3
- Modular HTTP client library using middleware heavily inspired by Rack.
4
-
5
- This mess is gonna get raw, like sushi. So, haters to the left.
6
-
7
- ## Usage
8
-
9
- conn = Faraday.new(:url => 'http://sushi.com') do |builder|
10
- builder.use Faraday::Request::UrlEncoded # convert request params as "www-form-urlencoded"
11
- builder.use Faraday::Request::JSON # encode request params as json
12
- builder.use Faraday::Response::Logger # log the request to STDOUT
13
- builder.use Faraday::Adapter::NetHttp # make http requests with Net::HTTP
14
-
15
- # or, use shortcuts:
16
- builder.request :url_encoded
17
- builder.request :json
18
- builder.response :logger
19
- builder.adapter :net_http
20
- end
21
-
22
- ## GET ##
23
-
24
- response = conn.get '/nigiri/sake.json' # GET http://sushi.com/nigiri/sake.json
25
- response.body
26
-
27
- conn.get '/nigiri', 'X-Awesome' => true # custom request header
28
-
29
- conn.get do |req| # GET http://sushi.com/search?page=2&limit=100
30
- req.url '/search', :page => 2
31
- req.params['limit'] = 100
32
- end
33
-
34
- ## POST ##
35
-
36
- conn.post '/nigiri', { :name => 'Maguro' } # POST "name=maguro" to http://sushi.com/nigiri
37
-
38
- # post payload as JSON instead of "www-form-urlencoded" encoding:
39
- conn.post '/nigiri', payload, 'Content-Type' => 'application/json'
40
-
41
- # a more verbose way:
42
- conn.post do |req|
43
- req.url '/nigiri'
44
- req.headers['Content-Type'] = 'application/json'
45
- req.body = { :name => 'Unagi' }
46
- end
1
+ # Faraday [![Build Status](https://secure.travis-ci.org/technoweenie/faraday.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/technoweenie/faraday.png?travis)][gemnasium]
2
+ [travis]: http://travis-ci.org/technoweenie/faraday
3
+ [gemnasium]: https://gemnasium.com/technoweenie/faraday
4
+
5
+ Faraday is an HTTP client lib that provides a common interface over many
6
+ adapters (such as Net::HTTP) and embraces the concept of Rack middleware when
7
+ processing the request/response cycle.
8
+
9
+ Faraday supports these adapters:
10
+
11
+ * Net/HTTP
12
+ * Excon
13
+ * Typhoeus
14
+ * Patron
15
+ * EventMachine
16
+
17
+ It also includes a Rack adapter for hitting loaded Rack applications through
18
+ Rack::Test, and a Test adapter for stubbing requests by hand.
19
+
20
+ ## <a name="usage"></a>Usage
21
+
22
+ ```ruby
23
+ conn = Faraday.new(:url => 'http://sushi.com') do |builder|
24
+ builder.use Faraday::Request::UrlEncoded # convert request params as "www-form-urlencoded"
25
+ builder.use Faraday::Response::Logger # log the request to STDOUT
26
+ builder.use Faraday::Adapter::NetHttp # make http requests with Net::HTTP
27
+
28
+ # or, use shortcuts:
29
+ builder.request :url_encoded
30
+ builder.response :logger
31
+ builder.adapter :net_http
32
+ end
33
+
34
+ ## GET ##
35
+
36
+ response = conn.get '/nigiri/sake.json' # GET http://sushi.com/nigiri/sake.json
37
+ response.body
38
+
39
+ conn.get '/nigiri', { :name => 'Maguro' } # GET /nigiri?name=Maguro
40
+
41
+ conn.get do |req| # GET http://sushi.com/search?page=2&limit=100
42
+ req.url '/search', :page => 2
43
+ req.params['limit'] = 100
44
+ end
45
+
46
+ ## POST ##
47
+
48
+ conn.post '/nigiri', { :name => 'Maguro' } # POST "name=maguro" to http://sushi.com/nigiri
49
+
50
+ # post payload as JSON instead of "www-form-urlencoded" encoding:
51
+ conn.post do |req|
52
+ req.url '/nigiri'
53
+ req.headers['Content-Type'] = 'application/json'
54
+ req.body = '{ "name": "Unagi" }'
55
+ end
56
+
57
+ ## Options ##
58
+
59
+ conn.get do |req|
60
+ req.url '/search'
61
+ req.options = {
62
+ :timeout => 5, # open/read timeout Integer in seconds
63
+ :open_timeout => 2, # read timeout Integer in seconds
64
+ :proxy => {
65
+ :uri => "http://example.org/", # proxy server URI
66
+ :user => "me", # proxy server username
67
+ :password => "test123" # proxy server password
68
+ }
69
+ }
70
+ end
71
+ ```
47
72
 
48
73
  If you're ready to roll with just the bare minimum:
49
74
 
50
- # default stack (net/http), no extra middleware:
51
- response = Faraday.get 'http://sushi.com/nigiri/sake.json'
75
+ ```ruby
76
+ # default stack (net/http), no extra middleware:
77
+ response = Faraday.get 'http://sushi.com/nigiri/sake.json'
78
+ ```
52
79
 
53
80
  ## Advanced middleware usage
81
+ The order in which middleware is stacked is important. Like with Rack, the
82
+ first middleware on the list wraps all others, while the last middleware is the
83
+ innermost one, so that's usually the adapter.
54
84
 
55
- The order in which middleware is stacked is important. Like with Rack, the first middleware on the list wraps all others, while the last middleware is the innermost one, so that's usually the adapter.
85
+ ```ruby
86
+ conn = Faraday.new(:url => 'http://sushi.com') do |builder|
87
+ # POST/PUT params encoders:
88
+ builder.request :multipart
89
+ builder.request :url_encoded
56
90
 
57
- conn = Faraday.new(:url => 'http://sushi.com') do |builder|
58
- # POST/PUT params encoders:
59
- builder.request :multipart
60
- builder.request :url_encoded
61
- builder.request :json
62
-
63
- builder.adapter :net_http
64
- end
91
+ builder.adapter :net_http
92
+ end
93
+ ```
65
94
 
66
95
  This request middleware setup affects POST/PUT requests in the following way:
67
96
 
68
- 1. `Request::Multipart` checks for files in the payload, otherwise leaves everything untouched;
69
- 2. `Request::UrlEncoded` encodes as "application/x-www-form-urlencoded" if not already encoded or of another type
70
- 2. `Request::JSON` encodes as "application/json" if not already encoded or of another type
97
+ 1. `Request::Multipart` checks for files in the payload, otherwise leaves
98
+ everything untouched;
99
+ 2. `Request::UrlEncoded` encodes as "application/x-www-form-urlencoded" if not
100
+ already encoded or of another type
71
101
 
72
- Because "UrlEncoded" is higher on the stack than JSON encoder, it will get to process the request first. Swapping them means giving the other priority. Specifying the "Content-Type" for the request is explicitly stating which middleware should process it.
102
+ Swapping middleware means giving the other priority. Specifying the
103
+ "Content-Type" for the request is explicitly stating which middleware should
104
+ process it.
73
105
 
74
106
  Examples:
75
107
 
76
- payload = { :name => 'Maguro' }
77
-
78
- # post payload as JSON instead of urlencoded:
79
- conn.post '/nigiri', payload, 'Content-Type' => 'application/json'
80
-
81
- # uploading a file:
82
- payload = { :profile_pic => Faraday::UploadIO.new('avatar.jpg', 'image/jpeg') }
83
-
84
- # "Multipart" middleware detects files and encodes with "multipart/form-data":
85
- conn.put '/profile', payload
108
+ ```ruby
109
+ payload = { :name => 'Maguro' }
86
110
 
87
- ## Writing middleware
111
+ # uploading a file:
112
+ payload = { :profile_pic => Faraday::UploadIO.new('avatar.jpg', 'image/jpeg') }
88
113
 
89
- Middleware are classes that respond to `call()`. They wrap the request/response cycle.
90
-
91
- def call(env)
92
- # do something with the request
93
-
94
- @app.call(env).on_complete do
95
- # do something with the response
96
- end
97
- end
98
-
99
- It's important to do all processing of the response only in the `on_complete` block. This enables middleware to work in parallel mode where requests are asynchronous.
100
-
101
- The `env` is a hash with symbol keys that contains info about the request and, later, response. Some keys are:
102
-
103
- # request phase
104
- :method - :get, :post, ...
105
- :url - URI for the current request; also contains GET parameters
106
- :body - POST parameters for :post/:put requests
107
- :request_headers
108
-
109
- # response phase
110
- :status - HTTP response status code, such as 200
111
- :body - the response body
112
- :response_headers
113
-
114
- ## Testing
115
-
116
- # It's possible to define stubbed request outside a test adapter block.
117
- stubs = Faraday::Adapter::Test::Stubs.new do |stub|
118
- stub.get('/tamago') { [200, {}, 'egg'] }
119
- end
120
-
121
- # You can pass stubbed request to the test adapter or define them in a block
122
- # or a combination of the two.
123
- test = Faraday.new do |builder|
124
- builder.adapter :test, stubs do |stub|
125
- stub.get('/ebi') {[ 200, {}, 'shrimp' ]}
126
- end
127
- end
128
-
129
- # It's also possible to stub additional requests after the connection has
130
- # been initialized. This is useful for testing.
131
- stubs.get('/uni') {[ 200, {}, 'urchin' ]}
132
-
133
- resp = test.get '/tamago'
134
- resp.body # => 'egg'
135
- resp = test.get '/ebi'
136
- resp.body # => 'shrimp'
137
- resp = test.get '/uni'
138
- resp.body # => 'urchin'
139
- resp = test.get '/else' #=> raises "no such stub" error
140
-
141
- # If you like, you can treat your stubs as mocks by verifying that all of
142
- # the stubbed calls were made. NOTE that this feature is still fairly
143
- # experimental: It will not verify the order or count of any stub, only that
144
- # it was called once during the course of the test.
145
- stubs.verify_stubbed_calls
146
-
147
- ## TODO
114
+ # "Multipart" middleware detects files and encodes with "multipart/form-data":
115
+ conn.put '/profile', payload
116
+ ```
148
117
 
118
+ ## Writing middleware
119
+ Middleware are classes that respond to `call()`. They wrap the request/response
120
+ cycle.
121
+
122
+ ```ruby
123
+ def call(env)
124
+ # do something with the request
125
+
126
+ @app.call(env).on_complete do
127
+ # do something with the response
128
+ end
129
+ end
130
+ ```
131
+
132
+ It's important to do all processing of the response only in the `on_complete`
133
+ block. This enables middleware to work in parallel mode where requests are
134
+ asynchronous.
135
+
136
+ The `env` is a hash with symbol keys that contains info about the request and,
137
+ later, response. Some keys are:
138
+
139
+ ```
140
+ # request phase
141
+ :method - :get, :post, ...
142
+ :url - URI for the current request; also contains GET parameters
143
+ :body - POST parameters for :post/:put requests
144
+ :request_headers
145
+
146
+ # response phase
147
+ :status - HTTP response status code, such as 200
148
+ :body - the response body
149
+ :response_headers
150
+ ```
151
+
152
+ ## <a name="testing"></a>Testing
153
+
154
+ ```ruby
155
+ # It's possible to define stubbed request outside a test adapter block.
156
+ stubs = Faraday::Adapter::Test::Stubs.new do |stub|
157
+ stub.get('/tamago') { [200, {}, 'egg'] }
158
+ end
159
+
160
+ # You can pass stubbed request to the test adapter or define them in a block
161
+ # or a combination of the two.
162
+ test = Faraday.new do |builder|
163
+ builder.adapter :test, stubs do |stub|
164
+ stub.get('/ebi') {[ 200, {}, 'shrimp' ]}
165
+ end
166
+ end
167
+
168
+ # It's also possible to stub additional requests after the connection has
169
+ # been initialized. This is useful for testing.
170
+ stubs.get('/uni') {[ 200, {}, 'urchin' ]}
171
+
172
+ resp = test.get '/tamago'
173
+ resp.body # => 'egg'
174
+ resp = test.get '/ebi'
175
+ resp.body # => 'shrimp'
176
+ resp = test.get '/uni'
177
+ resp.body # => 'urchin'
178
+ resp = test.get '/else' #=> raises "no such stub" error
179
+
180
+ # If you like, you can treat your stubs as mocks by verifying that all of
181
+ # the stubbed calls were made. NOTE that this feature is still fairly
182
+ # experimental: It will not verify the order or count of any stub, only that
183
+ # it was called once during the course of the test.
184
+ stubs.verify_stubbed_calls
185
+ ```
186
+
187
+ ## <a name="todo"></a>TODO
149
188
  * support streaming requests/responses
150
189
  * better stubbing API
151
- * Support timeouts
152
- * Add curb, em-http, fast_http
153
-
154
- ## Note on Patches/Pull Requests
155
-
156
- * Fork the project.
157
- * Make your feature addition or bug fix.
158
- * Add tests for it. This is important so I don't break it in a
159
- future version unintentionally.
160
- * Commit, do not mess with rakefile, version, or history.
161
- (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)
162
- * Send me a pull request. Bonus points for topic branches.
163
-
164
- ## Copyright
165
190
 
166
- Copyright (c) 2009-2011 rick, hobson. See LICENSE for details.
191
+ ## <a name="pulls"></a>Note on Patches/Pull Requests
192
+ 1. Fork the project.
193
+ 2. Make your feature addition or bug fix.
194
+ 3. Add tests for it. This is important so I don't break it in a future version
195
+ unintentionally.
196
+ 4. Commit, do not mess with rakefile, version, or history. (if you want to have
197
+ your own version, that is fine but bump version in a commit by itself I can
198
+ ignore when I pull)
199
+ 5. Send us a pull request. Bonus points for topic branches.
200
+
201
+ We are pushing towards a 1.0 release, when we will have to follow [Semantic
202
+ Versioning](http://semver.org/). If your patch includes changes to break
203
+ compatiblitity, note that so we can add it to the [Changelog](https://github.com/technoweenie/faraday/wiki/Changelog).
204
+
205
+ ## <a name="versions"></a>Supported Ruby Versions
206
+ This library aims to support and is [tested against][travis] the following Ruby
207
+ implementations:
208
+
209
+ * Ruby 1.8.7
210
+ * Ruby 1.9.2
211
+ * Ruby 1.9.3
212
+ * JRuby[]
213
+ * [Rubinius][]
214
+
215
+ [jruby]: http://jruby.org/
216
+ [rubinius]: http://rubini.us/
217
+
218
+ If something doesn't work on one of these interpreters, it should be considered
219
+ a bug.
220
+
221
+ This library may inadvertently work (or seem to work) on other Ruby
222
+ implementations, however support will only be provided for the versions listed
223
+ above.
224
+
225
+ If you would like this library to support another Ruby version, you may
226
+ volunteer to be a maintainer. Being a maintainer entails making sure all tests
227
+ run and pass on that implementation. When something breaks on your
228
+ implementation, you will be personally responsible for providing patches in a
229
+ timely fashion. If critical issues for a particular implementation exist at the
230
+ time of a major release, support for that Ruby version may be dropped.
231
+
232
+ ## <a name="copyright"></a>Copyright
233
+ Copyright (c) 2009-12 [Rick Olson](mailto:technoweenie@gmail.com), zack hobson.
234
+ See [LICENSE][] for details.
235
+
236
+ [license]: https://github.com/technoweenie/faraday/blob/master/LICENSE.md
data/Rakefile CHANGED
@@ -1,12 +1,9 @@
1
- require 'rubygems'
2
- require 'rake'
3
1
  require 'date'
2
+ require 'rake/testtask'
3
+
4
+ task :default => :test
4
5
 
5
- #############################################################################
6
- #
7
- # Helper functions
8
- #
9
- #############################################################################
6
+ ## helper functions
10
7
 
11
8
  def name
12
9
  @name ||= Dir['*.gemspec'].first.split('.').first
@@ -17,14 +14,6 @@ def version
17
14
  line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
18
15
  end
19
16
 
20
- def date
21
- Date.today.to_s
22
- end
23
-
24
- def rubyforge_project
25
- name
26
- end
27
-
28
17
  def gemspec_file
29
18
  "#{name}.gemspec"
30
19
  end
@@ -37,46 +26,29 @@ def replace_header(head, header_name)
37
26
  head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
38
27
  end
39
28
 
40
- #############################################################################
41
- #
42
- # Standard tasks
43
- #
44
- #############################################################################
45
-
46
- task :default => :test
29
+ ## standard tasks
47
30
 
48
- require 'rake/testtask'
49
31
  Rake::TestTask.new(:test) do |test|
50
32
  test.libs << 'lib' << 'test'
51
33
  test.pattern = 'test/**/*_test.rb'
52
34
  test.verbose = true
53
35
  end
54
36
 
37
+ desc "Run tests including live tests against a local server on port 4567"
38
+ task :"test:local" do
39
+ ENV['LIVE'] = '1'
40
+ Rake::Task[:test].invoke
41
+ end
42
+
55
43
  desc "Open an irb session preloaded with this library"
56
44
  task :console do
57
45
  sh "irb -rubygems -r ./lib/#{name}.rb"
58
46
  end
59
47
 
60
- #############################################################################
61
- #
62
- # Custom tasks (add your own tasks here)
63
- #
64
- #############################################################################
65
-
48
+ ## release management tasks
66
49
 
67
-
68
- #############################################################################
69
- #
70
- # Packaging tasks
71
- #
72
- #############################################################################
73
-
74
- desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
50
+ desc "Commit, create tag v#{version} and build and push #{gem_file} to Rubygems"
75
51
  task :release => :build do
76
- unless `git branch` =~ /^\* master$/
77
- puts "You must be on the master branch to release!"
78
- exit!
79
- end
80
52
  sh "git commit --allow-empty -a -m 'Release #{version}'"
81
53
  sh "git tag v#{version}"
82
54
  sh "git push origin master"
@@ -92,7 +64,7 @@ task :build => :gemspec do
92
64
  end
93
65
 
94
66
  desc "Generate #{gemspec_file}"
95
- task :gemspec => :validate do
67
+ task :gemspec do
96
68
  # read spec file and split out manifest section
97
69
  spec = File.read(gemspec_file)
98
70
  head, manifest, tail = spec.split(" # = MANIFEST =\n")
@@ -100,9 +72,6 @@ task :gemspec => :validate do
100
72
  # replace name version and date
101
73
  replace_header(head, :name)
102
74
  replace_header(head, :version)
103
- replace_header(head, :date)
104
- #comment this out if your rubyforge_project has a different name
105
- replace_header(head, :rubyforge_project)
106
75
 
107
76
  # determine file list from git ls-files
108
77
  files = `git ls-files`.
@@ -119,16 +88,3 @@ task :gemspec => :validate do
119
88
  File.open(gemspec_file, 'w') { |io| io.write(spec) }
120
89
  puts "Updated #{gemspec_file}"
121
90
  end
122
-
123
- desc "Validate #{gemspec_file}"
124
- task :validate do
125
- libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
126
- unless libfiles.empty?
127
- puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
128
- exit!
129
- end
130
- unless Dir['VERSION*'].empty?
131
- puts "A `VERSION` file at root level violates Gem best practices."
132
- exit!
133
- end
134
- end
data/config.ru ADDED
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
4
+
5
+ require File.expand_path('../test/live_server', __FILE__)
6
+ run Sinatra::Application