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 +1 -1
- data/generators/models_from_tables/models_from_tables_generator.rb +15 -14
- data/legacy_data.gemspec +1 -1
- data/spec/expected/factories.rb +2 -2
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
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
|
-
|
86
|
-
when :
|
87
|
-
|
88
|
-
when :
|
89
|
-
|
90
|
-
when :
|
91
|
-
|
92
|
-
when :
|
93
|
-
|
94
|
-
when :
|
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
|
-
|
97
|
+
"'Sorry the models_to_tables_generator is not sure how to default columns of type #{c.type}'"
|
98
98
|
end
|
99
|
-
|
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
data/spec/expected/factories.rb
CHANGED