nyny 1.0.1 → 1.0.2

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: cc338178211fc422842846bf3bb23284b8e4924e
4
- data.tar.gz: 16dedfbf23305f2e6bbf4e041b01b53b5b63e2d6
3
+ metadata.gz: 4590f5f6c66d42152fecc4f0749bfe4f198d6987
4
+ data.tar.gz: 799af0e6c6f79f90fa6ecf627a83d7e7f40e64bc
5
5
  SHA512:
6
- metadata.gz: 950ce1b36a87d5da3d6fabb67c223a16c09016b32e381843b71e3028eb4456171204cdf4ab43e461a7b3cb9243c00dfb1359d1be9fa370a7e8e005cf6ecb9af4
7
- data.tar.gz: abf1e6dcbf3ccd5e62a6af7ec21666f0f8c7f0b85d4fd0a512fa439cd36e1e47a620f616d2badd410ac97d637d5e39bd08949819231a3635ce61c25c0228ed69
6
+ metadata.gz: 1605466f98f71349ea745155617b54bcf91d245b92f878931457ffdffe7e44c55b348d280c20eeb84f73f6efbb4e4ee64bc4cbd203172d7ed6b8803b8930c31e
7
+ data.tar.gz: 28bb352a548d9eb62b759284c3cb153a624db86b640029fc318263c21ae5b1bc6f91df4c593895f32f7afb15d8588a2711c262db2a62b39a363e021ac418841d
data/Gemfile CHANGED
@@ -2,8 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rack'
6
-
7
5
  group :test do
8
6
  gem 'coveralls', :require => false
9
7
  gem 'rack-protection'
@@ -20,48 +20,54 @@ See below the code for each benchmark
20
20
 
21
21
  ## Code
22
22
  ### Simple
23
+ ```ruby
24
+ class App < NYNY::App #(or Sinatra::Base)
25
+ get '/' do
26
+ 'Hello World!'
27
+ end
28
+ end
29
+ ```
23
30
 
24
- class App < NYNY::App #(or Sinatra::Base)
25
- get '/' do
26
- 'Hello World!'
27
- end
28
- end
29
-
30
31
  ### UrlPattern
31
- class App < NYNY::App #(or Sinatra::Base)
32
- get '/hello/:name' do
33
- "Hello #{params[:name]}!"
34
- end
35
- end
32
+ ```ruby
33
+ class App < NYNY::App #(or Sinatra::Base)
34
+ get '/hello/:name' do
35
+ "Hello #{params[:name]}!"
36
+ end
37
+ end
38
+ ```
36
39
 
37
40
  ### Filters
38
- class App < NYNY::App #(or Sinatra::Base)
39
- before do
40
- request
41
- end
42
-
43
- after do
44
- response
45
- end
46
-
47
- get '/' do
48
- 'Hello World!'
49
- end
50
- end
51
-
41
+ ```ruby
42
+ class App < NYNY::App #(or Sinatra::Base)
43
+ before do
44
+ request
45
+ end
46
+
47
+ after do
48
+ response
49
+ end
50
+
51
+ get '/' do
52
+ 'Hello World!'
53
+ end
54
+ end
55
+ ```
56
+
52
57
  ### Helpers
53
- module Dude
54
- def da_request_man
55
- request
56
- end
57
- end
58
-
59
- class App < NYNY::App #(or Sinatra::Base)
60
- helpers Dude
61
-
62
- get '/' do
63
- da_request_man
64
- 'Hello World!'
65
- end
66
- end
58
+ ```ruby
59
+ module Dude
60
+ def da_request_man
61
+ request
62
+ end
63
+ end
64
+
65
+ class App < NYNY::App #(or Sinatra::Base)
66
+ helpers Dude
67
67
 
68
+ get '/' do
69
+ da_request_man
70
+ 'Hello World!'
71
+ end
72
+ end
73
+ ```
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # New York, New York.
2
2
  (very) small Sinatra clone.
3
3
 
