rmre 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rmre (0.0.7)
4
+ rmre (0.0.8)
5
5
  activerecord (>= 3.0.0)
6
6
  erubis
7
7
 
@@ -6,7 +6,7 @@ Changes:
6
6
 
7
7
  * Fixes
8
8
 
9
- * Fixed type on HISTORY.rdoc file
9
+ * Fixed typo in HISTORY.rdoc file
10
10
 
11
11
  === 0.0.6 / 2013-05-09
12
12
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Rmre
2
- VERSION = "0.0.7" unless defined?(::Rmre::VERSION)
2
+ VERSION = "0.0.8" unless defined?(::Rmre::VERSION)
3
3
  end
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.7
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-09 00:00:00.000000000 Z
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: -3979610488748515593
131
+ hash: 3490106450590144776
132
132
  required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  none: false
134
134
  requirements: