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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06bfc0c157a2d299e5fdd106a9019259f3736260
4
- data.tar.gz: 351eba6309457b94fa01d76e99ba54583ff5e3db
3
+ metadata.gz: e5d3bad1cc6eafa3b637ec345dbf41746913f24b
4
+ data.tar.gz: 96aea9ef97e0c21f93d8dbfdb8f72d1402953cb3
5
5
  SHA512:
6
- metadata.gz: 32c28e94c6c673e2c0f1b727d991e3457e48bbe3c5b44c440d218220abb92be0d284fa5dd2f6cbda8c5b5bae59135d58d00b0ca716cc5310c854179a83fda93f
7
- data.tar.gz: dec4cec1acb51120a6dc8b72f35912127225b600a9c70573b6faeede6f98153c50d539ae3152c42992c977b61cda2f863e45e096683c51ff9f1fa444abee85d5
6
+ metadata.gz: eeeb9104beea3a7f993463718dcb28133946a05221eb467d9817cb5a029aa9c85d9af1b98ee597de212be9d97dfea76a959f948d878d531c541ada446ca6388e
7
+ data.tar.gz: ca824228d45a83c93ad27b5790325e74a79624ac1f02fec21498a7b21d1c812d0a86adbd5f09b695c2b81e9d60a1c90b11ad9aea1480cf6b818cb0ce51d634e5
@@ -22,7 +22,7 @@ require_relative 'middleware'
22
22
  require_relative 'localization'
23
23
 
24
24
  require_relative 'content/node'
25
- require_relative 'content/processor'
25
+ require_relative 'content/markup'
26
26
 
27
27
  require 'trenni/template'
28
28
 
@@ -48,11 +48,12 @@ module Utopia
48
48
  end
49
49
  end
50
50
 
51
- class Processor
52
- def self.parse_markup(markup, delegate)
53
- processor = self.new(delegate)
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
- processor.parse(markup)
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::Parser::Location.new(@scanner.string, @start_position)
66
- @ending_line = Trenni::Parser::Location.new(@scanner.string, @scanner.pos)
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(input)
87
- @parser.parse(input)
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
@@ -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 'processor'
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.evaluate(context)
113
+ markup = template.to_buffer(context)
114
114
 
115
115
  transaction.parse_markup(markup)
116
116
  end
@@ -60,7 +60,7 @@ module Utopia
60
60
  end
61
61
 
62
62
  def parse_markup(markup)
63
- Processor.parse_markup(markup, self)
63
+ Markup.parse!(markup, self)
64
64
  end
65
65
 
66
66
  # The Rack::Request for this transaction.
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Utopia
22
- VERSION = "1.5.2"
22
+ VERSION = "1.6.0"
23
23
  end
@@ -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/link'
23
+ require 'utopia/content/markup'
24
24
 
25
- module Utopia::Content::ProcessorSpec
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::Processor do
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
- it "should parse single tag" do
48
+ def parse(string)
49
49
  delegate = TestDelegate.new
50
- processor = Utopia::Content::Processor.new(delegate)
51
50
 
52
- processor.parse %Q{<foo></foo>}
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 = TestDelegate.new
67
- processor = Utopia::Content::Processor.new(delegate)
68
-
69
- processor.parse %Q{<foo>Bob &amp; Barley<!-- Comment --><![CDATA[Hello & World]]></foo>}
73
+ delegate = parse %Q{<foo>Bob &amp; 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
- delegate = TestDelegate.new
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
- delegate = TestDelegate.new
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
@@ -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'
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.required_ruby_version = '~> 2.0'
26
26
 
27
- spec.add_dependency 'trenni', '~> 1.5.0'
27
+ spec.add_dependency 'trenni', '~> 1.6.0'
28
28
  spec.add_dependency 'mime-types', '~> 2.0'
29
29
 
30
30
  spec.add_dependency 'rack', '~> 1.6'
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.5.2
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-12 00:00:00.000000000 Z
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.5.0
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.5.0
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