opal-builder 3.2.2.1
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 +7 -0
- data/.gitignore +2 -0
- data/.gitmodules +6 -0
- data/.travis.yml +10 -0
- data/Gemfile +13 -0
- data/README.md +57 -0
- data/Rakefile +7 -0
- data/builder/lib/blankslate.rb +137 -0
- data/builder/lib/builder/blankslate.rb +23 -0
- data/builder/lib/builder/version.rb +8 -0
- data/builder/lib/builder/xchar.rb +197 -0
- data/builder/lib/builder/xmlbase.rb +199 -0
- data/builder/lib/builder/xmlevents.rb +63 -0
- data/builder/lib/builder/xmlmarkup.rb +339 -0
- data/builder/lib/builder.rb +13 -0
- data/config.ru +10 -0
- data/lib/opal-builder.rb +8 -0
- data/opal/builder.rb +4 -0
- data/opal/opal/builder/builder_mutable_string.rb +43 -0
- data/opal/opal/builder/builder_symbol.rb +14 -0
- data/opal/opal/builder/version.rb +8 -0
- data/opal/opal/builder/xmlbase.rb +68 -0
- data/opal/opal/builder/xmlmarkup.rb +28 -0
- data/opal-builder.gemspec +19 -0
- data/spec/builder_spec.rb +164 -0
- metadata +100 -0
@@ -0,0 +1,164 @@
|
|
1
|
+
require 'builder'
|
2
|
+
|
3
|
+
describe Builder::XmlMarkup do
|
4
|
+
let(:options) { {} }
|
5
|
+
let(:target) { nil }
|
6
|
+
let(:builder) {
|
7
|
+
args = options
|
8
|
+
args[:target] = target if target
|
9
|
+
Builder::XmlMarkup.new args
|
10
|
+
}
|
11
|
+
|
12
|
+
RSpec::Matchers.define :produce_xml do |expected_xml|
|
13
|
+
def get_xml(actual)
|
14
|
+
if target
|
15
|
+
raise "Expected subject to be a #{target.class} object but was a #{actual.class}" unless actual.class == target.class
|
16
|
+
actual.string
|
17
|
+
else
|
18
|
+
# Deal with string mutation class
|
19
|
+
actual.to_s
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
match do |actual_xml|
|
24
|
+
get_xml(actual) == expected_xml
|
25
|
+
end
|
26
|
+
|
27
|
+
failure_message do |actual_xml|
|
28
|
+
"Expected '#{expected_xml}' but got '#{get_xml(actual)}'"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
RSpec.shared_context :examples do
|
33
|
+
context 'basic case' do
|
34
|
+
subject { builder.person { |b| b.name("Jim"); b.phone("555-1234") } }
|
35
|
+
|
36
|
+
it { is_expected.to produce_xml '<person><name>Jim</name><phone>555-1234</phone></person>' }
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'indent' do
|
40
|
+
let(:options) { {indent: 2}}
|
41
|
+
subject { builder.person { |b| b.name("Jim"); b.phone("555-1234") } }
|
42
|
+
|
43
|
+
it {
|
44
|
+
is_expected.to produce_xml "<person>\n <name>Jim</name>\n <phone>555-1234</phone>\n</person>\n"
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'attributes' do
|
49
|
+
subject { builder.sample escaped: input[0], unescaped: input[1] }
|
50
|
+
|
51
|
+
context 'normal' do
|
52
|
+
let(:input) { ['This and That', 'Here and There' ]}
|
53
|
+
|
54
|
+
it {
|
55
|
+
is_expected.to produce_xml '<sample escaped="This and That" unescaped="Here and There"/>'
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'xml entities' do
|
60
|
+
context 'amp' do
|
61
|
+
let(:input) { ['This&That', 'Here&There' ]}
|
62
|
+
|
63
|
+
it {
|
64
|
+
is_expected.to produce_xml '<sample escaped="This&That" unescaped="Here&There"/>'
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'lt' do
|
69
|
+
let(:input) { ['This<That', 'Here<There' ]}
|
70
|
+
|
71
|
+
it {
|
72
|
+
is_expected.to produce_xml '<sample escaped="This<That" unescaped="Here<There"/>'
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'gt' do
|
77
|
+
let(:input) { ['This>That', 'Here>There' ]}
|
78
|
+
|
79
|
+
it {
|
80
|
+
is_expected.to produce_xml '<sample escaped="This>That" unescaped="Here>There"/>'
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'apos' do
|
85
|
+
let(:input) { ["This'That", 'Here'There' ]}
|
86
|
+
|
87
|
+
it {
|
88
|
+
is_expected.to produce_xml '<sample escaped="This'That" unescaped="Here'There"/>'
|
89
|
+
}
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'quotes' do
|
94
|
+
subject {
|
95
|
+
builder.sample escaped: 'This"That'
|
96
|
+
}
|
97
|
+
|
98
|
+
it {
|
99
|
+
is_expected.to produce_xml '<sample escaped="This"That"/>'
|
100
|
+
}
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'line feed' do
|
104
|
+
subject {
|
105
|
+
builder.sample escaped: "This\nThat"
|
106
|
+
}
|
107
|
+
|
108
|
+
it {
|
109
|
+
is_expected.to produce_xml '<sample escaped="This That"/>'
|
110
|
+
}
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'carriage return' do
|
114
|
+
subject {
|
115
|
+
builder.sample escaped: "This\rThat"
|
116
|
+
}
|
117
|
+
|
118
|
+
it {
|
119
|
+
is_expected.to produce_xml '<sample escaped="This That"/>'
|
120
|
+
}
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe '#comment!' do
|
125
|
+
# indent required for some reason (see builder source)
|
126
|
+
let(:options) { {indent: 1}}
|
127
|
+
|
128
|
+
subject { builder.comment! 'This is a comment' }
|
129
|
+
|
130
|
+
it {
|
131
|
+
is_expected.to produce_xml "<!-- This is a comment -->\n"
|
132
|
+
}
|
133
|
+
end
|
134
|
+
|
135
|
+
describe '#instruct!' do
|
136
|
+
# indent required for some reason (see builder source)
|
137
|
+
let(:options) { {indent: 1}}
|
138
|
+
|
139
|
+
subject { builder.instruct! :xml, version: '1.0', encoding: 'UTF-8' }
|
140
|
+
|
141
|
+
it {
|
142
|
+
is_expected.to produce_xml '<?xml version="1.0" encoding="UTF-8"?>'"\n"
|
143
|
+
}
|
144
|
+
end
|
145
|
+
|
146
|
+
describe 'declare!' do
|
147
|
+
subject { lambda { builder.declare! :DOCTYPE, :chapter, :SYSTEM, "../dtds/chapter.dtd" } }
|
148
|
+
|
149
|
+
it {
|
150
|
+
is_expected.to raise_exception 'declare! is not currently supported on Opal because symbols cannot be detected easily.'
|
151
|
+
}
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'default output' do
|
156
|
+
include_context :examples
|
157
|
+
end
|
158
|
+
|
159
|
+
context 'StringIO output' do
|
160
|
+
let(:target) { StringIO.new }
|
161
|
+
|
162
|
+
include_context :examples
|
163
|
+
end
|
164
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: opal-builder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.2.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brady Wied
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: opal
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.7.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0.9'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.7.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.9'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
description: Opal compatible builder library
|
48
|
+
email: brady@bswtechconsulting.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- ".gitignore"
|
54
|
+
- ".gitmodules"
|
55
|
+
- ".travis.yml"
|
56
|
+
- Gemfile
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- builder/lib/blankslate.rb
|
60
|
+
- builder/lib/builder.rb
|
61
|
+
- builder/lib/builder/blankslate.rb
|
62
|
+
- builder/lib/builder/version.rb
|
63
|
+
- builder/lib/builder/xchar.rb
|
64
|
+
- builder/lib/builder/xmlbase.rb
|
65
|
+
- builder/lib/builder/xmlevents.rb
|
66
|
+
- builder/lib/builder/xmlmarkup.rb
|
67
|
+
- config.ru
|
68
|
+
- lib/opal-builder.rb
|
69
|
+
- opal-builder.gemspec
|
70
|
+
- opal/builder.rb
|
71
|
+
- opal/opal/builder/builder_mutable_string.rb
|
72
|
+
- opal/opal/builder/builder_symbol.rb
|
73
|
+
- opal/opal/builder/version.rb
|
74
|
+
- opal/opal/builder/xmlbase.rb
|
75
|
+
- opal/opal/builder/xmlmarkup.rb
|
76
|
+
- spec/builder_spec.rb
|
77
|
+
homepage:
|
78
|
+
licenses: []
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.4.5
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Builder for Opal
|
100
|
+
test_files: []
|