hatetepe 0.5.2 → 0.6.0.pre
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.
- data/.gitignore +7 -0
- data/.rspec +3 -0
- data/.travis.yml +4 -0
- data/.yardopts +1 -0
- data/Gemfile +9 -4
- data/Gemfile.devtools +55 -0
- data/LICENSE.txt +22 -0
- data/README.md +39 -192
- data/Rakefile +3 -2
- data/bin/hatetepe +35 -2
- data/config/devtools.yml +2 -0
- data/config/flay.yml +3 -0
- data/config/flog.yml +2 -0
- data/config/mutant.yml +3 -0
- data/config/reek.yml +103 -0
- data/config/rubocop.yml +58 -0
- data/config/yardstick.yml +2 -0
- data/hatetepe.gemspec +23 -27
- data/lib/hatetepe/client/keep_alive.rb +59 -0
- data/lib/hatetepe/client/timeouts.rb +19 -0
- data/lib/hatetepe/client.rb +54 -302
- data/lib/hatetepe/connection/eventmachine.rb +61 -0
- data/lib/hatetepe/connection/status.rb +28 -0
- data/lib/hatetepe/errors.rb +7 -0
- data/lib/hatetepe/promise.rb +86 -0
- data/lib/hatetepe/request.rb +15 -39
- data/lib/hatetepe/response.rb +82 -22
- data/lib/hatetepe/serializer/encoding.rb +58 -0
- data/lib/hatetepe/serializer.rb +61 -0
- data/lib/hatetepe/server/keep_alive.rb +53 -13
- data/lib/hatetepe/server/timeouts.rb +17 -0
- data/lib/hatetepe/server.rb +37 -85
- data/lib/hatetepe/support/handlers.rb +19 -0
- data/lib/hatetepe/support/keep_alive.rb +14 -0
- data/lib/hatetepe/support/message.rb +40 -0
- data/lib/hatetepe/version.rb +3 -1
- data/lib/hatetepe.rb +29 -7
- data/spec/integration/error_handling_spec.rb +7 -0
- data/spec/integration/keep_alive_spec.rb +106 -0
- data/spec/integration/smoke_spec.rb +21 -0
- data/spec/integration/streaming_spec.rb +61 -0
- data/spec/integration/timeouts_spec.rb +82 -0
- data/spec/shared/integration/server_client_pair.rb +26 -0
- data/spec/spec_helper.rb +41 -10
- data/spec/support/handler.rb +55 -0
- data/spec/support/helper.rb +74 -0
- data/spec/unit/client_spec.rb +115 -156
- data/spec/unit/connection/eventmachine_spec.rb +146 -0
- data/spec/unit/request_spec.rb +35 -0
- data/spec/unit/response_spec.rb +42 -0
- data/spec/unit/server_spec.rb +65 -100
- data/spec/unit/support/keep_alive_spec.rb +52 -0
- data/spec/unit/support/message_spec.rb +41 -0
- metadata +68 -103
- data/Gemfile.lock +0 -46
- data/LICENSE +0 -19
- data/Procfile +0 -1
- data/config.ru +0 -7
- data/examples/parallel_requests.rb +0 -32
- data/lib/hatetepe/body.rb +0 -182
- data/lib/hatetepe/builder.rb +0 -171
- data/lib/hatetepe/cli.rb +0 -61
- data/lib/hatetepe/connection.rb +0 -73
- data/lib/hatetepe/events.rb +0 -35
- data/lib/hatetepe/message.rb +0 -13
- data/lib/hatetepe/parser.rb +0 -83
- data/lib/hatetepe/server/pipeline.rb +0 -20
- data/lib/hatetepe/server/rack_app.rb +0 -39
- data/lib/rack/handler/hatetepe.rb +0 -33
- data/spec/integration/cli/start_spec.rb +0 -113
- data/spec/integration/client/keep_alive_spec.rb +0 -23
- data/spec/integration/client/timeout_spec.rb +0 -97
- data/spec/integration/server/keep_alive_spec.rb +0 -27
- data/spec/integration/server/timeout_spec.rb +0 -51
- data/spec/unit/body_spec.rb +0 -205
- data/spec/unit/builder_spec.rb +0 -372
- data/spec/unit/connection_spec.rb +0 -62
- data/spec/unit/events_spec.rb +0 -96
- data/spec/unit/parser_spec.rb +0 -209
- data/spec/unit/rack_handler_spec.rb +0 -60
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/.yardopts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
- LICENSE
|
data/Gemfile
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
source 'https://rubygems.org'
|
|
4
4
|
|
|
5
5
|
gemspec
|
|
6
6
|
|
|
7
|
-
gem
|
|
8
|
-
gem
|
|
7
|
+
gem 'devtools', git: 'https://github.com/rom-rb/devtools.git'
|
|
8
|
+
gem 'fuubar', git: 'https://github.com/lgierth/fuubar.git',
|
|
9
|
+
ref: 'static-percentage'
|
|
10
|
+
gem 'awesome_print'
|
|
11
|
+
|
|
12
|
+
# Added by devtools
|
|
13
|
+
eval_gemfile 'Gemfile.devtools'
|
data/Gemfile.devtools
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
group :development do
|
|
4
|
+
gem 'rake', '~> 10.1.0'
|
|
5
|
+
gem 'rspec', '~> 2.14.1'
|
|
6
|
+
gem 'yard', '~> 0.8.7'
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
group :yard do
|
|
10
|
+
gem 'kramdown', '~> 1.2.0'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
group :guard do
|
|
14
|
+
gem 'guard', '~> 1.8.1'
|
|
15
|
+
gem 'guard-bundler', '~> 1.0.0'
|
|
16
|
+
gem 'guard-rspec', '~> 3.0.2'
|
|
17
|
+
gem 'guard-rubocop', '~> 0.2.0'
|
|
18
|
+
gem 'guard-mutant', '~> 0.0.1'
|
|
19
|
+
|
|
20
|
+
# file system change event handling
|
|
21
|
+
gem 'listen', '~> 1.3.0'
|
|
22
|
+
gem 'rb-fchange', '~> 0.0.6', require: false
|
|
23
|
+
gem 'rb-fsevent', '~> 0.9.3', require: false
|
|
24
|
+
gem 'rb-inotify', '~> 0.9.0', require: false
|
|
25
|
+
|
|
26
|
+
# notification handling
|
|
27
|
+
gem 'libnotify', '~> 0.8.0', require: false
|
|
28
|
+
gem 'rb-notifu', '~> 0.0.4', require: false
|
|
29
|
+
gem 'terminal-notifier-guard', '~> 1.5.3', require: false
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
group :metrics do
|
|
33
|
+
gem 'coveralls', '~> 0.6.7'
|
|
34
|
+
gem 'flay', '~> 2.4.0'
|
|
35
|
+
gem 'flog', '~> 4.1.1'
|
|
36
|
+
gem 'reek', '~> 1.3.2'
|
|
37
|
+
gem 'rubocop', '~> 0.12.0'
|
|
38
|
+
gem 'simplecov', '~> 0.7.1'
|
|
39
|
+
gem 'yardstick', '~> 0.9.7', git: 'https://github.com/dkubb/yardstick.git'
|
|
40
|
+
|
|
41
|
+
platforms :ruby_19, :ruby_20 do
|
|
42
|
+
gem 'mutant', git: 'https://github.com/mbj/mutant.git'
|
|
43
|
+
gem 'yard-spellcheck', '~> 0.1.5'
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
group :benchmarks do
|
|
48
|
+
gem 'rbench', '~> 0.2.3'
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
platform :jruby do
|
|
52
|
+
group :jruby do
|
|
53
|
+
gem 'jruby-openssl', '~> 0.8.5'
|
|
54
|
+
end
|
|
55
|
+
end
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2013 Lars Gierth
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,206 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
================
|
|
1
|
+
# Hatetepe
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
Ruby programming language. It makes use of EventMachine and uses a Fiber for
|
|
6
|
-
each request/response cycle to ensure maximum efficiency. It has some great
|
|
7
|
-
features that make it a good choice for building HTTP APIs.
|
|
3
|
+
The HTTP toolkit
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
## Installation
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
automatic JSON or form-data encoding, have a look at
|
|
13
|
-
[Faraday](https://github.com/technoweenie/faraday), there's also an
|
|
14
|
-
[Hatetepe adapter](https://github.com/technoweenie/faraday/pull/108)
|
|
15
|
-
for it being worked on.
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
16
8
|
|
|
9
|
+
gem 'hatetepe'
|
|
17
10
|
|
|
18
|
-
|
|
19
|
-
------------------------
|
|
11
|
+
And then execute:
|
|
20
12
|
|
|
21
|
-
|
|
22
|
-
the gem:
|
|
13
|
+
$ bundle
|
|
23
14
|
|
|
24
|
-
|
|
25
|
-
We're in development
|
|
26
|
-
Booting from /home/lars/workspace/hatetepe/config.ru
|
|
27
|
-
Binding to 127.0.0.1:3000
|
|
15
|
+
Or install it yourself as:
|
|
28
16
|
|
|
29
|
-
|
|
30
|
-
file to be used and the RACK_ENV to run in. More help is available via the
|
|
31
|
-
`hatetepe help` command.
|
|
17
|
+
$ gem install hatetepe
|
|
32
18
|
|
|
19
|
+
## Usage
|
|
33
20
|
|
|
34
|
-
|
|
35
|
-
------------------------
|
|
21
|
+
TODO: Write usage instructions here
|
|
36
22
|
|
|
37
|
-
|
|
23
|
+
## To do
|
|
38
24
|
|
|
39
|
-
|
|
25
|
+
- Next
|
|
26
|
+
- Error handling
|
|
27
|
+
- Unit tests
|
|
28
|
+
- Method/Status semantics (GET/HEAD/204/etc.)
|
|
29
|
+
- Host header
|
|
30
|
+
- Documentation
|
|
31
|
+
- Replace into hatetepe-dev
|
|
32
|
+
- Deprecate hatetepe-0.5
|
|
33
|
+
- Future
|
|
34
|
+
- SSL support
|
|
35
|
+
- Webmachine adapter
|
|
36
|
+
- Request/Response pass-through
|
|
37
|
+
- Graceful shutdown
|
|
38
|
+
- Celluloid::IO backend
|
|
39
|
+
- Circuit breaker
|
|
40
|
+
- Nice to have
|
|
41
|
+
- Rack handler
|
|
42
|
+
- Faraday adapter
|
|
43
|
+
- Following redirects
|
|
44
|
+
- Proxy support
|
|
45
|
+
- Client handling multipart responses
|
|
40
46
|
|
|
41
|
-
|
|
42
|
-
client << request
|
|
47
|
+
## Contributing
|
|
43
48
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
puts "Error Code: #{response.status}"
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
`Request` and `Response` objects are mostly the same, they offer:
|
|
53
|
-
|
|
54
|
-
- `#verb` (only `Request`)
|
|
55
|
-
- `#uri` (only `Request`)
|
|
56
|
-
- `#status` (only `Response`)
|
|
57
|
-
- `#http_version`
|
|
58
|
-
- `#headers`
|
|
59
|
-
- `#body`
|
|
60
|
-
|
|
61
|
-
`Request` also has `#to_h` which will turn the object into something your
|
|
62
|
-
app can respond to.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
Async Responses
|
|
66
|
-
---------------
|
|
67
|
-
|
|
68
|
-
Like Thin and Goliath, Hatetepe provides `env["async.callback"]` for responding
|
|
69
|
-
in an asynchronous fashion. Don't forget to synchronously indicate an
|
|
70
|
-
asynchronous response by responding with a status of `-1`.
|
|
71
|
-
|
|
72
|
-
def call(env)
|
|
73
|
-
EM.add_timer(5) do
|
|
74
|
-
env["async.callback"].call [200, {"Content-Type" => "text/html"}, ["Hello!"]]
|
|
75
|
-
end
|
|
76
|
-
[-1]
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
The reactor won't block while waiting for the timer to kick in, it will
|
|
80
|
-
instead process other requests meanwhile.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
Proxying
|
|
84
|
-
--------
|
|
85
|
-
|
|
86
|
-
You can easily proxy a request to another HTTP server. The response will be
|
|
87
|
-
proxied back to the original client automatically. Remember to return an
|
|
88
|
-
async response.
|
|
89
|
-
|
|
90
|
-
def call(env)
|
|
91
|
-
env["proxy.start"].call "http://intra.example.org/derp"
|
|
92
|
-
[-1]
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
This will internally just call `env["proxy.callback"]` (which defaults to
|
|
96
|
-
`env["async.callback"]`). So if you want to send the response yourself, just
|
|
97
|
-
override `env["proxy.callback"]`.
|
|
98
|
-
|
|
99
|
-
If you want to reuse proxy connections (e.g. when doing Connection Pooling),
|
|
100
|
-
simply create a `Client` instance and pass it to `env["proxy.start"]`.
|
|
101
|
-
|
|
102
|
-
env["proxy.start"].call "http://intra.example.org/derp", pool.acquire
|
|
103
|
-
|
|
104
|
-
The reactor won't block while waiting for the proxy endpoint's response,
|
|
105
|
-
it will instead process other requests meanwhile.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
Response Streaming
|
|
109
|
-
------------------
|
|
110
|
-
|
|
111
|
-
Streaming a response is easy. Just make your Rack app return a `-1` status code
|
|
112
|
-
and use the `stream.start`, `stream.send` and `stream.close` helpers.
|
|
113
|
-
|
|
114
|
-
def call(env)
|
|
115
|
-
EM.add_timer 0.5 do
|
|
116
|
-
env["stream.start"].call [200, {"Content-Type" => "text/plain"}]
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
1.upto 3 do |i|
|
|
120
|
-
EM.add_timer i do
|
|
121
|
-
env["stream.send"].call "I feel alive!\n"
|
|
122
|
-
env["stream.close"].call if i == 3
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
[-1]
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
There's no limit on how long you can stream, keep in mind though that you might
|
|
130
|
-
hit timeouts. You can occasionally send LFs or something similar to prevent this
|
|
131
|
-
from happening.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
Sending and Receiving BLOBs
|
|
135
|
-
---------------------------
|
|
136
|
-
|
|
137
|
-
Hatetepe provides a thin wrapper around StringIO that makes it easier to handle
|
|
138
|
-
streaming of request and response bodies. That means your app will be `#call`ed
|
|
139
|
-
as soon as all headers have arrived. It can then do stuff while it's still
|
|
140
|
-
receiving body data. You might for example want to track upload progress.
|
|
141
|
-
|
|
142
|
-
received = nil
|
|
143
|
-
total = nil
|
|
144
|
-
|
|
145
|
-
post "/upload" do
|
|
146
|
-
total = request.headers["Content-Length"].to_i
|
|
147
|
-
request.env["rack.input"].each do |chunk|
|
|
148
|
-
received += chunk.bytesize
|
|
149
|
-
end
|
|
150
|
-
request.env["rack.input"].rewind
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
get "/progress" do
|
|
154
|
-
json [received, total]
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
`Hatetepe::Body#each` will block until the response has been received completely
|
|
158
|
-
and yield each time a new chunk arrives. Calls to `#read`, `#gets` and `#length`
|
|
159
|
-
will block until everything arrived and then return their normal return value
|
|
160
|
-
as expected. `Body` includes `EM::Deferrable`, meaning you can attach
|
|
161
|
-
callbacks to it. `#close_write` will succeed it - this is important if you
|
|
162
|
-
want to make a request with a streaming body.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
Contributing
|
|
166
|
-
------------
|
|
167
|
-
|
|
168
|
-
1. Fork at [github.com/lgierth/hatetepe](https://github.com/lgierth/hatetepe)
|
|
169
|
-
2. Create a new branch
|
|
170
|
-
3. Commit, commit, commit!
|
|
171
|
-
4. Open a Pull Request
|
|
172
|
-
|
|
173
|
-
You can also open an issue for discussion first, if you like.
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
License
|
|
177
|
-
-------
|
|
178
|
-
|
|
179
|
-
Hatetepe is subject to an MIT-style license (see LICENSE file).
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
Roadmap
|
|
183
|
-
-------
|
|
184
|
-
|
|
185
|
-
- 0.6.0
|
|
186
|
-
- Direct recv<->send IO via EM.enable_proxy
|
|
187
|
-
- SSL/TLS
|
|
188
|
-
- HTTP proxying (in client and server)
|
|
189
|
-
- later
|
|
190
|
-
- Encoding support (ref. [github.com/tmm1/http_parser.rb#1](https://github.com/tmm1/http_parser.rb/pull/1))
|
|
191
|
-
- Optimize for performance
|
|
192
|
-
- Propagate connection errors to the app
|
|
193
|
-
|
|
194
|
-
Ideas
|
|
195
|
-
-----
|
|
196
|
-
|
|
197
|
-
- Support for rubygems-test
|
|
198
|
-
- Code reloading
|
|
199
|
-
- Preforking
|
|
200
|
-
- MVM support via Thread Pool
|
|
201
|
-
- Support for SPDY
|
|
202
|
-
- Serving via filesystem or in-memory
|
|
203
|
-
- Foreman support
|
|
204
|
-
- Daemonizing and dropping privileges
|
|
205
|
-
- Trailing headers
|
|
206
|
-
- REPL for Server and Client
|
|
49
|
+
1. Fork it
|
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
51
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
53
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
data/bin/hatetepe
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
2
3
|
|
|
3
|
-
require
|
|
4
|
-
|
|
4
|
+
require 'ap'
|
|
5
|
+
require 'hatetepe'
|
|
6
|
+
|
|
7
|
+
class RequestHandler
|
|
8
|
+
def initialize(config, server, connection)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def serve(request)
|
|
12
|
+
request.finished.then do
|
|
13
|
+
puts "#{request.http_method.upcase} #{request.uri}"
|
|
14
|
+
response = build_response
|
|
15
|
+
request.served.fulfill(response)
|
|
16
|
+
response.finished.fulfill
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def build_response
|
|
21
|
+
Hatetepe::Response.new(
|
|
22
|
+
200, { 'Content-Type' => 'text/plain' }, "hello, world\n")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
address = ENV.fetch('ADDRESS', '127.0.0.1')
|
|
27
|
+
port = ENV.fetch('PORT', 3000)
|
|
28
|
+
|
|
29
|
+
$stdout.sync = true
|
|
30
|
+
|
|
31
|
+
EM.run do
|
|
32
|
+
puts "Listening on http://#{address}:#{port}"
|
|
33
|
+
Hatetepe::Server.start(address: address, port: port,
|
|
34
|
+
handlers: [Hatetepe::Server::KeepAlive,
|
|
35
|
+
Hatetepe::Server::Timeouts,
|
|
36
|
+
RequestHandler])
|
|
37
|
+
end
|
data/config/devtools.yml
ADDED
data/config/flay.yml
ADDED
data/config/flog.yml
ADDED
data/config/mutant.yml
ADDED
data/config/reek.yml
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
Attribute:
|
|
3
|
+
enabled: true
|
|
4
|
+
exclude: []
|
|
5
|
+
BooleanParameter:
|
|
6
|
+
enabled: true
|
|
7
|
+
exclude: []
|
|
8
|
+
ClassVariable:
|
|
9
|
+
enabled: true
|
|
10
|
+
exclude: []
|
|
11
|
+
ControlParameter:
|
|
12
|
+
enabled: true
|
|
13
|
+
exclude: []
|
|
14
|
+
DataClump:
|
|
15
|
+
enabled: true
|
|
16
|
+
exclude: []
|
|
17
|
+
max_copies: 2
|
|
18
|
+
min_clump_size: 2
|
|
19
|
+
DuplicateMethodCall:
|
|
20
|
+
enabled: true
|
|
21
|
+
exclude: []
|
|
22
|
+
max_calls: 1
|
|
23
|
+
allow_calls: []
|
|
24
|
+
FeatureEnvy:
|
|
25
|
+
enabled: true
|
|
26
|
+
exclude: []
|
|
27
|
+
IrresponsibleModule:
|
|
28
|
+
enabled: true
|
|
29
|
+
exclude: []
|
|
30
|
+
LongParameterList:
|
|
31
|
+
enabled: true
|
|
32
|
+
exclude: []
|
|
33
|
+
max_params: 2
|
|
34
|
+
overrides:
|
|
35
|
+
initialize:
|
|
36
|
+
max_params: 3
|
|
37
|
+
LongYieldList:
|
|
38
|
+
enabled: true
|
|
39
|
+
exclude: []
|
|
40
|
+
max_params: 2
|
|
41
|
+
NestedIterators:
|
|
42
|
+
enabled: true
|
|
43
|
+
exclude: []
|
|
44
|
+
max_allowed_nesting: 1
|
|
45
|
+
ignore_iterators: []
|
|
46
|
+
NilCheck:
|
|
47
|
+
enabled: true
|
|
48
|
+
exclude: []
|
|
49
|
+
RepeatedConditional:
|
|
50
|
+
enabled: true
|
|
51
|
+
exclude: []
|
|
52
|
+
max_ifs: 1
|
|
53
|
+
TooManyInstanceVariables:
|
|
54
|
+
enabled: true
|
|
55
|
+
exclude: []
|
|
56
|
+
max_instance_variables: 3
|
|
57
|
+
TooManyMethods:
|
|
58
|
+
enabled: true
|
|
59
|
+
exclude: []
|
|
60
|
+
max_methods: 10
|
|
61
|
+
TooManyStatements:
|
|
62
|
+
enabled: true
|
|
63
|
+
exclude:
|
|
64
|
+
- each
|
|
65
|
+
max_statements: 2
|
|
66
|
+
UncommunicativeMethodName:
|
|
67
|
+
enabled: true
|
|
68
|
+
exclude: []
|
|
69
|
+
reject:
|
|
70
|
+
- !ruby/regexp /^[a-z]$/
|
|
71
|
+
- !ruby/regexp /[0-9]$/
|
|
72
|
+
- !ruby/regexp /[A-Z]/
|
|
73
|
+
accept: []
|
|
74
|
+
UncommunicativeModuleName:
|
|
75
|
+
enabled: true
|
|
76
|
+
exclude: []
|
|
77
|
+
reject:
|
|
78
|
+
- !ruby/regexp /^.$/
|
|
79
|
+
- !ruby/regexp /[0-9]$/
|
|
80
|
+
accept: []
|
|
81
|
+
UncommunicativeParameterName:
|
|
82
|
+
enabled: true
|
|
83
|
+
exclude: []
|
|
84
|
+
reject:
|
|
85
|
+
- !ruby/regexp /^.$/
|
|
86
|
+
- !ruby/regexp /[0-9]$/
|
|
87
|
+
- !ruby/regexp /[A-Z]/
|
|
88
|
+
accept: []
|
|
89
|
+
UncommunicativeVariableName:
|
|
90
|
+
enabled: true
|
|
91
|
+
exclude: []
|
|
92
|
+
reject:
|
|
93
|
+
- !ruby/regexp /^.$/
|
|
94
|
+
- !ruby/regexp /[0-9]$/
|
|
95
|
+
- !ruby/regexp /[A-Z]/
|
|
96
|
+
accept: []
|
|
97
|
+
UnusedParameters:
|
|
98
|
+
enabled: true
|
|
99
|
+
exclude: []
|
|
100
|
+
UtilityFunction:
|
|
101
|
+
enabled: true
|
|
102
|
+
exclude: []
|
|
103
|
+
max_helper_calls: 0
|
data/config/rubocop.yml
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
Includes:
|
|
3
|
+
- '**/*.rake'
|
|
4
|
+
- 'Gemfile'
|
|
5
|
+
- 'Gemfile.devtools'
|
|
6
|
+
Excludes:
|
|
7
|
+
- '**/vendor/**'
|
|
8
|
+
- '**/benchmarks/**'
|
|
9
|
+
|
|
10
|
+
# Avoid parameter lists longer than five parameters.
|
|
11
|
+
ParameterLists:
|
|
12
|
+
Max: 4
|
|
13
|
+
CountKeywordArgs: true
|
|
14
|
+
|
|
15
|
+
# Avoid more than `Max` levels of nesting.
|
|
16
|
+
BlockNesting:
|
|
17
|
+
Max: 3
|
|
18
|
+
|
|
19
|
+
# Align with the style guide.
|
|
20
|
+
CollectionMethods:
|
|
21
|
+
PreferredMethods:
|
|
22
|
+
collect: 'map'
|
|
23
|
+
inject: 'reduce'
|
|
24
|
+
find: 'detect'
|
|
25
|
+
find_all: 'select'
|
|
26
|
+
|
|
27
|
+
# Do not force public/protected/private keyword to be indented at the same
|
|
28
|
+
# level as the def keyword. My personal preference is to outdent these keywords
|
|
29
|
+
# because I think when scanning code it makes it easier to identify the
|
|
30
|
+
# sections of code and visually separate them. When the keyword is at the same
|
|
31
|
+
# level I think it sort of blends in with the def keywords and makes it harder
|
|
32
|
+
# to scan the code and see where the sections are.
|
|
33
|
+
AccessControl:
|
|
34
|
+
Enabled: false
|
|
35
|
+
|
|
36
|
+
# Limit line length
|
|
37
|
+
LineLength:
|
|
38
|
+
Max: 79
|
|
39
|
+
|
|
40
|
+
# Disable documentation checking until a class needs to be documented once
|
|
41
|
+
Documentation:
|
|
42
|
+
Enabled: false
|
|
43
|
+
|
|
44
|
+
# Do not favor modifier if/unless usage when you have a single-line body
|
|
45
|
+
IfUnlessModifier:
|
|
46
|
+
Enabled: false
|
|
47
|
+
|
|
48
|
+
# Allow case equality operator (in limited use within the specs)
|
|
49
|
+
CaseEquality:
|
|
50
|
+
Enabled: false
|
|
51
|
+
|
|
52
|
+
# Constants do not always have to use SCREAMING_SNAKE_CASE
|
|
53
|
+
ConstantName:
|
|
54
|
+
Enabled: false
|
|
55
|
+
|
|
56
|
+
# Not all trivial readers/writers can be defined with attr_* methods
|
|
57
|
+
TrivialAccessors:
|
|
58
|
+
Enabled: false
|
data/hatetepe.gemspec
CHANGED
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
#
|
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
-
require "hatetepe/version"
|
|
4
|
-
require "date"
|
|
1
|
+
# encoding: utf-8
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
s.date = Date.today.to_s
|
|
10
|
-
s.platform = Gem::Platform::RUBY
|
|
11
|
-
s.authors = ["Lars Gierth"]
|
|
12
|
-
s.email = ["lars.gierth@gmail.com"]
|
|
13
|
-
s.homepage = "https://github.com/lgierth/hatetepe"
|
|
14
|
-
s.summary = %q{The HTTP toolkit}
|
|
15
|
-
#s.description = %q{TODO: write description}
|
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
require 'hatetepe/version'
|
|
16
6
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
7
|
+
Gem::Specification.new do |spec|
|
|
8
|
+
spec.name = "hatetepe"
|
|
9
|
+
spec.version = Hatetepe::VERSION
|
|
10
|
+
spec.authors = ["Lars Gierth"]
|
|
11
|
+
spec.email = ["lars.gierth@gmail.com"]
|
|
12
|
+
spec.description = %q{The HTTP toolkit}
|
|
13
|
+
spec.summary = %q{General purpose toolkit for HTTP clients and servers}
|
|
14
|
+
spec.homepage = "https://github.com/lgierth/hatetepe"
|
|
15
|
+
spec.license = "MIT"
|
|
26
16
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
spec.files = `git ls-files`.split($/)
|
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
19
|
+
spec.test_files = spec.files.grep(%r{^spec/})
|
|
20
|
+
spec.require_paths = ["lib"]
|
|
21
|
+
|
|
22
|
+
spec.add_dependency "eventmachine"
|
|
23
|
+
spec.add_dependency "http_parser.rb"
|
|
24
|
+
spec.add_dependency "promise.rb"
|
|
25
|
+
|
|
26
|
+
spec.add_development_dependency "rspec"
|
|
31
27
|
end
|