xml-motor 0.1.4 → 0.1.5
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/CHANGELOG +11 -0
- data/README +2 -0
- data/lib/xml-motor/version.rb +1 -1
- data/lib/xml-motor/xml-index-handler.rb +1 -1
- data/lib/xml-motor/xml-motor-engine.rb +21 -6
- metadata +2 -2
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
@@ -7,6 +7,17 @@
|
|
7
7
|
=====================================================================
|
8
8
|
CHANGE-LOG
|
9
9
|
=====================================================================
|
10
|
+
Changes from v0.1.4 to v0.1.5
|
11
|
+
[] Fixed grep for nodes like "<splitline color='green'/>"
|
12
|
+
[] Fetch nodes with ATTRIB_KEY for a/all node by not giving its ATTRIB_VALUE
|
13
|
+
for e.g.
|
14
|
+
nodes_array = XMLMotorEngine.pre_processed_content nodes_, tags_, 'splitline', "ATTRIB_KEY"
|
15
|
+
nodes_array = XMLMotorEngine.pre_processed_content nodes_, tags_, nil, ["ATTRIB_KEY"]
|
16
|
+
[] Fetch nodes with ATTRIB_VALUE for a/all node by not giving its ATTRIB_KEY
|
17
|
+
for e.g. //just append value with '='
|
18
|
+
nodes_array = XMLMotorEngine.pre_processed_content nodes_, tags_, 'splitline', "='ATTRIB_VALUE'"
|
19
|
+
nodes_array = XMLMotorEngine.pre_processed_content nodes_, tags_, nil, ["='ATTRIB_KEY'"]
|
20
|
+
=====================================================================
|
10
21
|
Changes from v0.1.3 to v0.1.4
|
11
22
|
[] Fixed node tree (like x.y.z) parsing for not existing node
|
12
23
|
[] Err/Info messages just shown when env has VERBOSE=''
|
data/README
CHANGED
@@ -34,6 +34,8 @@ An easy-to-use XML Parser without any Native Dependencies.
|
|
34
34
|
nodes_array = XMLMotor.xmldata nodes_, tags_, "_TAG_"
|
35
35
|
nodes_array = XMLMotor.xmldata nodes_, tags_, "_TAG_", "ATTRIB_KEY=ATTRIB_VALUE"
|
36
36
|
nodes_array = XMLMotor.xmldata nodes_, tags_, nil, "ATTRIB_KEY=ATTRIB_VALUE"
|
37
|
+
nodes_array = XMLMotor.xmldata nodes_, tags_, nil, "ATTRIB_KEY"
|
38
|
+
nodes_array = XMLMotor.xmldata nodes_, tags_, nil, "='ATTRIB_VALUE'"
|
37
39
|
>>>>> for having root-node-tag also in returned result <<<<<
|
38
40
|
nodes_array = XMLMotor.xmldata nodes_, tags_, "_TAG_", nil, true
|
39
41
|
nodes_array = XMLMotor.xmldata nodes_, tags_, "_TAG_", "ATTRIB_KEY=ATTRIB_VALUE", true
|
data/lib/xml-motor/version.rb
CHANGED
@@ -2,7 +2,7 @@ module XMLIndexHandler
|
|
2
2
|
def self.get_tag_indexes(xml_motor, tag)
|
3
3
|
xml_idx_to_find = []
|
4
4
|
begin
|
5
|
-
xml_motor.xmltags[tag.split(".")[0]].each_value {|val|
|
5
|
+
xml_motor.xmltags[tag.split(".")[0]].each_value {|val| xml_idx_to_find.push val }
|
6
6
|
xml_idx_to_find = xml_idx_to_find.flatten
|
7
7
|
|
8
8
|
tag.split(".")[1..-1].each do |tag_i|
|
@@ -1,8 +1,17 @@
|
|
1
1
|
module XMLMotorEngine
|
2
2
|
def self._splitter_(xmldata)
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
start_splits = xmldata.split(/</)
|
4
|
+
@xmlnodes = [start_splits[0]]
|
5
|
+
start_splits[1..-1].each do |val|
|
6
|
+
tag_attr = XMLChopper.get_tag_attrib_value(val.gsub('/>','>'))
|
7
|
+
if val.match(/\/>/)
|
8
|
+
post_attr = tag_attr[1]
|
9
|
+
tag_attr[1] = ''
|
10
|
+
@xmlnodes.push tag_attr
|
11
|
+
@xmlnodes.push [["/#{tag_attr[0][0]}", nil], post_attr]
|
12
|
+
else
|
13
|
+
@xmlnodes.push tag_attr
|
14
|
+
end
|
6
15
|
end
|
7
16
|
@xmlnodes
|
8
17
|
end
|
@@ -43,15 +52,21 @@ module XMLMotorEngine
|
|
43
52
|
def self._grab_my_node_ (index_to_find, attrib_to_find=nil, with_tag=false)
|
44
53
|
unless attrib_to_find.nil? or attrib_to_find.empty?
|
45
54
|
attrib_keyval = [attrib_to_find].flatten.collect{|keyval| _get_attrib_key_val_ keyval }
|
55
|
+
attrib_justkey = attrib_keyval.select{|attr| attr[1].empty?}
|
56
|
+
attrib_justval = attrib_keyval.select{|attr| attr[0].empty?}
|
57
|
+
attrib_keyval -= (attrib_justkey + attrib_justval)
|
46
58
|
end
|
47
59
|
nodes = []
|
48
|
-
node_count = index_to_find.size/2 -1
|
60
|
+
node_count = index_to_find.size/2 - 1
|
49
61
|
0.upto node_count do |ncount|
|
50
62
|
node_start = index_to_find[ncount*2]
|
51
63
|
node_stop = index_to_find[ncount*2 +1]
|
52
64
|
unless attrib_to_find.nil? or attrib_to_find.empty?
|
53
|
-
|
54
|
-
|
65
|
+
next if @xmlnodes[node_start][0][1].nil?
|
66
|
+
check_keyval = attrib_keyval.collect{|keyval| @xmlnodes[node_start][0][1][keyval.first] == keyval.last}.include? false
|
67
|
+
check_key = attrib_justkey.collect{|key| @xmlnodes[node_start][0][1][key.first].nil? }.include? true
|
68
|
+
check_val = attrib_justval.collect{|val| @xmlnodes[node_start][0][1].each_value.include? val[1] }.include? false
|
69
|
+
next if check_keyval or check_key or check_val
|
55
70
|
end
|
56
71
|
nodes[ncount] ||= ""
|
57
72
|
nodes[ncount] += @xmlnodes[node_start][1] unless @xmlnodes[node_start][1].nil?
|
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.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-15 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'A new short XML Parsing Algorithm implemented directly in less-than-500
|
15
15
|
lines. An easy-to-use XML Parser without any Native Dependencies. Its under continuous
|