xml-motor 0.1.1 → 0.1.2
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.
- data/.gitignore +2 -0
- data/lib/xml-motor.rb +5 -216
- data/lib/xml-motor/version.rb +2 -4
- data/lib/xml-motor/xml-chopper.rb +30 -0
- data/lib/xml-motor/xml-index-handler.rb +40 -0
- data/lib/xml-motor/xml-joiner.rb +15 -0
- data/lib/xml-motor/xml-motor-engine.rb +114 -0
- data/lib/xml-motor/xml-stdout.rb +4 -0
- data/lib/xml-motor/xml-utils.rb +10 -0
- data/xml-motor.gemspec +32 -29
- metadata +27 -19
data/.gitignore
ADDED
data/lib/xml-motor.rb
CHANGED
@@ -1,221 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
module XMLUtils
|
9
|
-
def self.dbqot_string(attrib_val)
|
10
|
-
return nil if attrib_val.nil?
|
11
|
-
matched_data = attrib_val.strip.match(/^'(.*)'$/)
|
12
|
-
return attrib_val if matched_data.nil?
|
13
|
-
matched_data = matched_data[0].gsub("\"","'")
|
14
|
-
matched_data[0] = matched_data[-1] = "\""
|
15
|
-
matched_data
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
module XMLIndexHandler
|
20
|
-
def self.get_tag_indexes(xml_motor, tag)
|
21
|
-
xml_idx_to_find = []
|
22
|
-
begin
|
23
|
-
xml_motor.xmltags[tag.split(".")[0]].each_value {|val| xml_idx_to_find.push val }
|
24
|
-
xml_idx_to_find = xml_idx_to_find.flatten
|
25
|
-
|
26
|
-
tag.split(".")[1..-1].each do |tag_i|
|
27
|
-
outer_idx = xml_idx_to_find
|
28
|
-
x_curr = []
|
29
|
-
xml_motor.xmltags[tag_i].each_value {|val| x_curr.push val }
|
30
|
-
x_curr = x_curr.flatten
|
31
|
-
|
32
|
-
xml_idx_to_find = expand_node_indexes outer_idx, x_curr
|
33
|
-
end
|
34
|
-
rescue
|
35
|
-
XMLStdout._err "Finding index for tag:#{tag}.\nLook if it's actually present in the provided XML."
|
36
|
-
end
|
37
|
-
xml_idx_to_find
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.expand_node_indexes(outer_idx, x_curr)
|
41
|
-
osize = outer_idx.size/2 -1
|
42
|
-
xsize = x_curr.size/2 -1
|
43
|
-
expanded_node_indexes = []
|
44
|
-
0.upto osize do |o|
|
45
|
-
o1 = outer_idx[o*2]
|
46
|
-
o2 = outer_idx[o*2 +1]
|
47
|
-
0.upto xsize do |x|
|
48
|
-
x1 = x_curr[x*2]
|
49
|
-
x2 = x_curr[x*2 +1]
|
50
|
-
unless o1>x1 or o2<x2
|
51
|
-
expanded_node_indexes.push x1
|
52
|
-
expanded_node_indexes.push x2
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
expanded_node_indexes.flatten
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
module XMLChopper
|
61
|
-
def self.get_tag_attrib_value(tag_value)
|
62
|
-
tag_value_split = tag_value.split(/>/)
|
63
|
-
in_tag = tag_value_split.first
|
64
|
-
out_tag = tag_value_split[1..-1].join
|
65
|
-
in_tag_split = in_tag.split
|
66
|
-
tag_name = in_tag_split.first
|
67
|
-
attribzone = in_tag_split[1..-1].flatten.join(' ')
|
68
|
-
attrs = get_attribute_hash attribzone
|
69
|
-
[[tag_name.downcase, attrs],out_tag]
|
70
|
-
end
|
71
|
-
|
72
|
-
def self.get_attribute_hash(attribzone)
|
73
|
-
attribzone = attribzone.strip unless attribzone.nil?
|
74
|
-
return nil if attribzone.nil? or attribzone==""
|
75
|
-
attrs = {}
|
76
|
-
broken_attrib = attribzone.split(/=/)
|
77
|
-
attribs = broken_attrib.first.strip
|
78
|
-
values = nil
|
79
|
-
broken_attrib[1..-2].each do |attrib_part|
|
80
|
-
value_n_attrib = attrib_part.split
|
81
|
-
values = value_n_attrib[0..-2].join(' ')
|
82
|
-
attrs[attribs] = XMLUtils.dbqot_string values
|
83
|
-
attribs = value_n_attrib[-1].strip
|
84
|
-
end
|
85
|
-
values = broken_attrib.last.strip
|
86
|
-
attrs[attribs] = XMLUtils.dbqot_string values
|
87
|
-
attrs
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
module XMLJoiner
|
92
|
-
def self.dejavu_attributes(attrib_hash)
|
93
|
-
return nil if attrib_hash.nil?
|
94
|
-
attributes = ""
|
95
|
-
attrib_hash.each_key do |hash_key|
|
96
|
-
attributes += " " + hash_key + "=" + attrib_hash[hash_key]
|
97
|
-
end
|
98
|
-
attributes
|
99
|
-
end
|
100
|
-
|
101
|
-
def self.dejavu_node(node_block)
|
102
|
-
return nil if node_block.nil?
|
103
|
-
["<#{node_block.first}#{dejavu_attributes(node_block.last)}>", "</#{node_block.first}>"]
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
module XMLMotorEngine
|
108
|
-
def self._splitter_(xmldata)
|
109
|
-
@xmlnodes = [xmldata.split(/</)[0]]
|
110
|
-
xmldata.split(/</)[1..-1].each do |x1|
|
111
|
-
@xmlnodes.push XMLChopper.get_tag_attrib_value(x1)
|
112
|
-
end
|
113
|
-
@xmlnodes
|
114
|
-
end
|
115
|
-
|
116
|
-
def self._indexify_(_nodes=nil)
|
117
|
-
xmlnodes _nodes unless _nodes.nil?
|
118
|
-
@xmltags = {}
|
119
|
-
idx = 1
|
120
|
-
depth = 0
|
121
|
-
@xmlnodes[1..-1].each do |xnode|
|
122
|
-
tag_name = xnode[0][0].strip.downcase
|
123
|
-
unless tag_name.match(/^\/.*/) then
|
124
|
-
@xmltags[tag_name] ||= {}
|
125
|
-
@xmltags[tag_name][depth] ||= []
|
126
|
-
@xmltags[tag_name][depth].push idx
|
127
|
-
depth += 1
|
128
|
-
else
|
129
|
-
depth -= 1
|
130
|
-
@xmltags[tag_name[1..-1]][depth] ||= []
|
131
|
-
@xmltags[tag_name[1..-1]][depth].push idx
|
132
|
-
end
|
133
|
-
idx +=1
|
134
|
-
end
|
135
|
-
@xmltags
|
136
|
-
end
|
137
|
-
|
138
|
-
def self._get_attrib_key_val_ (attrib)
|
139
|
-
attrib_key = attrib.split(/=/)[0].strip
|
140
|
-
attrib_val = attrib.split(/=/)[1..-1].join.strip
|
141
|
-
[attrib_key, XMLUtils.dbqot_string(attrib_val)]
|
142
|
-
end
|
143
|
-
|
144
|
-
def self._grab_my_node_ (index_to_find, attrib_to_find=nil, with_tag=false)
|
145
|
-
unless attrib_to_find.nil? or attrib_to_find.empty?
|
146
|
-
attrib_keyval = [attrib_to_find].flatten.collect{|keyval| _get_attrib_key_val_ keyval }
|
147
|
-
end
|
148
|
-
nodes = []
|
149
|
-
node_count = index_to_find.size/2 -1
|
150
|
-
0.upto node_count do |ncount|
|
151
|
-
node_start = index_to_find[ncount*2]
|
152
|
-
node_stop = index_to_find[ncount*2 +1]
|
153
|
-
unless attrib_to_find.nil? or attrib_to_find.empty?
|
154
|
-
next if @xmlnodes[node_start][0][1].nil?
|
155
|
-
next if attrib_keyval.collect{|keyval| @xmlnodes[node_start][0][1][keyval.first] == keyval.last}.include? false
|
156
|
-
end
|
157
|
-
nodes[ncount] ||= ""
|
158
|
-
nodes[ncount] += @xmlnodes[node_start][1] unless @xmlnodes[node_start][1].nil?
|
159
|
-
(node_start+1).upto (node_stop-1) do |node_idx|
|
160
|
-
any_attrib ||= ""
|
161
|
-
any_attrib = XMLJoiner.dejavu_attributes(@xmlnodes[node_idx][0][1]).to_s unless @xmlnodes[node_idx][0][1].nil?
|
162
|
-
nodes[ncount] += "<" + @xmlnodes[node_idx][0][0] + any_attrib + ">"
|
163
|
-
nodes[ncount] += @xmlnodes[node_idx][1] unless @xmlnodes[node_idx][1].nil?
|
164
|
-
end
|
165
|
-
if with_tag
|
166
|
-
tagifyd = XMLJoiner.dejavu_node @xmlnodes[node_start][0]
|
167
|
-
nodes[ncount] = tagifyd.first + nodes[ncount] + tagifyd.last
|
168
|
-
end
|
169
|
-
end
|
170
|
-
nodes.delete(nil) unless attrib_to_find.nil?
|
171
|
-
nodes
|
172
|
-
end
|
173
|
-
|
174
|
-
def self.xml_extracter(tag_to_find=nil, attrib_to_find=nil, with_tag=false)
|
175
|
-
index_to_find = []
|
176
|
-
if attrib_to_find.nil? and tag_to_find.nil?
|
177
|
-
return nil
|
178
|
-
elsif tag_to_find.nil?
|
179
|
-
index_to_find = @xmltags.collect {|xtag| xtag[1].collect {|val| val[1] }}.flatten
|
180
|
-
else
|
181
|
-
index_to_find = XMLIndexHandler.get_tag_indexes self, tag_to_find.downcase
|
182
|
-
end
|
183
|
-
_grab_my_node_ index_to_find, attrib_to_find, with_tag
|
184
|
-
end
|
185
|
-
|
186
|
-
def self.xml_miner(xmldata, tag_to_find=nil, attrib_to_find=nil, with_tag=false)
|
187
|
-
return nil if xmldata.nil?
|
188
|
-
_splitter_ xmldata
|
189
|
-
_indexify_
|
190
|
-
xml_extracter tag_to_find, attrib_to_find, with_tag
|
191
|
-
end
|
192
|
-
|
193
|
-
def self.xmlnodes(xml_nodes=nil)
|
194
|
-
@xmlnodes = xml_nodes || @xmlnodes
|
195
|
-
end
|
196
|
-
|
197
|
-
def self.xmltags(xml_tags=nil)
|
198
|
-
@xmltags = xml_tags || @xmltags
|
199
|
-
end
|
200
|
-
|
201
|
-
def self.pre_processed_content(_nodes, _tags=nil, tag_to_find=nil, attrib_to_find=nil, with_tag=false)
|
202
|
-
begin
|
203
|
-
xmlnodes _nodes
|
204
|
-
unless _tags.nil?
|
205
|
-
xmltags _tags
|
206
|
-
else
|
207
|
-
_indexify_
|
208
|
-
end
|
209
|
-
return xml_extracter tag_to_find, attrib_to_find, with_tag
|
210
|
-
rescue
|
211
|
-
XMLStdout._err "Parsing processed XML Nodes."
|
212
|
-
end
|
213
|
-
return nil
|
214
|
-
end
|
2
|
+
#
|
3
|
+
# XMLMotor_EXECUTIONER ;)
|
4
|
+
xml_motor_libs = File.join(File.dirname(File.expand_path __FILE__), 'xml-motor', '*.rb')
|
5
|
+
Dir.glob(xml_motor_libs).each do |lib|
|
6
|
+
require lib
|
215
7
|
end
|
216
8
|
|
217
|
-
##
|
218
|
-
# XMLMotor_EXECUTIONER ;)
|
219
9
|
|
220
10
|
module XMLMotor
|
221
11
|
def self.get_node_from_file(file, my_tag=nil, my_attrib=nil, with_tag=false)
|
@@ -246,4 +36,3 @@ module XMLMotor
|
|
246
36
|
XMLMotorEngine.pre_processed_content nodes, tags, tag_to_find, attrib_to_find, with_tag
|
247
37
|
end
|
248
38
|
end
|
249
|
-
|
data/lib/xml-motor/version.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
module XMLChopper
|
2
|
+
def self.get_tag_attrib_value(tag_value)
|
3
|
+
tag_value_split = tag_value.split(/>/)
|
4
|
+
in_tag = tag_value_split.first
|
5
|
+
out_tag = tag_value_split[1..-1].join
|
6
|
+
in_tag_split = in_tag.split
|
7
|
+
tag_name = in_tag_split.first
|
8
|
+
attribzone = in_tag_split[1..-1].flatten.join(' ')
|
9
|
+
attrs = get_attribute_hash attribzone
|
10
|
+
[[tag_name.downcase, attrs],out_tag]
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.get_attribute_hash(attribzone)
|
14
|
+
attribzone = attribzone.strip unless attribzone.nil?
|
15
|
+
return nil if attribzone.nil? or attribzone==""
|
16
|
+
attrs = {}
|
17
|
+
broken_attrib = attribzone.split(/=/)
|
18
|
+
attribs = broken_attrib.first.strip
|
19
|
+
values = nil
|
20
|
+
broken_attrib[1..-2].each do |attrib_part|
|
21
|
+
value_n_attrib = attrib_part.split
|
22
|
+
values = value_n_attrib[0..-2].join(' ')
|
23
|
+
attrs[attribs] = XMLUtils.dbqot_string values
|
24
|
+
attribs = value_n_attrib[-1].strip
|
25
|
+
end
|
26
|
+
values = broken_attrib.last.strip
|
27
|
+
attrs[attribs] = XMLUtils.dbqot_string values
|
28
|
+
attrs
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module XMLIndexHandler
|
2
|
+
def self.get_tag_indexes(xml_motor, tag)
|
3
|
+
xml_idx_to_find = []
|
4
|
+
begin
|
5
|
+
xml_motor.xmltags[tag.split(".")[0]].each_value {|val| xml_idx_to_find.push val }
|
6
|
+
xml_idx_to_find = xml_idx_to_find.flatten
|
7
|
+
|
8
|
+
tag.split(".")[1..-1].each do |tag_i|
|
9
|
+
outer_idx = xml_idx_to_find
|
10
|
+
x_curr = []
|
11
|
+
xml_motor.xmltags[tag_i].each_value {|val| x_curr.push val }
|
12
|
+
x_curr = x_curr.flatten
|
13
|
+
|
14
|
+
xml_idx_to_find = expand_node_indexes outer_idx, x_curr
|
15
|
+
end
|
16
|
+
rescue
|
17
|
+
XMLStdout._err "Finding index for tag:#{tag}.\nLook if it's actually present in the provided XML."
|
18
|
+
end
|
19
|
+
xml_idx_to_find
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.expand_node_indexes(outer_idx, x_curr)
|
23
|
+
osize = outer_idx.size/2 -1
|
24
|
+
xsize = x_curr.size/2 -1
|
25
|
+
expanded_node_indexes = []
|
26
|
+
0.upto osize do |o|
|
27
|
+
o1 = outer_idx[o*2]
|
28
|
+
o2 = outer_idx[o*2 +1]
|
29
|
+
0.upto xsize do |x|
|
30
|
+
x1 = x_curr[x*2]
|
31
|
+
x2 = x_curr[x*2 +1]
|
32
|
+
unless o1>x1 or o2<x2
|
33
|
+
expanded_node_indexes.push x1
|
34
|
+
expanded_node_indexes.push x2
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
expanded_node_indexes.flatten
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module XMLJoiner
|
2
|
+
def self.dejavu_attributes(attrib_hash)
|
3
|
+
return nil if attrib_hash.nil?
|
4
|
+
attributes = ""
|
5
|
+
attrib_hash.each_key do |hash_key|
|
6
|
+
attributes += " " + hash_key + "=" + attrib_hash[hash_key]
|
7
|
+
end
|
8
|
+
attributes
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.dejavu_node(node_block)
|
12
|
+
return nil if node_block.nil?
|
13
|
+
["<#{node_block.first}#{dejavu_attributes(node_block.last)}>", "</#{node_block.first}>"]
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
module XMLMotorEngine
|
2
|
+
def self._splitter_(xmldata)
|
3
|
+
@xmlnodes = [xmldata.split(/</)[0]]
|
4
|
+
xmldata.split(/</)[1..-1].each do |x1|
|
5
|
+
@xmlnodes.push XMLChopper.get_tag_attrib_value(x1)
|
6
|
+
end
|
7
|
+
@xmlnodes
|
8
|
+
end
|
9
|
+
|
10
|
+
def self._indexify_(_nodes=nil)
|
11
|
+
xmlnodes _nodes unless _nodes.nil?
|
12
|
+
@xmltags = {}
|
13
|
+
idx = 1
|
14
|
+
depth = 0
|
15
|
+
@xmlnodes[1..-1].each do |xnode|
|
16
|
+
tag_name = xnode[0][0].strip.downcase
|
17
|
+
if tag_name.match(/^\/.*/) then
|
18
|
+
depth -= 1
|
19
|
+
@xmltags[tag_name[1..-1]][depth] ||= []
|
20
|
+
@xmltags[tag_name[1..-1]][depth].push idx
|
21
|
+
elsif tag_name.chomp.match(/^\/$/) then
|
22
|
+
@xmltags[tag_name] ||= {}
|
23
|
+
@xmltags[tag_name][depth] ||= []
|
24
|
+
@xmltags[tag_name][depth].push idx
|
25
|
+
@xmltags[tag_name][depth].push idx
|
26
|
+
else
|
27
|
+
@xmltags[tag_name] ||= {}
|
28
|
+
@xmltags[tag_name][depth] ||= []
|
29
|
+
@xmltags[tag_name][depth].push idx
|
30
|
+
depth += 1
|
31
|
+
end
|
32
|
+
idx +=1
|
33
|
+
end
|
34
|
+
@xmltags
|
35
|
+
end
|
36
|
+
|
37
|
+
def self._get_attrib_key_val_ (attrib)
|
38
|
+
attrib_key = attrib.split(/=/)[0].strip
|
39
|
+
attrib_val = attrib.split(/=/)[1..-1].join.strip
|
40
|
+
[attrib_key, XMLUtils.dbqot_string(attrib_val)]
|
41
|
+
end
|
42
|
+
|
43
|
+
def self._grab_my_node_ (index_to_find, attrib_to_find=nil, with_tag=false)
|
44
|
+
unless attrib_to_find.nil? or attrib_to_find.empty?
|
45
|
+
attrib_keyval = [attrib_to_find].flatten.collect{|keyval| _get_attrib_key_val_ keyval }
|
46
|
+
end
|
47
|
+
nodes = []
|
48
|
+
node_count = index_to_find.size/2 -1
|
49
|
+
0.upto node_count do |ncount|
|
50
|
+
node_start = index_to_find[ncount*2]
|
51
|
+
node_stop = index_to_find[ncount*2 +1]
|
52
|
+
unless attrib_to_find.nil? or attrib_to_find.empty?
|
53
|
+
next if @xmlnodes[node_start][0][1].nil?
|
54
|
+
next if attrib_keyval.collect{|keyval| @xmlnodes[node_start][0][1][keyval.first] == keyval.last}.include? false
|
55
|
+
end
|
56
|
+
nodes[ncount] ||= ""
|
57
|
+
nodes[ncount] += @xmlnodes[node_start][1] unless @xmlnodes[node_start][1].nil?
|
58
|
+
(node_start+1).upto (node_stop-1) do |node_idx|
|
59
|
+
any_attrib ||= ""
|
60
|
+
any_attrib = XMLJoiner.dejavu_attributes(@xmlnodes[node_idx][0][1]).to_s unless @xmlnodes[node_idx][0][1].nil?
|
61
|
+
nodes[ncount] += "<" + @xmlnodes[node_idx][0][0] + any_attrib + ">"
|
62
|
+
nodes[ncount] += @xmlnodes[node_idx][1] unless @xmlnodes[node_idx][1].nil?
|
63
|
+
end
|
64
|
+
if with_tag
|
65
|
+
tagifyd = XMLJoiner.dejavu_node @xmlnodes[node_start][0]
|
66
|
+
nodes[ncount] = tagifyd.first + nodes[ncount] + tagifyd.last
|
67
|
+
end
|
68
|
+
end
|
69
|
+
nodes.delete(nil) unless attrib_to_find.nil?
|
70
|
+
nodes
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.xml_extracter(tag_to_find=nil, attrib_to_find=nil, with_tag=false)
|
74
|
+
index_to_find = []
|
75
|
+
if attrib_to_find.nil? and tag_to_find.nil?
|
76
|
+
return nil
|
77
|
+
elsif tag_to_find.nil?
|
78
|
+
index_to_find = @xmltags.collect {|xtag| xtag[1].collect {|val| val[1] }}.flatten
|
79
|
+
else
|
80
|
+
index_to_find = XMLIndexHandler.get_tag_indexes self, tag_to_find.downcase
|
81
|
+
end
|
82
|
+
_grab_my_node_ index_to_find, attrib_to_find, with_tag
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.xml_miner(xmldata, tag_to_find=nil, attrib_to_find=nil, with_tag=false)
|
86
|
+
return nil if xmldata.nil?
|
87
|
+
_splitter_ xmldata
|
88
|
+
_indexify_
|
89
|
+
xml_extracter tag_to_find, attrib_to_find, with_tag
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.xmlnodes(xml_nodes=nil)
|
93
|
+
@xmlnodes = xml_nodes || @xmlnodes
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.xmltags(xml_tags=nil)
|
97
|
+
@xmltags = xml_tags || @xmltags
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.pre_processed_content(_nodes, _tags=nil, tag_to_find=nil, attrib_to_find=nil, with_tag=false)
|
101
|
+
begin
|
102
|
+
xmlnodes _nodes
|
103
|
+
unless _tags.nil?
|
104
|
+
xmltags _tags
|
105
|
+
else
|
106
|
+
_indexify_
|
107
|
+
end
|
108
|
+
return xml_extracter tag_to_find, attrib_to_find, with_tag
|
109
|
+
rescue
|
110
|
+
XMLStdout._err "Parsing processed XML Nodes."
|
111
|
+
end
|
112
|
+
return nil
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module XMLUtils
|
2
|
+
def self.dbqot_string(attrib_val)
|
3
|
+
return nil if attrib_val.nil?
|
4
|
+
matched_data = attrib_val.strip.match(/^'(.*)'$/)
|
5
|
+
return attrib_val if matched_data.nil?
|
6
|
+
matched_data = matched_data[0].gsub("\"","'")
|
7
|
+
matched_data[0] = matched_data[-1] = "\""
|
8
|
+
matched_data
|
9
|
+
end
|
10
|
+
end
|
data/xml-motor.gemspec
CHANGED
@@ -4,39 +4,42 @@ require "xml-motor/version"
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "xml-motor"
|
7
|
-
s.version =
|
7
|
+
s.version = XmlMotor::VERSION
|
8
8
|
s.authors = ["abhishekkr"]
|
9
9
|
s.email = ["abhikumar163@gmail.com"]
|
10
10
|
s.homepage = "http://github.com/abhishekkr/rubygem_xml_motor"
|
11
11
|
s.summary = %q{An easy-to-use XML Parser without any Native Dependencies}
|
12
|
-
s.description = %q{
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
12
|
+
s.description = %q{=begin
|
13
|
+
== A new short XML Parsing Algorithm implemented directly in >500 lines. An easy-to-use XML Parser without any Native Dependencies.
|
14
|
+
|
15
|
+
= [How To Use]:
|
16
|
+
* http://justfewtuts.blogspot.in/2012/03/xml-motor-what-it-is-how-why-should-you.html
|
17
|
+
|
18
|
+
== Loading:
|
19
|
+
* $ gem install xml-motor
|
20
|
+
* 'require' the 'xml-motor'
|
21
|
+
|
22
|
+
= Usage:
|
23
|
+
== [[ To Search Just One QUERY ]]
|
24
|
+
* nodes_array = XMLMotor.get_node_from_file "_XML_FILE_"
|
25
|
+
* nodes_array = XMLMotor.get_node_from_file "_XML_FILE_", "ATTRIB_KEY=ATTRIB_VALUE"
|
26
|
+
* nodes_array = XMLMotor.get_node_from_content "_XML_DATA_"
|
27
|
+
* nodes_array = XMLMotor.get_node_from_content "_XML_DATA_", "ATTRIB_KEY=ATTRIB_VALUE"
|
28
|
+
== [[ To Search More Than One QUERIES ]]
|
29
|
+
* str = {XML_DATA}
|
30
|
+
* nodes_ = XMLMotor.splitter str
|
31
|
+
* tags_ = XMLMotor.indexify nodes_
|
32
|
+
* nodes_array = XMLMotor.xmldata nodes_, tags_, "_TAG_"
|
33
|
+
* nodes_array = XMLMotor.xmldata nodes_, tags_, "_TAG_", "ATTRIB_KEY=ATTRIB_VALUE"
|
34
|
+
|
35
|
+
= Example Calls As Code:
|
36
|
+
* XMLMotor.get_node_from_content "<A>a</A><B><A>ba</A></B>", "A"
|
37
|
+
-- RETURNS: ["a", "ba"]
|
38
|
+
* XMLMotor.get_node_from_content "<A>a</A><B><A>ba</A></B>", "B.A"
|
39
|
+
-- RETURNS: ["ba"]
|
40
|
+
* XMLMotor.get_node_from_content "<A i='1'>a</A><B><A i='2'>ba</A></B>", "A", "i='1'"
|
41
|
+
-- RETURNS: ["a"]
|
42
|
+
=end
|
40
43
|
}
|
41
44
|
|
42
45
|
s.rubyforge_project = "xml-motor"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xml-motor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,37 +9,45 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-12 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description: ! "A new short XML Parsing Algorithm implemented directly
|
15
|
-
An easy-to-use XML Parser without any Native Dependencies.\n
|
16
|
-
To Use]:
|
17
|
-
\ Loading:\n
|
18
|
-
\ Usage:\n
|
19
|
-
= XMLMotor.get_node_from_file \"_XML_FILE_\"\n
|
20
|
-
\"_XML_FILE_\", \"ATTRIB_KEY=ATTRIB_VALUE\"\n
|
21
|
-
\
|
22
|
-
\"ATTRIB_KEY=ATTRIB_VALUE\"\n
|
23
|
-
\
|
24
|
-
= XMLMotor.
|
25
|
-
|
26
|
-
\"ATTRIB_KEY=ATTRIB_VALUE\"\n\n
|
27
|
-
\"<A>a</A><B><A>ba</A></B>\",
|
28
|
-
|
29
|
-
|
30
|
-
\"A
|
14
|
+
description: ! "=begin\n == A new short XML Parsing Algorithm implemented directly
|
15
|
+
in >500 lines. An easy-to-use XML Parser without any Native Dependencies.\n\n =
|
16
|
+
[How To Use]: \n * http://justfewtuts.blogspot.in/2012/03/xml-motor-what-it-is-how-why-should-you.html
|
17
|
+
\n\n == Loading:\n * $ gem install xml-motor\n * 'require'
|
18
|
+
the 'xml-motor'\n\n = Usage:\n == [[ To Search Just One QUERY ]]\n
|
19
|
+
\ * nodes_array = XMLMotor.get_node_from_file \"_XML_FILE_\"\n *
|
20
|
+
\ nodes_array = XMLMotor.get_node_from_file \"_XML_FILE_\", \"ATTRIB_KEY=ATTRIB_VALUE\"\n
|
21
|
+
\ * nodes_array = XMLMotor.get_node_from_content \"_XML_DATA_\"\n *
|
22
|
+
\ nodes_array = XMLMotor.get_node_from_content \"_XML_DATA_\", \"ATTRIB_KEY=ATTRIB_VALUE\"\n
|
23
|
+
\ == [[ To Search More Than One QUERIES ]]\n * str = {XML_DATA}\n
|
24
|
+
\ * nodes_ = XMLMotor.splitter str\n * tags_ = XMLMotor.indexify
|
25
|
+
nodes_\n * nodes_array = XMLMotor.xmldata nodes_, tags_, \"_TAG_\"\n
|
26
|
+
\ * nodes_array = XMLMotor.xmldata nodes_, tags_, \"_TAG_\", \"ATTRIB_KEY=ATTRIB_VALUE\"\n\n
|
27
|
+
\ = Example Calls As Code:\n * XMLMotor.get_node_from_content \"<A>a</A><B><A>ba</A></B>\",
|
28
|
+
\"A\"\n -- RETURNS: [\"a\", \"ba\"]\n * XMLMotor.get_node_from_content
|
29
|
+
\"<A>a</A><B><A>ba</A></B>\", \"B.A\"\n -- RETURNS: [\"ba\"]\n *
|
30
|
+
XMLMotor.get_node_from_content \"<A i='1'>a</A><B><A i='2'>ba</A></B>\", \"A\",
|
31
|
+
\"i='1'\"\n -- RETURNS: [\"a\"]\n=end\n "
|
31
32
|
email:
|
32
33
|
- abhikumar163@gmail.com
|
33
34
|
executables: []
|
34
35
|
extensions: []
|
35
36
|
extra_rdoc_files: []
|
36
37
|
files:
|
38
|
+
- .gitignore
|
37
39
|
- CHANGELOG
|
38
40
|
- Gemfile
|
39
41
|
- README
|
40
42
|
- Rakefile
|
41
43
|
- lib/xml-motor.rb
|
42
44
|
- lib/xml-motor/version.rb
|
45
|
+
- lib/xml-motor/xml-chopper.rb
|
46
|
+
- lib/xml-motor/xml-index-handler.rb
|
47
|
+
- lib/xml-motor/xml-joiner.rb
|
48
|
+
- lib/xml-motor/xml-motor-engine.rb
|
49
|
+
- lib/xml-motor/xml-stdout.rb
|
50
|
+
- lib/xml-motor/xml-utils.rb
|
43
51
|
- make_my_gem.sh
|
44
52
|
- xml-motor.gemspec
|
45
53
|
homepage: http://github.com/abhishekkr/rubygem_xml_motor
|