remote_table 0.2.26 → 0.2.27

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.26
1
+ 0.2.27
@@ -33,13 +33,11 @@ class RemoteTable
33
33
  end
34
34
  end
35
35
 
36
- private
37
-
38
36
  def staging_dir_path
39
37
  return @_staging_dir_path if @_staging_dir_path
40
- @_staging_dir_path = ::File.join Dir.tmpdir, rand.to_s
41
- FileUtils.mkdir @_staging_dir_path
42
- at_exit { FileUtils.rm_rf @_staging_dir_path }
38
+ @_staging_dir_path = ::File.join Dir.tmpdir, 'remote_table_gem', rand.to_s
39
+ FileUtils.mkdir_p @_staging_dir_path
40
+ RemoteTable.remove_at_exit @_staging_dir_path
43
41
  @_staging_dir_path
44
42
  end
45
43
  end
data/lib/remote_table.rb CHANGED
@@ -4,10 +4,12 @@ require 'tmpdir'
4
4
  require 'active_support'
5
5
  require 'active_support/version'
6
6
  %w{
7
+ active_support/core_ext/string/conversions
7
8
  active_support/core_ext/object/blank
8
9
  active_support/core_ext/string/inflections
9
10
  active_support/core_ext/array/wrap
10
11
  active_support/core_ext/hash/except
12
+ active_support/core_ext/class/attribute_accessors
11
13
  }.each do |active_support_3_requirement|
12
14
  require active_support_3_requirement
13
15
  end if ActiveSupport::VERSION::MAJOR == 3
@@ -29,6 +31,21 @@ require 'remote_table/file/xls'
29
31
  require 'remote_table/file/html'
30
32
 
31
33
  class RemoteTable
34
+ cattr_accessor :paths_for_removal
35
+ class << self
36
+ def cleanup
37
+ paths_for_removal.each do |path|
38
+ FileUtils.rm_rf path
39
+ paths_for_removal.delete path
40
+ end if paths_for_removal.is_a?(Array)
41
+ end
42
+
43
+ def remove_at_exit(path)
44
+ self.paths_for_removal ||= Array.new
45
+ paths_for_removal.push path
46
+ end
47
+ end
48
+
32
49
  attr_accessor :request, :package, :file, :transform
33
50
  attr_accessor :table
34
51
 
@@ -39,6 +56,7 @@ class RemoteTable
39
56
  @package = Package.new(bus)
40
57
  @request = Request.new(bus)
41
58
  @file = File.new(bus)
59
+ at_exit { RemoteTable.cleanup }
42
60
  end
43
61
 