4
- ![alt text](https://api.travis-ci.org/alisnic/nyny.png "build status")
4
+ [![Build Status](https://api.travis-ci.org/alisnic/nyny.png)](https://travis-ci.org/alisnic/nyny)
5
5
  [![Coverage Status](https://coveralls.io/repos/alisnic/nyny/badge.png)](https://coveralls.io/r/alisnic/nyny)
6
6
  [![Code Climate](https://codeclimate.com/repos/521b7ee513d637348712864a/badges/60e3637788bbac94f1cb/gpa.png)](https://codeclimate.com/repos/521b7ee513d637348712864a/feed)
7
7
 
@@ -18,13 +18,13 @@
18
18
 
19
19
  Install the gem:
20
20
 
21
- gem install nyny --pre
21
+ gem install nyny
22
22
 
23
- Run the file
23
+ Run the file:
24
24
 
25
25
  ruby myapp.rb
26
26
 
27
- Open the browser at [http://localhost:9292]()
27
+ Open the browser at [http://localhost:9292](http://localhost:9292)
28
28
 
29
29
  - [TOP](#new-york-new-york)
30
30
  - [Motivation](#motivation)
@@ -68,12 +68,12 @@ as middleware.
68
68
 
69
69
  # Usage
70
70
 
71
- A NYNY app must _always_ be in a class which inherits from `NYNY::App`.
71
+ A NYNY app must _always_ be in a class which inherits from `NYNY::App`:
72
72
 
73
73
  class App < NYNY::App
74
- get '/' do
75
- 'Hello, World'
76
- end
74
+ get '/' do
75
+ 'Hello, World'
76
+ end
77
77
  end
78
78
 
79
79
  ## Running
@@ -82,14 +82,16 @@ There are two ways to run a NYNY app __directly__ [[?]](#middleware):
82
82
  - by requiring it in a `config.ru` file, and then passing it as argument to the
83
83
  Rack's `run` function:
84
84
 
85
- #config.ru
85
+ # config.ru
86
+
86
87
  require 'app'
87
88
  run App.new
88
89
 
89
90
  - by using the `run!` method directly on the app class:
90
91
 
91
- #app.rb
92
- #...App class definition...
92
+ # app.rb
93
+
94
+ # ...app class definition...
93
95
 
94
96
  App.run!
95
97
 
@@ -115,7 +117,7 @@ NYNY also suports basic URL patterns:
115
117
 
116
118
  class App < NYNY::App
117
119
  get '/greet/:first_name/:last_name' do
118
- # The last expression in the block is _always_ considered the response body.
120
+ # the last expression in the block is _always_ considered the response body.
119
121
  "Hello #{params[:first_name]} #{params[:last_name]}!"
120
122
  end
121
123
  end
@@ -148,6 +150,8 @@ This means that several methods/objects available inside that block:
148
150
  (ex: `cookies[:foo] = 'bar'`)
149
151
  - `session` - a hash which allows you to access/modify/remove session variables
150
152
  (ex: `session[:foo] = 'bar'`)
153
+ - `halt` - allows you to instantly return a response, interrupting current
154
+ handler execution (see [halt][halt-definition])
151
155
 
152
156
  ## Filters
153
157
 
@@ -188,7 +192,7 @@ NYNY also supports middleware itself, and that means you can use Rack middleware
188
192
  (or a Sinatra app) inside a NYNY app:
189
193
 
190
194
  class App < NYNY::App
191
- #this will serve all the files in the "public" folder
195
+ # this will serve all the files in the "public" folder
192
196
  use Rack::Static :url => ['public']
193
197
  use SinatraApp
194
198
  end
@@ -210,7 +214,6 @@ definition block.
210
214
  # F. A. Q.
211
215
  TBD.
212
216
 
213
-
214
217
  # Contributing
215
218
 
216
219
  1. Fork it
@@ -226,3 +229,4 @@ TBD.
226
229
  [4]: http://rack.rubyforge.org/doc/classes/Rack/Response.html
227
230
  [performance]: https://github.com/alisnic/nyny/blob/master/Performance.md
228
231
  [rack-middleware]: https://github.com/rack/rack/wiki/List-of-Middleware
232
+ [halt-definition]: https://github.com/alisnic/nyny/blob/master/lib/nyny/request_scope.rb#L36
@@ -1,7 +1,6 @@
1
1
  module NYNY
2
2
  class RequestScope
3
3
  attr_reader :request, :response
4
- HaltError = Class.new(StandardError)
5
4
 
6
5
  def self.add_helper_module m
7
6
  include m
@@ -1,3 +1,3 @@
1
1
  module NYNY
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency "rack"
21
22
  spec.add_development_dependency "bundler", "~> 1.3"
22
23
  spec.add_development_dependency "rake"
23
24
  spec.add_development_dependency "rspec"
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nyny
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Lisnic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-27 00:00:00.000000000 Z
11
+ date: 2013-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement