utopia 0.11.5 → 0.12.0
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.
- checksums.yaml +8 -8
- data/.travis.yml +1 -1
- data/lib/utopia/middleware/controller.rb +5 -1
- data/lib/utopia/version.rb +1 -1
- data/test/test_controller_middleware.rb +66 -0
- data/utopia.gemspec +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmQ5MzEwYTYwZjY3NDI0MzUzYmIwYmYyODUxNDg2ODM0N2M2YjM4Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDk3OTk2ZjQ4NzY3NzZhOTIwZWFhY2E0ZGY2MGQ3MGRkOTE3M2Q4MA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTU0ODE1MGI1YjBjMTY5NWRmZTBmMzYyNTk0ZDZmYTFmZjcyNWEzNzY1NTM1
|
10
|
+
NjYyZWIyNGYyZjlhODk1NTM1MGRjMTgzNWQzMGJmNjBlMzYzNDZmODBlM2Jm
|
11
|
+
ODE1YjUyOGQ4OTkzMDM0NmE4Yzc1OWZlYzAzNWQzNWNlZWI4YmE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDU2M2E4NTZiMGMyMjhhYjhlMTdmNmQwNGEyYTYyYjA5Y2RhOGRkYjdhY2Jm
|
14
|
+
OTBiYTczMTEwNDg5MDk1ZTY0NWNlMGY2Y2MxNGJkMjE1ZmU5NzIyYjVhOWM5
|
15
|
+
MWI3NzdmNTE0N2EyYzU2NjJjOWI5NjE3YWVlOWU0ZmY1MzVlYjY=
|
data/.travis.yml
CHANGED
@@ -166,7 +166,7 @@ module Utopia
|
|
166
166
|
@_controller.app.call(env)
|
167
167
|
end
|
168
168
|
|
169
|
-
def respond!
|
169
|
+
def respond!(*args)
|
170
170
|
throw :response, args
|
171
171
|
end
|
172
172
|
|
@@ -182,6 +182,10 @@ module Utopia
|
|
182
182
|
respond! error
|
183
183
|
end
|
184
184
|
|
185
|
+
def success!(*args)
|
186
|
+
respond! :success, *args
|
187
|
+
end
|
188
|
+
|
185
189
|
def respond_with(*args)
|
186
190
|
return args[0] if args[0] == nil || Array === args[0]
|
187
191
|
|
data/lib/utopia/version.rb
CHANGED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'test/unit'
|
22
|
+
require 'rack/mock'
|
23
|
+
require 'utopia/middleware/controller'
|
24
|
+
|
25
|
+
class TestControllerMiddleware < Test::Unit::TestCase
|
26
|
+
APP = lambda {|env| [404, [], []]}
|
27
|
+
|
28
|
+
class TestController < Utopia::Middleware::Controller::Base
|
29
|
+
def on_success(path, request)
|
30
|
+
success!
|
31
|
+
end
|
32
|
+
|
33
|
+
def on_failure(path, request)
|
34
|
+
fail!
|
35
|
+
end
|
36
|
+
|
37
|
+
def on_variable(path, request)
|
38
|
+
@variable = :value
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class MockControllerMiddleware
|
43
|
+
attr :env
|
44
|
+
|
45
|
+
def call(env)
|
46
|
+
@env = env
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_controller_response
|
51
|
+
variables = Utopia::Middleware::Controller::Variables.new
|
52
|
+
request = Rack::Request.new("utopia.controller" => variables)
|
53
|
+
middleware = MockControllerMiddleware.new
|
54
|
+
controller = TestController.new(middleware)
|
55
|
+
|
56
|
+
result = controller.process!(Utopia::Path["/success"], request)
|
57
|
+
assert_equal [200, {}, []], result
|
58
|
+
|
59
|
+
result = controller.process!(Utopia::Path["/failure"], request)
|
60
|
+
assert_equal [400, {}, ["Bad Request"]], result
|
61
|
+
|
62
|
+
result = controller.process!(Utopia::Path["/variable"], request)
|
63
|
+
assert_equal({"variable"=>:value}, variables.to_hash)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
data/utopia.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
structure representing the website.
|
16
16
|
EOF
|
17
17
|
gem.summary = %q{Utopia is a framework for building dynamic content-driven websites.}
|
18
|
-
gem.homepage = ""
|
18
|
+
gem.homepage = "https://github.com/ioquatix/utopia"
|
19
19
|
|
20
20
|
gem.files = `git ls-files`.split($/)
|
21
21
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utopia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trenni
|
@@ -152,9 +152,10 @@ files:
|
|
152
152
|
- test/content_root/_heading.xnode
|
153
153
|
- test/content_root/index.xnode
|
154
154
|
- test/test_content_middleware.rb
|
155
|
+
- test/test_controller_middleware.rb
|
155
156
|
- test/test_path.rb
|
156
157
|
- utopia.gemspec
|
157
|
-
homepage:
|
158
|
+
homepage: https://github.com/ioquatix/utopia
|
158
159
|
licenses: []
|
159
160
|
metadata: {}
|
160
161
|
post_install_message:
|
@@ -181,4 +182,5 @@ test_files:
|
|
181
182
|
- test/content_root/_heading.xnode
|
182
183
|
- test/content_root/index.xnode
|
183
184
|
- test/test_content_middleware.rb
|
185
|
+
- test/test_controller_middleware.rb
|
184
186
|
- test/test_path.rb
|