alexrothenberg-legacy_data 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
@@ -11,7 +11,11 @@ class ModelsFromTablesGenerator < Rails::Generator::Base
|
|
11
11
|
|
12
12
|
analyzed_tables = LegacyData::Schema.analyze(:table_name=>options[:table_name])
|
13
13
|
LegacyData::TableClassNameMapper.save_dictionary
|
14
|
-
puts
|
14
|
+
puts <<-MSG
|
15
|
+
Done analyzing the tables.
|
16
|
+
Please review the class names shown above. If any do not look correct (for example it did not separate the words with CamelCase) please supply the correct mappings by editing the file #{LegacyData::TableClassNameMapper.dictionary_file_name}.
|
17
|
+
Once you're done hit <enter> to continue generating the models"
|
18
|
+
MSG
|
15
19
|
gets
|
16
20
|
LegacyData::TableClassNameMapper.load_dictionary
|
17
21
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class <%= class_name -%> < ActiveRecord::Base
|
2
|
-
set_table_name
|
3
|
-
<%= "set_primary_key #{primary_key.inspect}" if primary_key %>
|
2
|
+
set_table_name <%= table_name.to_sym.inspect %>
|
3
|
+
<%= "set_primary_key #{primary_key.to_sym.inspect}" if primary_key %>
|
4
4
|
|
5
5
|
# Relationships
|
6
6
|
<%- relations[:has_some].each do |table_name, foreign_key|
|
data/legacy_data.gemspec
CHANGED
@@ -26,7 +26,7 @@ module LegacyData
|
|
26
26
|
|
27
27
|
def load_dictionary
|
28
28
|
@dictionary = nil
|
29
|
-
YAML.load_file(dictionary_file_name)
|
29
|
+
File.exists?(dictionary_file_name) ? YAML.load_file(dictionary_file_name) : {}
|
30
30
|
end
|
31
31
|
|
32
32
|
def save_dictionary
|
@@ -36,7 +36,7 @@ module LegacyData
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def dictionary_file_name
|
39
|
-
File.join(RAILS_ROOT, 'app', 'models', 'table_mappings.
|
39
|
+
File.join(RAILS_ROOT, 'app', 'models', 'table_mappings.yml')
|
40
40
|
end
|
41
41
|
|
42
42
|
def self.class_name_for table_name
|