kaplan 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/kaplan.rb +10 -3
  2. data/lib/kaplan/version.rb +1 -1
  3. metadata +4 -4
@@ -186,9 +186,16 @@ module Kaplan
186
186
  load filename
187
187
  when "yml", "yaml"
188
188
  data = ::YAML.load_file(filename)
189
- records = (Hash === data) ? data[data.keys.first] : data
190
189
  yield
191
- insert_rows(records, model)
190
+ if Hash === data
191
+ data.each do |model, records|
192
+ # Support customization of the model to use
193
+ model = model.classify.constantize
194
+ insert_rows(records, model)
195
+ end
196
+ else
197
+ insert_rows(records, model)
198
+ end
192
199
  else
193
200
  lines = ::File.read(filename).split(/\n/)
194
201
  yield
@@ -199,7 +206,7 @@ module Kaplan
199
206
  def insert_rows(rows, model)
200
207
  rows.each do |row|
201
208
  record = model.new
202
- # set attributes explicitly instead of just shoving them into .new
209
+ # Set attributes explicitly instead of just shoving them into .new,
203
210
  # in case 'id' is one of the attributes (which would get ignored otherwise)
204
211
  row.each {|k,v| record.send("#{k}=", v) }
205
212
  record.save!
@@ -1,3 +1,3 @@
1
1
  module Kaplan
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaplan
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Elliot Winkler
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-30 00:00:00 -06:00
18
+ date: 2011-04-04 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies: []
21
21