ruil 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -17,7 +17,7 @@ This library helps you to buil web applications on top of rack.
17
17
  class MyController
18
18
  include Ruil::Controller
19
19
 
20
- resource :get, '/foo/:bar' do |request|
20
+ resource 'GET', '/foo/:bar' do |request|
21
21
  ok :text, 'hello ' + request[:path_info_params][:bar]
22
22
  end
23
23
  end
@@ -28,7 +28,7 @@ This library helps you to buil web applications on top of rack.
28
28
  class MyController
29
29
  include Ruil::Controller
30
30
 
31
- resource :get, '/foo/:bar' do |request|
31
+ resource 'GET', '/foo/:bar' do |request|
32
32
  ok :text, 'hello ' + request[:path_info_params][:bar]
33
33
  end
34
34
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -9,7 +9,7 @@ module Ruil
9
9
  # class MyController
10
10
  # include Ruil::Controller
11
11
  #
12
- # resource :get, '/mycontroller/:your_name' do |request|
12
+ # resource 'GET', '/mycontroller/:your_name' do |request|
13
13
  # ok :text, 'hello ' + request[:path_info_params][:your_name]
14
14
  # end
15
15
  # end
@@ -28,12 +28,12 @@ module Ruil
28
28
  #
29
29
  # @param methods
30
30
  # @param pattern
31
- def self.resource(methods, pattern, acl = false, &block)
31
+ def resource(methods, pattern, acl = false, &block)
32
32
  Ruil::Resource.new(methods, pattern, acl, &block)
33
33
  end
34
34
 
35
35
  # Redirect the request to other URL.
36
- def self.redirect(request, url)
36
+ def redirect(request, url)
37
37
  headers = {'Location'=> url + "?redirected_from=" + request.path_info}
38
38
  [302, headers, []]
39
39
  end
@@ -41,7 +41,7 @@ module Ruil
41
41
  # Respond OK
42
42
  #
43
43
  # @param body[String] the response body
44
- def self.ok(type, body, headers = {})
44
+ def ok(type, body, headers = {})
45
45
  # Apply custom skins.
46
46
  Ruil::Skin.call body if [:html, :xhtml].include? type
47
47
  # Setup headers.
data/lib/ruil/register.rb CHANGED
@@ -35,9 +35,9 @@ module Ruil
35
35
  end
36
36
  @@resources[request.request_method].each do |resource|
37
37
  response = resource.call(request)
38
- return response.finish if response
38
+ return response if response
39
39
  end
40
- Ruil::NotFoundResponder.call(request).finish
40
+ [401, {'Content-Type' => 'plain/text'}, ["Resource not found: #{request.url}"]]
41
41
  end
42
42
 
43
43
  end
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ require 'ruil'
3
+ require 'rspec'
4
+
5
+ describe Ruil::Register do
6
+
7
+ before(:all) do
8
+ class TestController
9
+ extend Ruil::Controller
10
+
11
+ resource 'GET', '/' do |request|
12
+ ok :text, 'Hola'
13
+ end
14
+ end
15
+ end
16
+
17
+ it 'should get responses for requests' do
18
+ request = Rack::Request.new(
19
+ Rack::MockRequest::DEFAULT_ENV.merge({
20
+ 'REQUEST_METHOD' => 'GET',
21
+ 'HTTP_USER_AGENT' => 'Mobile',
22
+ 'PATH_INFO' => '/'
23
+ }))
24
+ Ruil::Register.call(request)
25
+ end
26
+
27
+ end
28
+
@@ -18,7 +18,7 @@ describe Ruil::Register do
18
18
  @value = value
19
19
  end
20
20
  def call(request)
21
- request.path_info == @value ? MockResponse.new(@value) : false
21
+ request.path_info == @value ? MockResponse.new(@value).finish : false
22
22
  end
23
23
  def request_methods
24
24
  ['GET']
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruil
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Daniel Hern\xC3\xA1ndez"
@@ -42,6 +42,7 @@ files:
42
42
  - lib/ruil/resource.rb
43
43
  - lib/ruil/skin.rb
44
44
  - rakefile
45
+ - spec/controller.rb
45
46
  - spec/path_info_parser_spec.rb
46
47
  - spec/register_spec.rb
47
48
  - spec/resource_spec.rb
@@ -80,6 +81,7 @@ signing_key:
80
81
  specification_version: 3
81
82
  summary: Minimalist library to build web appplications on top of rack
82
83
  test_files:
84
+ - spec/controller.rb
83
85
  - spec/path_info_parser_spec.rb
84
86
  - spec/register_spec.rb
85
87
  - spec/resource_spec.rb