efficient_translations 0.0.3 → 0.0.4
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
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
efficient_translations (0.0.
|
4
|
+
efficient_translations (0.0.4)
|
5
5
|
activerecord (~> 2.3)
|
6
6
|
activesupport (~> 2.3)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activerecord (2.3.
|
12
|
-
activesupport (= 2.3.
|
13
|
-
activesupport (2.3.
|
11
|
+
activerecord (2.3.14)
|
12
|
+
activesupport (= 2.3.14)
|
13
|
+
activesupport (2.3.14)
|
14
14
|
diff-lcs (1.1.3)
|
15
15
|
rake (0.9.2.2)
|
16
16
|
rspec (2.7.0)
|
@@ -10,14 +10,14 @@ module EfficientTranslations
|
|
10
10
|
def create_translation_table model_name, translation_fields
|
11
11
|
translation_table_name = "#{model_name.singularize}_translations"
|
12
12
|
create_table translation_table_name do |t|
|
13
|
-
t.references model_name, :null => false
|
13
|
+
t.references model_name.singularize, :null => false
|
14
14
|
t.string :locale, :null => false
|
15
15
|
end
|
16
16
|
translation_fields.each do |name, type|
|
17
17
|
add_column translation_table_name, name.to_s, type.to_sym
|
18
18
|
end
|
19
|
-
add_index translation_table_name, "#{model_name}_id"
|
20
|
-
add_index translation_table_name, ["#{model_name}_id", 'locale'], :unique => true
|
19
|
+
add_index translation_table_name, "#{model_name.singularize}_id"
|
20
|
+
add_index translation_table_name, ["#{model_name.singularize}_id", 'locale'], :unique => true
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -14,6 +14,26 @@ describe EfficientTranslations::Schema do
|
|
14
14
|
schema.create_translation_table 'products', :name => :string
|
15
15
|
end
|
16
16
|
|
17
|
+
it 'should create the foreign key from translation table to model' do
|
18
|
+
schema.should_receive(:create_table) do |*args, &block|
|
19
|
+
t = double
|
20
|
+
t.stub :string
|
21
|
+
t.should_receive(:references).with 'pippo', an_instance_of(Hash)
|
22
|
+
block.call t
|
23
|
+
end
|
24
|
+
schema.create_translation_table 'pippo', :name => :string
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should use the singular model name for foreign key' do
|
28
|
+
schema.should_receive(:create_table) do |*args, &block|
|
29
|
+
t = double
|
30
|
+
t.stub :string
|
31
|
+
t.should_receive(:references).with 'product', an_instance_of(Hash)
|
32
|
+
block.call t
|
33
|
+
end
|
34
|
+
schema.create_translation_table 'products', :name => :string
|
35
|
+
end
|
36
|
+
|
17
37
|
it 'should create the given translation columns' do
|
18
38
|
schema.should_receive(:add_column).with('pippo_translations', 'name', :string)
|
19
39
|
schema.create_translation_table 'pippo', :name => :string
|
metadata
CHANGED
@@ -1,78 +1,104 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: efficient_translations
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Nicola Racco
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
requirement: &70137770084400 !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
17
|
+
|
18
|
+
date: 2012-02-23 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
22
21
|
type: :development
|
23
|
-
|
24
|
-
version_requirements: *70137770084400
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: rspec
|
27
|
-
requirement: &70137770083700 !ruby/object:Gem::Requirement
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
28
23
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
33
|
-
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 3
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
version_requirements: *id001
|
32
|
+
name: rake
|
34
33
|
prerelease: false
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
requirement: &70137770083200 !ruby/object:Gem::Requirement
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
type: :development
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
37
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
hash: 3
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
version: "0"
|
45
|
+
version_requirements: *id002
|
46
|
+
name: rspec
|
47
|
+
prerelease: false
|
48
|
+
- !ruby/object:Gem::Dependency
|
44
49
|
type: :development
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
hash: 3
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
version_requirements: *id003
|
60
|
+
name: sqlite3
|
45
61
|
prerelease: false
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
requirement: &70137770082540 !ruby/object:Gem::Requirement
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
type: :runtime
|
64
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
|
-
requirements:
|
66
|
+
requirements:
|
52
67
|
- - ~>
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
55
|
-
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
hash: 5
|
70
|
+
segments:
|
71
|
+
- 2
|
72
|
+
- 3
|
73
|
+
version: "2.3"
|
74
|
+
version_requirements: *id004
|
75
|
+
name: activerecord
|
56
76
|
prerelease: false
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
requirement: &70137770081800 !ruby/object:Gem::Requirement
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
type: :runtime
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
61
80
|
none: false
|
62
|
-
requirements:
|
81
|
+
requirements:
|
63
82
|
- - ~>
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
66
|
-
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 5
|
85
|
+
segments:
|
86
|
+
- 2
|
87
|
+
- 3
|
88
|
+
version: "2.3"
|
89
|
+
version_requirements: *id005
|
90
|
+
name: activesupport
|
67
91
|
prerelease: false
|
68
|
-
version_requirements: *70137770081800
|
69
92
|
description: Translation library for ActiveRecord models in Rails 2
|
70
|
-
email:
|
93
|
+
email:
|
71
94
|
- nicola@nicolaracco.com
|
72
95
|
executables: []
|
96
|
+
|
73
97
|
extensions: []
|
98
|
+
|
74
99
|
extra_rdoc_files: []
|
75
|
-
|
100
|
+
|
101
|
+
files:
|
76
102
|
- .gitignore
|
77
103
|
- Gemfile
|
78
104
|
- Gemfile.lock
|
@@ -91,37 +117,40 @@ files:
|
|
91
117
|
- spec/spec_helper.rb
|
92
118
|
- spec/support/fake_schema_adapter.rb
|
93
119
|
- spec/support/working_model.rb
|
94
|
-
homepage:
|
120
|
+
homepage: ""
|
95
121
|
licenses: []
|
122
|
+
|
96
123
|
post_install_message:
|
97
124
|
rdoc_options: []
|
98
|
-
|
125
|
+
|
126
|
+
require_paths:
|
99
127
|
- lib
|
100
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
129
|
none: false
|
102
|
-
requirements:
|
103
|
-
- -
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
|
106
|
-
segments:
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
hash: 3
|
134
|
+
segments:
|
107
135
|
- 0
|
108
|
-
|
109
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
version: "0"
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
138
|
none: false
|
111
|
-
requirements:
|
112
|
-
- -
|
113
|
-
- !ruby/object:Gem::Version
|
114
|
-
|
115
|
-
segments:
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
hash: 3
|
143
|
+
segments:
|
116
144
|
- 0
|
117
|
-
|
145
|
+
version: "0"
|
118
146
|
requirements: []
|
147
|
+
|
119
148
|
rubyforge_project:
|
120
|
-
rubygems_version: 1.8.
|
149
|
+
rubygems_version: 1.8.16
|
121
150
|
signing_key:
|
122
151
|
specification_version: 3
|
123
152
|
summary: Translation library for ActiveRecord models in Rails 2 with an eye on performances
|
124
|
-
test_files:
|
153
|
+
test_files:
|
125
154
|
- spec/fixtures/schema.rb
|
126
155
|
- spec/lib/efficient_translations/schema_spec.rb
|
127
156
|
- spec/lib/efficient_translations/translates_method_spec.rb
|