schema_to_scaffold 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8de36372e8689f2dde99b643b28c3a716db14e70
4
+ data.tar.gz: dfa57a6943cd21193c7c25fd2bc68b24211a5821
5
+ SHA512:
6
+ metadata.gz: dd9f750ec2ef14231d6ca6c3aec459f0e52fb90717d1872a93d9b3ac56c25d0ca4728f4c2e0618fb9af1a8d30475cc60d301ad976cd18a3b7a734f5a39b4348f
7
+ data.tar.gz: 47faed47d547fe093e0113418ac0bd2f9ef1543f0de9259629d4bab33fef9770ac97f10487e227c593f35e2dfd3585f40fdcab808fd03a6edb5c569739214d56
data/bin/scaffold CHANGED
@@ -33,17 +33,36 @@ begin
33
33
  raise if schema.table_names.empty?
34
34
  puts "\nLoaded tables:"
35
35
  schema.table_names.each_with_index {|name,i| puts "#{i}. #{name}" }
36
+
37
+ puts "\n*. All Tables"
38
+
36
39
  print "\nSelect a table: "
40
+
37
41
  rescue
38
42
  puts "Could not find tables in '#{path}'"
39
43
  exit 1
40
- end while schema.table_names[(table_id = gets.to_i)].nil?
44
+ end
45
+
46
+ result = gets.strip
47
+
48
+ if result == "*"
49
+ tables = (0..schema.table_names.count-1).map{|i|i}
50
+ else
51
+ tables = [result.to_i]
52
+ end
53
+
54
+ script_scaffold = []
55
+ script_factory_girl = []
56
+ tables.each do |table_id|
57
+ script_scaffold << SchemaToScaffold.generate_script(schema, table_id,"scaffold")
58
+ script_factory_girl << SchemaToScaffold.generate_script(schema, table_id,"factory_girl:model")
59
+ end
41
60
 
42
- script_scaffold = SchemaToScaffold.generate_script(schema, table_id,"scaffold")
43
- puts "\nScript for rails scaffold\n#{script_scaffold}"
61
+ puts "\nScript for rails scaffold"
62
+ puts script_scaffold.join("\n")
44
63
 
45
- script_factory_girl = SchemaToScaffold.generate_script(schema, table_id,"factory_girl:model")
46
- puts "\nScript for factory girl\n#{script_factory_girl}"
64
+ puts "\nScript for factory girl"
65
+ puts script_factory_girl.join("\n")
47
66
 
48
67
 
49
68
  if opts[:xclip]
@@ -12,7 +12,10 @@ module SchemaToScaffold
12
12
  end
13
13
 
14
14
  def self.parse(attribute)
15
- Attribute.new(*attribute.match(/t\.(\w+)\s+"(\w+)"/).captures)
15
+ match = attribute.match(/t\.(\w+)\s+"(\w+)"/)
16
+ if match
17
+ Attribute.new(*match.captures)
18
+ end
16
19
  end
17
20
 
18
21
 
@@ -12,8 +12,8 @@ module SchemaToScaffold
12
12
  end
13
13
 
14
14
  def to_script(target)
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"
15
+ return "rails generate #{target} #{modelize name} #{attributes.map(&:to_script).reject{|x| x.nil? || x.empty?}.join(' ')}" if target == "scaffold"
16
+ return "rails generate #{target} #{modelize name} #{attributes.map(&:to_script).reject{|x| x.nil? || x.empty?}.join(' ')}" if target == "factory_girl:model"
17
17
  end
18
18
 
19
19
  def self.parse(table_data)
@@ -1,6 +1,6 @@
1
1
  module SchemaToScaffold
2
2
  MAJOR = 0
3
- MINOR = 4
4
- REVISION = 2
3
+ MINOR = 5
4
+ REVISION = 0
5
5
  VERSION = [MAJOR, MINOR, REVISION].join('.')
6
6
  end
metadata CHANGED
@@ -1,8 +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.2
5
- prerelease:
4
+ version: 0.5.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - João Soares
@@ -10,28 +9,24 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-05-22 00:00:00.000000000 Z
12
+ date: 2013-12-19 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: activesupport
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: 3.2.1
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - '>='
29
26
  - !ruby/object:Gem::Version
30
27
  version: 3.2.1
31
- description: ! ' Command line app which parses a schema.rb file obtained from your
32
- rails repo or by running rake:schema:dump
33
-
34
- '
28
+ description: |2
29
+ Command line app which parses a schema.rb file obtained from your rails repo or by running rake:schema:dump
35
30
  email:
36
31
  - jsoaresgeral@gmail.com
37
32
  - hlsp999@gmail.com
@@ -56,26 +51,25 @@ files:
56
51
  homepage: http://github.com/frenesim/schema_to_scaffold
57
52
  licenses:
58
53
  - MIT
54
+ metadata: {}
59
55
  post_install_message: Thanks for installing!
60
56
  rdoc_options: []
61
57
  require_paths:
62
58
  - lib
63
59
  required_ruby_version: !ruby/object:Gem::Requirement
64
- none: false
65
60
  requirements:
66
- - - ! '>='
61
+ - - '>='
67
62
  - !ruby/object:Gem::Version
68
63
  version: '0'
69
64
  required_rubygems_version: !ruby/object:Gem::Requirement
70
- none: false
71
65
  requirements:
72
- - - ! '>='
66
+ - - '>='
73
67
  - !ruby/object:Gem::Version
74
68
  version: '0'
75
69
  requirements: []
76
70
  rubyforge_project:
77
- rubygems_version: 1.8.24
71
+ rubygems_version: 2.0.3
78
72
  signing_key:
79
- specification_version: 3
73
+ specification_version: 4
80
74
  summary: Generate rails scaffold script from a schema.rb file.
81
75
  test_files: []