activesupport 1.4.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activesupport might be problematic. Click here for more details.
- data/CHANGELOG +263 -7
- data/lib/active_support.rb +9 -4
- data/lib/active_support/basic_object.rb +5 -0
- data/lib/active_support/buffered_logger.rb +107 -0
- data/lib/active_support/clean_logger.rb +94 -5
- data/lib/active_support/core_ext.rb +4 -1
- data/lib/active_support/core_ext/array.rb +8 -2
- data/lib/active_support/core_ext/array/access.rb +28 -0
- data/lib/active_support/core_ext/array/conversions.rb +28 -15
- data/lib/active_support/core_ext/array/extract_options.rb +19 -0
- data/lib/active_support/core_ext/array/grouping.rb +20 -7
- data/lib/active_support/core_ext/array/random_access.rb +12 -0
- data/lib/active_support/core_ext/bigdecimal.rb +1 -2
- data/lib/active_support/core_ext/bigdecimal/{formatting.rb → conversions.rb} +1 -2
- data/lib/active_support/core_ext/blank.rb +2 -8
- data/lib/active_support/core_ext/cgi.rb +2 -2
- data/lib/active_support/core_ext/class.rb +4 -3
- data/lib/active_support/core_ext/class/attribute_accessors.rb +1 -1
- data/lib/active_support/core_ext/class/delegating_attributes.rb +40 -0
- data/lib/active_support/core_ext/class/inheritable_attributes.rb +3 -3
- data/lib/active_support/core_ext/class/removal.rb +2 -2
- data/lib/active_support/core_ext/date.rb +5 -1
- data/lib/active_support/core_ext/date/behavior.rb +13 -0
- data/lib/active_support/core_ext/date/calculations.rb +188 -0
- data/lib/active_support/core_ext/date/conversions.rb +69 -13
- data/lib/active_support/core_ext/date_time.rb +10 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +77 -0
- data/lib/active_support/core_ext/date_time/conversions.rb +54 -0
- data/lib/active_support/core_ext/duplicable.rb +37 -0
- data/lib/active_support/core_ext/enumerable.rb +1 -0
- data/lib/active_support/core_ext/exception.rb +2 -2
- data/lib/active_support/core_ext/file.rb +21 -0
- data/lib/active_support/core_ext/float.rb +5 -0
- data/lib/active_support/core_ext/float/rounding.rb +24 -0
- data/lib/active_support/core_ext/hash.rb +5 -5
- data/lib/active_support/core_ext/hash/conversions.rb +86 -34
- data/lib/active_support/core_ext/hash/diff.rb +8 -0
- data/lib/active_support/core_ext/hash/except.rb +24 -0
- data/lib/active_support/core_ext/hash/indifferent_access.rb +15 -2
- data/lib/active_support/core_ext/hash/keys.rb +10 -3
- data/lib/active_support/core_ext/hash/reverse_merge.rb +2 -2
- data/lib/active_support/core_ext/hash/slice.rb +28 -0
- data/lib/active_support/core_ext/integer.rb +2 -2
- data/lib/active_support/core_ext/kernel.rb +5 -4
- data/lib/active_support/core_ext/kernel/debugger.rb +13 -0
- data/lib/active_support/core_ext/module.rb +8 -7
- data/lib/active_support/core_ext/module/aliasing.rb +17 -5
- data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +31 -0
- data/lib/active_support/core_ext/module/attribute_accessors.rb +1 -1
- data/lib/active_support/core_ext/module/delegation.rb +21 -0
- data/lib/active_support/core_ext/name_error.rb +2 -2
- data/lib/active_support/core_ext/numeric.rb +2 -2
- data/lib/active_support/core_ext/numeric/time.rb +30 -11
- data/lib/active_support/core_ext/object.rb +3 -2
- data/lib/active_support/core_ext/object/extending.rb +40 -29
- data/lib/active_support/core_ext/object/instance_variables.rb +22 -0
- data/lib/active_support/core_ext/object/misc.rb +29 -4
- data/lib/active_support/core_ext/pathname.rb +1 -1
- data/lib/active_support/core_ext/range.rb +7 -1
- data/lib/active_support/core_ext/range/blockless_step.rb +22 -0
- data/lib/active_support/core_ext/range/conversions.rb +8 -6
- data/lib/active_support/core_ext/range/include_range.rb +22 -0
- data/lib/active_support/core_ext/range/overlaps.rb +12 -0
- data/lib/active_support/core_ext/string.rb +10 -7
- data/lib/active_support/core_ext/string/conversions.rb +5 -1
- data/lib/active_support/core_ext/string/unicode.rb +2 -2
- data/lib/active_support/core_ext/string/xchar.rb +11 -0
- data/lib/active_support/core_ext/symbol.rb +12 -10
- data/lib/active_support/core_ext/test.rb +1 -0
- data/lib/active_support/core_ext/test/unit/assertions.rb +62 -0
- data/lib/active_support/core_ext/time.rb +4 -2
- data/lib/active_support/core_ext/time/behavior.rb +13 -0
- data/lib/active_support/core_ext/time/calculations.rb +87 -54
- data/lib/active_support/core_ext/time/conversions.rb +71 -10
- data/lib/active_support/dependencies.rb +25 -24
- data/lib/active_support/deprecation.rb +4 -2
- data/lib/active_support/duration.rb +86 -0
- data/lib/active_support/inflections.rb +2 -1
- data/lib/active_support/inflector.rb +13 -6
- data/lib/active_support/json.rb +22 -39
- data/lib/active_support/json/decoding.rb +60 -0
- data/lib/active_support/json/encoders/date.rb +5 -0
- data/lib/active_support/json/encoders/date_time.rb +5 -0
- data/lib/active_support/json/encoders/enumerable.rb +12 -0
- data/lib/active_support/json/encoders/false_class.rb +5 -0
- data/lib/active_support/json/encoders/hash.rb +50 -0
- data/lib/active_support/json/encoders/nil_class.rb +5 -0
- data/lib/active_support/json/encoders/numeric.rb +5 -0
- data/lib/active_support/json/encoders/object.rb +6 -0
- data/lib/active_support/json/encoders/regexp.rb +5 -0
- data/lib/active_support/json/encoders/string.rb +30 -0
- data/lib/active_support/json/encoders/symbol.rb +5 -0
- data/lib/active_support/json/encoders/time.rb +5 -0
- data/lib/active_support/json/encoders/true_class.rb +5 -0
- data/lib/active_support/json/encoding.rb +38 -0
- data/lib/active_support/json/variable.rb +10 -0
- data/lib/active_support/multibyte.rb +7 -5
- data/lib/active_support/multibyte/chars.rb +6 -0
- data/lib/active_support/multibyte/handlers/utf8_handler.rb +115 -5
- data/lib/active_support/option_merger.rb +7 -7
- data/lib/active_support/ordered_options.rb +22 -17
- data/lib/active_support/test_case.rb +5 -0
- data/lib/active_support/testing.rb +1 -0
- data/lib/active_support/testing/default.rb +12 -0
- data/lib/active_support/values/time_zone.rb +3 -3
- data/lib/active_support/vendor.rb +14 -0
- data/lib/active_support/vendor/builder-2.1.2/blankslate.rb +113 -0
- data/lib/active_support/vendor/{builder.rb → builder-2.1.2/builder.rb} +0 -0
- data/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +20 -0
- data/lib/active_support/vendor/builder-2.1.2/builder/css.rb +250 -0
- data/lib/active_support/vendor/{builder → builder-2.1.2/builder}/xchar.rb +11 -8
- data/lib/active_support/vendor/{builder → builder-2.1.2/builder}/xmlbase.rb +38 -44
- data/lib/active_support/vendor/{builder → builder-2.1.2/builder}/xmlevents.rb +1 -1
- data/lib/active_support/vendor/{builder → builder-2.1.2/builder}/xmlmarkup.rb +40 -39
- data/lib/active_support/vendor/{xml_simple.rb → xml-simple-1.0.11/xmlsimple.rb} +3 -3
- data/lib/active_support/version.rb +3 -3
- data/lib/active_support/whiny_nil.rb +12 -12
- data/lib/activesupport.rb +1 -0
- metadata +69 -17
- data/lib/active_support/binding_of_caller.rb +0 -84
- data/lib/active_support/breakpoint.rb +0 -528
- data/lib/active_support/caching_tools.rb +0 -62
- data/lib/active_support/json/encoders.rb +0 -25
- data/lib/active_support/json/encoders/core.rb +0 -70
- data/lib/active_support/reloadable.rb +0 -60
- data/lib/active_support/vendor/builder/blankslate.rb +0 -63
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
module Builder
|
12
12
|
def self.check_for_name_collision(klass, method_name, defined_constant=nil)
|
13
|
-
if klass.instance_methods.include?(method_name)
|
13
|
+
if klass.instance_methods.include?(method_name.to_s)
|
14
14
|
fail RuntimeError,
|
15
15
|
"Name Collision: Method '#{method_name}' is already defined in #{klass}"
|
16
16
|
end
|
@@ -27,7 +27,7 @@ module Builder
|
|
27
27
|
|
28
28
|
####################################################################
|
29
29
|
# XML Character converter, from Sam Ruby:
|
30
|
-
# (see http://intertwingly.net/stories/2005/09/28/xchar.rb).
|
30
|
+
# (see http://intertwingly.net/stories/2005/09/28/xchar.rb).
|
31
31
|
#
|
32
32
|
module XChar # :nodoc:
|
33
33
|
|
@@ -73,8 +73,8 @@ module Builder
|
|
73
73
|
|
74
74
|
# See http://www.w3.org/TR/REC-xml/#charsets for details.
|
75
75
|
VALID = [
|
76
|
-
|
77
|
-
(0x20..0xD7FF),
|
76
|
+
0x9, 0xA, 0xD,
|
77
|
+
(0x20..0xD7FF),
|
78
78
|
(0xE000..0xFFFD),
|
79
79
|
(0x10000..0x10FFFF)
|
80
80
|
]
|
@@ -86,14 +86,17 @@ end
|
|
86
86
|
######################################################################
|
87
87
|
# Enhance the Fixnum class with a XML escaped character conversion.
|
88
88
|
#
|
89
|
-
class Fixnum
|
89
|
+
class Fixnum
|
90
90
|
XChar = Builder::XChar if ! defined?(XChar)
|
91
91
|
|
92
92
|
# XML escaped version of chr
|
93
93
|
def xchr
|
94
94
|
n = XChar::CP1252[self] || self
|
95
|
-
n
|
96
|
-
|
95
|
+
case n when *XChar::VALID
|
96
|
+
XChar::PREDEFINED[n] or (n<128 ? n.chr : "&##{n};")
|
97
|
+
else
|
98
|
+
'*'
|
99
|
+
end
|
97
100
|
end
|
98
101
|
end
|
99
102
|
|
@@ -102,7 +105,7 @@ end
|
|
102
105
|
# Enhance the String class with a XML escaped character version of
|
103
106
|
# to_s.
|
104
107
|
#
|
105
|
-
class String
|
108
|
+
class String
|
106
109
|
# XML escaped version of to_s
|
107
110
|
def to_xs
|
108
111
|
unpack('U*').map {|n| n.xchr}.join # ASCII, UTF-8
|
@@ -5,12 +5,11 @@ require 'builder/blankslate'
|
|
5
5
|
module Builder
|
6
6
|
|
7
7
|
# Generic error for builder
|
8
|
-
class IllegalBlockError < RuntimeError
|
9
|
-
end
|
8
|
+
class IllegalBlockError < RuntimeError; end
|
10
9
|
|
11
10
|
# XmlBase is a base class for building XML builders. See
|
12
11
|
# Builder::XmlMarkup and Builder::XmlEvents for examples.
|
13
|
-
class XmlBase < BlankSlate
|
12
|
+
class XmlBase < BlankSlate
|
14
13
|
|
15
14
|
# Create an XML markup builder.
|
16
15
|
#
|
@@ -24,12 +23,12 @@ module Builder
|
|
24
23
|
@indent = indent
|
25
24
|
@level = initial
|
26
25
|
end
|
27
|
-
|
26
|
+
|
28
27
|
# Create a tag named +sym+. Other than the first argument which
|
29
|
-
# is the tag name, the
|
28
|
+
# is the tag name, the arguments are the same as the tags
|
30
29
|
# implemented via <tt>method_missing</tt>.
|
31
30
|
def tag!(sym, *args, &block)
|
32
|
-
|
31
|
+
method_missing(sym.to_sym, *args, &block)
|
33
32
|
end
|
34
33
|
|
35
34
|
# Create XML markup based on the name of the method. This method
|
@@ -40,51 +39,50 @@ module Builder
|
|
40
39
|
attrs = nil
|
41
40
|
sym = "#{sym}:#{args.shift}" if args.first.kind_of?(Symbol)
|
42
41
|
args.each do |arg|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
42
|
+
case arg
|
43
|
+
when Hash
|
44
|
+
attrs ||= {}
|
45
|
+
attrs.merge!(arg)
|
46
|
+
else
|
47
|
+
text ||= ''
|
48
|
+
text << arg.to_s
|
49
|
+
end
|
51
50
|
end
|
52
51
|
if block
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
_newline
|
52
|
+
unless text.nil?
|
53
|
+
raise ArgumentError, "XmlMarkup cannot mix a text argument with a block"
|
54
|
+
end
|
55
|
+
_indent
|
56
|
+
_start_tag(sym, attrs)
|
57
|
+
_newline
|
58
|
+
_nested_structures(block)
|
59
|
+
_indent
|
60
|
+
_end_tag(sym)
|
61
|
+
_newline
|
64
62
|
elsif text.nil?
|
65
|
-
|
66
|
-
|
67
|
-
|
63
|
+
_indent
|
64
|
+
_start_tag(sym, attrs, true)
|
65
|
+
_newline
|
68
66
|
else
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
_indent
|
68
|
+
_start_tag(sym, attrs)
|
69
|
+
text! text
|
70
|
+
_end_tag(sym)
|
71
|
+
_newline
|
74
72
|
end
|
75
73
|
@target
|
76
74
|
end
|
77
75
|
|
78
76
|
# Append text to the output target. Escape any markup. May be
|
79
|
-
# used within the markup
|
77
|
+
# used within the markup brackets as:
|
80
78
|
#
|
81
79
|
# builder.p { |b| b.br; b.text! "HI" } #=> <p><br/>HI</p>
|
82
80
|
def text!(text)
|
83
81
|
_text(_escape(text))
|
84
82
|
end
|
85
|
-
|
83
|
+
|
86
84
|
# Append text to the output target without escaping any markup.
|
87
|
-
# May be used within the markup
|
85
|
+
# May be used within the markup brackets as:
|
88
86
|
#
|
89
87
|
# builder.p { |x| x << "<br/>HI" } #=> <p><br/>HI</p>
|
90
88
|
#
|
@@ -99,7 +97,7 @@ module Builder
|
|
99
97
|
def <<(text)
|
100
98
|
_text(text)
|
101
99
|
end
|
102
|
-
|
100
|
+
|
103
101
|
# For some reason, nil? is sent to the XmlMarkup object. If nil?
|
104
102
|
# is not defined and method_missing is invoked, some strange kind
|
105
103
|
# of recursion happens. Since nil? won't ever be an XML tag, it
|
@@ -111,7 +109,7 @@ module Builder
|
|
111
109
|
end
|
112
110
|
|
113
111
|
private
|
114
|
-
|
112
|
+
|
115
113
|
require 'builder/xchar'
|
116
114
|
def _escape(text)
|
117
115
|
text.to_xs
|
@@ -121,20 +119,16 @@ module Builder
|
|
121
119
|
_escape(text).gsub(%r{"}, '"') # " WART
|
122
120
|
end
|
123
121
|
|
124
|
-
def _capture_outer_self(block)
|
125
|
-
@self = eval("self", block)
|
126
|
-
end
|
127
|
-
|
128
122
|
def _newline
|
129
123
|
return if @indent == 0
|
130
124
|
text! "\n"
|
131
125
|
end
|
132
|
-
|
126
|
+
|
133
127
|
def _indent
|
134
128
|
return if @indent == 0 || @level == 0
|
135
129
|
text!(" " * (@level * @indent))
|
136
130
|
end
|
137
|
-
|
131
|
+
|
138
132
|
def _nested_structures(block)
|
139
133
|
@level += 1
|
140
134
|
block.call(self)
|
@@ -38,6 +38,7 @@ module Builder
|
|
38
38
|
# xm.title("History") # <title>History</title>
|
39
39
|
# } # </head>
|
40
40
|
# xm.body { # <body>
|
41
|
+
# xm.comment! "HI" # <! -- HI -->
|
41
42
|
# xm.h1("Header") # <h1>Header</h1>
|
42
43
|
# xm.p("paragraph") # <p>paragraph</p>
|
43
44
|
# } # </body>
|
@@ -46,7 +47,7 @@ module Builder
|
|
46
47
|
# == Notes:
|
47
48
|
#
|
48
49
|
# * The order that attributes are inserted in markup tags is
|
49
|
-
# undefined.
|
50
|
+
# undefined.
|
50
51
|
#
|
51
52
|
# * Sometimes you wish to insert text without enclosing tags. Use
|
52
53
|
# the <tt>text!</tt> method to accomplish this.
|
@@ -77,7 +78,7 @@ module Builder
|
|
77
78
|
# <tt>tag!</tt> will also take text and attribute arguments (after
|
78
79
|
# the tag name) like normal markup methods. (But see the next
|
79
80
|
# bullet item for a better way to handle XML namespaces).
|
80
|
-
#
|
81
|
+
#
|
81
82
|
# * Direct support for XML namespaces is now available. If the
|
82
83
|
# first argument to a tag call is a symbol, it will be joined to
|
83
84
|
# the tag to produce a namespace:tag combination. It is easier to
|
@@ -92,7 +93,7 @@ module Builder
|
|
92
93
|
# * XmlMarkup builds the markup in any object (called a _target_)
|
93
94
|
# that accepts the <tt><<</tt> method. If no target is given,
|
94
95
|
# then XmlMarkup defaults to a string target.
|
95
|
-
#
|
96
|
+
#
|
96
97
|
# Examples:
|
97
98
|
#
|
98
99
|
# xm = Builder::XmlMarkup.new
|
@@ -109,16 +110,16 @@ module Builder
|
|
109
110
|
# xm = Builder::XmlMarkup.new
|
110
111
|
# x2 = Builder::XmlMarkup.new(:target=>xm)
|
111
112
|
# # Markup written to +x2+ will be send to +xm+.
|
112
|
-
#
|
113
|
+
#
|
113
114
|
# * Indentation is enabled by providing the number of spaces to
|
114
115
|
# indent for each level as a second argument to XmlBuilder.new.
|
115
116
|
# Initial indentation may be specified using a third parameter.
|
116
117
|
#
|
117
118
|
# Example:
|
118
119
|
#
|
119
|
-
# xm = Builder.new(:
|
120
|
+
# xm = Builder.new(:indent=>2)
|
120
121
|
# # xm will produce nicely formatted and indented XML.
|
121
|
-
#
|
122
|
+
#
|
122
123
|
# xm = Builder.new(:indent=>2, :margin=>4)
|
123
124
|
# # xm will produce nicely formatted and indented XML with 2
|
124
125
|
# # spaces per indent and an over all indentation level of 4.
|
@@ -164,15 +165,15 @@ module Builder
|
|
164
165
|
# :target=><em>target_object</em>::
|
165
166
|
# Object receiving the markup. +out+ must respond to the
|
166
167
|
# <tt><<</tt> operator. The default is a plain string target.
|
167
|
-
#
|
168
|
+
#
|
168
169
|
# :indent=><em>indentation</em>::
|
169
170
|
# Number of spaces used for indentation. The default is no
|
170
171
|
# indentation and no line breaks.
|
171
|
-
#
|
172
|
+
#
|
172
173
|
# :margin=><em>initial_indentation_level</em>::
|
173
174
|
# Amount of initial indentation (specified in levels, not
|
174
175
|
# spaces).
|
175
|
-
#
|
176
|
+
#
|
176
177
|
# :escape_attrs=><b>OBSOLETE</em>::
|
177
178
|
# The :escape_attrs option is no longer supported by builder
|
178
179
|
# (and will be quietly ignored). String attribute values are
|
@@ -180,14 +181,14 @@ module Builder
|
|
180
181
|
# values (perhaps you are using entities in the attribute
|
181
182
|
# values), then give the value as a Symbol. This allows much
|
182
183
|
# finer control over escaping attribute values.
|
183
|
-
#
|
184
|
+
#
|
184
185
|
def initialize(options={})
|
185
186
|
indent = options[:indent] || 0
|
186
187
|
margin = options[:margin] || 0
|
187
188
|
super(indent, margin)
|
188
189
|
@target = options[:target] || ""
|
189
190
|
end
|
190
|
-
|
191
|
+
|
191
192
|
# Return the target of the builder.
|
192
193
|
def target!
|
193
194
|
@target
|
@@ -208,18 +209,18 @@ module Builder
|
|
208
209
|
_indent
|
209
210
|
@target << "<!#{inst}"
|
210
211
|
args.each do |arg|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
212
|
+
case arg
|
213
|
+
when String
|
214
|
+
@target << %{ "#{arg}"} # " WART
|
215
|
+
when Symbol
|
216
|
+
@target << " #{arg}"
|
217
|
+
end
|
217
218
|
end
|
218
219
|
if block_given?
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
220
|
+
@target << " ["
|
221
|
+
_newline
|
222
|
+
_nested_structures(block)
|
223
|
+
@target << "]"
|
223
224
|
end
|
224
225
|
@target << ">"
|
225
226
|
_newline
|
@@ -237,15 +238,15 @@ module Builder
|
|
237
238
|
def instruct!(directive_tag=:xml, attrs={})
|
238
239
|
_ensure_no_block block_given?
|
239
240
|
if directive_tag == :xml
|
240
|
-
|
241
|
-
|
241
|
+
a = { :version=>"1.0", :encoding=>"UTF-8" }
|
242
|
+
attrs = a.merge attrs
|
242
243
|
end
|
243
244
|
_special(
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
245
|
+
"<?#{directive_tag}",
|
246
|
+
"?>",
|
247
|
+
nil,
|
248
|
+
attrs,
|
249
|
+
[:version, :encoding, :standalone])
|
249
250
|
end
|
250
251
|
|
251
252
|
# Insert a CDATA section into the XML markup.
|
@@ -259,7 +260,7 @@ module Builder
|
|
259
260
|
_ensure_no_block block_given?
|
260
261
|
_special("<![CDATA[", "]]>", text, nil)
|
261
262
|
end
|
262
|
-
|
263
|
+
|
263
264
|
private
|
264
265
|
|
265
266
|
# NOTE: All private methods of a builder object are prefixed when
|
@@ -269,8 +270,8 @@ module Builder
|
|
269
270
|
def _text(text)
|
270
271
|
@target << text
|
271
272
|
end
|
272
|
-
|
273
|
-
# Insert special instruction.
|
273
|
+
|
274
|
+
# Insert special instruction.
|
274
275
|
def _special(open, close, data=nil, attrs=nil, order=[])
|
275
276
|
_indent
|
276
277
|
@target << open
|
@@ -288,7 +289,7 @@ module Builder
|
|
288
289
|
@target << "/" if end_too
|
289
290
|
@target << ">"
|
290
291
|
end
|
291
|
-
|
292
|
+
|
292
293
|
# Insert an ending tag.
|
293
294
|
def _end_tag(sym)
|
294
295
|
@target << "</#{sym}>"
|
@@ -298,27 +299,27 @@ module Builder
|
|
298
299
|
def _insert_attributes(attrs, order=[])
|
299
300
|
return if attrs.nil?
|
300
301
|
order.each do |k|
|
301
|
-
|
302
|
-
|
302
|
+
v = attrs[k]
|
303
|
+
@target << %{ #{k}="#{_attr_value(v)}"} if v # " WART
|
303
304
|
end
|
304
305
|
attrs.each do |k, v|
|
305
|
-
|
306
|
+
@target << %{ #{k}="#{_attr_value(v)}"} unless order.member?(k) # " WART
|
306
307
|
end
|
307
308
|
end
|
308
309
|
|
309
310
|
def _attr_value(value)
|
310
311
|
case value
|
311
312
|
when Symbol
|
312
|
-
|
313
|
+
value.to_s
|
313
314
|
else
|
314
|
-
|
315
|
+
_escape_quote(value.to_s)
|
315
316
|
end
|
316
317
|
end
|
317
318
|
|
318
319
|
def _ensure_no_block(got_block)
|
319
320
|
if got_block
|
320
|
-
|
321
|
-
|
321
|
+
fail IllegalBlockError,
|
322
|
+
"Blocks are not allowed on XML instructions"
|
322
323
|
end
|
323
324
|
end
|
324
325
|
|
@@ -11,11 +11,11 @@ require 'stringio'
|
|
11
11
|
class XmlSimple
|
12
12
|
include REXML
|
13
13
|
|
14
|
-
@@VERSION = '1.0.
|
14
|
+
@@VERSION = '1.0.11'
|
15
15
|
|
16
16
|
# A simple cache for XML documents that were already transformed
|
17
17
|
# by xml_in.
|
18
|
-
class Cache
|
18
|
+
class Cache
|
19
19
|
# Creates and initializes a new Cache object.
|
20
20
|
def initialize
|
21
21
|
@mem_share_cache = {}
|
@@ -129,7 +129,7 @@ class XmlSimple
|
|
129
129
|
unless defaults.nil? || defaults.instance_of?(Hash)
|
130
130
|
raise ArgumentError, "Options have to be a Hash."
|
131
131
|
end
|
132
|
-
@default_options = normalize_option_names(defaults, KNOWN_OPTIONS['in']
|
132
|
+
@default_options = normalize_option_names(defaults, (KNOWN_OPTIONS['in'] + KNOWN_OPTIONS['out']).uniq)
|
133
133
|
@options = Hash.new
|
134
134
|
@_var_values = nil
|
135
135
|
end
|