data_miner 0.3.6 → 0.3.7

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.3.6
1
+ 0.3.7
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{data_miner}
8
- s.version = "0.3.6"
8
+ s.version = "0.3.7"
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-03-08}
12
+ s.date = %q{2010-03-09}
13
13
  s.description = %q{Mine remote data into your ActiveRecord models. You can also perform associations and convert units.}
14
14
  s.email = %q{seamus@abshere.net}
15
15
  s.extra_rdoc_files = [
@@ -21,9 +21,16 @@ module DataMiner
21
21
  runnables << DataMiner::Process.new(self, runnable_counter, method_name_or_block_description, &block)
22
22
  end
23
23
 
24
- def import(options = {}, &block)
24
+ def import(*args, &block)
25
+ if args.length == 1
26
+ description = '(no description)'
27
+ else
28
+ description = args.first
29
+ end
30
+ options = args.last
31
+
25
32
  self.runnable_counter += 1
26
- runnables << DataMiner::Import.new(self, runnable_counter, options, &block)
33
+ runnables << DataMiner::Import.new(self, runnable_counter, description, options, &block)
27
34
  end
28
35
 
29
36
  def after_invoke
@@ -1,12 +1,14 @@
1
1
  module DataMiner
2
2
  class Import
3
3
  attr_accessor :configuration, :position_in_run, :options, :table, :errata
4
+ attr_accessor :description
4
5
  delegate :klass, :to => :configuration
5
6
  delegate :unique_indices, :to => :configuration
6
7
 
7
- def initialize(configuration, position_in_run, options = {}, &block)
8
+ def initialize(configuration, position_in_run, description, options = {}, &block)
8
9
  @configuration = configuration
9
10
  @position_in_run = position_in_run
11
+ @description = description
10
12
  @options = options
11
13
  yield self if block_given? # pull in attributes
12
14
  @errata = Errata.new(:url => options[:errata], :klass => klass) if options[:errata]
@@ -14,7 +16,7 @@ module DataMiner
14
16
  end
15
17
 
16
18
  def inspect
17
- "Import(#{klass}) position #{position_in_run}"
19
+ "Import(#{klass}) position #{position_in_run} (#{description})"
18
20
  end
19
21
 
20
22
  def attributes
@@ -537,14 +537,12 @@ class Country < ActiveRecord::Base
537
537
  data_miner do
538
538
  unique_index 'iso_3166'
539
539
 
540
- # get a complete list
541
- import :url => 'http://www.iso.org/iso/list-en1-semic-3.txt', :skip => 2, :headers => false, :delimiter => ';' do |attr|
540
+ import 'The official ISO country list', :url => 'http://www.iso.org/iso/list-en1-semic-3.txt', :skip => 2, :headers => false, :delimiter => ';' do |attr|
542
541
  attr.store 'iso_3166', :field_number => 1
543
542
  attr.store 'name', :field_number => 0
544
543
  end
545
544
 
546
- # get nicer names
547
- import :url => 'http://www.cs.princeton.edu/introcs/data/iso3166.csv' do |attr|
545
+ import 'A Princeton dataset with better capitalization', :url => 'http://www.cs.princeton.edu/introcs/data/iso3166.csv' do |attr|
548
546
  attr.store 'iso_3166', :field_name => 'country code'
549
547
  attr.store 'name', :field_name => 'country'
550
548
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_miner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
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: 2010-03-08 00:00:00 -05:00
13
+ date: 2010-03-09 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency