seamusabshere-data_miner 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/data_miner.gemspec +2 -2
- data/lib/data_miner/attribute.rb +7 -3
- data/test/data_miner_test.rb +6 -6
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/data_miner.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{data_miner}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
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{2009-09-
|
12
|
+
s.date = %q{2009-09-08}
|
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 = [
|
data/lib/data_miner/attribute.rb
CHANGED
@@ -75,7 +75,11 @@ module DataMiner
|
|
75
75
|
def value_as_association(step, value)
|
76
76
|
@_value_as_association ||= {}
|
77
77
|
@_value_as_association[step] ||= {}
|
78
|
-
|
78
|
+
if !@_value_as_association[step].has_key?(value)
|
79
|
+
dynamic_matcher = wants_create?(step) ? "find_or_create_by_#{foreign_key(step)}" : "find_by_#{foreign_key(step)}"
|
80
|
+
@_value_as_association[step][value] = reflection_klass(step).send(dynamic_matcher, value)
|
81
|
+
end
|
82
|
+
@_value_as_association[step][value]
|
79
83
|
end
|
80
84
|
|
81
85
|
# this will overwrite nils, even if wants_overwriting?(step) is false
|
@@ -193,7 +197,7 @@ module DataMiner
|
|
193
197
|
{
|
194
198
|
:static => 'options_for_step[step].has_key?(:static)',
|
195
199
|
:prefix => :prefix,
|
196
|
-
:create =>
|
200
|
+
:create => :create,
|
197
201
|
:keep => :keep,
|
198
202
|
:upcase => :upcase,
|
199
203
|
:conversion => '!from(step).nil? or !unit_in_source(step).nil?',
|
@@ -247,7 +251,7 @@ module DataMiner
|
|
247
251
|
end
|
248
252
|
|
249
253
|
def wants_inline_association?
|
250
|
-
|
254
|
+
reflection.present?
|
251
255
|
end
|
252
256
|
|
253
257
|
def callback(step)
|
data/test/data_miner_test.rb
CHANGED
@@ -69,10 +69,10 @@ class DataMinerTest < Test::Unit::TestCase
|
|
69
69
|
assert_equal 0, Airport.count
|
70
70
|
end
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
72
|
+
should "mine all classes" do
|
73
|
+
DataMiner.mine
|
74
|
+
uy = Country.find_by_iso_3166('UY')
|
75
|
+
assert_equal 'Uruguay', uy.name
|
76
|
+
assert_equal uy, Airport.find_by_iata_code('MVD').country
|
77
|
+
end
|
78
78
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seamusabshere-data_miner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
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: 2009-09-
|
13
|
+
date: 2009-09-08 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|