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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0754c654539db2a8f0404255dbe15e50dc553b4
4
- data.tar.gz: 80d3faae39da584b6531678b57536db27bce9ae6
3
+ metadata.gz: eb4394aa3b48d0bbd477917db8fd791f11cd2190
4
+ data.tar.gz: 744a0b8042b2ef6556956459114ac2c9526217a9
5
5
  SHA512:
6
- metadata.gz: 703ea8e2e0708fba0baa997c8c9c7a1cd536a2bde142eecfeba8883921500de2011ee6b27299248c7167104e1816bd26c3db2ca3e861a7f777bb656c58e98f3b
7
- data.tar.gz: f54c6f0811fe80b3a10b304c018a006132603e71ccabe6306cb7e84f7175814beb17dbfa7109dd25c290defcf551cfd39810e4d6e5e5a03a70d071b0b0a27366
6
+ metadata.gz: 128211194c513e3f1f42fc815d535f5b7b01d75eedcb9fd536c924fad119bbd78bf6afd092b8541b03c42de10af400e96b61d0f756cad3d0d1c0d314ba6a2bd0
7
+ data.tar.gz: 2ff7364d01557d7189bf9bc5e4f11d663b2239e950538846321c9357f35e33fb16f22758ed43e6c1d75a4515bdb3d1434b50bec52550422ed51ae14c2bb80e0c
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - jruby-19mode
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in newark.gemspec
4
4
  gemspec
5
+
6
+ gem 'coveralls', require: false
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
@@ -4,7 +4,7 @@ require 'rake/testtask'
4
4
  Rake::TestTask.new(:test) do |test|
5
5
  test.libs << 'test'
6
6
  test.pattern = 'test/**/test_*.rb'
7
- test.warning = true
7
+ test.warning = false
8
8
  test.verbose = true
9
9
  end
10
10
 
@@ -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
@@ -1,7 +1,7 @@
1
1
  module Newark
2
2
  class Router
3
3
 
4
- FOUR_O_FOUR = [404, {}, []].freeze
4
+ FOUR_O_FOUR = [ 404, {}, [] ].freeze
5
5
 
6
6
  attr_accessor :request, :response
7
7
 
@@ -1,3 +1,3 @@
1
1
  module Newark
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.3'
3
3
  end
data/newark.gemspec CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'bundler', '~> 1.5'
25
25
  spec.add_development_dependency 'rake'
26
26
  spec.add_development_dependency 'rack-test'
27
+ spec.add_development_dependency 'pry'
27
28
  end
data/test/helper.rb CHANGED
@@ -1,7 +1,54 @@
1
- # require 'pry'
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.1
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-13 00:00:00.000000000 Z
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.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: