rexle 0.9.83 → 1.0.0
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/rexle.rb +38 -9
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d522697ad86b01ad2c6508a38e3b43ac8a542aee
|
4
|
+
data.tar.gz: e28721a0311ba1b84a4f298aa2d341c068c47c7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b72e9db604f8f7ecfeee7097d1cf4be2cde4f0c7874f0b5193afec8682728da14d99b29c764fc228d72a6556a529b0c18f7b1b2f4783477b75ff3a6350e9743
|
7
|
+
data.tar.gz: 5640b27dbd1636915b3e6ef42e8ff15afef2cc37f19f9a66b3829f7d56d5d8917e6368e4cac3547a2e62e0fa9187a2cb2a1bb32708ebdc786a6357246caf68e2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/rexle.rb
CHANGED
@@ -11,6 +11,9 @@ include REXML
|
|
11
11
|
|
12
12
|
# modifications:
|
13
13
|
|
14
|
+
# modifications:
|
15
|
+
|
16
|
+
# 31-Dec-2013: feature: now supports processing instructions
|
14
17
|
# 18-Dec-2013: feature fix: the result of text() is no longer unescaped
|
15
18
|
# 13-Dec-2013: bug fix: elements with dashes can now be queried
|
16
19
|
# 14-Nov-2013: feature: Implemented method content() to output XML as
|
@@ -63,7 +66,14 @@ module XMLhelper
|
|
63
66
|
|
64
67
|
body = (children.nil? or children.empty? or children.is_an_empty_string? ) ? '' : scan_print(children).join
|
65
68
|
a = self.root.attributes.to_a.map{|k,v| "%s='%s'" % [k,v]}
|
66
|
-
"<%s%s>%s</%s>" % [self.root.name, a.empty? ? '' :
|
69
|
+
xml = "<%s%s>%s</%s>" % [self.root.name, a.empty? ? '' : \
|
70
|
+
' ' + a.join(' '), body, self.root.name]
|
71
|
+
|
72
|
+
if self.instructions then
|
73
|
+
processing_instructions() + xml
|
74
|
+
else
|
75
|
+
xml
|
76
|
+
end
|
67
77
|
end
|
68
78
|
|
69
79
|
def doc_pretty_print(children)
|
@@ -71,7 +81,18 @@ module XMLhelper
|
|
71
81
|
body = pretty_print(children,2).join
|
72
82
|
a = self.root.attributes.to_a.map{|k,v| "%s='%s'" % [k,v]}
|
73
83
|
ind = "\n "
|
74
|
-
"<%s%s>%s%s%s</%s>" % [self.root.name, a.empty? ? '' :
|
84
|
+
xml = "<%s%s>%s%s%s</%s>" % [self.root.name, a.empty? ? '' : \
|
85
|
+
' ' + a.join(' '), ind, body, "\n", self.root.name]
|
86
|
+
|
87
|
+
if self.instructions then
|
88
|
+
processing_instructions("\n") + "\n" + xml
|
89
|
+
else
|
90
|
+
xml
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def processing_instructions(s='')
|
95
|
+
self.instructions.map { |instruction| "<?%s %s?>" % instruction }.join s
|
75
96
|
end
|
76
97
|
|
77
98
|
def scan_print(nodes)
|
@@ -163,7 +184,7 @@ end
|
|
163
184
|
class Rexle
|
164
185
|
include XMLhelper
|
165
186
|
|
166
|
-
attr_reader :prefixes
|
187
|
+
attr_reader :prefixes, :instructions
|
167
188
|
|
168
189
|
def initialize(x=nil)
|
169
190
|
|
@@ -203,7 +224,7 @@ class Rexle
|
|
203
224
|
include XMLhelper
|
204
225
|
|
205
226
|
attr_accessor :name, :value, :parent
|
206
|
-
attr_reader :child_lookup, :child_elements, :doc_id
|
227
|
+
attr_reader :child_lookup, :child_elements, :doc_id, :instructions
|
207
228
|
|
208
229
|
alias original_clone clone
|
209
230
|
|
@@ -588,7 +609,7 @@ class Rexle
|
|
588
609
|
e = self.element(s)
|
589
610
|
result = e.value if e
|
590
611
|
end
|
591
|
-
#
|
612
|
+
#result = CGI.unescape_html result.to_s
|
592
613
|
|
593
614
|
def result.unescape()
|
594
615
|
s = self.clone
|
@@ -888,9 +909,10 @@ class Rexle
|
|
888
909
|
msg = o[:pretty] == false ? :doc_print : :doc_pretty_print
|
889
910
|
|
890
911
|
r = ''
|
891
|
-
r = "<?xml version='1.0' encoding='UTF-8'
|
892
|
-
r <<
|
912
|
+
r = "<?xml version='1.0' encoding='UTF-8'?>" if o[:declaration] == true
|
913
|
+
r << "\n" if o[:pretty] == true
|
893
914
|
|
915
|
+
r << method(msg).call(self.root.children).strip
|
894
916
|
r
|
895
917
|
end
|
896
918
|
|
@@ -917,11 +939,18 @@ class Rexle
|
|
917
939
|
procs[recordx_type].call(x)
|
918
940
|
else
|
919
941
|
|
920
|
-
RexleParser.new(x)
|
942
|
+
rp = RexleParser.new(x)
|
943
|
+
a = rp.to_a
|
944
|
+
@instructions = rp.instructions
|
945
|
+
return a
|
921
946
|
end
|
922
947
|
else
|
923
948
|
|
924
|
-
RexleParser.new(x)
|
949
|
+
rp = RexleParser.new(x)
|
950
|
+
a = rp.to_a
|
951
|
+
@instructions = rp.instructions
|
952
|
+
return a
|
953
|
+
|
925
954
|
end
|
926
955
|
|
927
956
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rexle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
EgghkUCgC30KsgaYheoN5ILHCE52JXCfr1Qto26qUSdC49xWkxnQz2yrSq8z085Q
|
30
30
|
h0bKDk/qqjLsNUnSPxhypj3wTgJNdHKX
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2013-12-
|
32
|
+
date: 2013-12-31 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rexleparser
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
117
|
+
rubygems_version: 2.1.11
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: Rexle is a simple XML parser written purely in Ruby
|
metadata.gz.sig
CHANGED
Binary file
|