utopia 0.12.4 → 0.12.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20f4fb0f0dd6620a3397cc71850c5042353de35d
4
- data.tar.gz: ba6be29fd0f357af7c92478009134a3b55209026
3
+ metadata.gz: ea079ab122d29c56750a675d963b90ef916f5eac
4
+ data.tar.gz: c9b2cc7c6224f2d298c519af4a07d5f78fee8633
5
5
  SHA512:
6
- metadata.gz: 5cc836f964b89833ebb853f727417db22362b0e7e6be3129529669a25e69a00872e90f8b2ba0a26a9e4ae041c7ec2c13b0e1162c84b255098be6c2bf84717431
7
- data.tar.gz: 80ac68148e79498b3f971c6596ea06ba389870a416a35fe4aa722aadb26fb50907a3563c8e12412da75b053ab5451508b7af1b8eb6490a30421c88e650f315a8
6
+ metadata.gz: fb8391a52441f77e987fae432167b8b4c826e9c2856ac0e3facc96cc9e4b18ceae665df604fbeafe079542da2cffa6242125f3c6f6035b46bdceb4842d3e9598
7
+ data.tar.gz: 12752a420f331461d35b47292a88f58f0134a5664ebfa76dea992e47f4e4824557074e417f07c030cc2fe1c3c2502b3bdbd63c39db36042dde9b49942a2780f1
data/Gemfile CHANGED
@@ -2,12 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in utopia.gemspec
4
4
  gemspec
5
-
6
- group :test do
7
- gem "rake"
8
- gem "minitest"
9
- end
10
-
11
- group :development do
12
- gem "thin"
13
- end
data/Rakefile CHANGED
@@ -1,9 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
- require "rake/testtask"
2
+ require "rspec/core/rake_task"
3
3
 
4
- Rake::TestTask.new do |t|
5
- t.libs << 'test'
6
- end
4
+ RSpec::Core::RakeTask.new(:spec)
7
5
 
8
- desc "Run tests"
9
- task :default => :test
6
+ task :default => :spec
@@ -35,14 +35,6 @@ end
35
35
  module Utopia
36
36
  module Middleware
37
37
  class Controller
38
- module Direct
39
- def process!(path, request)
40
- return nil unless path.dirname == self.class.uri_path
41
-
42
- passthrough(path, request)
43
- end
44
- end
45
-
46
38
  CONTROLLER_RB = "controller.rb"
47
39
 
48
40
  class Variables
@@ -224,8 +216,14 @@ module Utopia
224
216
  # Utopia::LOG.debug([status, headers, body].inspect)
225
217
  return [status, headers, body]
226
218
  end
227
-
219
+
220
+ def direct?(path)
221
+ path.dirname == self.class.uri_path
222
+ end
223
+
228
224
  def process!(path, request)
225
+ return nil unless direct?(path)
226
+
229
227
  passthrough(path, request)
230
228
  end
231
229
 
@@ -321,6 +319,5 @@ module Utopia
321
319
  return @app.call(env)
322
320
  end
323
321
  end
324
-
325
322
  end
326
323
  end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Utopia
22
- VERSION = "0.12.4"
22
+ VERSION = "0.12.5"
23
23
  end
@@ -0,0 +1,88 @@
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 'rack/mock'
22
+ require 'utopia/middleware/content'
23
+
24
+ module Utopia::Middleware::ContentSpec
25
+ APP = lambda {|env| [404, [], []]}
26
+
27
+ class TestDelegate
28
+ def initialize
29
+ @events = []
30
+ end
31
+
32
+ attr :events
33
+
34
+ def method_missing(*args)
35
+ @events << args
36
+ end
37
+ end
38
+
39
+ describe Utopia::Middleware::Content::Processor do
40
+ it "should parse single tag" do
41
+ delegate = TestDelegate.new
42
+ processor = Utopia::Middleware::Content::Processor.new(delegate)
43
+
44
+ processor.parse %Q{<foo></foo>}
45
+
46
+ foo_tag = Utopia::Tag.new("foo")
47
+ expected_events = [
48
+ [:tag_begin, foo_tag],
49
+ [:tag_end, foo_tag],
50
+ ]
51
+
52
+ expect(delegate.events).to be == expected_events
53
+ end
54
+
55
+ it "should parse and escape text" do
56
+ delegate = TestDelegate.new
57
+ processor = Utopia::Middleware::Content::Processor.new(delegate)
58
+
59
+ processor.parse %Q{<foo>Bob &amp; Barley<!-- Comment --><![CDATA[Hello & World]]></foo>}
60
+
61
+ foo_tag = Utopia::Tag.new("foo")
62
+ expected_events = [
63
+ [:tag_begin, foo_tag],
64
+ [:cdata, "Bob &amp; Barley"],
65
+ [:cdata, "<!-- Comment -->"],
66
+ [:cdata, "Hello &amp; World"],
67
+ [:tag_end, foo_tag],
68
+ ]
69
+
70
+ expect(delegate.events).to be == expected_events
71
+ end
72
+ end
73
+
74
+ describe Utopia::Middleware::Content do
75
+ it "Should parse file and expand variables" do
76
+ root = File.expand_path("../content_root", __FILE__)
77
+ content = Utopia::Middleware::Content.new(APP, :root => root)
78
+
79
+ path = Utopia::Path.create('/index')
80
+ node = content.lookup_node(path)
81
+ expect(node).to be_kind_of Utopia::Middleware::Content::Node
82
+
83
+ output = StringIO.new
84
+ node.process!({}, output, {})
85
+ expect(output.string).to be == %Q{<h1>Hello World</h1>}
86
+ end
87
+ end
88
+ end
@@ -18,15 +18,17 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'minitest/autorun'
22
-
23
21
  require 'rack/mock'
