data_miner 0.4.25 → 0.4.26

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ begin
17
17
  gem.add_dependency 'conversions', '>=1.4.4'
18
18
  gem.add_dependency 'blockenspiel', '>=0.3.2'
19
19
  gem.add_dependency 'log4r', '>=1.1.7'
20
- gem.add_development_dependency 'errata', '>=0.2.1'
20
+ gem.add_dependency 'errata', '>=0.2.1'
21
21
  gem.add_development_dependency "loose_tight_dictionary", ">=0.0.5"
22
22
  gem.require_path = "lib"
23
23
  gem.files.include %w(lib/data_miner) unless gem.files.empty? # seems to fail once it's in the wild
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.25
1
+ 0.4.26
data/data_miner.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{data_miner}
8
- s.version = "0.4.25"
8
+ s.version = "0.4.26"
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"]
@@ -59,7 +59,7 @@ Gem::Specification.new do |s|
59
59
  s.add_runtime_dependency(%q<conversions>, [">= 1.4.4"])
60
60
  s.add_runtime_dependency(%q<blockenspiel>, [">= 0.3.2"])
61
61
  s.add_runtime_dependency(%q<log4r>, [">= 1.1.7"])
62
- s.add_development_dependency(%q<errata>, [">= 0.2.1"])
62
+ s.add_runtime_dependency(%q<errata>, [">= 0.2.1"])
63
63
  s.add_development_dependency(%q<loose_tight_dictionary>, [">= 0.0.5"])
64
64
  else
65
65
  s.add_dependency(%q<remote_table>, [">= 0.2.20"])
@@ -14,6 +14,11 @@ module DataMiner
14
14
  @configuration = configuration
15
15
  @position_in_run = position_in_run
16
16
  @description = description
17
+
18
+ if table_options[:errata].is_a?(String)
19
+ table_options[:errata] = Errata.new :url => table_options[:errata], :responder => resource
20
+ end
21
+
17
22
  if table_options[:table].present?
18
23
  DataMiner.log_or_raise "You should specify :table or :url, but not both" if table_options[:url].present?
19
24
  @table = table_options[:table]
data/lib/data_miner.rb CHANGED
@@ -11,6 +11,7 @@ end if ActiveSupport::VERSION::MAJOR == 3
11
11
  require 'active_record'
12
12
  require 'blockenspiel'
13
13
  require 'conversions'
14
+ require 'errata'
14
15
  require 'remote_table'
15
16
  require 'andand'
16
17
  require 'log4r'
@@ -1022,6 +1022,61 @@ class Aircraft < ActiveRecord::Base
1022
1022
  end
1023
1023
  end
1024
1024
 
1025
+ # note that this depends on stuff in Aircraft
1026
+ class AircraftDeux < ActiveRecord::Base
1027
+ set_primary_key :icao_code
1028
+
1029
+ # defined on the class because we defined the errata with a shorthand
1030
+ class << self
1031
+ def is_not_attributed_to_aerospatiale?(row)
1032
+ not row['Manufacturer'] =~ /AEROSPATIALE/i
1033
+ end
1034
+
1035
+ def is_not_attributed_to_cessna?(row)
1036
+ not row['Manufacturer'] =~ /CESSNA/i
1037
+ end
1038
+
1039
+ def is_not_attributed_to_learjet?(row)
1040
+ not row['Manufacturer'] =~ /LEAR/i
1041
+ end
1042
+
1043
+ def is_not_attributed_to_dehavilland?(row)
1044
+ not row['Manufacturer'] =~ /DE ?HAVILLAND/i
1045
+ end
1046
+
1047
+ def is_not_attributed_to_mcdonnell_douglas?(row)
1048
+ not row['Manufacturer'] =~ /MCDONNELL DOUGLAS/i
1049
+ end
1050
+
1051
+ def is_not_a_dc_plane?(row)
1052
+ not row['Model'] =~ /DC/i
1053
+ end
1054
+
1055
+ def is_a_crj_900?(row)
1056
+ row['Designator'].downcase == 'crj9'
1057
+ end
1058
+ end
1059
+
1060
+ data_miner do
1061
+ # ('A'..'Z').each do |letter|
1062
+ # Note: for the purposes of testing, only importing "D"
1063
+ %w{ D }.each do |letter|
1064
+ import("ICAO codes starting with letter #{letter} used by the FAA",
1065
+ :url => "http://www.faa.gov/air_traffic/publications/atpubs/CNT/5-2-#{letter}.htm",
1066
+ :encoding => 'US-ASCII',
1067
+ :errata => 'http://spreadsheets.google.com/pub?key=tObVAGyqOkCBtGid0tJUZrw',
1068
+ :row_xpath => '//table/tr[2]/td/table/tr',
1069
+ :column_xpath => 'td') do
1070
+ key 'icao_code', :field_name => 'Designator'
1071
+ store 'bts_name', :matcher => Aircraft::BtsNameMatcher.new
1072
+ store 'bts_aircraft_type_code', :matcher => Aircraft::BtsAircraftTypeCodeMatcher.new
1073
+ store 'manufacturer_name', :field_name => 'Manufacturer'
1074
+ store 'name', :field_name => 'Model'
1075
+ end
1076
+ end
1077
+ end
1078
+ end
1079
+
1025
1080
  # todo: have somebody properly organize these
