rmre 0.0.7 → 0.0.8
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/Gemfile.lock +1 -1
- data/HISTORY.rdoc +1 -1
- data/README.rdoc +83 -0
- data/lib/rmre/version.rb +1 -1
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/HISTORY.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -63,6 +63,89 @@ If you want to try *Rmre* and you do not have sample database you can use
|
|
63
63
|
_Sakila_ at http://dev.mysql.com/doc/sakila/en/sakila.html#sakila-installation for MySQL and
|
64
64
|
_Pagila_ at http://pgfoundry.org/projects/dbsamples for PostgreSQL.
|
65
65
|
|
66
|
+
== Configuration file
|
67
|
+
|
68
|
+
Rmre will automatically generate sample configuration file if it is invoked with +-f+ switch
|
69
|
+
without file name:
|
70
|
+
|
71
|
+
rmre -o /tmp/test -f
|
72
|
+
|
73
|
+
Rmre creates two files +/tmp/test/rmre_db.rb+ and +/tmp/test/rmre_db.yml+. First file is sample
|
74
|
+
how configuration and all models created by Rmre can be loaded and how connection to database
|
75
|
+
can be established.
|
76
|
+
|
77
|
+
require "yaml"
|
78
|
+
require "active_record"
|
79
|
+
|
80
|
+
dir = File.join('/tmp/test', '*.rb')
|
81
|
+
Dir.glob(dir) { |file| require file }
|
82
|
+
|
83
|
+
def connect
|
84
|
+
settings_file = './rmre_db.yml'
|
85
|
+
exit unless File.exists?(settings_file)
|
86
|
+
settings = YAML.load_file(settings_file)
|
87
|
+
ActiveRecord::Base.establish_connection(settings[:db])
|
88
|
+
ActiveRecord::Base.connection
|
89
|
+
end
|
90
|
+
|
91
|
+
File comes in handy if you want to quickly check how generated models work. Just require this file
|
92
|
+
when you start IRB and you're ready to go:
|
93
|
+
|
94
|
+
irb -r/tmp/rmre_db.rb
|
95
|
+
>> connect
|
96
|
+
>> ... test your model here
|
97
|
+
|
98
|
+
Second file is sample configuration file which can be used to set databse connection, output path
|
99
|
+
instead of setting them through command line options. Generated file is:
|
100
|
+
|
101
|
+
---
|
102
|
+
:db:
|
103
|
+
:username: ''
|
104
|
+
:password: ''
|
105
|
+
:port:
|
106
|
+
:timeout: 5000
|
107
|
+
:adapter: adapter_name
|
108
|
+
:database: db_name
|
109
|
+
:out_path: /tmp/test
|
110
|
+
|
111
|
+
After setting values in configuration file Rmre can be started with just one option - path to
|
112
|
+
configuration file.
|
113
|
+
|
114
|
+
rmre -r /tmp/test/rmre_db.yml
|
115
|
+
|
116
|
+
== If table names do not fit in Rails naming convention
|
117
|
+
|
118
|
+
Rmre uses ActiveSupport inflections to create names of the model. This can have side effect
|
119
|
+
if table name ends with letter 's' and is not actually plural. Final file and class name will be
|
120
|
+
truncated like for example for table name +generated_des+. Converting this name to singular
|
121
|
+
form and forming file name will result in +generated_de.rb+ and model name will be GeneratedDe.
|
122
|
+
Both of these are wrong. For that purpose Rmre allows defining additional inflections in the
|
123
|
+
configuration file which can be used to properly convert (or leave as they are) table names
|
124
|
+
to singular and plural form. Inflections can be defined in Rmre configuration file.
|
125
|
+
|
126
|
+
:inflections:
|
127
|
+
- :plural:
|
128
|
+
- (.*)_des$
|
129
|
+
- \1_des
|
130
|
+
:singular:
|
131
|
+
- (.*)_des$
|
132
|
+
- \1_des
|
133
|
+
- :plural:
|
134
|
+
- (.*)_fis$
|
135
|
+
- rmre_\1_d
|
136
|
+
:singular:
|
137
|
+
- (.*)_fis$
|
138
|
+
- rmre_\1_d
|
139
|
+
|
140
|
+
Array given in +:inflections+ key must contain hashes and each hash must contain two keys
|
141
|
+
+:plural+ and +:singular+. Values for each key is array with two elements. First element is
|
142
|
+
regular expression which will be used to match table names and second element is regular expression
|
143
|
+
used to transform table name to plural or singular form. In the above example first hash will keep
|
144
|
+
all table names wich end with +_des+ string as they are. This means for table +generated_des+ resulting
|
145
|
+
file and model names will be +generated_des.rb+ and +GeneratedDes+. Second inflection will convert
|
146
|
+
all names that end with +_fis+ by prepending string +rmre+ and appending suffix +_d+. For
|
147
|
+
+tone_fis+ table resulting file and class names will be +rmre_fone_d+ and +RmreToneD+.
|
148
|
+
|
66
149
|
= Copying databases
|
67
150
|
|
68
151
|
Rmre gem has built-in support for copying databases (structure and data). This feature is
|
data/lib/rmre/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rmre
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -128,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: '0'
|
129
129
|
segments:
|
130
130
|
- 0
|
131
|
-
hash:
|
131
|
+
hash: 3490106450590144776
|
132
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
133
|
none: false
|
134
134
|
requirements:
|