hobbit 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 13aaaa7026f03efacdb617e198af50cc3639a92b
4
+ data.tar.gz: 1d9e50852b00d78c2323aa71ffe913f47403a47a
5
+ SHA512:
6
+ metadata.gz: 9f6302144d5b8a10b1b5f413e7a80d300f66bec46d49283c3d5257dad1a410535a788ff629728c6fdf0493e85bee5d76951c06c10622c56394be03d5d90c7be6
7
+ data.tar.gz: 3063236837643a0ea6bbc0bf80febb18ce015eacd3a00cf9c2b3ba89ec111bec8619f677b6aee5c4ea88be761b74aad4e7720c70848d54999d2e534dc0e5cef8
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ examples/example_1/Gemfile.lock
12
+ examples/example_2/Gemfile.lock
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
@@ -0,0 +1,12 @@
1
+ ---
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - rbx-19mode
6
+ - jruby-19mode
7
+ - jruby-20mode
8
+ - jruby-head
9
+ - ruby-head
10
+ matrix:
11
+ allow_failures:
12
+ - rvm: ruby-head
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Patricio Mac Adden
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.
@@ -0,0 +1,299 @@
1
+ # Hobbit
2
+
3
+ [![Build Status](https://travis-ci.org/patriciomacadden/hobbit.png?branch=master)](https://travis-ci.org/patriciomacadden/hobbit)
4
+ [![Code Climate](https://codeclimate.com/github/patriciomacadden/hobbit.png)](https://codeclimate.com/github/patriciomacadden/hobbit)
5
+
6
+ A minimalistic microframework built on top of [Rack](http://rack.github.io/).
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'hobbit'
14
+ # or this if you want to use master
15
+ # gem 'hobbit', github: 'patriciomacadden/hobbit'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ ```bash
21
+ $ bundle
22
+ ```
23
+
24
+ Or install it yourself as:
25
+
26
+ ```bash
27
+ $ gem install hobbit
28
+ ```
29
+
30
+ ## Features
31
+
32
+ * DSL inspired by [Sinatra](http://www.sinatrarb.com/).
33
+ * Extensible with standard ruby classes and modules, with no extra logic (see
34
+ the included modules).
35
+
36
+ ## Usage
37
+
38
+ `Hobbit` applications are just instances of `Hobbit::Base`, which complies the
39
+ [Rack SPEC](http://rack.rubyforge.org/doc/SPEC.html).
40
+
41
+ Here is a classic **Hello World!** example (write this code in `config.ru`):
42
+
43
+ ```ruby
44
+ require 'hobbit'
45
+
46
+ class App < Hobbit::Base
47
+ get '/' do
48
+ 'Hello World!'
49
+ end
50
+ end
51
+
52
+ run App.new
53
+ ```
54
+
55
+ ### Routes
56
+
57
+ You can define routes as in [Sinatra](http://www.sinatrarb.com/):
58
+
59
+ ```ruby
60
+ class App < Hobbit::Base
61
+ get '/' do
62
+ 'Hello world'
63
+ end
64
+
65
+ get '/hi/:name' do
66
+ "Hello #{request.params[:name]}"
67
+ end
68
+ end
69
+ ```
70
+
71
+ Every route is composed of a verb, a path and a block. When an incoming request
72
+ matches a route, the block is executed and a response is sent back to the
73
+ client. The return value of the block will be the `body` of the response. The
74
+ `headers` and `status code` of the response will be calculated by
75
+ `Rack::Response`, but you could modify it anyway you want it.
76
+
77
+ Additionally, when a route gets called you have this methods available:
78
+
79
+ * `env`: The Rack environment.
80
+ * `request`: a `Rack::Request` instance.
81
+ * `response`: a `Rack::Response` instance.
82
+
83
+ ### Rendering
84
+
85
+ `Hobbit` comes with a module that uses [Tilt](https://github.com/rtomayko/tilt)
86
+ for rendering templates. See the example:
87
+
88
+ In `config.ru`:
89
+
90
+ ```ruby
91
+ require 'hobbit'
92
+
93
+ class App < Hobbit::Base
94
+ include Hobbit::Render
95
+
96
+ get '/' do
97
+ render 'views/index.erb'
98
+ end
99
+ end
100
+
101
+ run App.new
102
+ ```
103
+
104
+ and in `views/index.erb`:
105
+
106
+ ```html
107
+ <!DOCTYPE html>
108
+ <html>
109
+ <head>
110
+ <title>Hello World!</title>
111
+ </head>
112
+ <body>
113
+ <h1>Hello World!</h1>
114
+ </body>
115
+ </html>
116
+ ```
117
+
118
+ #### Layout
119
+
120
+ For now, the `Hobbit::Render` module is pretty simple (just `render`). If you
121
+ want to render a template within a layout, you could simply do this:
122
+
123
+ In `config.ru`:
124
+
125
+ ```ruby
126
+ require 'hobbit'
127
+
128
+ class App < Hobbit::Base
129
+ include Hobbit::Render
130
+
131
+ get '/' do
132
+ render 'views/layout.erb' do
133
+ render 'views/index.erb'
134
+ end
135
+ end
136
+ end
137
+
138
+ run App.new
139
+ ```
140
+
141
+ In `views/layout.erb`:
142
+
143
+ ```html
144
+ <!DOCTYPE html>
145
+ <html>
146
+ <head>
147
+ <title>Hello World!</title>
148
+ </head>
149
+ <body>
150
+ <%= yield %>
151
+ </body>
152
+ </html>
153
+ ```
154
+
155
+ And in `views/index.erb`:
156
+
157
+ ```html
158
+ <h1>Hello World!</h1>
159
+ ```
160
+
161
+ #### Partials
162
+
163
+ Partials are just `render` calls:
164
+
165
+ ```ruby
166
+ <%= render 'views/_some_partial.erb' %>
167
+ ```
168
+
169
+ #### Helpers
170
+
171
+ Who needs helpers when you have standard ruby methods? All methods defined in
172
+ the application can be used in the templates, since the template code is
173
+ executed within the scope of the application instance. See an example:
174
+
175
+ ```ruby
176
+ require 'hobbit'
177
+
178
+ class App < Hobbit::Base
179
+ include Hobbit::Render
180
+
181
+ def name
182
+ 'World'
183
+ end
184
+
185
+ get '/' do
186
+ render 'views/index.erb'
187
+ end
188
+ end
189
+
190
+ run App.new
191
+ ```
192
+
193
+ and in `views/index.erb`:
194
+
195
+ ```ruby
196
+ <!DOCTYPE html>
197
+ <html>
198
+ <head>
199
+ <title>Hello <%= name %>!</title>
200
+ </head>
201
+ <body>
202
+ <h1>Hello <%= name %>!</h1>
203
+ </body>
204
+ </html>
205
+ ```
206
+
207
+ ### Redirecting
208
+
209
+ If you look at Hobbit implementation, you may notice that there is no
210
+ `redirect` method (or similar). This is because such functionality is provided
211
+ by [Rack::Response](https://github.com/rack/rack/blob/master/lib/rack/response.rb)
212
+ and for now we [don't wan't to repeat ourselves](http://en.wikipedia.org/wiki/Don't_repeat_yourself).
213
+ So, if you want to redirect to another route, do it like this:
214
+
215
+ ```ruby
216
+ require 'hobbit'
217
+
218
+ class App < Hobbit::Base
219
+ get '/' do
220
+ response.redirect '/hi'
221
+ end
222
+
223
+ get '/hi' do
224
+ 'Hello World!'
225
+ end
226
+ end
227
+
228
+ run App.new
229
+ ```
230
+
231
+ ### Sessions
232
+
233
+ You can add user sessions using any [Rack session middleware](https://github.com/rack/rack/tree/master/lib/rack/session)
234
+ and then access the session through `env['rack.session']`. Fortunately, there
235
+ is `Hobbit::Session` which comes with a useful helper:
236
+
237
+ ```ruby
238
+ require 'hobbit'
239
+ require 'securerandom'
240
+
241
+ class App < Hobbit::Base
242
+ include Hobbit::Session
243
+ use Rack::Session::Cookie, secret: SecureRandom.hex(64)
244
+
245
+ get '/' do
246
+ session[:name] = 'hobbit'
247
+ end
248
+
249
+ get '/' do
250
+ session[:name]
251
+ end
252
+ end
253
+
254
+ run App.new
255
+ ```
256
+
257
+ ### Rack middleware
258
+
259
+ Each hobbit application is a Rack stack (See this [blog post](http://m.onkey.org/ruby-on-rack-2-the-builder)).
260
+ You can add any Rack middleware to the stack by using the `use` class method:
261
+
262
+ ```ruby
263
+ require 'hobbit'
264
+
265
+ class App < Hobbit::Base
266
+ include Hobbit::Session
267
+ use Rack::Session::Cookie, secret: SecureRandom.hex(64)
268
+ use Rack::ShowExceptions
269
+
270
+ get '/' do
271
+ session[:name] = 'hobbit'
272
+ end
273
+
274
+ # more routes...
275
+ end
276
+
277
+ run App
278
+ ```
279
+
280
+ ### Extending Hobbit
281
+
282
+ You can extend hobbit by creating modules or classes. See `Hobbit::Render` or
283
+ `Hobbit::Session` for examples.
284
+
285
+ ## More examples
286
+
287
+ See the `examples` directory.
288
+
289
+ ## Contributing
290
+
291
+ 1. Fork it
292
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
293
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
294
+ 4. Push to the branch (`git push origin my-new-feature`)
295
+ 5. Create new Pull Request
296
+
297
+ ## License
298
+
299
+ See the [LICENSE](https://github.com/patriciomacadden/hobbit/blob/master/LICENSE).
@@ -0,0 +1,9 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'spec'
6
+ t.pattern = 'spec/**/*_spec.rb'
7
+ end
8
+
9
+ task default: :test
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'hobbit', path: '../../../hobbit'
@@ -0,0 +1,9 @@
1
+ class App < Hobbit::Base
2
+ get '/' do
3
+ 'Hello Hobbit!'
4
+ end
5
+
6
+ get '/hi' do
7
+ response.redirect '/'
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ require 'bundler'
2
+ Bundler.require
3
+
4
+ require File.expand_path('app')
5
+
6
+ run App.new
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'hobbit', path: '../../../hobbit'
@@ -0,0 +1,7 @@
1
+ class App < Hobbit::Base
2
+ include Hobbit::Render
3
+
4
+ get '/' do
5
+ render File.expand_path('../views/index.html.erb', __FILE__)
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ require 'bundler'
2
+ Bundler.require
3
+
4
+ require File.expand_path('app')
5
+
6
+ run App.new
@@ -0,0 +1,7 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Hello World!</title>
5
+ </head>
6
+ <body>Hello World!</body>
7
+ </html>
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hobbit/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'hobbit'
8
+ spec.version = Hobbit::VERSION
9
+ spec.authors = ['Patricio Mac Adden']
10
+ spec.email = ['patriciomacadden@gmail.com']
11
+ spec.description = %q{A minimalistic microframework built on top of rack}
12
+ spec.summary = %q{A minimalistic microframework built on top of rack}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'rack'
22
+ spec.add_dependency 'tilt'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.3'
25
+ spec.add_development_dependency 'minitest'
26
+ spec.add_development_dependency 'rack-test'
27
+ spec.add_development_dependency 'rake'
28
+ end
@@ -0,0 +1,4 @@
1
+ require 'hobbit/base'
2
+ require 'hobbit/render'
3
+ require 'hobbit/session'
4
+ require 'hobbit/version'
@@ -0,0 +1,75 @@
1
+ module Hobbit
2
+ class Base
3
+ class << self
4
+ %w(DELETE GET HEAD OPTIONS PATCH POST PUT).each do |verb|
5
+ define_method(verb.downcase) { |path, &block| routes[verb] << compile_route!(path, &block) }
6
+ end
7
+
8
+ def app
9
+ @app ||= Rack::Builder.new
10
+ end
11
+
12
+ alias :new! :new
13
+ def new(*args, &block)
14
+ app.run new!(*args, &block)
15
+ app
16
+ end
17
+
18
+ def routes
19
+ @routes ||= Hash.new { |hash, key| hash[key] = [] }
20
+ end
21
+
22
+ def use(middleware, *args, &block)
23
+ app.use(middleware, *args, &block)
24
+ end
25
+
26
+ private
27
+
28
+ def compile_route!(path, &block)
29
+ route = { block: block, compiled_path: nil, extra_params: [], path: path }
30
+
31
+ compiled_path = path.gsub(/:\w+/) do |match|
32
+ route[:extra_params] << match.gsub(':', '').to_sym
33
+ '([^/?#]+)'
34
+ end
35
+ route[:compiled_path] = /^#{compiled_path}$/
36
+
37
+ route
38
+ end
39
+ end
40
+
41
+ attr_reader :env, :request, :response
42
+
43
+ def call(env)
44
+ dup._call(env)
45
+ end
46
+
47
+ def _call(env)
48
+ @env = env
49
+ @request = Rack::Request.new(@env)
50
+ @response = Rack::Response.new
51
+ route_eval
52
+ @response.finish
53
+ end
54
+
55
+ private
56
+
57
+ def route_eval
58
+ catch(:halt) do
59
+ self.class.routes[@request.request_method].each do |route|
60
+ if route[:compiled_path] =~ @request.path_info
61
+ if route[:extra_params].any?
62
+ route[:compiled_path].match(@request.path_info).captures.each_with_index do |value, index|
63
+ param = route[:extra_params][index]
64
+ @request.params[param] = value
65
+ end
66
+ end
67
+ @response.write instance_eval(&route[:block])
68
+ throw :halt
69
+ end
70
+ end
71
+ @response.status = 404
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,17 @@
1
+ require 'tilt'
2
+
3
+ module Hobbit
4
+ module Render
5
+ def render(template, locals = {}, options = {}, &block)
6
+ cache.fetch(template) do
7
+ Tilt.new(template, options)
8
+ end.render(self, locals, &block)
9
+ end
10
+
11
+ private
12
+
13
+ def cache
14
+ Thread.current[:cache] ||= Tilt::Cache.new
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ module Hobbit
2
+ module Session
3
+ def session
4
+ env['rack.session']
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Hobbit
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,100 @@
1
+ require 'minitest_helper'
2
+
3
+ describe Hobbit::Base do
4
+ include Rack::Test::Methods
5
+
6
+ def app
7
+ TestBaseApp.new
8
+ end
9
+
10
+ %w(DELETE GET HEAD OPTIONS PATCH POST PUT).each do |verb|
11
+ str = <<EOS
12
+ describe "::#{verb.downcase}" do
13
+ it 'must add a route to @routes' do
14
+ #route = TestBaseApp.routes['#{verb}'].first
15
+ #route[:path].must_equal '/'
16
+ end
17
+
18
+ it 'must extract the extra_params' do
19
+ route = TestBaseApp.routes['#{verb}'].last
20
+ route[:extra_params].must_equal [:name]
21
+ end
22
+ end
23
+ EOS
24
+ class_eval str
25
+ end
26
+
27
+ describe '::app' do
28
+ it 'must return an instance of Rack::Builder' do
29
+ TestBaseApp.app.must_be_kind_of Rack::Builder
30
+ end
31
+ end
32
+
33
+ describe '::new' do
34
+ it 'should return an instance of Rack::Builder' do
35
+ TestBaseApp.new.must_be_kind_of Rack::Builder
36
+ end
37
+ end
38
+
39
+ describe '::routes' do
40
+ it 'must return a Hash' do
41
+ TestBaseApp.routes.must_be_kind_of Hash
42
+ end
43
+ end
44
+
45
+ describe '::use' do
46
+ it 'must add a middleware to the app stack' do
47
+ skip '::use'
48
+ end
49
+ end
50
+
51
+ describe '#call' do
52
+ %w(DELETE GET HEAD OPTIONS PATCH POST PUT).each do |verb|
53
+ str = <<EOS
54
+ describe 'when the request matches a route' do
55
+ it 'must match #{verb} /' do
56
+ #{verb.downcase} '/'
57
+ last_response.must_be :ok?
58
+ last_response.body.must_equal '#{verb}'
59
+ end
60
+
61
+ it 'must match #{verb} /route.json' do
62
+ #{verb.downcase} '/route.json'
63
+ last_response.must_be :ok?
64
+ last_response.body.must_equal '#{verb} /route.json'
65
+ end
66
+
67
+ it 'must match #{verb} /route/:id.json' do
68
+ #{verb.downcase} '/route/1.json'
69
+ last_response.must_be :ok?
70
+ last_response.body.must_equal '1'
71
+ end
72
+
73
+ it 'must match #{verb} /:name' do
74
+ #{verb.downcase} '/hobbit'
75
+ last_response.must_be :ok?
76
+ last_response.body.must_equal 'hobbit'
77
+
78
+ #{verb.downcase} '/hello-hobbit'
79
+ last_response.must_be :ok?
80
+ last_response.body.must_equal 'hello-hobbit'
81
+ end
82
+ end
83
+
84
+ describe 'when the request not matches a route' do
85
+ it 'must respond with 404 status code' do
86
+ #{verb.downcase} '/not/found'
87
+ last_response.must_be :not_found?
88
+ last_response.body.must_equal ''
89
+ end
90
+ end
91
+ EOS
92
+ class_eval str
93
+ end
94
+ end
95
+
96
+ it 'must respond to call' do
97
+ app = TestBaseApp.new
98
+ app.must_respond_to :call
99
+ end
100
+ end
@@ -0,0 +1,8 @@
1
+ class TestBaseApp < Hobbit::Base
2
+ %w(DELETE GET HEAD OPTIONS PATCH POST PUT).each do |verb|
3
+ class_eval "#{verb.downcase}('/') { '#{verb}' }"
4
+ class_eval "#{verb.downcase}('/route.json') { '#{verb} /route.json' }"
5
+ class_eval "#{verb.downcase}('/route/:id.json') { request.params[:id] }"
6
+ class_eval "#{verb.downcase}('/:name') { request.params[:name] }"
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ class TestRenderApp < Hobbit::Base
2
+ include Hobbit::Render
3
+
4
+ def name
5
+ 'Hobbit'
6
+ end
7
+
8
+ get('/') { render File.expand_path('../views/index.erb', __FILE__) }
9
+ get('/using-context') { render File.expand_path('../views/hello.erb', __FILE__) }
10
+ end
@@ -0,0 +1,14 @@
1
+ require 'securerandom'
2
+
3
+ class TestSessionApp < Hobbit::Base
4
+ include Hobbit::Session
5
+ use Rack::Session::Cookie, secret: SecureRandom.hex(64)
6
+
7
+ get '/' do
8
+ session[:name] = 'hobbit'
9
+ end
10
+
11
+ get '/name' do
12
+ session[:name]
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head><title>Hello <%= name %>!</title></head>
4
+ <body>Hello <%= name %>!</body>
5
+ </html>
@@ -0,0 +1,5 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head><title>Hello World!</title></head>
4
+ <body>Hello World!</body>
5
+ </html>
@@ -0,0 +1,15 @@
1
+ ENV['RACK_ENV'] ||= 'test'
2
+
3
+ require 'bundler'
4
+ Bundler.require :default, ENV['RACK_ENV'].to_sym
5
+
6
+ require 'minitest/autorun'
7
+ require 'rack'
8
+ require 'rack/test'
9
+
10
+ require 'hobbit'
11
+
12
+ # hobbit test apps
13
+ require 'fixtures/test_base_app'
14
+ require 'fixtures/test_render_app'
15
+ require 'fixtures/test_session_app'
@@ -0,0 +1,23 @@
1
+ require 'minitest_helper'
2
+
3
+ describe Hobbit::Render do
4
+ include Rack::Test::Methods
5
+
6
+ def app
7
+ TestRenderApp.new
8
+ end
9
+
10
+ describe '#render' do
11
+ it 'must render a template' do
12
+ get '/'
13
+ last_response.must_be :ok?
14
+ last_response.body.must_match /Hello World!/
15
+ end
16
+
17
+ it 'must use the app as context' do
18
+ get '/using-context'
19
+ last_response.must_be :ok?
20
+ last_response.body.must_match /Hello Hobbit!/
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ require 'minitest_helper'
2
+
3
+ describe Hobbit::Session do
4
+ include Rack::Test::Methods
5
+
6
+ def app
7
+ TestSessionApp.new
8
+ end
9
+
10
+ describe '#session' do
11
+ it 'must return a session object' do
12
+ get '/'
13
+ last_response.must_be :ok?
14
+ last_response.body.must_equal 'hobbit'
15
+
16
+ get '/name'
17
+ last_response.must_be :ok?
18
+ last_response.body.must_equal 'hobbit'
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,7 @@
1
+ require 'minitest_helper'
2
+
3
+ describe Hobbit::VERSION do
4
+ it 'is wont be nil' do
5
+ Hobbit::VERSION.wont_be_nil
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hobbit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Patricio Mac Adden
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-04-13 00:00:00.000000000 Z
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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: tilt
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack-test
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
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'
97
+ description: A minimalistic microframework built on top of rack
98
+ email:
99
+ - patriciomacadden@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .travis.yml
106
+ - Gemfile
107
+ - LICENSE
108
+ - README.md
109
+ - Rakefile
110
+ - examples/example_1/Gemfile
111
+ - examples/example_1/app.rb
112
+ - examples/example_1/config.ru
113
+ - examples/example_2/Gemfile
114
+ - examples/example_2/app.rb
115
+ - examples/example_2/config.ru
116
+ - examples/example_2/views/index.erb
117
+ - hobbit.gemspec
118
+ - lib/hobbit.rb
119
+ - lib/hobbit/base.rb
120
+ - lib/hobbit/render.rb
121
+ - lib/hobbit/session.rb
122
+ - lib/hobbit/version.rb
123
+ - spec/base_spec.rb
124
+ - spec/fixtures/test_base_app.rb
125
+ - spec/fixtures/test_render_app.rb
126
+ - spec/fixtures/test_session_app.rb
127
+ - spec/fixtures/views/hello.erb
128
+ - spec/fixtures/views/index.erb
129
+ - spec/minitest_helper.rb
130
+ - spec/render_spec.rb
131
+ - spec/session_spec.rb
132
+ - spec/version_spec.rb
133
+ homepage: ''
134
+ licenses:
135
+ - MIT
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.0.0
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: A minimalistic microframework built on top of rack
157
+ test_files:
158
+ - spec/base_spec.rb
159
+ - spec/fixtures/test_base_app.rb
160
+ - spec/fixtures/test_render_app.rb
161
+ - spec/fixtures/test_session_app.rb
162
+ - spec/fixtures/views/hello.erb
163
+ - spec/fixtures/views/index.erb
164
+ - spec/minitest_helper.rb
165
+ - spec/render_spec.rb
166
+ - spec/session_spec.rb
167
+ - spec/version_spec.rb