44
62
  def each
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.2.26"
8
+ s.version = "0.2.27"
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{2010-05-24}
12
+ s.date = %q{2010-06-30}
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 = [
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
44
44
  s.require_paths = ["lib"]
45
45
  s.requirements = ["curl"]
46
46
  s.rubyforge_project = %q{remotetable}
47
- s.rubygems_version = %q{1.3.6}
47
+ s.rubygems_version = %q{1.3.7}
48
48
  s.summary = %q{Remotely open and parse XLS, ODS, CSV and fixed-width tables.}
49
49
  s.test_files = [
50
50
  "test/remote_table_test.rb",
@@ -55,7 +55,7 @@ Gem::Specification.new do |s|
55
55
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
56
56
  s.specification_version = 3
57
57
 
58
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
58
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
59
59
  s.add_runtime_dependency(%q<roo>, ["= 1.3.11"])
60
60
  s.add_runtime_dependency(%q<fastercsv>, [">= 1.5.0"])
61
61
  s.add_runtime_dependency(%q<activesupport>, [">= 2.3.4"])
@@ -37,32 +37,31 @@ class FuelOilParser
37
37
  end
38
38
 
39
39
  class AircraftGuru
40
- def is_not_attributed_to_aerospatiale?(row)
41
- not row['Manufacturer'] =~ /AEROSPATIALE/i
40
+ def is_a_dc_plane?(row)
41
+ row['Designator'] =~ /^DC\d/i
42
42
  end
43
43
 
44
- def is_not_attributed_to_cessna?(row)
45
- not row['Manufacturer'] =~ /CESSNA/i
46
- end
47
-
48
- def is_not_attributed_to_learjet?(row)
49
- not row['Manufacturer'] =~ /LEAR/i
50
- end
51
-
52
- def is_not_attributed_to_dehavilland?(row)
53
- not row['Manufacturer'] =~ /DE ?HAVILLAND/i
54
- end
44
+ # def is_a_crj_900?(row)
45
+ # row['Designator'].downcase == 'crj9'
46
+ # end
55
47
 
56
- def is_not_attributed_to_mcdonnell_douglas?(row)
57
- not row['Manufacturer'] =~ /MCDONNELL DOUGLAS/i
48
+ def is_a_g159?(row)
49
+ row['Designator'] =~ /^G159$/
58
50
  end
59
-
60
- def is_not_a_dc_plane?(row)
61
- not row['Model'] =~ /DC/i
51
+
52
+ def is_a_galx?(row)
53
+ row['Designator'] =~ /^GALX$/
62
54
  end
63
55
 
64
- def is_a_crj_900?(row)
65
- row['Designator'].downcase == 'crj9'
56
+ def method_missing(method_id, *args, &block)
57
+ if method_id.to_s =~ /\Ais_n?o?t?_?attributed_to_([^\?]+)/
58
+ manufacturer_name = $1
59
+ manufacturer_regexp = Regexp.new(manufacturer_name.gsub('_', ' ?'), Regexp::IGNORECASE)
60
+ matches = manufacturer_regexp.match(args.first['Manufacturer']) # row['Manufacturer'] =~ /mcdonnell douglas/i
61
+ method_id.to_s.include?('not_attributed') ? matches.nil? : !matches.nil?
62
+ else
63
+ super
64
+ end
66
65
  end
67
66
  end
68
67
 
@@ -155,8 +154,8 @@ class RemoteTableTest < Test::Unit::TestCase
155
154
  :responder => AircraftGuru.new)
156
155
  g1 = t.rows.detect { |row| row['Model'] =~ /Gulfstream I/ }
157
156
  assert g1
158
- assert_equal 'GRUMMAN', g1['Manufacturer']
159
- assert_equal 'G159 Gulfstream I (TC4 Academe, VC4)', g1['Model']
157
+ assert_equal 'GULFSTREAM AEROSPACE', g1['Manufacturer']
158
+ assert_equal 'Gulfstream I', g1['Model']
160
159
  end
161
160
 
162
161
  # this will die with an error about libcurl if your curl doesn't support ssl
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remote_table
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 33
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 2
8
- - 26
9
- version: 0.2.26
9
+ - 27
10
+ version: 0.2.27
10
11
  platform: ruby
11
12
  authors:
12
13
  - Seamus Abshere
@@ -15,16 +16,18 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-05-24 00:00:00 -04:00
19
+ date: 2010-06-30 00:00:00 -04:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  name: roo
23
24
  prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
25
27
  requirements:
26
28
  - - "="
27
29
  - !ruby/object:Gem::Version
30
+ hash: 13
28
31
  segments:
29
32
  - 1
30
33
  - 3
@@ -36,9 +39,11 @@ dependencies:
36
39
  name: fastercsv
37
40
  prerelease: false
38
41
  requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
39
43
  requirements:
40
44
  - - ">="
41
45
  - !ruby/object:Gem::Version
46
+ hash: 3
42
47
  segments:
43
48
  - 1
44
49
  - 5
@@ -50,9 +55,11 @@ dependencies:
50
55
  name: activesupport
51
56
  prerelease: false
52
57
  requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
53
59
  requirements:
54
60
  - - ">="
55
61
  - !ruby/object:Gem::Version
62
+ hash: 11
56
63
  segments:
57
64
  - 2
58
65
  - 3
@@ -64,9 +71,11 @@ dependencies:
64
71
  name: slither
65
72
  prerelease: false
66
73
  requirement: &id004 !ruby/object:Gem::Requirement
74
+ none: false
67
75
  requirements:
68
76
  - - ">="
69
77
  - !ruby/object:Gem::Version
78
+ hash: 405
70
79
  segments:
71
80
  - 0
72
81
  - 99
@@ -78,9 +87,11 @@ dependencies:
78
87
  name: nokogiri
79
88
  prerelease: false
80
89
  requirement: &id005 !ruby/object:Gem::Requirement
90
+ none: false
81
91
  requirements:
82
92
  - - ">="
83
93
  - !ruby/object:Gem::Version
94
+ hash: 5
84
95
  segments:
85
96
  - 1
86
97
  - 4
@@ -92,9 +103,11 @@ dependencies:
92
103
  name: escape
93
104
  prerelease: false
94
105
  requirement: &id006 !ruby/object:Gem::Requirement
106
+ none: false
95
107
  requirements:
96
108
  - - ">="
97
109
  - !ruby/object:Gem::Version
110
+ hash: 23
98
111
  segments:
99
112
  - 0
100
113
  - 0
@@ -106,9 +119,11 @@ dependencies:
106
119
  name: errata
107
120
  prerelease: false
108
121
  requirement: &id007 !ruby/object:Gem::Requirement
122
+ none: false
109
123
  requirements:
110
124
  - - ">="
111
125
  - !ruby/object:Gem::Version
126
+ hash: 23
112
127
  segments:
113
128
  - 0
114
129
  - 2
@@ -159,23 +174,27 @@ rdoc_options:
159
174
  require_paths:
160
175
  - lib
161
176
  required_ruby_version: !ruby/object:Gem::Requirement
177
+ none: false
162
178
  requirements:
163
179
  - - ">="
164
180
  - !ruby/object:Gem::Version
181
+ hash: 3
165
182
  segments:
166
183
  - 0
167
184
  version: "0"
168
185
  required_rubygems_version: !ruby/object:Gem::Requirement
186
+ none: false
169
187
  requirements:
170
188
  - - ">="
171
189
  - !ruby/object:Gem::Version
190
+ hash: 3
172
191
  segments:
173
192
  - 0
174
193
  version: "0"
175
194
  requirements:
176
195
  - curl
177
196
  rubyforge_project: remotetable
178
- rubygems_version: 1.3.6
197
+ rubygems_version: 1.3.7
179
198
  signing_key:
180
199
  specification_version: 3
181
200
  summary: Remotely open and parse XLS, ODS, CSV and fixed-width tables.