rmre 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/rmre +0 -0
- data/lib/rmre/generator.rb +1 -1
- data/lib/rmre/model.eruby +4 -3
- data/lib/rmre/version.rb +1 -1
- data/spec/rmre/generator_spec.rb +2 -2
- metadata +25 -9
data/bin/rmre
CHANGED
File without changes
|
data/lib/rmre/generator.rb
CHANGED
@@ -84,7 +84,7 @@ module Rmre
|
|
84
84
|
def constraint_src(table_name, fk={})
|
85
85
|
src = nil
|
86
86
|
if fk['from_table'] == table_name
|
87
|
-
src = "belongs_to :#{fk['to_table'].downcase}, :class_name => '#{fk['to_table'].tableize.classify}', :foreign_key => :#{fk['from_column']}"
|
87
|
+
src = "belongs_to :#{fk['to_table'].downcase.singularize}, :class_name => '#{fk['to_table'].tableize.classify}', :foreign_key => :#{fk['from_column']}"
|
88
88
|
elsif fk['to_table'] == table_name
|
89
89
|
src = "has_many :#{fk['from_table'].downcase.pluralize}, :class_name => '#{fk['from_table'].tableize.classify}'"
|
90
90
|
end
|
data/lib/rmre/model.eruby
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
class <%= table_name.tableize.classify %> < ActiveRecord::Base
|
2
2
|
<% unless table_name == table_name.tableize %>
|
3
|
-
<%= "
|
3
|
+
<%= "self.table_name = '#{table_name}'" -%>
|
4
4
|
<% end %>
|
5
5
|
|
6
6
|
<% unless "id" == primary_key || primary_key.nil? %>
|
7
|
-
<%= "
|
7
|
+
<%= "self.primary_key = :#{primary_key}" -%>
|
8
8
|
<% end %>
|
9
9
|
|
10
10
|
<% if has_type_column %>
|
11
|
-
<%= "
|
11
|
+
<%= "self.inheritance_column = :ruby_type" -%>
|
12
12
|
<% end %>
|
13
13
|
|
14
14
|
<% constraints.each do |constraint| %>
|
15
15
|
<%= constraint -%>
|
16
|
+
|
16
17
|
<% end %>
|
17
18
|
end
|
data/lib/rmre/version.rb
CHANGED
data/spec/rmre/generator_spec.rb
CHANGED
@@ -38,7 +38,7 @@ module Rmre
|
|
38
38
|
|
39
39
|
it "should contain set_table_name 'incl1_tbl1' in generated source" do
|
40
40
|
generator.stub_chain(:connection, :primary_key).and_return("id")
|
41
|
-
generator.send(:generate_model_source, 'incl1_tbl1', []).should match(/
|
41
|
+
generator.send(:generate_model_source, 'incl1_tbl1', []).should match(/self\.table_name = \'incl1_tbl1\'/)
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should create three model files" do
|
@@ -68,7 +68,7 @@ module Rmre
|
|
68
68
|
generator.connection.stub(:primary_key).and_return("usr_id")
|
69
69
|
|
70
70
|
File.stub(:open).and_yield(file)
|
71
|
-
file.should_receive(:write).with(/
|
71
|
+
file.should_receive(:write).with(/self\.primary_key = :usr_id/)
|
72
72
|
|
73
73
|
generator.create_model("users")
|
74
74
|
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.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.0.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: erubis
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: 2.6.6
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.6.6
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rspec
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,7 +53,12 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
description: Rmre creates ActiveRecord models for legacy database with all constraints
|
48
63
|
found.
|
49
64
|
email:
|
@@ -95,8 +110,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
110
|
version: 1.3.6
|
96
111
|
requirements: []
|
97
112
|
rubyforge_project: rmre
|
98
|
-
rubygems_version: 1.8.
|
113
|
+
rubygems_version: 1.8.24
|
99
114
|
signing_key:
|
100
115
|
specification_version: 3
|
101
116
|
summary: The easiest way to create ActiveRecord models for legacy database
|
102
117
|
test_files: []
|
118
|
+
has_rdoc:
|