remote_table 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,8 @@
1
+ 1.1.0
2
+ * Fixed difference in row hashes between Ruby 1.8 and 1.9
3
+ * Properly required fastercsv depending on Ruby version
1
4
  1.0.0
5
+ * Using bundler and gemspec instead of jeweler
2
6
  * Refactored to follow more Ruby conventions
3
7
  * Suggesting new syntax that looks more like an Enumerable... t[5] instead of t.rows[5]
4
8
  * Switching to string option keys (but old syntax is supported)
data/README.rdoc CHANGED
@@ -28,8 +28,6 @@ See the test file and also data_miner examples of custom parsers.
28
28
 
29
29
  * The new parser syntax (aka transformer) hasn't been defined yet... only the old-style syntax is available
30
30
  * We currently call curl (and a lot of other utilities) using a shell. Is there a safer way to do this?
31
- * Row hashes may come out differently for Ruby 1.8 and Ruby 1.9, which ruins the whole purpose.
32
- * Since <tt>Enumerable</tt> provides <tt>#to_a</tt>, I'm not sure if it's caching the row loading.
33
31
 
34
32
  ==Authors
35
33
 
data/lib/remote_table.rb CHANGED
@@ -9,9 +9,6 @@ require 'active_support/version'
9
9
  require active_support_3_requirement
10
10
  end if ::ActiveSupport::VERSION::MAJOR == 3
11
11
 
12
- # sabshere 1/25/11 sometimes people call Slither from add_hints! (deprecated)
13
- autoload :Slither, ::Gem.required_location('slither', 'slither.rb')
14
-
15
12
  class RemoteTable
16
13
  autoload :Format, 'remote_table/format'
17
14
  autoload :Properties, 'remote_table/properties'
@@ -1,7 +1,5 @@
1
1
  class RemoteTable
2
2
  class Format
3
- class Unknown < StandardError; end
4
-
5
3
  autoload :Excel, 'remote_table/format/excel'
6
4
  autoload :Excelx, 'remote_table/format/excelx'
7
5
  autoload :Delimited, 'remote_table/format/delimited'
@@ -1,25 +1,23 @@
1
1
  require 'singleton'
2
2
  require 'digest/md5'
3
+ require 'active_support'
4
+ require 'active_support/version'
5
+ %w{
6
+ active_support/core_ext/hash/keys
7
+ active_support/core_ext/object/to_query
8
+ }.each do |active_support_3_requirement|
9
+ require active_support_3_requirement
10
+ end if ::ActiveSupport::VERSION::MAJOR == 3
3
11
  class RemoteTable
4
12
  class Hasher
5
13
  include ::Singleton
6
14
  def hash(row)
7
- normalized_hash = if RUBY_VERSION >= '1.9'
8
- row.keys.sort.inject(::Hash.new) do |memo, k|
9
- normalized_k = k.to_s.toutf8
10
- normalized_v = row[k].respond_to?(:to_s) ? row[k].to_s.toutf8 : row[k]
11
- memo[normalized_k] = normalized_v
12
- memo
13
- end
14
- else
15
- ::Hash.new.replace(row)
16
- end
17
- # sabshere 1/21/11 may currently break across versions of ruby
18
- # ruby-1.8.7-p174 > Marshal.dump({'a' => '1'})
19
- # => "\004\b{\006\"\006a\"\0061"
20
- # ruby-1.9.2-p0 > Marshal.dump({'a' => '1'})
21
- # => "\x04\b{\x06I\"\x06a\x06:\x06ETI\"\x061\x06;\x00T"
22
- ::Digest::MD5.hexdigest ::Marshal.dump(normalized_hash)
15
+ row = row.dup
16
+ row.stringify_keys!
17
+ str = row.keys.sort.map do |k|
18
+ row[k].to_query k
19
+ end.join('&')
20
+ ::Digest::MD5.hexdigest str
23
21
  end
24
22
  end
25
23
  end
@@ -34,8 +34,9 @@ class RemoteTable
34
34
  # sabshere 1/20/11 FIXME: ::RemoteTable.config.curl_bin_path or smth