24
22
  require 'utopia/middleware/controller'
25
23
 
26
- class TestControllerMiddleware < MiniTest::Test
24
+ module Utopia::Middleware::ControllerSpec
27
25
  APP = lambda {|env| [404, [], []]}
28
26
 
29
27
  class TestController < Utopia::Middleware::Controller::Base
28
+ def direct?(path)
29
+ true
30
+ end
31
+
30
32
  def on_success(path, request)
31
33
  success!
32
34
  end
@@ -48,20 +50,21 @@ class TestControllerMiddleware < MiniTest::Test
48
50
  end
49
51
  end
50
52
 
51
- def test_controller_response
52
- variables = Utopia::Middleware::Controller::Variables.new
53
- request = Rack::Request.new("utopia.controller" => variables)
54
- middleware = MockControllerMiddleware.new
55
- controller = TestController.new(middleware)
53
+ describe Utopia::Middleware::Controller do
54
+ it "should call controller methods" do
55
+ variables = Utopia::Middleware::Controller::Variables.new
56
+ request = Rack::Request.new("utopia.controller" => variables)
57
+ middleware = MockControllerMiddleware.new
58
+ controller = TestController.new(middleware)
56
59
 
57
- result = controller.process!(Utopia::Path["/success"], request)
58
- assert_equal [200, {}, []], result
60
+ result = controller.process!(Utopia::Path["/success"], request)
61
+ expect(result).to be == [200, {}, []]
59
62
 
60
- result = controller.process!(Utopia::Path["/failure"], request)
61
- assert_equal [400, {}, ["Bad Request"]], result
63
+ result = controller.process!(Utopia::Path["/failure"], request)
64
+ expect(result).to be == [400, {}, ["Bad Request"]]
62
65
 
63
- result = controller.process!(Utopia::Path["/variable"], request)
64
- assert_equal({"variable"=>:value}, variables.to_hash)
66
+ result = controller.process!(Utopia::Path["/variable"], request)
67
+ expect(variables.to_hash).to be == {"variable"=>:value}
68
+ end
65
69
  end
66
70
  end
67
-
@@ -18,14 +18,15 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'minitest/autorun'
22
21
  require 'utopia/path'
23
22
 
24
- class TestPath < MiniTest::Test
25
- def test_absolute_path_concatenation
26
- root = Utopia::Path["/"]
27
-
28
- assert root.absolute?
29
- assert_equal Utopia::Path["/foo/bar"], (root + Utopia::Path["foo/bar"])
23
+ module Utopia::PathSpec
24
+ describe Utopia::Path do
25
+ it "should concatenate absolute paths" do
26
+ root = Utopia::Path["/"]
27
+
28
+ expect(root).to be_absolute
29
+ expect(root + Utopia::Path["foo/bar"]).to be == Utopia::Path["/foo/bar"]
30
+ end
30
31
  end
31
32
  end
data/utopia.gemspec CHANGED
@@ -23,10 +23,15 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ["lib"]
24
24
 
25
25
  spec.add_dependency "trenni", "~> 1.3.0"
26
- spec.add_dependency "mime-types", "~> 1.16"
26
+ spec.add_dependency "mime-types", "~> 2.0"
27
27
 
28
28
  spec.add_dependency "rack", "~> 1.5"
29
29
  spec.add_dependency "rack-cache", "~> 1.2.0"
30
30
 
