dataisland 0.1.3 → 0.1.4
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/lib/dataisland.rb +40 -9
- metadata +2 -2
data/lib/dataisland.rb
CHANGED
@@ -24,12 +24,12 @@ class DataIsland
|
|
24
24
|
|
25
25
|
h = @html_doc.element('//object').attributes
|
26
26
|
|
27
|
-
|
28
27
|
path = { url: -> {File.dirname(location)},
|
29
28
|
file: -> {File.expand_path(File.dirname(location))},
|
30
29
|
xml: -> {File.expand_path('.')}}
|
31
30
|
|
32
31
|
@location = path[typex].call
|
32
|
+
|
33
33
|
@html_doc.xpath("//object[@type='text/xml']").each do |x|
|
34
34
|
|
35
35
|
h = x.attributes
|
@@ -51,7 +51,6 @@ class DataIsland
|
|
51
51
|
dynarex.flat_records.reverse : dynarex.flat_records
|
52
52
|
|
53
53
|
xpath = "//*[@datasrc='" + '#' + h[:id] + "']"
|
54
|
-
|
55
54
|
@html_doc.xpath(xpath).each do |island|
|
56
55
|
render(records, x.attributes, island.element('//*[@datafld]'));
|
57
56
|
end
|
@@ -96,7 +95,7 @@ class DataIsland
|
|
96
95
|
Range.new(0,rpp - 1)
|
97
96
|
end
|
98
97
|
|
99
|
-
records = range ? flat_records[range] : flat_records
|
98
|
+
records = range ? flat_records[range] : flat_records
|
100
99
|
|
101
100
|
if sort_by then
|
102
101
|
if sort_by[/^-/].nil? then
|
@@ -105,14 +104,21 @@ class DataIsland
|
|
105
104
|
recs = records.sort_by {|record| record[sort_by[1..-1]] }.reverse
|
106
105
|
end
|
107
106
|
else
|
108
|
-
recs =
|
107
|
+
recs = records
|
109
108
|
end
|
110
109
|
|
111
110
|
recs.each do |record|
|
112
111
|
|
113
112
|
rec = rec_orig.deep_clone
|
114
113
|
|
115
|
-
rec.xpath('
|
114
|
+
rec.xpath('.//span[@class]|.//a[@class]').each do |e|
|
115
|
+
r = e.attribute(:class)[/\{([^\}]+)\}$/,1]
|
116
|
+
dest_nodes[r.to_sym] = e if r
|
117
|
+
end
|
118
|
+
puts '!bank: ' + rec.xpath('.//a[@class]').inspect
|
119
|
+
|
120
|
+
|
121
|
+
rec.xpath('.//*[@datafld]').each do |e|
|
116
122
|
dest_nodes[e.attribute(:datafld).downcase.to_sym] = e
|
117
123
|
end
|
118
124
|
|
@@ -122,12 +128,36 @@ class DataIsland
|
|
122
128
|
next if record[field].nil?
|
123
129
|
|
124
130
|
case dest_nodes[field].name.downcase.to_sym
|
131
|
+
|
125
132
|
when :span
|
126
|
-
|
133
|
+
|
134
|
+
classx = dest_nodes[field].attributes[:class]
|
135
|
+
|
136
|
+
if classx then
|
137
|
+
|
138
|
+
if classx[/{#{field}/] then
|
139
|
+
val = record[field]
|
140
|
+
new_class = classx.sub(/\{[^\}]+\}/,val)
|
141
|
+
dest_nodes[field].attributes[:class] = new_class
|
142
|
+
elsif
|
143
|
+
dest_nodes[field].text = record[field]
|
144
|
+
end
|
145
|
+
elsif
|
146
|
+
dest_nodes[field].text = record[field]
|
147
|
+
end
|
148
|
+
|
127
149
|
when :a
|
128
|
-
dest_nodes[field].attributes[
|
129
|
-
|
130
|
-
|
150
|
+
dest_nodes[field].attributes[:href] = record[field]
|
151
|
+
classx = dest_nodes[field].attributes[:class]
|
152
|
+
|
153
|
+
if classx and classx[/{#{field}/] then
|
154
|
+
|
155
|
+
val = record[field]
|
156
|
+
new_class = classx.sub(/\{[^\}]+\}/,val)
|
157
|
+
dest_nodes[field].attributes[:class] = new_class
|
158
|
+
end
|
159
|
+
when :img
|
160
|
+
dest_nodes[field].attributes[:src] = record[field]
|
131
161
|
end
|
132
162
|
end
|
133
163
|
|
@@ -140,3 +170,4 @@ class DataIsland
|
|
140
170
|
end
|
141
171
|
|
142
172
|
end
|
173
|
+
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: dataisland
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- James Robertson
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-06-
|
13
|
+
date: 2012-06-19 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: dynarex
|