data_miner 1.1.6 → 1.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/data_miner.gemspec +1 -1
- data/lib/data_miner/active_record_extensions.rb +6 -2
- data/lib/data_miner/attribute.rb +8 -21
- data/lib/data_miner/dictionary.rb +1 -1
- data/lib/data_miner/import.rb +1 -0
- data/lib/data_miner/version.rb +1 -1
- data/lib/data_miner.rb +0 -1
- data/test/support/aircraft.rb +1 -1
- data/test/support/airport.rb +3 -1
- data/test/test_old_syntax.rb +262 -243
- metadata +9 -11
data/data_miner.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency 'remote_table', '>=1.
|
22
|
+
s.add_dependency 'remote_table', '>=1.2.2'
|
23
23
|
s.add_dependency 'escape', '>=0.0.4'
|
24
24
|
s.add_dependency 'activerecord', '>=2.3.4'
|
25
25
|
s.add_dependency 'activesupport', '>=2.3.4'
|
@@ -3,7 +3,7 @@ require 'blockenspiel'
|
|
3
3
|
|
4
4
|
class DataMiner
|
5
5
|
module ActiveRecordExtensions
|
6
|
-
def data_miner(&blk)
|
6
|
+
def data_miner(options = {}, &blk)
|
7
7
|
::DataMiner.instance.start_logging
|
8
8
|
|
9
9
|
::DataMiner.logger.debug "Database table `#{table_name}` doesn't exist. It might be created in the data_miner block, but if it's not, DataMiner probably won't work properly until you run a migration or otherwise fix the schema." unless table_exists?
|
@@ -26,7 +26,11 @@ class DataMiner
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
if options[:append]
|
30
|
+
self.data_miner_config ||= ::DataMiner::Config.new self
|
31
|
+
else
|
32
|
+
self.data_miner_config = ::DataMiner::Config.new self
|
33
|
+
end
|
30
34
|
|
31
35
|
::Blockenspiel.invoke blk, data_miner_config
|
32
36
|
|
data/lib/data_miner/attribute.rb
CHANGED
@@ -50,16 +50,18 @@ class DataMiner
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def value_in_source(row)
|
53
|
-
if wants_static?
|
54
|
-
|
53
|
+
value = if wants_static?
|
54
|
+
static
|
55
55
|
elsif field_number
|
56
56
|
if field_number.is_a?(::Range)
|
57
|
-
|
57
|
+
field_number.map { |n| row[n] }.join(delimiter)
|
58
58
|
else
|
59
|
-
|
59
|
+
row[field_number]
|
60
60
|
end
|
61
|
+
elsif field_name == 'row_hash'
|
62
|
+
row.row_hash
|
61
63
|
else
|
62
|
-
|
64
|
+
row[field_name]
|
63
65
|
end
|
64
66
|
return nil if value.nil?
|
65
67
|
return value if value.is_a?(::ActiveRecord::Base) # escape valve for parsers that look up associations directly
|
@@ -91,25 +93,10 @@ class DataMiner
|
|
91
93
|
value
|
92
94
|
end
|
93
95
|
|
94
|
-
# this will overwrite nils, even if wants_overwriting? is false
|
95
|
-
# returns true if an attr was changed, otherwise false
|
96
96
|
def set_record_from_row(record, row)
|
97
97
|
return false if !wants_overwriting? and !record.send(name).nil?
|
98
|
-
|
99
|
-
what_it_should_be = value_from_row row
|
100
|
-
|
101
|
-
record.send "#{name}=", what_it_should_be
|
98
|
+
record.send "#{name}=", value_from_row(row)
|
102
99
|
record.send "#{name}_units=", (to_units || unit_from_source(row)).to_s if wants_units?
|
103
|
-
|
104
|
-
what_it_is = record.send name
|
105
|
-
if what_it_is.nil? and !what_it_should_be.nil?
|
106
|
-
::DataMiner.logger.debug "ActiveRecord didn't like trying to set #{resource}.#{name} = #{what_it_should_be} (it came out as nil)"
|
107
|
-
nil
|
108
|
-
elsif what_it_is == what_it_was
|
109
|
-
false
|
110
|
-
else
|
111
|
-
true
|
112
|
-
end
|
113
100
|
end
|
114
101
|
|
115
102
|
def unit_from_source(row)
|
data/lib/data_miner/import.rb
CHANGED
data/lib/data_miner/version.rb
CHANGED
data/lib/data_miner.rb
CHANGED
data/test/support/aircraft.rb
CHANGED
@@ -80,7 +80,7 @@ class Aircraft < ActiveRecord::Base
|
|
80
80
|
%w{ D }.each do |letter|
|
81
81
|
import("ICAO codes starting with letter #{letter} used by the FAA",
|
82
82
|
:url => "http://www.faa.gov/air_traffic/publications/atpubs/CNT/5-2-#{letter}.htm",
|
83
|
-
:encoding => '
|
83
|
+
:encoding => 'windows-1252',
|
84
84
|
:errata => { :url => 'http://spreadsheets.google.com/pub?key=tObVAGyqOkCBtGid0tJUZrw', :responder => 'Aircraft::Guru' },
|
85
85
|
:row_xpath => '//table/tr[2]/td/table/tr',
|
86
86
|
:column_xpath => 'td') do
|
data/test/support/airport.rb
CHANGED
@@ -2,7 +2,9 @@ class Airport < ActiveRecord::Base
|
|
2
2
|
set_primary_key :iata_code
|
3
3
|
|
4
4
|
data_miner do
|
5
|
-
import :url => '
|
5
|
+
import :url => 'https://openflights.svn.sourceforge.net/svnroot/openflights/openflights/data/airports.dat',
|
6
|
+
:headers => false,
|
7
|
+
:select => lambda { |row| row[4].present? } do
|
6
8
|
key 'iata_code', :field_number => 4
|
7
9
|
store 'name', :field_number => 1
|
8
10
|
store 'city', :field_number => 2
|
data/test/test_old_syntax.rb
CHANGED
@@ -631,253 +631,272 @@ end
|
|
631
631
|
|
632
632
|
# todo: have somebody properly organize these
|
633
633
|
class TestOldSyntax < Test::Unit::TestCase
|
634
|
-
if ENV['WIP']
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
end
|
645
|
-
|
646
|
-
if ENV['ALL'] == 'true'
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
end
|
655
|
-
|
656
|
-
if ENV['ALL'] == 'true' or ENV['FAST'] == 'true'
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
634
|
+
# if ENV['WIP']
|
635
|
+
# context 'with nullify option' do
|
636
|
+
# should 'treat blank fields as null values' do
|
637
|
+
# Aircraft.delete_all
|
638
|
+
# Aircraft.data_miner_runs.delete_all
|
639
|
+
# Aircraft.run_data_miner!
|
640
|
+
# assert_greater_than 0, Aircraft.count
|
641
|
+
# assert_false Aircraft.where(:brighter_planet_aircraft_class_code => nil).empty?
|
642
|
+
# end
|
643
|
+
# end
|
644
|
+
# end
|
645
|
+
#
|
646
|
+
# if ENV['ALL'] == 'true'
|
647
|
+
# should 'directly create a table for the model' do
|
648
|
+
# if AutomobileMakeFleetYear.table_exists?
|
649
|
+
# ActiveRecord::Base.connection.execute 'DROP TABLE automobile_make_fleet_years;'
|
650
|
+
# end
|
651
|
+
# AutomobileMakeFleetYear.execute_schema
|
652
|
+
# assert AutomobileMakeFleetYear.table_exists?
|
653
|
+
# end
|
654
|
+
# end
|
655
|
+
#
|
656
|
+
# if ENV['ALL'] == 'true' or ENV['FAST'] == 'true'
|
657
|
+
# should 'append to an existing config' do
|
658
|
+
# AutomobileFuelType.class_eval do
|
659
|
+
# data_miner :append => true do
|
660
|
+
# import 'example1', :url => 'http://example1.com' do
|
661
|
+
# key 'code'
|
662
|
+
# store 'name'
|
663
|
+
# end
|
664
|
+
# end
|
665
|
+
# data_miner :append => true do
|
666
|
+
# import 'example2', :url => 'http://example2.com' do
|
667
|
+
# key 'code'
|
668
|
+
# store 'name'
|
669
|
+
# end
|
670
|
+
# end
|
671
|
+
# end
|
672
|
+
# assert_equal 'http://example1.com', AutomobileFuelType.data_miner_config.steps[-2].table.url
|
673
|
+
# assert_equal 'http://example2.com', AutomobileFuelType.data_miner_config.steps[-1].table.url
|
674
|
+
# end
|
675
|
+
#
|
676
|
+
# should 'override an existing data_miner configuration' do
|
677
|
+
# AutomobileFuelType.class_eval do
|
678
|
+
# data_miner do
|
679
|
+
# import 'example', :url => 'http://example.com' do
|
680
|
+
# key 'code'
|
681
|
+
# store 'name'
|
682
|
+
# end
|
683
|
+
# end
|
684
|
+
# end
|
685
|
+
# assert_kind_of DataMiner::Import, AutomobileFuelType.data_miner_config.steps.first
|
686
|
+
# assert_equal 'http://example.com', AutomobileFuelType.data_miner_config.steps.first.table.url
|
687
|
+
# end
|
688
|
+
# should "stop and finish if it gets a DataMiner::Finish" do
|
689
|
+
# AutomobileMakeFleetYear.delete_all
|
690
|
+
# AutomobileMakeFleetYear.data_miner_runs.delete_all
|
691
|
+
# $force_finish = true
|
692
|
+
# AutomobileMakeFleetYear.run_data_miner!
|
693
|
+
# assert_equal 0, AutomobileMakeFleetYear.count
|
694
|
+
# assert (AutomobileMakeFleetYear.data_miner_runs.count > 0)
|
695
|
+
# assert AutomobileMakeFleetYear.data_miner_runs.all? { |run| run.finished? and not run.skipped and not run.killed? }
|
696
|
+
# $force_finish = false
|
697
|
+
# AutomobileMakeFleetYear.run_data_miner!
|
698
|
+
# assert AutomobileMakeFleetYear.exists?(:name => 'Alfa Romeo IP 1978')
|
699
|
+
# end
|
700
|
+
#
|
701
|
+
# should "stop and register skipped if it gets a DataMiner::Skip" do
|
702
|
+
# AutomobileMakeFleetYear.delete_all
|
703
|
+
# AutomobileMakeFleetYear.data_miner_runs.delete_all
|
704
|
+
# $force_skip = true
|
705
|
+
# AutomobileMakeFleetYear.run_data_miner!
|
706
|
+
# assert_equal 0, AutomobileMakeFleetYear.count
|
707
|
+
# assert (AutomobileMakeFleetYear.data_miner_runs.count > 0)
|
708
|
+
# assert AutomobileMakeFleetYear.data_miner_runs.all? { |run| run.skipped? and not run.finished? and not run.killed? }
|
709
|
+
# $force_skip = false
|
710
|
+
# AutomobileMakeFleetYear.run_data_miner!
|
711
|
+
# assert AutomobileMakeFleetYear.exists?(:name => 'Alfa Romeo IP 1978')
|
712
|
+
# end
|
713
|
+
#
|
714
|
+
# should "eagerly enforce a schema" do
|
715
|
+
# ActiveRecord::Base.connection.create_table 'census_division_trois', :force => true, :options => 'ENGINE=InnoDB default charset=utf8' do |t|
|
716
|
+
# t.string 'name'
|
717
|
+
# t.string 'census_region_name'
|
718
|
+
# # t.integer 'census_region_number'
|
719
|
+
# end
|
720
|
+
# ActiveRecord::Base.connection.execute 'ALTER TABLE census_division_trois ADD INDEX (census_region_name)'
|
721
|
+
# CensusDivisionTrois.reset_column_information
|
722
|
+
# missing_columns = %w{ census_region_number }
|
723
|
+
#
|
724
|
+
# # sanity check
|
725
|
+
# missing_columns.each do |column|
|
726
|
+
# assert_false CensusDivisionTrois.column_names.include?(column)
|
727
|
+
# end
|
728
|
+
# assert_false ActiveRecord::Base.connection.indexes(CensusDivisionTrois.table_name).any? { |index| index.name == 'homefry' }
|
729
|
+
#
|
730
|
+
# 3.times do
|
731
|
+
# CensusDivisionTrois.run_data_miner!
|
732
|
+
# missing_columns.each do |column|
|
733
|
+
# assert CensusDivisionTrois.column_names.include?(column)
|
734
|
+
# end
|
735
|
+
# assert ActiveRecord::Base.connection.indexes(CensusDivisionTrois.table_name).any? { |index| index.name == 'homefry' }
|
736
|
+
# assert_equal :string, CensusDivisionTrois.columns_hash[CensusDivisionTrois.primary_key].type
|
737
|
+
# end
|
738
|
+
# end
|
739
|
+
#
|
740
|
+
# should "let schemas work with default id primary keys" do
|
741
|
+
# ActiveRecord::Base.connection.create_table 'census_division_fours', :force => true, :options => 'ENGINE=InnoDB default charset=utf8' do |t|
|
742
|
+
# t.string 'name'
|
743
|
+
# t.string 'census_region_name'
|
744
|
+
# # t.integer 'census_region_number'
|
745
|
+
# end
|
746
|
+
# ActiveRecord::Base.connection.execute 'ALTER TABLE census_division_fours ADD INDEX (census_region_name)'
|
747
|
+
# CensusDivisionFour.reset_column_information
|
748
|
+
# missing_columns = %w{ census_region_number }
|
749
|
+
#
|
750
|
+
# # sanity check
|
751
|
+
# missing_columns.each do |column|
|
752
|
+
# assert_false CensusDivisionFour.column_names.include?(column)
|
753
|
+
# end
|
754
|
+
# assert_false ActiveRecord::Base.connection.indexes(CensusDivisionFour.table_name).any? { |index| index.name == 'homefry' }
|
755
|
+
#
|
756
|
+
# 3.times do
|
757
|
+
# CensusDivisionFour.run_data_miner!
|
758
|
+
# missing_columns.each do |column|
|
759
|
+
# assert CensusDivisionFour.column_names.include?(column)
|
760
|
+
# end
|
761
|
+
# assert ActiveRecord::Base.connection.indexes(CensusDivisionFour.table_name).any? { |index| index.name == 'homefry' }
|
762
|
+
# assert_equal :integer, CensusDivisionFour.columns_hash[CensusDivisionFour.primary_key].type
|
763
|
+
# end
|
764
|
+
# end
|
746
765
|
|
747
766
|
should "allow specifying dictionaries explicitly" do
|
748
767
|
CensusDivisionDeux.run_data_miner!
|
749
768
|
assert_equal 'South Region', CensusDivisionDeux.find(5).census_region_name
|
750
769
|
end
|
751
770
|
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
end
|
844
|
-
|
845
|
-
if ENV['ALL'] == 'true' or ENV['SLOW'] == 'true'
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
end
|
871
|
-
should "mark the run as skipped if verification fails" do
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
end
|
771
|
+
# should "be able to key on things other than the primary key" do
|
772
|
+
# Aircraft.run_data_miner!
|
773
|
+
# assert_equal 'SP', Aircraft.find('DHC6').brighter_planet_aircraft_class_code
|
774
|
+
# end
|
775
|
+
#
|
776
|
+
# should "be able to synthesize rows without using a full parser class" do
|
777
|
+
# AutomobileMakeFleetYear.run_data_miner!
|
778
|
+
# assert AutomobileMakeFleetYear.exists?(:name => 'Alfa Romeo IP 1978')
|
779
|
+
# end
|
780
|
+
#
|
781
|
+
# should "keep a call stack so that you can call run_data_miner! on a child" do
|
782
|
+
# CrosscallingCensusDivision.run_data_miner!
|
783
|
+
# assert CrosscallingCensusDivision.exists? :name => 'Mountain Division', :number => 8, :census_region_number => 4, :census_region_name => 'West Region'
|
784
|
+
# assert CrosscallingCensusRegion.exists? :name => 'West Region', :number => 4
|
785
|
+
# end
|
786
|
+
#
|
787
|
+
# should "keep a call stack so that you can call run_data_miner! on a parent" do
|
788
|
+
# CrosscallingCensusRegion.run_data_miner!
|
789
|
+
# assert CrosscallingCensusDivision.exists? :name => 'Mountain Division', :number => 8, :census_region_number => 4, :census_region_name => 'West Region'
|
790
|
+
# assert CrosscallingCensusRegion.exists? :name => 'West Region', :number => 4
|
791
|
+
# end
|
792
|
+
#
|
793
|
+
# should "import airports" do
|
794
|
+
# Airport.run_data_miner!
|
795
|
+
# assert Airport.count > 0
|
796
|
+
# end
|
797
|
+
#
|
798
|
+
# should "tap airports" do
|
799
|
+
# TappedAirport.run_data_miner!
|
800
|
+
# assert TappedAirport.count > 0
|
801
|
+
# end
|
802
|
+
#
|
803
|
+
# should "pull in census divisions using a data.brighterplanet.com dictionary" do
|
804
|
+
# CensusDivision.run_data_miner!
|
805
|
+
# assert CensusDivision.count > 0
|
806
|
+
# end
|
807
|
+
#
|
808
|
+
# should "have a way to queue up runs that works with delated_job's send_later" do
|
809
|
+
# assert AutomobileVariant.respond_to?(:run_data_miner!)
|
810
|
+
# end
|
811
|
+
#
|
812
|
+
# should "be idempotent" do
|
813
|
+
# Country.data_miner_config.run
|
814
|
+
# a = Country.count
|
815
|
+
# Country.data_miner_config.run
|
816
|
+
# b = Country.count
|
817
|
+
# assert_equal a, b
|
818
|
+
#
|
819
|
+
# CensusRegion.data_miner_config.run
|
820
|
+
# a = CensusRegion.count
|
821
|
+
# CensusRegion.data_miner_config.run
|
822
|
+
# b = CensusRegion.count
|
823
|
+
# assert_equal a, b
|
824
|
+
# end
|
825
|
+
#
|
826
|
+
# should "hash things" do
|
827
|
+
# AutomobileVariant.data_miner_config.steps[0].run
|
828
|
+
# assert AutomobileVariant.first.row_hash.present?
|
829
|
+
# end
|
830
|
+
#
|
831
|
+
# should "process a callback block instead of a method" do
|
832
|
+
# AutomobileVariant.delete_all
|
833
|
+
# AutomobileVariant.data_miner_config.steps[0].run
|
834
|
+
# assert !AutomobileVariant.first.fuel_efficiency_city.present?
|
835
|
+
# AutomobileVariant.data_miner_config.steps.last.run
|
836
|
+
# assert AutomobileVariant.first.fuel_efficiency_city.present?
|
837
|
+
# end
|
838
|
+
#
|
839
|
+
# should "keep a log when it does a run" do
|
840
|
+
# approx_started_at = Time.now
|
841
|
+
# DataMiner.run :resource_names => %w{ Country }
|
842
|
+
# approx_terminated_at = Time.now
|
843
|
+
# last_run = DataMiner::Run.first(:conditions => { :resource_name => 'Country' }, :order => 'id DESC')
|
844
|
+
# assert (last_run.started_at - approx_started_at).abs < 5 # seconds
|
845
|
+
# assert (last_run.terminated_at - approx_terminated_at).abs < 5 # seconds
|
846
|
+
# end
|
847
|
+
#
|
848
|
+
# should "request a re-import from scratch" do
|
849
|
+
# c = Country.new
|
850
|
+
# c.iso_3166 = 'JUNK'
|
851
|
+
# c.save!
|
852
|
+
# assert Country.exists?(:iso_3166 => 'JUNK')
|
853
|
+
# DataMiner.run :resource_names => %w{ Country }, :from_scratch => true
|
854
|
+
# assert !Country.exists?(:iso_3166 => 'JUNK')
|
855
|
+
# end
|
856
|
+
#
|
857
|
+
# should "know what runs were on a resource" do
|
858
|
+
# DataMiner.run :resource_names => %w{ Country }
|
859
|
+
# DataMiner.run :resource_names => %w{ Country }
|
860
|
+
# assert Country.data_miner_runs.count > 0
|
861
|
+
# end
|
862
|
+
# end
|
863
|
+
#
|
864
|
+
# if ENV['ALL'] == 'true' or ENV['SLOW'] == 'true'
|
865
|
+
# should "allow errata to be specified with a shorthand, assuming the responder is the resource class itself" do
|
866
|
+
# AircraftDeux.run_data_miner!
|
867
|
+
# assert AircraftDeux.exists? :icao_code => 'DC91', :bts_aircraft_type_code => '630'
|
868
|
+
# end
|
869
|
+
#
|
870
|
+
# should "mine aircraft" do
|
871
|
+
# Aircraft.run_data_miner!
|
872
|
+
# assert Aircraft.exists? :icao_code => 'DC91', :bts_aircraft_type_code => '630'
|
873
|
+
# end
|
874
|
+
#
|
875
|
+
# should "mine automobile variants" do
|
876
|
+
# AutomobileVariant.run_data_miner!
|
877
|
+
# assert AutomobileVariant.count('make_name LIKE "%tesla"') > 0
|
878
|
+
# end
|
879
|
+
#
|
880
|
+
# should "mine T100 flight segments" do
|
881
|
+
# T100FlightSegment.run_data_miner!
|
882
|
+
# assert T100FlightSegment.count('dest_country_name LIKE "%United States"') > 0
|
883
|
+
# end
|
884
|
+
#
|
885
|
+
# should "mine residence survey responses" do
|
886
|
+
# ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
887
|
+
# assert ResidentialEnergyConsumptionSurveyResponse.find(6).residence_class.start_with?('Single-family detached house')
|
888
|
+
# end
|
889
|
+
# end
|
890
|
+
# should "mark the run as skipped if verification fails" do
|
891
|
+
# AutomobileFuelType.data_miner_config.instance_eval do
|
892
|
+
# verify "failure" do
|
893
|
+
# false
|
894
|
+
# end
|
895
|
+
# end
|
896
|
+
#
|
897
|
+
# DataMiner::Run.delete_all
|
898
|
+
# assert_raise do
|
899
|
+
# AutomobileFuelType.run_data_miner! :from_scratch => true
|
900
|
+
# end
|
901
|
+
# end
|
883
902
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_miner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 8
|
10
|
+
version: 1.1.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Seamus Abshere
|
@@ -17,8 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-
|
21
|
-
default_executable:
|
20
|
+
date: 2011-05-06 00:00:00 Z
|
22
21
|
dependencies:
|
23
22
|
- !ruby/object:Gem::Dependency
|
24
23
|
name: remote_table
|
@@ -28,12 +27,12 @@ dependencies:
|
|
28
27
|
requirements:
|
29
28
|
- - ">="
|
30
29
|
- !ruby/object:Gem::Version
|
31
|
-
hash:
|
30
|
+
hash: 27
|
32
31
|
segments:
|
33
32
|
- 1
|
34
|
-
-
|
35
|
-
-
|
36
|
-
version: 1.
|
33
|
+
- 2
|
34
|
+
- 2
|
35
|
+
version: 1.2.2
|
37
36
|
type: :runtime
|
38
37
|
version_requirements: *id001
|
39
38
|
- !ruby/object:Gem::Dependency
|
@@ -261,7 +260,6 @@ files:
|
|
261
260
|
- test/test_data_miner_process.rb
|
262
261
|
- test/test_data_miner_verify.rb
|
263
262
|
- test/test_old_syntax.rb
|
264
|
-
has_rdoc: true
|
265
263
|
homepage: https://github.com/seamusabshere/data_miner
|
266
264
|
licenses: []
|
267
265
|
|
@@ -291,7 +289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
291
289
|
requirements: []
|
292
290
|
|
293
291
|
rubyforge_project: data_miner
|
294
|
-
rubygems_version: 1.
|
292
|
+
rubygems_version: 1.7.2
|
295
293
|
signing_key:
|
296
294
|
specification_version: 3
|
297
295
|
summary: Mine remote data into your ActiveRecord models.
|