utopia 1.1.0 → 1.1.1

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: 965466abaa777fe6b33b71c24253718da3544bd1
4
- data.tar.gz: 1a53312d2f58949a2a6027292dd5d6a66e0c56ab
3
+ metadata.gz: 614d40f19533fc62a561a328da3eb0c6967d3932
4
+ data.tar.gz: b0be93ad3767370b1be9fe9348d634cea1d33bdb
5
5
  SHA512:
6
- metadata.gz: a24b35e08ccdbb23e1a85236e25b5166235a39d04d08fa2b5d8b5f00f9feb7ae07a43956bf6629ef4e2e98eaf00ac32b95638efa5b5e8df5cb7eb9d33a1fc002
7
- data.tar.gz: 56ec05c1856d72c0bf9305f6c0ce821348c83f9d8c2d90a4cc3c53586755533b67c2b89fb1d50c7a4b0fa865e747b25d0d8b94d64983e23210717766325ddb81
6
+ metadata.gz: 7767bc2f59c64cfb51a54c0c702fa852c20e060c3b0e66b79e21838e2ecf910f545ea487180c97d12507d63dc1693c7f2cd98dd667170d2802b7ebac0e225e35
7
+ data.tar.gz: 6c7689c25c3fa8d40c84f41312ac3f42fa36bac19423ba6a352455d1cc21ec871a6c5b6768e37c58777a682a4e65fce0853074616d6b565374354782268527cb
@@ -74,20 +74,25 @@ module Utopia
74
74
  self.class.lookup(path)
75
75
  end
76
76
 
77
+ def catch_response
78
+ response = catch(:response) do
79
+ yield and nil
80
+ end
81
+
82
+ if response
83
+ return self.respond_with(*response)
84
+ end
85
+ end
86
+
77
87
  # Given a request, call associated actions if at least one exists.
78
88
  def passthrough(request, path)
79
89
  actions = actions_for_request(request, path)
80
90
 
81
91
  unless actions.empty?
82
- response = catch(:response) do
83
- # By default give nothing - i.e. keep on processing:
92
+ return catch_response do
84
93
  actions.each do |action|
85
94
  action.invoke!(self, request, path)
86
- end and nil
87
- end
88
-
89
- if response
90
- return self.respond_with(*response)
95
+ end
91
96
  end
92
97
  end
93
98
 
@@ -95,9 +95,9 @@ module Utopia
95
95
 
96
96
  # Rewrite the path before processing the request if possible.
97
97
  def passthrough(request, path)
98
- self.class.rewrite.invoke!(self, request, path)
99
-
100
- super
98
+ catch_response do
99
+ self.class.rewrite.invoke!(self, request, path)
100
+ end || super
101
101
  end
102
102
  end
103
103
  end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Utopia
22
- VERSION = "1.1.0"
22
+ VERSION = "1.1.1"
23
23
  end
@@ -43,64 +43,4 @@ module Utopia::Content::LinkSpec
43
43
  expect(subject.path).to be == nil
44
44
  end
45
45
  end
