legacy_data 0.1.7 → 0.1.8

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.1.7
1
+ 0.1.8
@@ -78,25 +78,26 @@ protected
78
78
 
79
79
  File.open("#{RAILS_ROOT}/spec/factories.rb", 'a+') do |file|
80
80
  file.write "Factory.define :#{factory_name} do |#{factory_name.to_s.first}|\n"
81
+ column_with_longest_name = columns.max {|a,b| a.name.length <=> b.name.length }
81
82
  columns.each do |c|
82
83
  if c.null == false && c.name != analyzed_schema[:primary_key]
83
84
  value = case c.type
84
- when :integer
85
- "7"
86
- when :string
87
- "'hi'"
88
- when :boolean
89
- 'false'
90
- when :date
91
- '{Time.now}'
92
- when :datetime
93
- '{Time.now}'
94
- when :decimal
95
- '12.3'
85
+ when :integer then %[7]
86
+ when :float then %[12.3]
87
+ when :decimal then %[12.3]
88
+ when :datetime then %[{Time.now}]
89
+ when :date then %[{Time.now}]
90
+ when :timestamp then %[{Time.now}]
91
+ when :time then %[{Time.now}]
92
+ when :text then %['some text value']
93
+ when :string then %['some string']
94
+ when :binary then %['some binary stuff']
95
+ when :boolean then %[false]
96
96
  else
97
- raise "the generator forgot to handle columns of type #{c.type}"
97
+ "'Sorry the models_to_tables_generator is not sure how to default columns of type #{c.type}'"
98
98
  end
99
- file.write " #{factory_name.to_s.first}.#{c.name} #{value}\n"
99
+ spaces = column_with_longest_name.name.size - c.name.size
100
+ file.write " #{factory_name.to_s.first}.#{c.name}#{' ' * spaces} #{value}\n"
100
101
  end
101
102
  end
102
103
  file.write "end\n\n"
data/legacy_data.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{legacy_data}
8
- s.version = "0.1.7"
8
+ s.version = "0.1.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alex Rothenberg"]
@@ -1,5 +1,5 @@
1
1
  Factory.define :post do |p|
2
- p.title 'hi'
3
- p.body 'hi'
2
+ p.title 'some string'
3
+ p.body 'some string'
4
4
  end
5
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legacy_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Rothenberg