newark 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/Gemfile +2 -0
- data/README.md +4 -0
- data/Rakefile +1 -1
- data/lib/newark/request.rb +9 -8
- data/lib/newark/router.rb +1 -1
- data/lib/newark/version.rb +1 -1
- data/newark.gemspec +1 -0
- data/test/helper.rb +48 -1
- data/test/test_request.rb +43 -0
- data/test/test_router.rb +0 -44
- metadata +21 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb4394aa3b48d0bbd477917db8fd791f11cd2190
|
4
|
+
data.tar.gz: 744a0b8042b2ef6556956459114ac2c9526217a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 128211194c513e3f1f42fc815d535f5b7b01d75eedcb9fd536c924fad119bbd78bf6afd092b8541b03c42de10af400e96b61d0f756cad3d0d1c0d314ba6a2bd0
|
7
|
+
data.tar.gz: 2ff7364d01557d7189bf9bc5e4f11d663b2239e950538846321c9357f35e33fb16f22758ed43e6c1d75a4515bdb3d1434b50bec52550422ed51ae14c2bb80e0c
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Newark
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/mje113/newark.png?branch=master)](https://travis-ci.org/mje113/newark)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/mje113/newark/badge.png)](https://coveralls.io/r/mje113/newark)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/mje113/newark.png)](https://codeclimate.com/github/mje113/newark)
|
6
|
+
|
3
7
|
A Pico Web Framework
|
4
8
|
|
5
9
|
## Installation
|
data/Rakefile
CHANGED
data/lib/newark/request.rb
CHANGED
@@ -3,19 +3,20 @@ require 'active_support/hash_with_indifferent_access'
|
|
3
3
|
module Newark
|
4
4
|
class Request < Rack::Request
|
5
5
|
|
6
|
-
def initialize(*)
|
7
|
-
super
|
8
|
-
@body = @env["rack.input"].clone.read
|
9
|
-
@params = ActiveSupport::HashWithIndifferentAccess.new(params)
|
10
|
-
@headers = original_headers
|
11
|
-
end
|
12
|
-
|
13
6
|
def uri
|
14
7
|
URI(base_url + fullpath)
|
15
8
|
end
|
16
9
|
|
10
|
+
def params
|
11
|
+
@params ||= ActiveSupport::HashWithIndifferentAccess.new(super)
|
12
|
+
end
|
13
|
+
|
17
14
|
def body
|
18
|
-
@body
|
15
|
+
@body ||= @env['rack.input'].clone.read
|
16
|
+
end
|
17
|
+
|
18
|
+
def headers
|
19
|
+
@headers ||= original_headers
|
19
20
|
end
|
20
21
|
|
21
22
|
protected
|
data/lib/newark/router.rb
CHANGED
data/lib/newark/version.rb
CHANGED
data/newark.gemspec
CHANGED
data/test/helper.rb
CHANGED
@@ -1,7 +1,54 @@
|
|
1
|
-
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
|
+
|
4
|
+
require 'pry'
|
2
5
|
require 'newark'
|
3
6
|
require 'minitest/autorun'
|
4
7
|
|
8
|
+
class App
|
9
|
+
|
10
|
+
include Newark
|
11
|
+
|
12
|
+
before do
|
13
|
+
headers['X-Newark-Version'] = Newark::VERSION
|
14
|
+
end
|
15
|
+
|
16
|
+
after do
|
17
|
+
headers['X-Newark-Done'] = 'true'
|
18
|
+
end
|
19
|
+
|
20
|
+
get '/', params: { user: 'frank' } do
|
21
|
+
'hello frank'
|
22
|
+
end
|
23
|
+
|
24
|
+
get '/' do
|
25
|
+
'hello'
|
26
|
+
end
|
27
|
+
|
28
|
+
get(/\/regexp/) do
|
29
|
+
'regexp'
|
30
|
+
end
|
31
|
+
|
32
|
+
get '/create' do
|
33
|
+
'whoops'
|
34
|
+
end
|
35
|
+
|
36
|
+
post '/create' do
|
37
|
+
'created'
|
38
|
+
end
|
39
|
+
|
40
|
+
get '/request_and_response' do
|
41
|
+
request && response
|
42
|
+
headers && params
|
43
|
+
'ok'
|
44
|
+
end
|
45
|
+
|
46
|
+
get '/variables/:a/:b' do
|
47
|
+
"#{params[:a]}:#{params[:b]}"
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
5
52
|
class Minitest::Unit::TestCase
|
6
53
|
|
7
54
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'rack/test'
|
3
|
+
|
4
|
+
class RequestApp
|
5
|
+
include Newark
|
6
|
+
|
7
|
+
get '/uri' do
|
8
|
+
request.uri.to_s
|
9
|
+
end
|
10
|
+
|
11
|
+
get '/headers' do
|
12
|
+
request.headers['X-Fu']
|
13
|
+
end
|
14
|
+
|
15
|
+
post '/body' do
|
16
|
+
request.body
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class TestRequest < Minitest::Unit::TestCase
|
21
|
+
|
22
|
+
include Rack::Test::Methods
|
23
|
+
|
24
|
+
def app
|
25
|
+
RequestApp.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_uri
|
29
|
+
get '/uri', { fu: 'bar' }
|
30
|
+
assert_equal 'http://example.org/uri?fu=bar', last_response.body
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_headers
|
34
|
+
get '/headers', {}, { 'HTTP_X_FU' => 'Bar' }
|
35
|
+
assert_equal 'Bar', last_response.body
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_body
|
39
|
+
post '/body', {}, { 'rack.input' => StringIO.new('fubar') }
|
40
|
+
assert_equal 'fubar', last_response.body
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
data/test/test_router.rb
CHANGED
@@ -1,50 +1,6 @@
|
|
1
1
|
require 'helper'
|
2
2
|
require 'rack/test'
|
3
3
|
|
4
|
-
class App
|
5
|
-
|
6
|
-
include Newark
|
7
|
-
|
8
|
-
before do
|
9
|
-
headers['X-Newark-Version'] = Newark::VERSION
|
10
|
-
end
|
11
|
-
|
12
|
-
after do
|
13
|
-
headers['X-Newark-Done'] = 'true'
|
14
|
-
end
|
15
|
-
|
16
|
-
get '/', params: { user: 'frank' } do
|
17
|
-
'hello frank'
|
18
|
-
end
|
19
|
-
|
20
|
-
get '/' do
|
21
|
-
'hello'
|
22
|
-
end
|
23
|
-
|
24
|
-
get(/\/regexp/) do
|
25
|
-
'regexp'
|
26
|
-
end
|
27
|
-
|
28
|
-
get '/create' do
|
29
|
-
'whoops'
|
30
|
-
end
|
31
|
-
|
32
|
-
post '/create' do
|
33
|
-
'created'
|
34
|
-
end
|
35
|
-
|
36
|
-
get '/request_and_response' do
|
37
|
-
request && response
|
38
|
-
headers && params
|
39
|
-
'ok'
|
40
|
-
end
|
41
|
-
|
42
|
-
get '/variables/:a/:b' do
|
43
|
-
"#{params[:a]}:#{params[:b]}"
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
4
|
class TestRouter < Minitest::Unit::TestCase
|
49
5
|
|
50
6
|
include Rack::Test::Methods
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: Because everyone should write their own framework.
|
84
98
|
email:
|
85
99
|
- mike@urlgonomics.com
|
@@ -88,6 +102,7 @@ extensions: []
|
|
88
102
|
extra_rdoc_files: []
|
89
103
|
files:
|
90
104
|
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
91
106
|
- Gemfile
|
92
107
|
- LICENSE.txt
|
93
108
|
- README.md
|
@@ -101,6 +116,7 @@ files:
|
|
101
116
|
- lib/newark/version.rb
|
102
117
|
- newark.gemspec
|
103
118
|
- test/helper.rb
|
119
|
+
- test/test_request.rb
|
104
120
|
- test/test_router.rb
|
105
121
|
homepage: ''
|
106
122
|
licenses:
|
@@ -122,10 +138,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
138
|
version: '0'
|
123
139
|
requirements: []
|
124
140
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.2.
|
141
|
+
rubygems_version: 2.2.1
|
126
142
|
signing_key:
|
127
143
|
specification_version: 4
|
128
144
|
summary: Pico Web Framework
|
129
145
|
test_files:
|
130
146
|
- test/helper.rb
|
147
|
+
- test/test_request.rb
|
131
148
|
- test/test_router.rb
|
149
|
+
has_rdoc:
|