hi 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8bbd54fb327c3e7b130df186485b8ca1df580cc
4
- data.tar.gz: d8184e3e8465aed9ae58bd516a02c0c65e16f995
3
+ metadata.gz: 90b9c09d4718077fca4fc2f656da9becf7f54517
4
+ data.tar.gz: 4053b75715a16a474269a6ed608dd679794e03e1
5
5
  SHA512:
6
- metadata.gz: 2f0065cbc2ea2f70a279d13c1affbbae432793a72970732bb69b7659ca9d616a2d139c5b9f8456050b26e4e72fb711fec57059c2bfdd9a625d142fd9ae76c63c
7
- data.tar.gz: ead378f1dcf608e175646f5c74a44e641a97dea9dfd2a302e89b10194853f4e4cf36a4c1a33e2da8cb62a5bb81180540711a4d7a35ced7e4253da0572439080e
6
+ metadata.gz: ecb8367a1625838354d137a540def00a06e699f048ff98fc1f4f610525152b8cfabb37a697a4970a1b937cf363feb39beec14ee59263ec0dd7e1c7c699178961
7
+ data.tar.gz: d1a587364e141c112de9daa65d98cb763b9c83252ec3b2cf785e0d680430bcdafcd3d1193adf9b039a782fd2df2a74ad8064a4298cfbae218aa03759c05d16f0
data/CHANGELOG.md CHANGED
@@ -1,9 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ##v1.1.1
4
+ *2013-12-28*
5
+
6
+ - [#3](https://github.com/chrishunt/hi/pull/3) Delegate all request methods to the request
7
+
3
8
  ##v1.1.0
4
9
  *2013-12-27*
5
10
 
6
- - #1 Show request headers
11
+ - [#1](https://github.com/chrishunt/hi/pull/1) Show request headers
7
12
 
8
13
  ##v1.0.0
9
14
  *2013-12-27*
data/README.md CHANGED
@@ -6,19 +6,17 @@
6
6
 
7
7
  ### hi, I'm here to debug your HTTP
8
8
 
9
- ## Description
9
+ [chrishunt.co/hi](http://chrishunt.co/hi/)
10
10
 
11
- `hi` is a simple HTTP server that will accept any request you throw at it and
12
- reply with 'hi'. Since all requests are dumped to the console, it's probably
13
- most useful for debugging.
11
+ ## Usage
14
12
 
15
- Get started by installing the gem:
13
+ Hi, I'm here to help you debug your HTTP. To get started, install me.
16
14
 
17
15
  ```bash
18
16
  $ gem install hi
19
17
  ```
20
18
 
21
- Then start up the server:
19
+ Now start me up:
22
20
 
23
21
  ```bash
24
22
  $ hi
@@ -27,7 +25,7 @@ $ hi
27
25
  >> Listening on 0.0.0.0:3000, CTRL+C to stop
28
26
  ```
29
27
 
30
- The default port is `3000`. You can start on another port if you like:
28
+ If you don't like my default port, try something else:
31
29
 
32
30
  ```bash
33
31
  $ hi 1234
@@ -36,7 +34,8 @@ $ hi 1234
36
34
  >> Listening on 0.0.0.0:1234, CTRL+C to stop
37
35
  ```
38
36
 
39
- Now start debugging those requests:
37
+ Let's start debugging! Just send a request my way and I'll tell you everything
38
+ I know about it.
40
39
 
41
40
  ```bash
42
41
  $ curl localhost:3000/foo/bar\?message=hello
@@ -65,36 +64,7 @@ $ curl localhost:3000/foo/bar\?message=hello
65
64
  }
66
65
  ```
67
66
 
68
- `hi` accepts anything. Try a `POST` instead:
69
-
70
- ```bash
71
- $ curl -d 'message=hello' localhost:3000
72
-
73
- "POST http://localhost:3000/ (2013-12-27 14:18:59 -0800)"
74
- {
75
- :host => "localhost",
76
- :ip => "127.0.0.1",
77
- :port => 3000,
78
- :request_method => "POST",
79
- :scheme => "http",
80
- :url => "http://localhost:3000/",
81
- :query_string => "",
82
- :body => "message=hello",
83
- :content_length => "13",
84
- :media_type => "application/x-www-form-urlencoded",
85
- :referer => nil,
86
- :user_agent => "curl/7.30.0",
87
- :xhr => false,
88
- :headers => {
89
- "HTTP_VERSION" => "HTTP/1.1",
90
- "HTTP_USER_AGENT" => "curl/7.30.0",
91
- "HTTP_HOST" => "localhost:3000",
92
- "HTTP_ACCEPT" => "*/*"
93
- }
94
- }
95
- ```
96
-
97
- Or an xhr request:
67
+ The fancier your request, the better.
98
68
 
99
69
  ```bash
100
70
  $ curl -H 'X-Requested-With: XMLHttpRequest' -d "message=hello" localhost:3000
data/hi.gemspec CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency 'thin', '~> 1.5.1'
23
23
 
24
24
  spec.add_development_dependency 'coveralls', '~> 0.7.0'
25
+ spec.add_development_dependency 'pry', '~> 0.9.12.4'
25
26
  spec.add_development_dependency 'rack-test', '~> 0.6.2'
26
27
  spec.add_development_dependency 'rake', '~> 10.1.1'
27
28
  spec.add_development_dependency 'rspec', '~> 2.14.1'
data/lib/hi/request.rb CHANGED
@@ -2,6 +2,25 @@ require 'rack/request'
2
2
 
3
3
  module Hi
4
4
  class Request
5
+ extend Forwardable
6
+
7
+ ATTRIBUTES = [
8
+ :host,
9
+ :ip,
10
+ :port,
11
+ :request_method,
12
+ :scheme,
13
+ :url,
14
+ :query_string,
15
+ :body,
16
+ :content_length,
17
+ :media_type,
18
+ :referer,
19
+ :user_agent,
20
+ :xhr?
21
+ ]
22
+
23
+ def_delegators :request, *ATTRIBUTES
5
24
  attr_reader :env, :request
6
25
 
7
26
  def initialize(env)
@@ -13,23 +32,21 @@ module Hi
13
32
  env.select { |key| key.start_with? 'HTTP_' }
14
33
  end
15
34
 
35
+ def body_string
36
+ body.string if body
37
+ end
38
+
16
39
  def to_h
17
- {
18
- host: request.host,
19
- ip: request.ip,
20
- port: request.port,
21
- request_method: request.request_method,
22
- scheme: request.scheme,
23
- url: request.url,
24
- query_string: request.query_string,
25
- body: (request.body.string if request.body),
26
- content_length: request.content_length,
27
- media_type: request.media_type,
28
- referer: request.referer,
29
- user_agent: request.user_agent,
30
- xhr: request.xhr?,
40
+ request_hash.merge({
41
+ body: body_string,
31
42
  headers: headers,
32
- }
43
+ })
44
+ end
45
+
46
+ private
47
+
48
+ def request_hash
49
+ ATTRIBUTES.inject({}) { |hash, attr| hash[attr] = send(attr); hash }
33
50
  end
34
51
  end
35
52
  end
data/lib/hi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hi
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
data/screenshot.png CHANGED
Binary file
@@ -25,4 +25,14 @@ describe Hi::Request do
25
25
  expect(request.headers).to eq headers
26
26
  end
27
27
  end
28
+
29
+ describe '#host' do
30
+ it 'returns the host passed in the environment' do
31
+ host = 'amazing.dev'
32
+
33
+ request = described_class.new('HTTP_HOST' => host)
34
+
35
+ expect(request.host).to eq host
36
+ end
37
+ end
28
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Hunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-27 00:00:00.000000000 Z
11
+ date: 2013-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.7.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.12.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.9.12.4
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rack-test
57
71
  requirement: !ruby/object:Gem::Requirement