Sha256: cb3cadb656302c56f8142038b11057404dc1e11d5a2c13d9b289de29cdff99d1

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

PETS = File.expand_path('../pets.csv', __FILE__)
PETS_FUNNY = File.expand_path('../pets_funny.csv', __FILE__)
COLOR_DICTIONARY_ENGLISH = File.expand_path('../pet_color_dictionary.en.csv', __FILE__)
COLOR_DICTIONARY_SPANISH = File.expand_path('../pet_color_dictionary.es.csv', __FILE__)

class Pet < ActiveRecord::Base
  self.primary_key = "name"
  col :name
  col :breed_id
  col :color_id
  col :age, :type => :integer
  col :weight, :type => :float
  col :height, :type => :float
  col :favorite_food
  col :command_phrase
  col :emphatic_command_phrase
  col :age_weight
  belongs_to :breed



  data_miner do

    process :auto_upgrade!
    
    process :run_data_miner_on_parent_associations!

    import("A list of pets", :url => "file://#{PETS}") do
      key :name
      store :age
      store :breed_id, :field_name => :breed
      store :color_id, :field_name => :color, :dictionary => RemoteTable.new("file://#{COLOR_DICTIONARY_ENGLISH}").inject({}) { |memo, row| memo[row['input']] = row['output']; memo }
      store :weight
      store :favorite_food
      store :command_phrase
      store :height
      store :emphatic_command_phrase do |row|
        (row['command_phrase'] + "!!!!!") if row['command_phrase']
      end
      store :age_weight, field_name: [:age, :weight]
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
data_miner-3.0.0 test/support/pet.rb
data_miner-3.0.0.rc2 test/support/pet.rb
data_miner-3.0.0.rc1 test/support/pet.rb