remote_table 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NmMzNjkxNDIyZmJlOGQ0MjNlNjZhZjIwMTE1NDNkNWMzN2I2ZGYxNg==
4
+ YzE1ZTc4ZmI1MGYzMWNmNmI3MTJjNmU5ZWE2NmEyZmMzNGY0MDAyOA==
5
5
  data.tar.gz: !binary |-
6
- ZWQ4MDg4YzQwNTEwMTlkMjk3OTM1NzQzOTI5YzNhODBiOWU3NDVmMA==
6
+ MWExYTNiZjk0ZGE2MmEzNWRjYjI4YWEyMzVkMzU5MWE1YTAwYmJhOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTg0N2ZiZjBhNTllNTg2MmEzMDQ0OGZkZDQwODNkMDg3YjUzY2M1YWMwZTdj
10
- ODcwMWZhNzQxMzI0ZDY5MDU2MTY5ZDVkNjEwMzZkY2Q3YzExMmFmMzUwNzcz
11
- MzI3ZjY1N2M2ZTYzYjY4YmNhN2RlODQzZTIwMDkyYmEyM2Q1Zjk=
9
+ ZWVhNzUxMWRmZWE5Yjk5YmMxZmZiZmUyNWUxYjE2NzNjYjBlYjE4ZDc2Y2Jj
10
+ NGY0ZDY1MGVmZDk1MDY0NDRiNTNmYTc3ZDViOGE3YjZmZTAxMjk2N2Y2M2Nl
11
+ NzA1N2M2ZmE0OWY2MGMyNjYyNTlmOWRmMjRlODJmNGQ3MmUyNmM=
12
12
  data.tar.gz: !binary |-
13
- MWY4YjMyNjA3Yzc1ZTRiMDYxNTEyMjk4M2Q5YmFhZDc2OTUwNTBiODVhZWVi
14
- YTIwNTEzYmRmMjdiMGRjODkzNTIyM2FlM2FkMWNhNDhjNDk3YWQ4NTk3YzJl
15
- OWVlMjkwY2UyMTZiNzk0MjM0Mjg3ZTFhNTcwYWZiNjVhNDMyMzM=
13
+ NmIwNGI4ZjEzNDIyOTE4ZjA3ZmFlZjJiOTY2OTk5ZDRmZWEyMjdjNWZkODc0
14
+ NzBlMWVlMWEzMWE2NGU0YTcyMjRjOWIwMGNlZDAyNDI4MGZkNmJkNWQ4NTlj
15
+ MzM0ZWFlZTMwNDM5ZGJjYWNlZDMxN2NhYmM5ZTgyMTFlMjk3NjQ=
data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ 3.1.0 / 2014-01-06
2
+
3
+ * Breaking changes
4
+
5
+ * Stop requiring rubyzip2 on behalf of Roo per @rossmeissl https://github.com/seamusabshere/remote_table/issues/15 ... you may have to require it yourself
6
+
7
+ * Enhancements
8
+
9
+ * by default, treat single and double quotes as "not special" in pipe- or tab-delimited files - thanks @dwillis https://github.com/seamusabshere/remote_table/pull/14
10
+
1
11
  3.0.0 / 2013-11-26
2
12
 
3
13
  * Breaking changes
data/lib/remote_table.rb CHANGED
@@ -156,8 +156,6 @@ class RemoteTable
156
156
  :keep_blank_rows => false,
157
157
  :skip => 0,
158
158
  :encoding => 'UTF-8',
159
- :delimiter => ',',
160
- :quote_char => '"',
161
159
  }
