rmre 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile.lock +34 -26
- data/HISTORY.rdoc +5 -0
- data/README.rdoc +3 -3
- data/bin/rmre +6 -1
- data/lib/rmre/model.eruby +1 -1
- data/lib/rmre/version.rb +1 -1
- data/spec/rmre/generator_spec.rb +13 -11
- data/spec/rmre/migrator_spec.rb +28 -42
- metadata +18 -31
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 974e70408ee5d4b952db276c74a68d63c6b0c6e3
|
4
|
+
data.tar.gz: a6215d5293c53088c50d8d8dba84aabc3accd183
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a7a39c5eb37a7a66d140417e8bfa981c00770db8e0e96a464cab72a5c424048c5691e5d2c05b91db9907e5e9fd5fced4bf4967e8b7742409eedd8ce1c0f2a1d5
|
7
|
+
data.tar.gz: 984fa53045177f0cdd03bc8fa5ba6fc9bb8e6ecf4ed3ccbae8e07b70e8d85065f912352645b41969952709f9467563abe82e00a664d9b32fa523c76492fe400e
|
data/Gemfile.lock
CHANGED
@@ -1,39 +1,47 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rmre (0.0.
|
4
|
+
rmre (0.0.9)
|
5
5
|
activerecord (>= 3.0.0)
|
6
6
|
erubis
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (
|
12
|
-
activesupport (=
|
13
|
-
builder (~> 3.
|
14
|
-
activerecord (
|
15
|
-
activemodel (=
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
11
|
+
activemodel (4.0.0)
|
12
|
+
activesupport (= 4.0.0)
|
13
|
+
builder (~> 3.1.0)
|
14
|
+
activerecord (4.0.0)
|
15
|
+
activemodel (= 4.0.0)
|
16
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
17
|
+
activesupport (= 4.0.0)
|
18
|
+
arel (~> 4.0.0)
|
19
|
+
activerecord-deprecated_finders (1.0.3)
|
20
|
+
activesupport (4.0.0)
|
21
|
+
i18n (~> 0.6, >= 0.6.4)
|
22
|
+
minitest (~> 4.2)
|
23
|
+
multi_json (~> 1.3)
|
24
|
+
thread_safe (~> 0.1)
|
25
|
+
tzinfo (~> 0.3.37)
|
26
|
+
arel (4.0.0)
|
27
|
+
atomic (1.1.13)
|
28
|
+
builder (3.1.4)
|
29
|
+
diff-lcs (1.2.4)
|
25
30
|
erubis (2.7.0)
|
26
|
-
i18n (0.6.
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
rspec-
|
32
|
-
rspec-
|
33
|
-
|
34
|
-
rspec-
|
35
|
-
|
36
|
-
|
31
|
+
i18n (0.6.5)
|
32
|
+
minitest (4.7.5)
|
33
|
+
multi_json (1.7.9)
|
34
|
+
rake (10.1.0)
|
35
|
+
rspec (2.14.1)
|
36
|
+
rspec-core (~> 2.14.0)
|
37
|
+
rspec-expectations (~> 2.14.0)
|
38
|
+
rspec-mocks (~> 2.14.0)
|
39
|
+
rspec-core (2.14.5)
|
40
|
+
rspec-expectations (2.14.2)
|
41
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
42
|
+
rspec-mocks (2.14.3)
|
43
|
+
thread_safe (0.1.2)
|
44
|
+
atomic
|
37
45
|
tzinfo (0.3.37)
|
38
46
|
|
39
47
|
PLATFORMS
|
data/HISTORY.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -91,7 +91,7 @@ can be established.
|
|
91
91
|
File comes in handy if you want to quickly check how generated models work. Just require this file
|
92
92
|
when you start IRB and you're ready to go:
|
93
93
|
|
94
|
-
irb -r/tmp/rmre_db.rb
|
94
|
+
irb -r/tmp/test/rmre_db.rb
|
95
95
|
>> connect
|
96
96
|
>> ... test your model here
|
97
97
|
|
@@ -111,7 +111,7 @@ instead of setting them through command line options. Generated file is:
|
|
111
111
|
After setting values in configuration file Rmre can be started with just one option - path to
|
112
112
|
configuration file.
|
113
113
|
|
114
|
-
rmre -
|
114
|
+
rmre -f /tmp/test/rmre_db.yml
|
115
115
|
|
116
116
|
== If table names do not fit in Rails naming convention
|
117
117
|
|
@@ -144,7 +144,7 @@ used to transform table name to plural or singular form. In the above example fi
|
|
144
144
|
all table names wich end with +_des+ string as they are. This means for table +generated_des+ resulting
|
145
145
|
file and model names will be +generated_des.rb+ and +GeneratedDes+. Second inflection will convert
|
146
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 +
|
147
|
+
+tone_fis+ table resulting file and class names will be +rmre_tone_d+ and +RmreToneD+.
|
148
148
|
|
149
149
|
= Copying databases
|
150
150
|
|
data/bin/rmre
CHANGED
@@ -66,6 +66,10 @@ optparse = OptionParser.new do |opts|
|
|
66
66
|
options[:db][:host] = s
|
67
67
|
end
|
68
68
|
|
69
|
+
opts.on('--ssl-ca [FILE]','SSL Certificate') do |ssl|
|
70
|
+
options[:db][:sslca] = ssl
|
71
|
+
end
|
72
|
+
|
69
73
|
opts.on('-i', '--include pattern1,pattern2', Array, 'Include prefixes') do |i|
|
70
74
|
options[:include] = i
|
71
75
|
end
|
@@ -78,6 +82,7 @@ optparse = OptionParser.new do |opts|
|
|
78
82
|
opts.on('--dump-schema [FILE]', 'Create schema migration to FILE') do |ds_file|
|
79
83
|
options[:dump_schema] = ds_file
|
80
84
|
end
|
85
|
+
|
81
86
|
end
|
82
87
|
|
83
88
|
begin
|
@@ -89,7 +94,7 @@ rescue OptionParser::ParseError => pe
|
|
89
94
|
end
|
90
95
|
|
91
96
|
if options[:file] == true
|
92
|
-
options[:db].merge!(:adapter=>'adapter_name',:database=>'db_name') if options[:db][:adapter].nil?
|
97
|
+
options[:db].merge!(:adapter=>'adapter_name',:database=>'db_name',:host=>'localhost') if options[:db][:adapter].nil?
|
93
98
|
options.delete(:file)
|
94
99
|
file_name = 'rmre_db'
|
95
100
|
file_path = File.join(options[:out_path], "#{file_name}.yml")
|
data/lib/rmre/model.eruby
CHANGED
data/lib/rmre/version.rb
CHANGED
data/spec/rmre/generator_spec.rb
CHANGED
@@ -2,21 +2,23 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
module Rmre
|
4
4
|
describe Generator do
|
5
|
-
let(:settings) do
|
6
|
-
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
5
|
+
let(:settings) do
|
6
|
+
{ db: {adapter: 'some_adapter',
|
7
|
+
database: 'db',
|
8
|
+
username: 'user',
|
9
|
+
password: 'pass'},
|
10
|
+
out_path: File.join(Dir.tmpdir, 'gne-test'),
|
11
|
+
include: ['incl1_', 'incl2_'],
|
12
|
+
inflections: [{plural: ["(.*)_des$", '\1_des'], singular: ["(.*)_des$", '\1_des']}]
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
16
|
-
let(:
|
16
|
+
let(:connection) do
|
17
|
+
double("db_connection", columns: [])
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:generator) do
|
17
21
|
gen = Generator.new(settings[:db], settings[:out_path], settings[:include], settings[:inflections])
|
18
|
-
connection = double("db_connection")
|
19
|
-
connection.stub(:columns).and_return([])
|
20
22
|
gen.stub(:connection).and_return(connection)
|
21
23
|
gen
|
22
24
|
end
|
data/spec/rmre/migrator_spec.rb
CHANGED
@@ -2,52 +2,38 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
module Rmre
|
4
4
|
describe Migrator do
|
5
|
-
let(:src_connection)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
let(:
|
10
|
-
tgt_con = double("target_connection")
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:src_db_opts) do |opts|
|
14
|
-
opts = { :adapter => "fake_adapter", :database => "source_db" }
|
15
|
-
end
|
16
|
-
|
17
|
-
let(:tgt_db_opts) do |opts|
|
18
|
-
opts = { :adapter => "fake_adapter", :database => "target_db" }
|
19
|
-
end
|
20
|
-
|
21
|
-
let(:id_column) do |col|
|
5
|
+
let(:src_connection) { double("source_connection") }
|
6
|
+
let(:tgt_connection) { tgt_con = double("target_connection") }
|
7
|
+
let(:src_db_opts) { { adapter: "fake_adapter", database: "source_db" } }
|
8
|
+
let(:tgt_db_opts) { { adapter: "fake_adapter", database: "target_db" } }
|
9
|
+
let(:id_column) do
|
22
10
|
col = double("id_column")
|
23
|
-
col.stub
|
24
|
-
col.stub
|
25
|
-
col.stub
|
26
|
-
col.stub
|
11
|
+
col.stub(:name).and_return("id")
|
12
|
+
col.stub(:null).and_return(false)
|
13
|
+
col.stub(:default).and_return(nil)
|
14
|
+
col.stub(:type).and_return("integer")
|
27
15
|
col
|
28
16
|
end
|
29
|
-
|
30
|
-
let(:name_column) do |col|
|
17
|
+
let(:name_column) do
|
31
18
|
col = double("name_column")
|
32
|
-
col.stub
|
33
|
-
col.stub
|
34
|
-
col.stub
|
35
|
-
col.stub
|
19
|
+
col.stub(:name).and_return("name")
|
20
|
+
col.stub(:null).and_return(false)
|
21
|
+
col.stub(:default).and_return(nil)
|
22
|
+
col.stub(:type).and_return("integer")
|
36
23
|
col
|
37
24
|
end
|
38
|
-
|
39
|
-
let(:table) do |tbl|
|
25
|
+
let(:table) do
|
40
26
|
tbl = double("created_table")
|
41
|
-
tbl.stub
|
27
|
+
tbl.stub(:column)
|
42
28
|
tbl
|
43
29
|
end
|
44
30
|
|
45
31
|
before(:each) do
|
46
|
-
Source::Db.stub
|
47
|
-
Source::Db.stub
|
32
|
+
Source::Db.stub(:establish_connection).and_return(true)
|
33
|
+
Source::Db.stub(:connection).and_return(src_connection)
|
48
34
|
|
49
|
-
Target::Db.stub
|
50
|
-
Target::Db.stub
|
35
|
+
Target::Db.stub(:establish_connection).and_return(true)
|
36
|
+
Target::Db.stub(:connection).and_return(tgt_connection)
|
51
37
|
end
|
52
38
|
|
53
39
|
context "initialization" do
|
@@ -67,11 +53,11 @@ module Rmre
|
|
67
53
|
context "copying tables" do
|
68
54
|
before(:each) do
|
69
55
|
src_connection.stub(:tables).and_return %w{parent_table child_table}
|
70
|
-
src_connection.stub
|
71
|
-
src_connection.stub
|
56
|
+
src_connection.stub(:columns).and_return([id_column, name_column])
|
57
|
+
src_connection.stub(:primary_key).and_return("id")
|
72
58
|
|
73
59
|
@migrator = Migrator.new(src_db_opts, tgt_db_opts)
|
74
|
-
@migrator.stub
|
60
|
+
@migrator.stub(:copy_data)
|
75
61
|
end
|
76
62
|
|
77
63
|
it "copies all tables if they do not exist" do
|
@@ -111,7 +97,7 @@ module Rmre
|
|
111
97
|
context "copying tables with 'skip existing' turned on" do
|
112
98
|
before(:each) do
|
113
99
|
src_connection.stub(:tables).and_return %w{parent_table child_table}
|
114
|
-
src_connection.stub
|
100
|
+
src_connection.stub(:columns).and_return([id_column, name_column])
|
115
101
|
|
116
102
|
@migrator = Migrator.new(src_db_opts, tgt_db_opts, {:skip_existing => true})
|
117
103
|
end
|
@@ -131,8 +117,8 @@ module Rmre
|
|
131
117
|
context "Rails copy mode" do
|
132
118
|
before(:each) do
|
133
119
|
@migrator = Migrator.new(src_db_opts, tgt_db_opts)
|
134
|
-
src_connection.stub
|
135
|
-
tgt_connection.stub
|
120
|
+
src_connection.stub(:primary_key).and_return("id")
|
121
|
+
tgt_connection.stub(:adapter_name).and_return("fake adapter")
|
136
122
|
end
|
137
123
|
|
138
124
|
it "does not explicitely create ID column" do
|
@@ -153,8 +139,8 @@ module Rmre
|
|
153
139
|
context "non-Rails copy mode" do
|
154
140
|
before(:each) do
|
155
141
|
@migrator = Migrator.new(src_db_opts, tgt_db_opts, {:rails_copy_mode => false})
|
156
|
-
tgt_connection.stub
|
157
|
-
src_connection.stub
|
142
|
+
tgt_connection.stub(:adapter_name).times.and_return("fake adapter")
|
143
|
+
src_connection.stub(:primary_key).and_return("primaryIdColumn")
|
158
144
|
end
|
159
145
|
|
160
146
|
it "explicitely creates ID column" do
|
metadata
CHANGED
@@ -1,78 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rmre
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.9
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Bosko Ivanisevic
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-11-10 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activerecord
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 3.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 3.0.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: erubis
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
description: Rmre creates ActiveRecord models for legacy database with all constraints
|
@@ -87,7 +78,7 @@ extra_rdoc_files:
|
|
87
78
|
- README.rdoc
|
88
79
|
- LICENSE.txt
|
89
80
|
files:
|
90
|
-
- .gitignore
|
81
|
+
- ".gitignore"
|
91
82
|
- Gemfile
|
92
83
|
- Gemfile.lock
|
93
84
|
- HISTORY.rdoc
|
@@ -112,34 +103,30 @@ files:
|
|
112
103
|
- spec/spec_helper.rb
|
113
104
|
homepage: http://github.com/bosko/rmre
|
114
105
|
licenses: []
|
106
|
+
metadata: {}
|
115
107
|
post_install_message:
|
116
108
|
rdoc_options:
|
117
|
-
- --title
|
109
|
+
- "--title"
|
118
110
|
- Rmre -- Rails Models Reverse Engineering
|
119
|
-
- --main
|
111
|
+
- "--main"
|
120
112
|
- README.rdoc
|
121
113
|
require_paths:
|
122
114
|
- lib
|
123
115
|
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
-
none: false
|
125
116
|
requirements:
|
126
|
-
- -
|
117
|
+
- - ">="
|
127
118
|
- !ruby/object:Gem::Version
|
128
119
|
version: '0'
|
129
|
-
segments:
|
130
|
-
- 0
|
131
|
-
hash: 3490106450590144776
|
132
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
-
none: false
|
134
121
|
requirements:
|
135
|
-
- -
|
122
|
+
- - ">="
|
136
123
|
- !ruby/object:Gem::Version
|
137
124
|
version: 1.3.6
|
138
125
|
requirements: []
|
139
126
|
rubyforge_project: rmre
|
140
|
-
rubygems_version:
|
127
|
+
rubygems_version: 2.2.2
|
141
128
|
signing_key:
|
142
|
-
specification_version:
|
129
|
+
specification_version: 4
|
143
130
|
summary: The easiest way to create ActiveRecord models for legacy database
|
144
131
|
test_files:
|
145
132
|
- spec/rmre/generator_spec.rb
|