35
35
  ::RemoteTable.executor.backtick_with_reporting %{
36
36
  curl
37
- --header "Expect: "
37
+ --silent
38
38
  --location
39
+ --header "Expect: "
39
40
  #{"--data #{::Escape.shell_single_word t.properties.form_data}" if t.properties.form_data.present?}
40
41
  --output #{::Escape.shell_single_word @path}
41
42
  #{::Escape.shell_single_word t.properties.uri.to_s}
@@ -192,7 +192,6 @@ class RemoteTable
192
192
  else
193
193
  ::File.extname t.local_file.path
194
194
  end
195
- return Format::Delimited if clue.blank?
196
195
  case clue.downcase
197
196
  when /xlsx/, /excelx/
198
197
  Format::Excelx
@@ -206,11 +205,8 @@ class RemoteTable
206
205
  Format::FixedWidth
207
206
  when /htm/
208
207
  Format::HTML
209
- when /txt/, /dat/
210
- # legacy
211
- Format::Delimited
212
208
  else
213
- raise Format::Unknown, clue
209
+ Format::Delimited
214
210
  end
215
211
  end
216
212
  end
@@ -1,3 +1,3 @@
1
1
  class RemoteTable
2
- VERSION = "1.0.3"
2
+ VERSION = "1.1.0"
3
3
  end
data/remote_table.gemspec CHANGED
@@ -20,8 +20,6 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ["lib"]
21
21
 
22
22
  s.add_dependency 'activesupport', '>=2.3.4'
23
- # sabshere 9/30/10 depending on fastercsv when using ruby 1.9.2 results in exiting with error
24
- # s.add_dependency 'fastercsv', '>=1.5.0'
25
23
  s.add_dependency 'roo', '~>1.9'
26
24
  s.add_dependency 'slither', '>=0.99.4'
27
25
  s.add_dependency 'i18n' # activesupport?
@@ -31,8 +29,16 @@ Gem::Specification.new do |s|
31
29
  s.add_dependency 'spreadsheet' #roo
32
30
  s.add_dependency 'google-spreadsheet-ruby' #roo
33
31
  s.add_dependency 'escape', '>=0.0.4'
32
+ unless RUBY_VERSION >= '1.9'
33
+ s.add_dependency 'fastercsv', '>=1.5.0'
34
+ end
35
+
34
36
  s.add_development_dependency 'errata', '>=0.2.0'
35
37
  s.add_development_dependency 'test-unit'
36
38
  s.add_development_dependency 'shoulda'
37
- s.add_development_dependency 'ruby-debug'
39
+ if RUBY_VERSION >= '1.9'
40
+ s.add_development_dependency 'ruby-debug19'
41
+ else
42
+ s.add_development_dependency 'ruby-debug'
43
+ end
38
44
  end
data/test/helper.rb CHANGED
@@ -1,16 +1,9 @@
1
1
  require 'rubygems'
2
2
  require 'bundler'
3
- unless RUBY_VERSION >= '1.9'
4
- gem 'fastercsv'
5
- require 'fastercsv'
6
- end
7
3
  Bundler.setup
8
4
  require 'test/unit'
9
5
  require 'shoulda'
10
6
  require 'ruby-debug'
11
- # require 'ruby-debug'
12
- # require 'errata'
13
- # require 'active_support/all'
14
7
 
15
8
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
16
9
  $LOAD_PATH.unshift(File.dirname(__FILE__))
@@ -8,7 +8,7 @@ class TestRemoteTable < Test::Unit::TestCase
8
8
 
9
9
  should "add a row hash to every row" do
10
10
  t = RemoteTable.new(:url => 'www.customerreferenceprogram.org/uploads/CRP_RFP_template.xlsx')
11
- assert_equal "59d68cfc1cd6b32f5b333d6f0e4bea6d", t[5]['row_hash']
11
+ assert_equal "06d8a738551c17735e2731e25c8d0461", t[5]['row_hash']
12
12
  end
13
13
 
14
14
  should "open a google doc" do
@@ -18,10 +18,6 @@ class TestRemoteTable < Test::Unit::TestCase
18
18
 
19
19
  should "return an ordered hash" do
20
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
21
+ assert_equal ::ActiveSupport::OrderedHash, t[0].class
26
22
  end
27
23
  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: 17
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 3
10
- version: 1.0.3
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Seamus Abshere
@@ -169,9 +169,25 @@ dependencies:
169
169
  type: :runtime
170
170
  version_requirements: *id010
171
171
  - !ruby/object:Gem::Dependency
172
- name: errata
172
+ name: fastercsv
173
173
  prerelease: false
174
174
  requirement: &id011 !ruby/object:Gem::Requirement
175
+ none: false
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ hash: 3
180
+ segments:
181
+ - 1
182
+ - 5
183
+ - 0
184
+ version: 1.5.0
185
+ type: :runtime
186
+ version_requirements: *id011
187
+ - !ruby/object:Gem::Dependency
188
+ name: errata
189
+ prerelease: false
190
+ requirement: &id012 !ruby/object:Gem::Requirement
175
191
  none: false
176
192
  requirements:
177
193
  - - ">="
@@ -183,11 +199,11 @@ dependencies:
183
199
  - 0
184
200
  version: 0.2.0
185
201
  type: :development
186
- version_requirements: *id011
202
+ version_requirements: *id012
187
203
  - !ruby/object:Gem::Dependency
188
204
  name: test-unit
189
205
  prerelease: false
190
- requirement: &id012 !ruby/object:Gem::Requirement
206
+ requirement: &id013 !ruby/object:Gem::Requirement
191
207
  none: false
192
208
  requirements:
193
209
  - - ">="
@@ -197,11 +213,11 @@ dependencies:
197
213
  - 0
198
214
  version: "0"
199
215
  type: :development
200
- version_requirements: *id012
216
+ version_requirements: *id013
201
217
  - !ruby/object:Gem::Dependency
202
218
  name: shoulda
203
219
  prerelease: false
204
- requirement: &id013 !ruby/object:Gem::Requirement
220
+ requirement: &id014 !ruby/object:Gem::Requirement
205
221
  none: false
206
222
  requirements:
207
223
  - - ">="
@@ -211,11 +227,11 @@ dependencies:
211
227
  - 0
212
228
  version: "0"
213
229
  type: :development
214
- version_requirements: *id013
230
+ version_requirements: *id014
215
231
  - !ruby/object:Gem::Dependency
216
232
  name: ruby-debug
217
233
  prerelease: false
218
- requirement: &id014 !ruby/object:Gem::Requirement
234
+ requirement: &id015 !ruby/object:Gem::Requirement
219
235
  none: false
220
236
  requirements:
221
237
  - - ">="
@@ -225,7 +241,7 @@ dependencies:
225
241
  - 0
226
242
  version: "0"
227
243
  type: :development
228
- version_requirements: *id014
244
+ version_requirements: *id015
229
245
  description: Gives you a standard way to parse various formats and treat them as an array of hashes.
230
246
  email:
231
247
  - seamus@abshere.net