utopia 1.5.2 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/utopia/content.rb +1 -1
- data/lib/utopia/content/{processor.rb → markup.rb} +11 -11
- data/lib/utopia/content/node.rb +2 -2
- data/lib/utopia/content/transaction.rb +1 -1
- data/lib/utopia/version.rb +1 -1
- data/spec/utopia/content/{processor_spec.rb → markup_spec.rb} +16 -18
- data/spec/utopia/setup_spec.rb +1 -1
- data/utopia.gemspec +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5d3bad1cc6eafa3b637ec345dbf41746913f24b
|
4
|
+
data.tar.gz: 96aea9ef97e0c21f93d8dbfdb8f72d1402953cb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eeeb9104beea3a7f993463718dcb28133946a05221eb467d9817cb5a029aa9c85d9af1b98ee597de212be9d97dfea76a959f948d878d531c541ada446ca6388e
|
7
|
+
data.tar.gz: ca824228d45a83c93ad27b5790325e74a79624ac1f02fec21498a7b21d1c812d0a86adbd5f09b695c2b81e9d60a1c90b11ad9aea1480cf6b818cb0ce51d634e5
|
data/lib/utopia/content.rb
CHANGED
@@ -48,11 +48,12 @@ module Utopia
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
class
|
52
|
-
def self.
|
53
|
-
|
51
|
+
class Markup
|
52
|
+
def self.parse!(markup, delegate)
|
53
|
+
# This is for compatibility with the existing API which passes in a string:
|
54
|
+
markup = Buffer.new(markup) if markup.is_a? String
|
54
55
|
|
55
|
-
|
56
|
+
self.new(markup, delegate).parse!
|
56
57
|
end
|
57
58
|
|
58
59
|
class UnbalancedTagError < StandardError
|
@@ -62,8 +63,8 @@ module Utopia
|
|
62
63
|
@current_tag = current_tag
|
63
64
|
@closing_tag = closing_tag
|
64
65
|
|
65
|
-
@starting_line = Trenni::
|
66
|
-
@ending_line = Trenni::
|
66
|
+
@starting_line = Trenni::Location.new(@scanner.string, @start_position)
|
67
|
+
@ending_line = Trenni::Location.new(@scanner.string, @scanner.pos)
|
67
68
|
end
|
68
69
|
|
69
70
|
attr :scanner
|
@@ -76,15 +77,14 @@ module Utopia
|
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
79
|
-
def initialize(delegate)
|
80
|
+
def initialize(buffer, delegate)
|
81
|
+
@buffer = buffer
|
80
82
|
@delegate = delegate
|
81
83
|
@stack = []
|
82
|
-
|
83
|
-
@parser = Trenni::Parser.new(self)
|
84
84
|
end
|
85
85
|
|
86
|
-
def parse
|
87
|
-
@
|
86
|
+
def parse!
|
87
|
+
Trenni::Parser.new(@buffer, self).parse!
|
88
88
|
|
89
89
|
unless @stack.empty?
|
90
90
|
current_tag, current_position = @stack.pop
|
data/lib/utopia/content/node.rb
CHANGED
@@ -18,7 +18,7 @@
|
|
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_relative '
|
21
|
+
require_relative 'markup'
|
22
22
|
require_relative 'links'
|
23
23
|
require_relative 'transaction'
|
24
24
|
|
@@ -110,7 +110,7 @@ module Utopia
|
|
110
110
|
template = @controller.fetch_template(@file_path)
|
111
111
|
|
112
112
|
context = Context.new(transaction, state)
|
113
|
-
markup = template.
|
113
|
+
markup = template.to_buffer(context)
|
114
114
|
|
115
115
|
transaction.parse_markup(markup)
|
116
116
|
end
|
data/lib/utopia/version.rb
CHANGED
@@ -20,9 +20,9 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
21
|
# THE SOFTWARE.
|
22
22
|
|
23
|
-
require 'utopia/content/
|
23
|
+
require 'utopia/content/markup'
|
24
24
|
|
25
|
-
module Utopia::Content::
|
25
|
+
module Utopia::Content::MarkupSpec
|
26
26
|
class TestDelegate
|
27
27
|
def initialize
|
28
28
|
@events = []
|
@@ -35,7 +35,7 @@ module Utopia::Content::ProcessorSpec
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
describe Utopia::Content::
|
38
|
+
describe Utopia::Content::Markup do
|
39
39
|
it "should format open tags correctly" do
|
40
40
|
foo_tag = Utopia::Content::Tag.new("foo", bar: nil, baz: 'bob')
|
41
41
|
|
@@ -45,11 +45,18 @@ module Utopia::Content::ProcessorSpec
|
|
45
45
|
expect(foo_tag.to_s('content')).to be == '<foo bar baz="bob">content</foo>'
|
46
46
|
end
|
47
47
|
|
48
|
-
|
48
|
+
def parse(string)
|
49
49
|
delegate = TestDelegate.new
|
50
|
-
processor = Utopia::Content::Processor.new(delegate)
|
51
50
|
|
52
|
-
|
51
|
+
buffer = Trenni::Buffer.new(string)
|
52
|
+
Utopia::Content::Markup.new(buffer, delegate).parse!
|
53
|
+
|
54
|
+
return delegate
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should parse single tag" do
|
58
|
+
|
59
|
+
delegate = parse %Q{<foo></foo>}
|
53
60
|
|
54
61
|
foo_tag = Utopia::Content::Tag.new("foo")
|
55
62
|
expected_events = [
|
@@ -63,10 +70,7 @@ module Utopia::Content::ProcessorSpec
|
|
63
70
|
end
|
64
71
|
|
65
72
|
it "should parse and escape text" do
|
66
|
-
delegate =
|
67
|
-
processor = Utopia::Content::Processor.new(delegate)
|
68
|
-
|
69
|
-
processor.parse %Q{<foo>Bob & Barley<!-- Comment --><![CDATA[Hello & World]]></foo>}
|
73
|
+
delegate = parse %Q{<foo>Bob & Barley<!-- Comment --><![CDATA[Hello & World]]></foo>}
|
70
74
|
|
71
75
|
foo_tag = Utopia::Content::Tag.new("foo")
|
72
76
|
expected_events = [
|
@@ -81,17 +85,11 @@ module Utopia::Content::ProcessorSpec
|
|
81
85
|
end
|
82
86
|
|
83
87
|
it "should fail with incorrect closing tag" do
|
84
|
-
|
85
|
-
processor = Utopia::Content::Processor.new(delegate)
|
86
|
-
|
87
|
-
expect{processor.parse %Q{<p>Foobar</dl>}}.to raise_exception(Utopia::Content::Processor::UnbalancedTagError)
|
88
|
+
expect{parse %Q{<p>Foobar</dl>}}.to raise_exception(Utopia::Content::Markup::UnbalancedTagError)
|
88
89
|
end
|
89
90
|
|
90
91
|
it "should fail with unclosed tag" do
|
91
|
-
|
92
|
-
processor = Utopia::Content::Processor.new(delegate)
|
93
|
-
|
94
|
-
expect{processor.parse %Q{<p>Foobar}}.to raise_exception(Utopia::Content::Processor::UnbalancedTagError)
|
92
|
+
expect{parse %Q{<p>Foobar}}.to raise_exception(Utopia::Content::Markup::UnbalancedTagError)
|
95
93
|
end
|
96
94
|
end
|
97
95
|
end
|
data/spec/utopia/setup_spec.rb
CHANGED
@@ -25,7 +25,7 @@ RSpec.describe "utopia executable" do
|
|
25
25
|
|
26
26
|
before(:all) do
|
27
27
|
# We need to build a package to test deployment:
|
28
|
-
system("rake", "build")
|
28
|
+
system("rake", "build") or abort("Could not build package for setup spec!")
|
29
29
|
|
30
30
|
ENV.delete 'BUNDLE_BIN_PATH'
|
31
31
|
ENV.delete 'BUNDLE_GEMFILE'
|
data/utopia.gemspec
CHANGED
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.
|
4
|
+
version: 1.6.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: 2016-03-
|
11
|
+
date: 2016-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trenni
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.6.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.6.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mime-types
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -191,8 +191,8 @@ files:
|
|
191
191
|
- lib/utopia/content.rb
|
192
192
|
- lib/utopia/content/link.rb
|
193
193
|
- lib/utopia/content/links.rb
|
194
|
+
- lib/utopia/content/markup.rb
|
194
195
|
- lib/utopia/content/node.rb
|
195
|
-
- lib/utopia/content/processor.rb
|
196
196
|
- lib/utopia/content/tag.rb
|
197
197
|
- lib/utopia/content/transaction.rb
|
198
198
|
- lib/utopia/content_length.rb
|
@@ -265,6 +265,7 @@ files:
|
|
265
265
|
- spec/utopia/content/localized/three/index.xnode
|
266
266
|
- spec/utopia/content/localized/two.en.xnode
|
267
267
|
- spec/utopia/content/localized/two.zh.xnode
|
268
|
+
- spec/utopia/content/markup_spec.rb
|
268
269
|
- spec/utopia/content/node/ordered/first.xnode
|
269
270
|
- spec/utopia/content/node/ordered/index.xnode
|
270
271
|
- spec/utopia/content/node/ordered/links.yaml
|
@@ -273,7 +274,6 @@ files:
|
|
273
274
|
- spec/utopia/content/node/related/foo.ja.xnode
|
274
275
|
- spec/utopia/content/node/related/links.yaml
|
275
276
|
- spec/utopia/content/node_spec.rb
|
276
|
-
- spec/utopia/content/processor_spec.rb
|
277
277
|
- spec/utopia/content_spec.rb
|
278
278
|
- spec/utopia/content_spec.ru
|
279
279
|
- spec/utopia/controller/action_spec.rb
|
@@ -379,6 +379,7 @@ test_files:
|
|
379
379
|
- spec/utopia/content/localized/three/index.xnode
|
380
380
|
- spec/utopia/content/localized/two.en.xnode
|
381
381
|
- spec/utopia/content/localized/two.zh.xnode
|
382
|
+
- spec/utopia/content/markup_spec.rb
|
382
383
|
- spec/utopia/content/node/ordered/first.xnode
|
383
384
|
- spec/utopia/content/node/ordered/index.xnode
|
384
385
|
- spec/utopia/content/node/ordered/links.yaml
|
@@ -387,7 +388,6 @@ test_files:
|
|
387
388
|
- spec/utopia/content/node/related/foo.ja.xnode
|
388
389
|
- spec/utopia/content/node/related/links.yaml
|
389
390
|
- spec/utopia/content/node_spec.rb
|
390
|
-
- spec/utopia/content/processor_spec.rb
|
391
391
|
- spec/utopia/content_spec.rb
|
392
392
|
- spec/utopia/content_spec.ru
|
393
393
|
- spec/utopia/controller/action_spec.rb
|