31
- spec.add_dependency "mail", "~> 2.5.4"
31
+ spec.add_dependency "mail", "~> 2.6.1"
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.3"
34
+ spec.add_development_dependency "rspec", "~> 3.0.0"
35
+ spec.add_development_dependency "thin"
36
+ spec.add_development_dependency "rake"
32
37
  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: 0.12.4
4
+ version: 0.12.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-27 00:00:00.000000000 Z
11
+ date: 2014-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trenni
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.16'
33
+ version: '2.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.16'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rack
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,70 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 2.5.4
75
+ version: 2.6.1
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 2.5.4
82
+ version: 2.6.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: thin
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
83
139
  description: "\t\tUtopia is a website generation framework which provides a robust
84
140
  set of tools\n\t\tto build highly complex dynamic websites. It uses the filesystem
85
141
  heavily for\n\t\tcontent and provides frameworks for interacting with files and
@@ -149,11 +205,11 @@ files:
149
205
  - lib/utopia/tags/override.rb
150
206
  - lib/utopia/time_store.rb
151
207
  - lib/utopia/version.rb
152
- - test/content_root/_heading.xnode
153
- - test/content_root/index.xnode
154
- - test/test_content_middleware.rb
155
- - test/test_controller_middleware.rb
156
- - test/test_path.rb
208
+ - spec/utopia/middleware/content_root/_heading.xnode
209
+ - spec/utopia/middleware/content_root/index.xnode
210
+ - spec/utopia/middleware/content_spec.rb
211
+ - spec/utopia/middleware/controller_spec.rb
212
+ - spec/utopia/path_spec.rb
157
213
  - utopia.gemspec
158
214
  homepage: https://github.com/ioquatix/utopia
159
215
  licenses: []
@@ -179,8 +235,8 @@ signing_key:
179
235
  specification_version: 4
180
236
  summary: Utopia is a framework for building dynamic content-driven websites.
181
237
  test_files:
182
- - test/content_root/_heading.xnode
183
- - test/content_root/index.xnode
184
- - test/test_content_middleware.rb
185
- - test/test_controller_middleware.rb
186
- - test/test_path.rb
238
+ - spec/utopia/middleware/content_root/_heading.xnode
239
+ - spec/utopia/middleware/content_root/index.xnode
240
+ - spec/utopia/middleware/content_spec.rb
241
+ - spec/utopia/middleware/controller_spec.rb
242
+ - spec/utopia/path_spec.rb
@@ -1,87 +0,0 @@
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 'minitest/autorun'
22
-
23
- require 'rack/mock'
24
- require 'utopia/middleware/content'
25
-
26
- class TestContentMiddleware < MiniTest::Test
27
- APP = lambda {|env| [404, [], []]}
28
-
29
- class TestDelegate
30
- def initialize
31
- @events = []
32
- end
33
-
34
- attr :events
35
-
36
- def method_missing(*args)
37
- @events << args
38
- end
39
- end
40
-
41
- def test_processor_events_single_tag
42
- delegate = TestDelegate.new
43
- processor = Utopia::Middleware::Content::Processor.new(delegate)
44
-
45
- processor.parse %Q{<foo></foo>}
46
-
47
- foo_tag = Utopia::Tag.new("foo")
48
- expected_events = [
49
- [:tag_begin, foo_tag],
50
- [:tag_end, foo_tag],
51
- ]
52
-
53
- assert_equal expected_events, delegate.events
54
- end
55
-
56
- def test_processor_events_text
57
- delegate = TestDelegate.new
58
- processor = Utopia::Middleware::Content::Processor.new(delegate)
59
-
60
- processor.parse %Q{<foo>Bob &amp; Barley<!-- Comment --><![CDATA[Hello & World]]></foo>}
61
-
62
- foo_tag = Utopia::Tag.new("foo")
63
- expected_events = [
64
- [:tag_begin, foo_tag],
65
- [:cdata, "Bob &amp; Barley"],
66
- [:cdata, "<!-- Comment -->"],
67
- [:cdata, "Hello &amp; World"],
68
- [:tag_end, foo_tag],
69
- ]
70
-
71
- assert_equal expected_events, delegate.events
72
- end
73
-
74
- def test_content_xnode
75
- root = File.expand_path("../content_root", __FILE__)
76
- content = Utopia::Middleware::Content.new(APP, :root => root)
77
-
78
- path = Utopia::Path.create('/index')
79
- node = content.lookup_node(path)
80
- assert_equal Utopia::Middleware::Content::Node, node.class
81
-
82
- output = StringIO.new
83
- node.process!({}, output, {})
84
- assert_equal %Q{<h1>Hello World</h1>}, output.string
85
- end
86
- end
87
-