dummy_data 0.9.5 → 0.9.6

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.
@@ -12,18 +12,16 @@ module Dummy
12
12
  assoc_name = assoc.name.to_s.camelcase
13
13
  assoc_options = assoc.options
14
14
 
15
- if assoc_options.empty?
15
+ if !assoc_options.has_key?(:foreign_key)
16
16
  @models[model][:associations].push({
17
17
  :model => assoc_name.constantize,
18
18
  :foreign_key => "#{assoc_name.underscore}_id"
19
19
  })
20
- elsif assoc_options.has_key?(:class_name) and assoc_options.has_key?(:foreign_key)
20
+ else
21
21
  @models[model][:associations].push({
22
- :model => assoc_options[:class_name].constantize, # TODO: handle class_name
22
+ :model => assoc.class_name.constantize,
23
23
  :foreign_key => assoc_options[:foreign_key]
24
24
  })
25
- else
26
- next
27
25
  end
28
26
 
29
27
  assoc_model = @models[model][:associations].last[:model]
@@ -36,17 +34,17 @@ module Dummy
36
34
  def generate_record_data(name, info, column, fixtures=true)
37
35
  column_name = String.new(column.name) # this shouldn't be needed, ruby bug?
38
36
  if((column_name == "id") or (["created_at", "created_on", "updated_at", "updated_on"].include?(column_name) and column.type == :datetime))
39
- return
37
+ return
40
38
  end
41
39
 
42
40
  associated_model = associated_class_name(info, column_name)
43
41
 
44
42
  if associated_model
45
43
  if fixtures
44
+ val = ActiveRecord::Fixtures.identify(generate_association_data(associated_model))
45
+ else
46
46
  val = generate_association_data(associated_model)
47
47
  column_name.gsub!(/_id$/, "")
48
- else
49
- val = Fixtures.identify(generate_association_data(associated_model))
50
48
  end
51
49
  else
52
50
  val = generate_regular_data(column)
@@ -104,7 +104,7 @@ module Dummy
104
104
  fixture_data.merge!(key_value) unless key_value.nil?
105
105
  end
106
106
 
107
- data[model.table_name] = Hash.new if data[model.table_name].nil?
107
+ data[model.table_name] ||= Hash.new
108
108
  data[model.table_name].merge!({ "#{name}_#{num}" => fixture_data })
109
109
  end
110
110
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dummy_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dummy
16
- requirement: &70167432360500 !ruby/object:Gem::Requirement
16
+ requirement: &70279314576120 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.9.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70167432360500
24
+ version_requirements: *70279314576120
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rails
27
- requirement: &70167432360020 !ruby/object:Gem::Requirement
27
+ requirement: &70279314575380 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 3.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70167432360020
35
+ version_requirements: *70279314575380
36
36
  description: Uses dummy to generate consistent fake data for your models (including
37
37
  associations) and provides a rake task to import it into the database
38
38
  email: