remote_table 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,3 @@
1
+ 0.1.6
2
+ * For CSVs, force convert headers using String#toutf8. :encoding => 'N'|'U' didn't work.
3
+ * Fix handling of long urls when passing off to Tempfile.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -2,7 +2,7 @@ class RemoteTable
2
2
  module Csv
3
3
  def each_row(&block)
4
4
  skip_rows!
5
- FasterCSV.parse(open(path), fastercsv_options) do |row|
5
+ FasterCSV.foreach(path, fastercsv_options) do |row|
6
6
  if row.respond_to?(:fields) # it's a traditional fastercsv row hash
7
7
  next if row.fields.compact.blank?
8
8
  hash = HashWithIndifferentAccess.new(row.to_hash)
@@ -20,7 +20,7 @@ class RemoteTable
20
20
  private
21
21
 
22
22
  def fastercsv_options
23
- fastercsv_options = { :skip_blanks => true } # ...and this will skip []
23
+ fastercsv_options = { :skip_blanks => true, :header_converters => lambda { |k| k.toutf8 } }
24
24
  if headers == false
25
25
  fastercsv_options.merge!(:headers => nil)
26
26
  else
@@ -17,13 +17,17 @@ class RemoteTable
17
17
  private
18
18
 
19
19
  def staging_dir_path
20
- path = Tempfile.open(url.gsub(/[^a-z0-9]+/i, '_')).path
20
+ path = tempfile_path_from_url
21
21
  FileUtils.rm_f(path)
22
22
  FileUtils.mkdir(path)
23
23
  at_exit { FileUtils.rm_rf(path) }
24
24
  path
25
25
  end
26
26
 
27
+ def tempfile_path_from_url
28
+ Tempfile.open(url.gsub(/[^a-z0-9]+/i, '_')[0,100]).path
29
+ end
30
+
27
31
  def url_with_google_docs_handling
28
32
  url = self.url
29
33
  if url.include?('spreadsheets.google.com')
data/remote_table.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{remote_table}
8
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Seamus Abshere", "Andy Rossmeissl"]
12
- s.date = %q{2009-11-02}
12
+ s.date = %q{2009-11-05}
13
13
  s.description = %q{Remotely open and parse Excel XLS, ODS, CSV and fixed-width tables.}
14
14
  s.email = %q{seamus@abshere.net}
15
15
  s.extra_rdoc_files = [
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.files = [
20
20
  ".document",
21
21
  ".gitignore",
22
+ "CHANGELOG",
22
23
  "LICENSE",
23
24
  "README.rdoc",
24
25
  "Rakefile",
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: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seamus Abshere
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-11-02 00:00:00 -05:00
13
+ date: 2009-11-05 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -65,6 +65,7 @@ extra_rdoc_files:
65
65
  files:
66
66
  - .document
67
67
  - .gitignore
68
+ - CHANGELOG
68
69
  - LICENSE
69
70
  - README.rdoc
70
71
  - Rakefile