46
-
47
- describe Utopia::Content::Links do
48
- it "should give a list of links" do
49
- links = Utopia::Content::Links.index(File.expand_path("links", __dir__), Utopia::Path.create("/"))
50
-
51
- expect(links.size).to be == 3
52
-
53
- expect(links[0].kind).to be == :virtual
54
- expect(links[0].href).to be == nil
55
-
56
- expect(links[1].title).to be == "Welcome"
57
- expect(links[1].to_href).to be == '<a class="link" href="/welcome">Welcome</a>'
58
- expect(links[1].kind).to be == :file
59
- expect(links[1].href).to be == "/welcome"
60
- expect(links[1].name).to be == 'welcome'
61
-
62
- expect(links[2].title).to be == 'Foo Bar'
63
- expect(links[2].kind).to be == :directory
64
- expect(links[2].href).to be == "/foo/index"
65
- expect(links[2].name).to be == 'foo'
66
-
67
- expect(links[1]).to be_eql links[1]
68
- expect(links[0]).to_not be_eql links[1]
69
- end
70
-
71
- it "should filter links by name" do
72
- links = Utopia::Content::Links.index(File.expand_path("links", __dir__), Utopia::Path.create("/"), name: /foo/)
73
-
74
- expect(links.size).to be == 1
75
- end
76
-
77
- it "should select localized links" do
78
- root = File.expand_path("links", __dir__)
79
-
80
- # Select both test links
81
- links = Utopia::Content::Links.index(root, Utopia::Path.create("/foo"))
82
- expect(links.size).to be == 2
83
-
84
- links = Utopia::Content::Links.index(root, Utopia::Path.create("/foo"), variant: 'en')
85
- expect(links.size).to be == 1
86
- end
87
-
88
- it "should read correct link order for en" do
89
- root = File.expand_path("localized", __dir__)
90
-
91
- # Select both test links
92
- links = Utopia::Content::Links.index(root, Utopia::Path.create("/"), variant: 'en')
93
-
94
- expect(links.collect(&:title)).to be == ['One', 'Two', 'Three', 'Four', 'Five']
95
- end
96
-
97
- it "should read correct link order for zh" do
98
- root = File.expand_path("localized", __dir__)
99
-
100
- # Select both test links
101
- links = Utopia::Content::Links.index(root, Utopia::Path.create("/"), variant: 'zh')
102
-
103
- expect(links.collect(&:title)).to be == ['One', 'Two', 'Three', '四']
104
- end
105
- end
106
46
  end
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env rspec
2
+
3
+ # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ require 'utopia/content/links'
24
+
25
+ module Utopia::Content::LinksSpec
26
+ describe Utopia::Content::Links do
27
+ it "should give a list of links" do
28
+ links = Utopia::Content::Links.index(File.expand_path("links", __dir__), Utopia::Path.create("/"))
29
+
30
+ expect(links.size).to be == 3
31
+
32
+ expect(links[0].kind).to be == :virtual
33
+ expect(links[0].href).to be == nil
34
+
35
+ expect(links[1].title).to be == "Welcome"
36
+ expect(links[1].to_href).to be == '<a class="link" href="/welcome">Welcome</a>'
37
+ expect(links[1].kind).to be == :file
38
+ expect(links[1].href).to be == "/welcome"
39
+ expect(links[1].name).to be == 'welcome'
40
+
41
+ expect(links[2].title).to be == 'Foo Bar'
42
+ expect(links[2].kind).to be == :directory
43
+ expect(links[2].href).to be == "/foo/index"
44
+ expect(links[2].name).to be == 'foo'
45
+
46
+ expect(links[1]).to be_eql links[1]
47
+ expect(links[0]).to_not be_eql links[1]
48
+ end
49
+
50
+ it "should filter links by name" do
51
+ links = Utopia::Content::Links.index(File.expand_path("links", __dir__), Utopia::Path.create("/"), name: /foo/)
52
+
53
+ expect(links.size).to be == 1
54
+ end
55
+
56
+ it "should select localized links" do
57
+ root = File.expand_path("links", __dir__)
58
+
59
+ # Select both test links
60
+ links = Utopia::Content::Links.index(root, Utopia::Path.create("/foo"))
61
+ expect(links.size).to be == 2
62
+
63
+ links = Utopia::Content::Links.index(root, Utopia::Path.create("/foo"), variant: 'en')
64
+ expect(links.size).to be == 1
65
+ end
66
+
67
+ it "should read correct link order for en" do
68
+ root = File.expand_path("localized", __dir__)
69
+
70
+ # Select both test links
71
+ links = Utopia::Content::Links.index(root, Utopia::Path.create("/"), variant: 'en')
72
+
73
+ expect(links.collect(&:title)).to be == ['One', 'Two', 'Three', 'Four', 'Five']
74
+ end
75
+
76
+ it "should read correct link order for zh" do
77
+ root = File.expand_path("localized", __dir__)
78
+
79
+ # Select both test links
80
+ links = Utopia::Content::Links.index(root, Utopia::Path.create("/"), variant: 'zh')
81
+
82
+ expect(links.collect(&:title)).to be == ['One', 'Two', 'Three', '四']
83
+ end
84
+ end
85
+ end
@@ -40,6 +40,10 @@ module Utopia::Controller::RewriteSpec
40
40
  attr :user_id
41
41
  attr :order_id
42
42
 
43
+ rewrite.extract_prefix fail: 'fail' do
44
+ fail! 444
45
+ end
46
+
43
47
  def self.uri_path
44
48
  Utopia::Path['/']
45
49
  end
@@ -62,5 +66,14 @@ module Utopia::Controller::RewriteSpec
62
66
  expect(controller.order_id).to be == 20
63
67
  expect(controller.edit).to be true
64
68
  end
69
+
70
+ it "should allow rewrite to fail request" do
71
+ request, path, variables = mock_request("/fail")
72
+ relative_path = path - controller.class.uri_path
73
+
74
+ response = controller.process!(request, relative_path)
75
+
76
+ expect(response[0]).to be == 444
77
+ end
65
78
  end
66
79
  end
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: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-15 00:00:00.000000000 Z
11
+ date: 2015-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trenni
@@ -212,6 +212,7 @@ files:
212
212
  - spec/utopia/content/links/foo/test.en.xnode
213
213
  - spec/utopia/content/links/links.yaml
214
214
  - spec/utopia/content/links/welcome.xnode
215
+ - spec/utopia/content/links_spec.rb
215
216
  - spec/utopia/content/localized/five/index.en.xnode
216
217
  - spec/utopia/content/localized/four/index.en.xnode
217
218
  - spec/utopia/content/localized/four/index.zh.xnode
@@ -296,6 +297,7 @@ test_files:
296
297
  - spec/utopia/content/links/foo/test.en.xnode
297
298
  - spec/utopia/content/links/links.yaml
298
299
  - spec/utopia/content/links/welcome.xnode
300
+ - spec/utopia/content/links_spec.rb
299
301
  - spec/utopia/content/localized/five/index.en.xnode
300
302
  - spec/utopia/content/localized/four/index.en.xnode
301
303
  - spec/utopia/content/localized/four/index.zh.xnode