1026
1081
  class DataMinerTest < Test::Unit::TestCase
1027
1082
  if ENV['ALL'] == 'true' or ENV['NEW'] == 'true'
@@ -1140,6 +1195,11 @@ class DataMinerTest < Test::Unit::TestCase
1140
1195
  end
1141
1196
 
1142
1197
  if ENV['ALL'] == 'true' or ENV['SLOW'] == 'true'
1198
+ should "allow errata to be specified with a shorthand, assuming the responder is the resource class itself" do
1199
+ AircraftDeux.run_data_miner!
1200
+ assert AircraftDeux.exists? :icao_code => 'DC91', :bts_aircraft_type_code => '630'
1201
+ end
1202
+
1143
1203
  should "mine aircraft" do
1144
1204
  Aircraft.run_data_miner!
1145
1205
  assert Aircraft.exists? :icao_code => 'DC91', :bts_aircraft_type_code => '630'
data/test/test_helper.rb CHANGED
@@ -3,8 +3,6 @@ require 'test/unit'
3
3
  require 'shoulda'
4
4
  require 'ruby-debug'
5
5
 
6
- require 'errata'
7
-
8
6
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
9
7
  $LOAD_PATH.unshift(File.dirname(__FILE__))
10
8
  require 'data_miner'
@@ -17,7 +15,7 @@ ActiveRecord::Base.establish_connection(
17
15
  )
18
16
 
19
17
  ActiveSupport::Inflector.inflections do |inflect|
20
- inflect.uncountable 'aircraft'
18
+ inflect.uncountable %w{ aircraft aircraft_deux }
21
19
  end
22
20
 
23
21
  class Test::Unit::TestCase
@@ -295,6 +293,26 @@ ActiveRecord::Schema.define(:version => 20090819143429) do
295
293
  t.integer 'data_miner_last_run_id'
296
294
  end
297
295
  execute 'ALTER TABLE aircraft ADD PRIMARY KEY (icao_code);'
296
+
297
+ create_table 'aircraft_deux', :force => true, :options => 'ENGINE=InnoDB default charset=utf8', :id => false do |t|
298
+ t.string 'icao_code'
299
+ t.string 'manufacturer_name'
300
+ t.string 'name'
301
+
302
+ t.string "bts_name"
303
+ t.string "bts_aircraft_type_code"
304
+
305
+ # t.string 'brighter_planet_aircraft_class_code'
306
+ # t.float 'm3'
307
+ # t.float 'm2'
308
+ # t.float 'm1'
309
+ # t.float 'endpoint_fuel'
310
+ t.datetime 'updated_at'
311
+ t.datetime 'created_at'
312
+ t.integer 'data_miner_touch_count'
313
+ t.integer 'data_miner_last_run_id'
314
+ end
315
+ execute 'ALTER TABLE aircraft_deux ADD PRIMARY KEY (icao_code);'
298
316
  end
299
317
 
300
318
  DataMiner::Run.create_tables
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 25
9
- version: 0.4.25
8
+ - 26
9
+ version: 0.4.26
10
10
  platform: ruby
11
11
  authors:
12
12
  - Seamus Abshere
@@ -128,7 +128,7 @@ dependencies:
128
128
  - 2
129
129
  - 1
130
130
  version: 0.2.1
131
- type: :development
131
+ type: :runtime
132
132
  version_requirements: *id008
133
133
  - !ruby/object:Gem::Dependency
134
134
  name: loose_tight_dictionary