xamplr 1.9.11 → 1.9.12

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.
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 9
4
- :patch: 11
4
+ :patch: 12
5
5
  :build:
@@ -44,6 +44,8 @@ module Xampl
44
44
  return prefix
45
45
  end
46
46
 
47
+ =begin
48
+
47
49
  def attr_esc_fast(s)
48
50
  #NOTE -- there are known issues with using Ruby 1.9.1 and libxml-ruby, which this is using. Seems to mostly
49
51
  # be related to DOM and XPATH but...
@@ -57,13 +59,13 @@ module Xampl
57
59
  (@@doc.root.to_s)[6..-4]
58
60
  end
59
61
 
62
+ =end
63
+
60
64
  def attr_esc_slow(s)
61
65
  if (s.kind_of? XamplObject)
62
66
  return attr_esc(s.to_xml)
63
67
  end
64
68
 
65
- # stupid_test()
66
-
67
69
  result = s.to_s.dup
68
70
 
69
71
  result.gsub!("&", "&")
@@ -72,34 +74,54 @@ module Xampl
72
74
  result.gsub!("'", "'")
73
75
  result.gsub!("\"", """)
74
76
 
75
- return result
77
+ return "\"result\""
78
+ end
79
+
80
+ def attr_esc_encoding_safe(s)
81
+ return attr_esc(s.to_xml) if (s.kind_of? XamplObject)
82
+
83
+ begin
84
+ options = {
85
+ :invalid => :replace,
86
+ :undef=>:replace,
87
+ :xml => :attr
88
+ }
89
+ result = s.to_s.dup.encode('UTF-8', 'UTF-8', options)
90
+
91
+ # puts "#{ File.basename __FILE__ }:#{ __LINE__ } [#{__method__}] IN: [[#{ s.to_s }]], OUT: [[#{ result }]]"
92
+
93
+ return result
94
+ rescue => e
95
+ puts "Naughty Programmer! No! Bad!: #{ e } encoding in: #{ s.encoding }, out: #{ result.encoding }"
96
+ puts e.backtrace
97
+ end
98
+
99
+
100
+ return ''
101
+
76
102
  end
77
103
 
78
- alias attr_esc attr_esc_fast
79
-
80
- # def content_esc(s)
81
- # #NO! the attribute has the right to compact white space
82
- # unless defined?(@@doc) then
83
- # @@doc = LibXML::XML::Document.new()
84
- # @@doc.root = LibXML::XML::Node.new('r')
85
- # @@attr = LibXML::XML::Attr.new(@@doc.root, 'v', 'v')
86
- # end
87
- #
88
- # @@attr.value = s
89
- # (@@doc.root.to_s)[6..-4]
90
- # end
91
-
92
- #TODO -- use libxml for this too
104
+ # alias attr_esc attr_esc_fast
105
+ alias attr_esc attr_esc_encoding_safe
106
+
93
107
  def content_esc(s)
94
- result = s.to_s.dup
108
+ return content_esc(s.to_s.dup) if (s.kind_of? XamplObject)
95
109
 
96
- return result if (s.kind_of? XamplObject)
110
+ begin
111
+ options = {
112
+ :invalid => :replace,
113
+ :undef=>:replace,
114
+ :xml => :text
115
+ }
116
+ result = s.to_s.dup.encode('UTF-8', 'UTF-8', options)
97
117
 
98
- result.gsub!("&", "&")
99
- result.gsub!("<", "&lt;")
100
- result.gsub!(">", "&gt;")
118
+ return result
119
+ rescue => e
120
+ puts "Naughty Programmer! No! Bad!: #{ e } encoding in: #{ s.encoding }, out: #{ result.encoding }"
121
+ puts e.backtrace
122
+ end
101
123
 
102
- return result
124
+ return ''
103
125
  end
104
126
 
105
127
  def attribute(xampl)
@@ -117,7 +139,7 @@ module Xampl
117
139
  else
118
140
  value = xampl.instance_variable_get(attr_spec[0])
119
141
  end
120
- @attr_list << (" " << prefix << attr_spec[1] << '="' << attr_esc(value) << '"') unless nil == value
142
+ @attr_list << (" " << prefix << attr_spec[1] << '=' << attr_esc(value)) unless nil == value
121
143
  end
122
144
  end
123
145
  end
@@ -132,7 +154,7 @@ module Xampl
132
154
  value = @pid_substitutions[xampl]
133
155
  # puts "#{ File.basename __FILE__ }:#{ __LINE__ } [#{__method__}] xampl: #{ xampl }, substitute: #{ value }" if value
134
156
  value = xampl.instance_variable_get(attr_spec[0]) unless value
135
- @attr_list << (" " << prefix << attr_spec[1] << '="' << attr_esc(value) << '"') unless nil == value
157
+ @attr_list << (" " << prefix << attr_spec[1] << '=' << attr_esc(value)) unless nil == value
136
158
  break
137
159
  end
138
160
  end
@@ -33,7 +33,7 @@ module Xampl
33
33
  else
34
34
  rmsg = "either not actually a TokyoCabinet Error, or @tc_db was never opened"
35
35
  end
36
- STDERR.puts "NOTE: TokyoCabinet Error!"
36
+ STDERR.puts "NOTE: TokyoCabinet Error at #{ Time.now }!"
37
37
  STDERR.puts(rmsg)
38
38
  STDERR.puts "---------"
39
39
  STDERR.puts caller(0)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{xamplr}
8
- s.version = "1.9.11"
8
+ s.version = "1.9.12"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bob Hutchison"]
12
- s.date = %q{2010-04-26}
12
+ s.date = %q{2010-05-19}
13
13
  s.description = %q{xamplr is the ruby version of xampl.}
14
14
  s.email = %q{hutch@recursive.ca}
15
15
  s.extra_rdoc_files = [
@@ -115,14 +115,14 @@ Gem::Specification.new do |s|
115
115
  s.homepage = %q{http://github.com/hutch/xamplr}
116
116
  s.rdoc_options = ["--charset=UTF-8"]
117
117
  s.require_paths = ["lib"]
118
- s.rubygems_version = %q{1.3.6}
118
+ s.rubygems_version = %q{1.3.7}
119
119
  s.summary = %q{xamplr is the ruby version of xampl}
120
120
 
121
121
  if s.respond_to? :specification_version then
122
122
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
123
123
  s.specification_version = 3
124
124
 
125
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
125
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
126
126
  s.add_runtime_dependency(%q<xamplr-pp>, [">= 1.2.0"])
127
127
  s.add_runtime_dependency(%q<libxml-ruby>, [">= 1.1.3"])
128
128
  else
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xamplr
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 43
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 9
8
- - 11
9
- version: 1.9.11
9
+ - 12
10
+ version: 1.9.12
10
11
  platform: ruby
11
12
  authors:
12
13
  - Bob Hutchison
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-04-26 00:00:00 -04:00
18
+ date: 2010-05-19 00:00:00 -04:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: xamplr-pp
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 31
27
30
  segments:
28
31
  - 1
29
32
  - 2
@@ -35,9 +38,11 @@ dependencies:
35
38
  name: libxml-ruby
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 21
41
46
  segments:
42
47
  - 1
43
48
  - 1
@@ -159,23 +164,27 @@ rdoc_options:
159
164
  require_paths:
160
165
  - lib
161
166
  required_ruby_version: !ruby/object:Gem::Requirement
167
+ none: false
162
168
  requirements:
163
169
  - - ">="
164
170
  - !ruby/object:Gem::Version
171
+ hash: 3
165
172
  segments:
166
173
  - 0
167
174
  version: "0"
168
175
  required_rubygems_version: !ruby/object:Gem::Requirement
176
+ none: false
169
177
  requirements:
170
178
  - - ">="
171
179
  - !ruby/object:Gem::Version
180
+ hash: 3
172
181
  segments:
173
182
  - 0
174
183
  version: "0"
175
184
  requirements: []
176
185
 
177
186
  rubyforge_project:
178
- rubygems_version: 1.3.6
187
+ rubygems_version: 1.3.7
179
188
  signing_key:
180
189
  specification_version: 3
181
190
  summary: xamplr is the ruby version of xampl