remote_table 1.0.1 → 1.0.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/lib/remote_table/properties.rb +10 -2
- data/lib/remote_table/version.rb +1 -1
- data/test/test_errata.rb +15 -2
- data/test/test_remote_table.rb +14 -0
- metadata +3 -3
@@ -168,9 +168,14 @@ class RemoteTable
|
|
168
168
|
t.options['reject']
|
169
169
|
end
|
170
170
|
|
171
|
-
#
|
171
|
+
# A hash of options to create a new Errata instance (see the Errata gem at http://github.com/seamusabshere/errata) to be used on every row.
|
172
172
|
def errata
|
173
|
-
t.options
|
173
|
+
return unless t.options.has_key? 'errata'
|
174
|
+
@errata ||= if t.options['errata'].is_a? ::Hash
|
175
|
+
::Errata.new t.options['errata']
|
176
|
+
else
|
177
|
+
t.options['errata']
|
178
|
+
end
|
174
179
|
end
|
175
180
|
|
176
181
|
# Get the format in the form of RemoteTable::Format::Excel, etc.
|
@@ -201,6 +206,9 @@ class RemoteTable
|
|
201
206
|
Format::FixedWidth
|
202
207
|
when /htm/
|
203
208
|
Format::HTML
|
209
|
+
when /txt/, /dat/
|
210
|
+
# legacy
|
211
|
+
Format::Delimited
|
204
212
|
else
|
205
213
|
raise Format::Unknown, clue
|
206
214
|
end
|
data/lib/remote_table/version.rb
CHANGED
data/test/test_errata.rb
CHANGED
@@ -31,16 +31,29 @@ class AircraftGuru
|
|
31
31
|
end
|
32
32
|
|
33
33
|
class TestErrata < Test::Unit::TestCase
|
34
|
-
should "be able to apply
|
34
|
+
should "be able to apply Errata instances directly" do
|
35
35
|
t = RemoteTable.new :url => "http://www.faa.gov/air_traffic/publications/atpubs/CNT/5-2-G.htm",
|
36
36
|
:encoding => 'windows-1252',
|
37
37
|
:row_xpath => '//table/tr[2]/td/table/tr',
|
38
38
|
:column_xpath => 'td',
|
39
|
-
:errata => Errata.new(:
|
39
|
+
:errata => Errata.new(:url => 'http://spreadsheets.google.com/pub?key=tObVAGyqOkCBtGid0tJUZrw',
|
40
40
|
:responder => AircraftGuru.new)
|
41
41
|
g1 = t.rows.detect { |row| row['Model'] =~ /Gulfstream I/ }
|
42
42
|
assert g1
|
43
43
|
assert_equal 'GULFSTREAM AEROSPACE', g1['Manufacturer']
|
44
44
|
assert_equal 'Gulfstream I', g1['Model']
|
45
45
|
end
|
46
|
+
|
47
|
+
should "be able to apply erratas given a hash of options" do
|
48
|
+
t = RemoteTable.new :url => "http://www.faa.gov/air_traffic/publications/atpubs/CNT/5-2-G.htm",
|
49
|
+
:encoding => 'windows-1252',
|
50
|
+
:row_xpath => '//table/tr[2]/td/table/tr',
|
51
|
+
:column_xpath => 'td',
|
52
|
+
:errata => { :url => 'http://spreadsheets.google.com/pub?key=tObVAGyqOkCBtGid0tJUZrw',
|
53
|
+
:responder => AircraftGuru.new }
|
54
|
+
g1 = t.rows.detect { |row| row['Model'] =~ /Gulfstream I/ }
|
55
|
+
assert g1
|
56
|
+
assert_equal 'GULFSTREAM AEROSPACE', g1['Manufacturer']
|
57
|
+
assert_equal 'Gulfstream I', g1['Model']
|
58
|
+
end
|
46
59
|
end
|
data/test/test_remote_table.rb
CHANGED
@@ -10,4 +10,18 @@ class TestRemoteTable < Test::Unit::TestCase
|
|
10
10
|
t = RemoteTable.new(:url => 'www.customerreferenceprogram.org/uploads/CRP_RFP_template.xlsx')
|
11
11
|
assert_equal "59d68cfc1cd6b32f5b333d6f0e4bea6d", t[5]['row_hash']
|
12
12
|
end
|
13
|
+
|
14
|
+
should "open a google doc" do
|
15
|
+
t = RemoteTable.new 'http://spreadsheets.google.com/pub?key=tObVAGyqOkCBtGid0tJUZrw'
|
16
|
+
assert_equal 'Seamus Abshere', t[0]['name']
|
17
|
+
end
|
18
|
+
|
19
|
+
should "return an ordered hash" do
|
20
|
+
t = RemoteTable.new 'http://spreadsheets.google.com/pub?key=tObVAGyqOkCBtGid0tJUZrw'
|
21
|
+
if RUBY_VERSION >= '1.9'
|
22
|
+
assert_equal ::Hash, t[0].class
|
23
|
+
else
|
24
|
+
assert_equal ::ActiveSupport::OrderedHash, t[0].class
|
25
|
+
end
|
26
|
+
end
|
13
27
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remote_table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Seamus Abshere
|