162
160
  OLD_SETTING_NAMES = {
163
161
  :pre_select => [:select],
@@ -63,11 +63,24 @@ class RemoteTable
63
63
  end
64
64
 
65
65
  def csv_options
66
- {
66
+ retval = {
67
67
  skip_blanks: !keep_blank_rows,
68
- col_sep: delimiter,
69
- quote_char: quote_char,
70
68
  }
69
+ if delimiter
70
+ retval[:col_sep] = delimiter
71
+ end
72
+ if adaptive_quote_char
73
+ retval[:quote_char] = adaptive_quote_char
74
+ end
75
+ retval
76
+ end
77
+
78
+ def adaptive_quote_char
79
+ if quote_char
80
+ quote_char
81
+ elsif delimiter == "\t" or delimiter == '|'
82
+ "\0"
83
+ end
71
84
  end
72
85
 
73
86
  def headers
@@ -28,7 +28,7 @@ class RemoteTable
28
28
  harmful = [ Plaintext.soft_hyphen(encoding), UTF8_BOM ]
29
29
  local_copy.in_place :perl, "s/#{harmful.join('//g; s/')}//g"
30
30
  end
31
-
31
+
32
32
  # No matter what the file encoding is SUPPOSED to be, run it through the system iconv binary to make sure it's UTF-8
33
33
  #
34
34
  # @example
@@ -1,3 +1,3 @@
1
1
  class RemoteTable
2
- VERSION = '3.0.0'
2
+ VERSION = '3.1.0'
3
3
  end
data/remote_table.gemspec CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
7
7
  s.authors = ["Seamus Abshere", "Andy Rossmeissl"]
8
8
  s.email = ["seamus@abshere.net"]
9
9
  s.homepage = "https://github.com/seamusabshere/remote_table"
10
- s.summary = %{Open Google Docs spreadsheets, local or remote XLSX, XLS, ODS, CSV (comma separated), TSV (tab separated), other delimited, fixed-width files, and shapefiles.}
11
- s.description = %{Open Google Docs spreadsheets, local or remote XLSX, XLS, ODS, CSV (comma separated), TSV (tab separated), other delimited, fixed-width files, and shapefiles. Returns an Array of Arrays or Hashes, depending on whether there are headers.}
10
+ s.summary = %{Open local or remote XLSX, XLS, ODS, CSV (comma separated), TSV (tab separated), other delimited, fixed-width files, and Google Docs. Returns an enumerator of Arrays or Hashes, depending on whether there are headers.}
11
+ s.description = %{Open local or remote XLSX, XLS, ODS, CSV (comma separated), TSV (tab separated), other delimited, fixed-width files, and Google Docs. Returns an enumerator of Arrays or Hashes, depending on whether there are headers.}
12
12
 
13
13
  s.rubyforge_project = "remotetable"
14
14
 
@@ -24,7 +24,6 @@ Gem::Specification.new do |s|
24
24
  s.add_runtime_dependency 'unix_utils', '>=0.0.8'
25
25
  s.add_runtime_dependency 'fastercsv', '>=1.5.0'
26
26
  s.add_runtime_dependency 'hash_digest'
27
- s.add_runtime_dependency 'rubyzip2'
28
27
 
29
28
  s.add_development_dependency 'errata', '>=0.2.0'
30
29
  s.add_development_dependency 'minitest'
@@ -0,0 +1,7 @@
1
+ C00008896|`OPEIU LOCAL 153 '"|VOTE|"' (VOICE OF THE ELECTORATE) COMMITTEE`|RICHARD J LANIGAN|265 WEST 14TH ST.||NEW YORK|NY|10011|U|Q||Q|L|EMPLOYEES INT'L UNION; OFFICE & PROF.|
2
+ C00009282|NORFOLK SOUTHERN CORPORATION GOOD GOVERNMENT FUND|LEDOUX, MARQUE|ONE CONSTITUTION AVE NE||WASHINGTON|DC|20002|B|Q|UNK|M|C|NORFOLK SOUTHERN CORPORATION|
3
+ C00009357|THE RECORDING INDUSTRY ASSOCIATION OF AMERICA POLITICAL ACTION COMMITTEE|GLAZIER, MITCH|1025 F STREET NW|10TH FLOOR|WASHINGTON|DC|20004|B|Q||Q|T|THE RECORDING INDUSTRY ASSOCIATION OF AMERICA, INC.|
4
+ C00009423|LAND O'LAKES, INC., PAC|GRABOW, KAREN|P.O. BOX 64101||ST. PAUL|MN|55164|B|Q||Q|V|LAND O'LAKES, INC.|
5
+ C00009456|3RD CONGRESSIONAL DISTRICT DEMOCRATIC PARTY OF WISCONSIN|UGLAND, GERALD DAVID MR.|2450 RIVER BEND ROAD||PLOVER|WI|544672728|U|Y|DEM|Q||DEMOCRATIC PARTY OF WISCONSIN|
6
+ C00009597|NATIONAL COUNCIL OF COAL LESSORS INC PAC|CRAWFORD, THOMAS|101 CONSTITUTION AVENUE NW|SUITE 900|WASHINGTON|DC|20001|U|Q||A|T|COAL LESSORS INC; NAT'L COUNCIL OF|
7
+ C00277525|`JERRY CARROLL |S| COMMITTEE`|JERRY CARROLL|PO BOX 9079||STOCKTON|CA|95208|P|S|IND|A|||S2CA00591
data/test/data/cm.tsv ADDED
@@ -0,0 +1,7 @@
1
+ C00008896 OPEIU LOCAL 153 "VOTE" (VOICE OF THE ELECTORATE) COMMITTEE RICHARD J LANIGAN 265 WEST 14TH ST. NEW YORK NY 10011 U Q Q L EMPLOYEES INT'L UNION; OFFICE & PROF.
2
+ C00009282 NORFOLK SOUTHERN CORPORATION GOOD GOVERNMENT FUND LEDOUX, MARQUE ONE CONSTITUTION AVE NE WASHINGTON DC 20002 B Q UNK M C NORFOLK SOUTHERN CORPORATION
3
+ C00009357 THE RECORDING INDUSTRY ASSOCIATION OF AMERICA POLITICAL ACTION COMMITTEE GLAZIER, MITCH 1025 F STREET NW 10TH FLOOR WASHINGTON DC 20004 B Q Q T THE RECORDING INDUSTRY ASSOCIATION OF AMERICA, INC.
4
+ C00009423 LAND O'LAKES, INC., PAC GRABOW, KAREN P.O. BOX 64101 ST. PAUL MN 55164 B Q Q V LAND O'LAKES, INC.
5
+ C00009456 3RD CONGRESSIONAL DISTRICT DEMOCRATIC PARTY OF WISCONSIN UGLAND, GERALD DAVID MR. 2450 RIVER BEND ROAD PLOVER WI 544672728 U Y DEM Q DEMOCRATIC PARTY OF WISCONSIN
6
+ C00009597 NATIONAL COUNCIL OF COAL LESSORS INC PAC CRAWFORD, THOMAS 101 CONSTITUTION AVENUE NW SUITE 900 WASHINGTON DC 20001 U Q A T COAL LESSORS INC; NAT'L COUNCIL OF
7
+ C00277525 JERRY CARROLL "S" COMMITTEE JERRY CARROLL PO BOX 9079 STOCKTON CA 95208 P S IND A S2CA00591
data/test/data/cm.txt ADDED
@@ -0,0 +1,7 @@
1
+ C00008896|OPEIU LOCAL 153 "VOTE" (VOICE OF THE ELECTORATE) COMMITTEE|RICHARD J LANIGAN|265 WEST 14TH ST.||NEW YORK|NY|10011|U|Q||Q|L|EMPLOYEES INT'L UNION; OFFICE & PROF.|
2
+ C00009282|NORFOLK SOUTHERN CORPORATION GOOD GOVERNMENT FUND|LEDOUX, MARQUE|ONE CONSTITUTION AVE NE||WASHINGTON|DC|20002|B|Q|UNK|M|C|NORFOLK SOUTHERN CORPORATION|
3
+ C00009357|THE RECORDING INDUSTRY ASSOCIATION OF AMERICA POLITICAL ACTION COMMITTEE|GLAZIER, MITCH|1025 F STREET NW|10TH FLOOR|WASHINGTON|DC|20004|B|Q||Q|T|THE RECORDING INDUSTRY ASSOCIATION OF AMERICA, INC.|
4
+ C00009423|LAND O'LAKES, INC., PAC|GRABOW, KAREN|P.O. BOX 64101||ST. PAUL|MN|55164|B|Q||Q|V|LAND O'LAKES, INC.|
5
+ C00009456|3RD CONGRESSIONAL DISTRICT DEMOCRATIC PARTY OF WISCONSIN|UGLAND, GERALD DAVID MR.|2450 RIVER BEND ROAD||PLOVER|WI|544672728|U|Y|DEM|Q||DEMOCRATIC PARTY OF WISCONSIN|
6
+ C00009597|NATIONAL COUNCIL OF COAL LESSORS INC PAC|CRAWFORD, THOMAS|101 CONSTITUTION AVENUE NW|SUITE 900|WASHINGTON|DC|20001|U|Q||A|T|COAL LESSORS INC; NAT'L COUNCIL OF|
7
+ C00277525|JERRY CARROLL "S" COMMITTEE|JERRY CARROLL|PO BOX 9079||STOCKTON|CA|95208|P|S|IND|A|||S2CA00591
@@ -59,6 +59,22 @@ describe RemoteTable do
59
59
  f.close
60
60
  end
61
61
 
62
+ it "treats quotes as not special in a pipe-delimited file" do
63
+ t = RemoteTable.new "file://#{File.expand_path('../data/cm.txt', __FILE__)}", :delimiter => '|', :headers => false
64
+ t[0][1].must_equal %{OPEIU LOCAL 153 "VOTE" (VOICE OF THE ELECTORATE) COMMITTEE}
65
+ end
66
+
67
+ it "treats quotes as not special in a tab-delimited file" do
68
+ t = RemoteTable.new "file://#{File.expand_path('../data/cm.tsv', __FILE__)}", :delimiter => "\t", :headers => false
69
+ t[0][1].must_equal %{OPEIU LOCAL 153 "VOTE" (VOICE OF THE ELECTORATE) COMMITTEE}
70
+ end
71
+
72
+ # using backticks
73
+ it "allows quoted pipes in a pipe-delimited file" do
74
+ t = RemoteTable.new "file://#{File.expand_path('../data/cm.pathological.txt', __FILE__)}", :delimiter => '|', :headers => false, :quote_char => '`'
75
+ t[0][1].must_equal %{OPEIU LOCAL 153 '"|VOTE|"' (VOICE OF THE ELECTORATE) COMMITTEE}
76
+ end
77
+
62
78
  it "open a yaml" do
63
79
  t = RemoteTable.new "file://#{File.expand_path('../data/data.yml', __FILE__)}"
64
80
  t[0]['name'].must_equal 'Seamus Abshere'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remote_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seamus Abshere
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-26 00:00:00.000000000 Z
12
+ date: 2014-01-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -109,20 +109,6 @@ dependencies:
109
109
  - - ! '>='
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
- - !ruby/object:Gem::Dependency
113
- name: rubyzip2
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - ! '>='
117
- - !ruby/object:Gem::Version
118
- version: '0'
119
- type: :runtime
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - ! '>='
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
112
  - !ruby/object:Gem::Dependency
127
113
  name: errata
128
114
  requirement: !ruby/object:Gem::Requirement
@@ -221,9 +207,9 @@ dependencies:
221
207
  - - ! '>='
222
208
  - !ruby/object:Gem::Version
223
209
  version: '0'
224
- description: Open Google Docs spreadsheets, local or remote XLSX, XLS, ODS, CSV (comma
225
- separated), TSV (tab separated), other delimited, fixed-width files, and shapefiles.
226
- Returns an Array of Arrays or Hashes, depending on whether there are headers.
210
+ description: Open local or remote XLSX, XLS, ODS, CSV (comma separated), TSV (tab
211
+ separated), other delimited, fixed-width files, and Google Docs. Returns an enumerator
212
+ of Arrays or Hashes, depending on whether there are headers.
227
213
  email:
228
214
  - seamus@abshere.net
229
215
  executables: []
@@ -256,6 +242,9 @@ files:
256
242
  - test/data/airports.utf8.csv
257
243
  - test/data/backup/http___www.customerreferenceprogram.org_uploads_CRP_RFP_template.xlsx
258
244
  - test/data/bom.csv
245
+ - test/data/cm.pathological.txt
246
+ - test/data/cm.tsv
247
+ - test/data/cm.txt
259
248
  - test/data/color.csv
260
249
  - test/data/data.yml
261
250
  - test/data/faa-aircraft.html.bz2
@@ -307,12 +296,16 @@ rubyforge_project: remotetable
307
296
  rubygems_version: 2.1.11
308
297
  signing_key:
309
298
  specification_version: 4
310
- summary: Open Google Docs spreadsheets, local or remote XLSX, XLS, ODS, CSV (comma
311
- separated), TSV (tab separated), other delimited, fixed-width files, and shapefiles.
299
+ summary: Open local or remote XLSX, XLS, ODS, CSV (comma separated), TSV (tab separated),
300
+ other delimited, fixed-width files, and Google Docs. Returns an enumerator of Arrays
301
+ or Hashes, depending on whether there are headers.
312
302
  test_files:
313
303
  - test/data/airports.utf8.csv
314
304
  - test/data/backup/http___www.customerreferenceprogram.org_uploads_CRP_RFP_template.xlsx
315
305
  - test/data/bom.csv
306
+ - test/data/cm.pathological.txt
307
+ - test/data/cm.tsv
308
+ - test/data/cm.txt
316
309
  - test/data/color.csv
317
310
  - test/data/data.yml
318
311
  - test/data/faa-aircraft.html.bz2