ez_model 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,15 +3,47 @@ Generate models and schema.rb from existing database just in one command line. I
3
3
 
4
4
  It uses [Rmre](https://github.com/bosko/rmre "Rmre") as underlying reverse engine to generate models. I made some modifications to Rmre to support mysql2 adapter, and had those auto-generated model files placed in a subfolder inside ~/app/models/ez_models/ instead of the default ~/app/models/, so that regenerating models will not overwrite the existing ones. Over the times, db schema can ge changed, all it needs is to run the command again to regenerate models, developers can feel free to add methods to the models classes in ~/app/models/ without worrying about being overwritten.
5
5
 
6
+
7
+ ## How it works
8
+ First let's take a look at what it does.
9
+
10
+ In ~/app/models/ez_models/, it will generate model files inherit ActiveRecord::Base
11
+
12
+ ~/app/models/ez_models/billing_info.rb
13
+
14
+ # This file is auto-generated from the current state of the database registered
15
+ # in ~config/database.yml. Instead of editing this file, please go to ~/app/models/
16
+ # and find the file with same name and class that inherits this class
17
+ module EZModel
18
+ module ActiveRecord
19
+ class BillingInfo < ActiveRecord::Base
20
+ belongs_to :users, :class_name => 'User', :foreign_key => :user_id
21
+ belongs_to :invoices, :class_name => 'Invoice', :foreign_key => :invoice_id
22
+ has_many :chargebacks, :class_name => 'Chargeback'
23
+ end
24
+ end
25
+ end
26
+
27
+ Isn't model files supposed to be in ~/app/models/? Take a look at the following first
28
+ In ~/app/models/, it will generate same model files and inherit the above classes
29
+
30
+ ~/app/models/billing_info.rb
31
+
32
+ require File.expand_path('../ez_models/billing_info', __FILE__)
33
+ # Please add your own methods to this class.
34
+ # It's strongly recommended to check this file into your version control system.
35
+ class BillingInfo < EZModel::ActiveRecord::BillingInfo
36
+
37
+ end
38
+
39
+
6
40
  ## How to use it
7
41
  ###Prerequisite
8
- ####1. Setup database server, mysql is suggested;
9
-
10
- ####2. Setup database schema, if you already have a database set up, skip this step;
42
+ ####1. Setup database schema, if you already have a database set up, skip this step;
11
43
  there are many tools can be use for database design, you can then export scripts to generate db schema;
12
44
  checkout mysql-workbench and its forward-engineering feature for more details about designing ER diagram and generate schema;
13
45
 
14
- ####3. Prepare ~/config/database.yml, here is a sample:
46
+ ####2. Prepare ~/config/database.yml, here is a sample:
15
47
 
16
48
  development:
17
49
  adapter: mysql2
@@ -71,7 +103,7 @@ see version
71
103
 
72
104
  See here for more details: [http://rubygems.org/gems/ez_model](http://rubygems.org/gems/ez_model "EZModel RubyGem Page")
73
105
 
74
- ## Author
106
+ ## Authors
75
107
  Tianyu Huang
76
108
  The reverse engine for generating models was created by Bosko Ivanisevic, check out https://github.com/bosko/rmre for details
77
109
 
data/ez_model.gemspec CHANGED
@@ -11,9 +11,8 @@ Gem::Specification.new do |s|
11
11
  s.version = ::EZModel::VERSION
12
12
  s.platform = Gem::Platform::RUBY
13
13
  s.date = "2012-04-08"
14
- s.summary = "%q{Generate model files just in one command line}"
15
- s.description = "%q{ Generate models and schema.rb from existing database just in one command line. If you prefer design ER diagram and export scripts to generate database schema, or if you have to work with a legacy database, this can save you insane amount of time. All you need to do is to have a database.yml configuraiton file in ~/config/. Besides creating all models it sets proper table name and primary key if tables and columns naming doesn’t follow Rails convention. It also tries to read all foreign keys data from a database.
16
- It uses Rmre as underlying reverse engine to generate models. I made some modifications to Rmre to support mysql2 adapter, and had those auto-generated model files placed in a subfolder inside ~/app/models/ez_models/ instead of the default ~/app/models/, so that regenerating models will not overwrite the existing ones. Over the times, db schema can ge changed, all it needs is to run the command again to regenerate models, developers can feel free to add methods to the models classes in ~/app/models/ without worrying about being overwritten.}"
14
+ s.summary = "Rails gem for generating model files in one command line"
15
+ s.description = "Generate models and schema.rb from existing(legacy) database just in one command line. If you prefer design ER diagram and export scripts to generate database schema, or if you have to work with a legacy database, this can save you insane amount of time. All you need to do is to have a database.yml configuraiton file in ~/config/. Besides creating all models it sets proper table name and primary key if tables and columns naming doesn’t follow Rails convention. It also tries to read all foreign keys data from a database. It uses Rmre as underlying reverse engine to generate models..."
17
16
 
18
17
  # Author info
19
18
  s.authors = ["Tianyu Huang"]
@@ -1,3 +1,3 @@
1
1
  module EZModel
2
- VERSION = "1.0.2" unless defined?(::EZModel::VERSION)
2
+ VERSION = "1.0.3" unless defined?(::EZModel::VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ez_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &72362480 !ruby/object:Gem::Requirement
16
+ requirement: &82647050 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *72362480
24
+ version_requirements: *82647050
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: erubis
27
- requirement: &72362180 !ruby/object:Gem::Requirement
27
+ requirement: &82646710 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,20 +32,15 @@ dependencies:
32
32
  version: 2.6.6
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *72362180
36
- description: ! "%q{\tGenerate models and schema.rb from existing database just in
35
+ version_requirements: *82646710
36
+ description: Generate models and schema.rb from existing(legacy) database just in
37
37
  one command line. If you prefer design ER diagram and export scripts to generate
38
38
  database schema, or if you have to work with a legacy database, this can save you
39
39
  insane amount of time. All you need to do is to have a database.yml configuraiton
40
40
  file in ~/config/. Besides creating all models it sets proper table name and primary
41
41
  key if tables and columns naming doesn’t follow Rails convention. It also tries
42
- to read all foreign keys data from a database.\n\tIt uses Rmre as underlying reverse
43
- engine to generate models. I made some modifications to Rmre to support mysql2 adapter,
44
- and had those auto-generated model files placed in a subfolder inside ~/app/models/ez_models/
45
- instead of the default ~/app/models/, so that regenerating models will not overwrite
46
- the existing ones. Over the times, db schema can ge changed, all it needs is to
47
- run the command again to regenerate models, developers can feel free to add methods
48
- to the models classes in ~/app/models/ without worrying about being overwritten.}"
42
+ to read all foreign keys data from a database. It uses Rmre as underlying reverse
43
+ engine to generate models...
49
44
  email:
50
45
  - tianhsky@yahoo.com
51
46
  executables:
@@ -94,6 +89,6 @@ rubyforge_project:
94
89
  rubygems_version: 1.8.17
95
90
  signing_key:
96
91
  specification_version: 3
97
- summary: ! '%q{Generate model files just in one command line}'
92
+ summary: Rails gem for generating model files in one command line
98
93
  test_files: []
99
94
  has_rdoc: