builder 3.2.3
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/CHANGES +107 -0
- data/MIT-LICENSE +20 -0
- data/README.md +258 -0
- data/Rakefile +195 -0
- data/doc/jamis.rb +591 -0
- data/doc/releases/builder-1.2.4.rdoc +31 -0
- data/doc/releases/builder-2.0.0.rdoc +46 -0
- data/doc/releases/builder-2.1.1.rdoc +58 -0
- data/lib/blankslate.rb +137 -0
- data/lib/builder.rb +13 -0
- data/lib/builder/blankslate.rb +23 -0
- data/lib/builder/version.rb +8 -0
- data/lib/builder/xchar.rb +197 -0
- data/lib/builder/xmlbase.rb +199 -0
- data/lib/builder/xmlevents.rb +63 -0
- data/lib/builder/xmlmarkup.rb +339 -0
- data/rakelib/publish.rake +20 -0
- data/rakelib/tags.rake +62 -0
- data/rakelib/testing.rake +7 -0
- data/test/helper.rb +12 -0
- data/test/performance.rb +41 -0
- data/test/preload.rb +39 -0
- data/test/test_blankslate.rb +213 -0
- data/test/test_eventbuilder.rb +150 -0
- data/test/test_markupbuilder.rb +611 -0
- data/test/test_method_caching.rb +62 -0
- data/test/test_namecollision.rb +39 -0
- data/test/test_xchar.rb +78 -0
- metadata +87 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#--
|
4
|
+
# Portions copyright 2011 by Bart ten Brinke (info@retrosync.com).
|
5
|
+
# All rights reserved.
|
6
|
+
|
7
|
+
# Permission is granted for use, copying, modification, distribution,
|
8
|
+
# and distribution of modified versions of this work as long as the
|
9
|
+
# above copyright notice is included.
|
10
|
+
#++
|
11
|
+
|
12
|
+
require 'helper'
|
13
|
+
require 'preload'
|
14
|
+
require 'builder'
|
15
|
+
|
16
|
+
class TestMethodCaching < Builder::Test
|
17
|
+
|
18
|
+
# We can directly ask if xml object responds to the cache_me or
|
19
|
+
# do_not_cache_me methods because xml is derived from BasicObject
|
20
|
+
# (and repond_to? is not defined in BasicObject).
|
21
|
+
#
|
22
|
+
# Instead we are going to stub out method_missing so that it throws
|
23
|
+
# an error, and then make sure that error is either thrown or not
|
24
|
+
# thrown as appropriate.
|
25
|
+
|
26
|
+
def teardown
|
27
|
+
super
|
28
|
+
Builder::XmlBase.cache_method_calls = true
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_caching_does_not_break_weird_symbols
|
32
|
+
xml = Builder::XmlMarkup.new
|
33
|
+
xml.__send__("work-order", 1)
|
34
|
+
assert_equal "<work-order>1</work-order>", xml.target!
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_method_call_caching
|
38
|
+
xml = Builder::XmlMarkup.new
|
39
|
+
xml.cache_me
|
40
|
+
|
41
|
+
def xml.method_missing(*args)
|
42
|
+
::Kernel.fail StandardError, "SHOULD NOT BE CALLED"
|
43
|
+
end
|
44
|
+
assert_nothing_raised do
|
45
|
+
xml.cache_me
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_method_call_caching_disabled
|
50
|
+
Builder::XmlBase.cache_method_calls = false
|
51
|
+
xml = Builder::XmlMarkup.new
|
52
|
+
xml.do_not_cache_me
|
53
|
+
|
54
|
+
def xml.method_missing(*args)
|
55
|
+
::Kernel.fail StandardError, "SHOULD BE CALLED"
|
56
|
+
end
|
57
|
+
assert_raise(StandardError, "SHOULD BE CALLED") do
|
58
|
+
xml.do_not_cache_me
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#--
|
4
|
+
# Portions copyright 2004 by Jim Weirich (jim@weirichhouse.org).
|
5
|
+
# Portions copyright 2005 by Sam Ruby (rubys@intertwingly.net).
|
6
|
+
# All rights reserved.
|
7
|
+
|
8
|
+
# Permission is granted for use, copying, modification, distribution,
|
9
|
+
# and distribution of modified versions of this work as long as the
|
10
|
+
# above copyright notice is included.
|
11
|
+
#++
|
12
|
+
|
13
|
+
require 'helper'
|
14
|
+
require 'builder/xchar'
|
15
|
+
|
16
|
+
class TestNameCollisions < Builder::Test
|
17
|
+
module Collide
|
18
|
+
def xchr
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_no_collision
|
23
|
+
assert_nothing_raised do
|
24
|
+
Builder.check_for_name_collision(Collide, :not_defined)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_collision
|
29
|
+
assert_raise RuntimeError do
|
30
|
+
Builder.check_for_name_collision(Collide, "xchr")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_collision_with_symbol
|
35
|
+
assert_raise RuntimeError do
|
36
|
+
Builder.check_for_name_collision(Collide, :xchr)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/test/test_xchar.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: us-ascii
|
3
|
+
|
4
|
+
#--
|
5
|
+
# Portions copyright 2004 by Jim Weirich (jim@weirichhouse.org).
|
6
|
+
# Portions copyright 2005 by Sam Ruby (rubys@intertwingly.net).
|
7
|
+
# All rights reserved.
|
8
|
+
|
9
|
+
# Permission is granted for use, copying, modification, distribution,
|
10
|
+
# and distribution of modified versions of this work as long as the
|
11
|
+
# above copyright notice is included.
|
12
|
+
#++
|
13
|
+
|
14
|
+
#!/usr/bin/env ruby
|
15
|
+
|
16
|
+
require 'helper'
|
17
|
+
require 'builder/xchar'
|
18
|
+
|
19
|
+
if String.method_defined?(:encode)
|
20
|
+
class String
|
21
|
+
ENCODING_BINARY = Encoding.find('BINARY')
|
22
|
+
|
23
|
+
# shim method for testing purposes
|
24
|
+
def to_xs(escape=true)
|
25
|
+
raise NameError.new('to_xs') unless caller[0].index(__FILE__)
|
26
|
+
|
27
|
+
result = Builder::XChar.encode(self)
|
28
|
+
if escape
|
29
|
+
result.gsub(/[^\u0000-\u007F]/) {|c| "&##{c.ord};"}
|
30
|
+
else
|
31
|
+
# really only useful for testing purposes
|
32
|
+
result.force_encoding(ENCODING_BINARY)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class TestXmlEscaping < Builder::Test
|
39
|
+
REPLACEMENT_CHAR = Builder::XChar::REPLACEMENT_CHAR.to_xs
|
40
|
+
|
41
|
+
def test_ascii
|
42
|
+
assert_equal 'abc', 'abc'.to_xs
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_predefined
|
46
|
+
assert_equal '&', '&'.to_xs # ampersand
|
47
|
+
assert_equal '<', '<'.to_xs # left angle bracket
|
48
|
+
assert_equal '>', '>'.to_xs # right angle bracket
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_invalid
|
52
|
+
assert_equal REPLACEMENT_CHAR, "\x00".to_xs # null
|
53
|
+
assert_equal REPLACEMENT_CHAR, "\x0C".to_xs # form feed
|
54
|
+
assert_equal REPLACEMENT_CHAR, "\xEF\xBF\xBF".to_xs # U+FFFF
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_iso_8859_1
|
58
|
+
assert_equal 'ç', "\xE7".to_xs # small c cedilla
|
59
|
+
assert_equal '©', "\xA9".to_xs # copyright symbol
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_win_1252
|
63
|
+
assert_equal '’', "\x92".to_xs # smart quote
|
64
|
+
assert_equal '€', "\x80".to_xs # euro
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_utf8
|
68
|
+
assert_equal '’', "\xE2\x80\x99".to_xs # right single quote
|
69
|
+
assert_equal '©', "\xC2\xA9".to_xs # copy
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_utf8_verbatim
|
73
|
+
assert_equal "\xE2\x80\x99", "\xE2\x80\x99".to_xs(false) # right single quote
|
74
|
+
assert_equal "\xC2\xA9", "\xC2\xA9".to_xs(false) # copy
|
75
|
+
assert_equal "\xC2\xA9&\xC2\xA9",
|
76
|
+
"\xC2\xA9&\xC2\xA9".to_xs(false) # copy with ampersand
|
77
|
+
end
|
78
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: builder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.2.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jim Weirich
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-13 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: |
|
14
|
+
Builder provides a number of builder objects that make creating structured data
|
15
|
+
simple to do. Currently the following builder objects are supported:
|
16
|
+
|
17
|
+
* XML Markup
|
18
|
+
* XML Events
|
19
|
+
email: jim.weirich@gmail.com
|
20
|
+
executables: []
|
21
|
+
extensions: []
|
22
|
+
extra_rdoc_files: []
|
23
|
+
files:
|
24
|
+
- CHANGES
|
25
|
+
- MIT-LICENSE
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- doc/jamis.rb
|
29
|
+
- doc/releases/builder-1.2.4.rdoc
|
30
|
+
- doc/releases/builder-2.0.0.rdoc
|
31
|
+
- doc/releases/builder-2.1.1.rdoc
|
32
|
+
- lib/blankslate.rb
|
33
|
+
- lib/builder.rb
|
34
|
+
- lib/builder/blankslate.rb
|
35
|
+
- lib/builder/version.rb
|
36
|
+
- lib/builder/xchar.rb
|
37
|
+
- lib/builder/xmlbase.rb
|
38
|
+
- lib/builder/xmlevents.rb
|
39
|
+
- lib/builder/xmlmarkup.rb
|
40
|
+
- rakelib/publish.rake
|
41
|
+
- rakelib/tags.rake
|
42
|
+
- rakelib/testing.rake
|
43
|
+
- test/helper.rb
|
44
|
+
- test/performance.rb
|
45
|
+
- test/preload.rb
|
46
|
+
- test/test_blankslate.rb
|
47
|
+
- test/test_eventbuilder.rb
|
48
|
+
- test/test_markupbuilder.rb
|
49
|
+
- test/test_method_caching.rb
|
50
|
+
- test/test_namecollision.rb
|
51
|
+
- test/test_xchar.rb
|
52
|
+
homepage: http://onestepback.org
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options:
|
58
|
+
- "--title"
|
59
|
+
- Builder -- Easy XML Building
|
60
|
+
- "--main"
|
61
|
+
- README.rdoc
|
62
|
+
- "--line-numbers"
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.6.8
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Builders for MarkUp.
|
81
|
+
test_files:
|
82
|
+
- test/test_blankslate.rb
|
83
|
+
- test/test_eventbuilder.rb
|
84
|
+
- test/test_markupbuilder.rb
|
85
|
+
- test/test_method_caching.rb
|
86
|
+
- test/test_namecollision.rb
|
87
|
+
- test/test_xchar.rb
|