schema_to_scaffold 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,7 @@ module SchemaToScaffold
|
|
2
2
|
require 'active_support/inflector'
|
3
3
|
##
|
4
4
|
# fetch table names and convert them to a scaffold syntax
|
5
|
+
|
5
6
|
class Table
|
6
7
|
|
7
8
|
attr_reader :attributes, :name
|
@@ -11,8 +12,8 @@ module SchemaToScaffold
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def to_script(target)
|
14
|
-
return "rails generate #{target} #{name} #{attributes.map(&:to_script).join(' ')}" if target == "scaffold"
|
15
|
-
return "rails generate #{target} #{name
|
15
|
+
return "rails generate #{target} #{modelize name} #{attributes.map(&:to_script).join(' ')}" if target == "scaffold"
|
16
|
+
return "rails generate #{target} #{modelize name} #{attributes.map(&:to_script).join(' ')}" if target == "factory_girl:model"
|
16
17
|
end
|
17
18
|
|
18
19
|
def self.parse(table_data)
|
@@ -21,5 +22,11 @@ module SchemaToScaffold
|
|
21
22
|
atts = table_data.lines.to_a.select {|line| line =~ /t\.\w+/ }.map {|att| Attribute.parse att }
|
22
23
|
Table.new(name, atts)
|
23
24
|
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def modelize (string)
|
28
|
+
string.camelize.singularize
|
29
|
+
end
|
30
|
+
|
24
31
|
end
|
25
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_to_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-05-
|
13
|
+
date: 2013-05-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|