schema_to_scaffold 0.2.1 → 0.2.2

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/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # Schema to Scaffold #
1
+ # Schema to Scaffold
2
+
3
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/frenesim/schema_to_scaffold)
2
4
 
3
5
  Generate rails scaffold pages based on a rails database schema you already have.
4
6
 
@@ -10,14 +12,14 @@ SchemaToScaffold will generate rails scaffolding scripts by table like this:
10
12
  rails g scaffold users fname:string lname:string bdate:date email:string encrypted_password:string
11
13
 
12
14
 
13
- ## Installation ##
15
+ ## Installation
14
16
 
15
17
  Assuming that you have rubygems-bundler installed, just type:
16
18
 
17
19
  gem install schema_to_scaffold
18
20
 
19
21
 
20
- ## Usage ##
22
+ ## Usage
21
23
 
22
24
  Just type:
23
25
 
@@ -30,6 +32,23 @@ Just type:
30
32
  -c Works only on linux. Will copy the script copied to your clipboard.
31
33
  You will need to have xclip installed(see below).
32
34
 
33
- ### To install xclip ###
35
+ ### To install xclip
34
36
 
35
37
  sudo apt-get install xclip
38
+
39
+ ### Contributing
40
+
41
+ Want to contribute? Great!
42
+
43
+ 1. Fork it.
44
+ 2. Create a branch (`git checkout -b my_schema_to_scaffold`)
45
+ 3. Commit your changes (`git commit -am "Added great stuff"`)
46
+ 4. Push to the branch (`git push origin my_schema_to_scaffold`)
47
+ 5. Open a [Pull Request][1]
48
+ 6. That's all!!
49
+
50
+ [1]: http://github.com/frenesim/schema_to_scaffold/pulls
51
+
52
+ ### Collaborate
53
+
54
+ If you want to collaborate send me an email please.
data/bin/scaffold CHANGED
@@ -15,8 +15,8 @@ end
15
15
  ## looking for schema.rb in user directory
16
16
 
17
17
  unless opts[:path].to_s.match(/\.rb$/)
18
- paths = SchemaToScaffold::Path.new
19
- paths.search_in opts[:path]
18
+ paths = SchemaToScaffold::Path.new(opts[:path])
19
+ paths.search_rb
20
20
  path = paths.choose
21
21
  end
22
22
 
@@ -3,25 +3,29 @@ module SchemaToScaffold
3
3
 
4
4
  PATH_NAMES = ["HOME", "HOMEPATH", "USERPROFILE"]
5
5
 
6
+ ##
7
+ # Deal with the path argument
8
+
6
9
  class Path
7
10
 
8
- def initialize
9
- @search_path = ENV[PATH_NAMES.detect {|h| ENV[h] != nil}]
11
+ def initialize(path)
12
+ @search_path = ENV[PATH_NAMES.detect {|home| ENV[home] != nil}]
13
+ @path = path
10
14
  end
11
15
 
12
- def check_directory(path)
13
- unless File.directory?(path)
14
- puts "\nSorry #{path} is not a valid directory!"
16
+ def check_directory
17
+ unless File.directory?(@search_path)
18
+ puts "\nSorry #{@search_path} is not a valid directory!"
15
19
  exit
16
20
  end
17
- path
21
+ puts "\nLooking for schema.rb in #{@search_path}"
18
22
  end
19
23
 
20
24
  ##
21
25
  # Will search for schema.rb in the user directory
22
- def search_in(path = nil)
23
- @search_path = path.to_s unless path.nil?
24
- puts "\nLooking for schema.rb in #{check_directory @search_path}"
26
+ def search_rb
27
+ @search_path = @path.to_s unless @path.nil?
28
+ check_directory
25
29
  @schema_paths = Array.new
26
30
  Find.find(@search_path) do |s_p|
27
31
  @schema_paths<<s_p if s_p[/schema\.rb$/]
@@ -31,7 +35,7 @@ module SchemaToScaffold
31
35
  ##
32
36
  # Return the chosen path
33
37
  def choose
34
- @schema_paths.each_with_index {|path,i| puts "#{i}. #{path}" }
38
+ @schema_paths.each_with_index {|path,indx| puts "#{indx}. #{path}" }
35
39
  begin
36
40
  print "\nSelect a path to the target schema: "
37
41
  end while @schema_paths[(id = gets.to_i)].nil?
@@ -25,7 +25,7 @@ module SchemaToScaffold
25
25
  end
26
26
 
27
27
  def self.parse(data)
28
- data.split(/create_/)[1..-1].map {|table_data| Table.parse table_data }
28
+ data.split(/^\s*create_/)[1..-1].map {|table_data| Table.parse table_data }
29
29
  end
30
30
  end
31
31
  end
@@ -1,4 +1,7 @@
1
1
  module SchemaToScaffold
2
+
3
+ ##
4
+ # fetch table names and convert them to a scaffold syntax
2
5
  class Table
3
6
 
4
7
  attr_reader :attributes, :name
@@ -1,3 +1,6 @@
1
1
  module SchemaToScaffold
2
- VERSION = "0.2.1"
2
+ REVISION = 2
3
+ MINOR = 2
4
+ MAJOR = 0
5
+ VERSION = [MAJOR, MINOR, REVISION].join('.')
3
6
  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.2.1
4
+ version: 0.2.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: 2012-12-06 00:00:00.000000000 Z
13
+ date: 2013-01-17 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: ! ' Command line app which parses a schema.rb file obtained from your
16
16
  rails repo or by running rake:schema:dump
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  version: '0'
59
59
  requirements: []
60
60
  rubyforge_project:
61
- rubygems_version: 1.8.16
61
+ rubygems_version: 1.8.24
62
62
  signing_key:
63
63
  specification_version: 3
64
64
  summary: Generate rails scaffold script from a schema.rb file.