globalize 3.0.0 → 3.0.1
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +60 -66
- data/lib/globalize.rb +0 -1
- data/lib/globalize/active_record.rb +1 -0
- data/lib/globalize/active_record/class_methods.rb +23 -1
- data/lib/globalize/active_record/migration.rb +1 -1
- data/lib/globalize/active_record/relation.rb +16 -0
- data/lib/globalize/version.rb +1 -1
- metadata +4 -5
- data/lib/patches/active_record/relation.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b12c925d8338f75e9dfa650c3f12b1305bd6ccfb
|
4
|
+
data.tar.gz: d538a66932ea892300d07134c3198ae7a99a731f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3317c480503cc55735336c7d6ac01dcc9e9dc46db171e3f4d8c71da6a6cdb6e2b7323474b5eee5a85c76e1787816308156caf0ff0a812a27d7f66412bf99d19
|
7
|
+
data.tar.gz: 195bddff49e9d4905893697a705e25f9b65d4b1c8eaee548a89a2faa7e168e5e025446bf9d674d16a72477a18367cab65e955d77d54b8b0cc37bcdda0ac14b8b
|
data/Gemfile.lock
CHANGED
@@ -1,87 +1,81 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/airblade/paper_trail.git
|
3
|
+
revision: 44f2380ec6cd45c15a8b654d5e7d694499c6e11c
|
4
|
+
branch: master
|
5
|
+
specs:
|
6
|
+
paper_trail (3.0.0.beta2)
|
7
|
+
activerecord (>= 3.0, < 5.0)
|
8
|
+
|
9
|
+
GIT
|
10
|
+
remote: git://github.com/bmabey/database_cleaner.git
|
11
|
+
revision: 6da38c4c1a565bbcc62ed9b84c2574537c6ebae2
|
12
|
+
branch: master
|
13
|
+
specs:
|
14
|
+
database_cleaner (1.2.0)
|
15
|
+
|
1
16
|
PATH
|
2
17
|
remote: .
|
3
18
|
specs:
|
4
|
-
globalize (
|
5
|
-
activemodel (>=
|
6
|
-
activerecord (>=
|
7
|
-
paper_trail (~>
|
19
|
+
globalize (4.0.0.alpha.2)
|
20
|
+
activemodel (>= 4.0.0)
|
21
|
+
activerecord (>= 4.0.0)
|
22
|
+
paper_trail (~> 3.0.0.beta)
|
8
23
|
|
9
24
|
GEM
|
10
25
|
remote: https://rubygems.org/
|
11
26
|
specs:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
activemodel (3.2.15)
|
23
|
-
activesupport (= 3.2.15)
|
24
|
-
builder (~> 3.0.0)
|
25
|
-
activerecord (3.2.15)
|
26
|
-
activemodel (= 3.2.15)
|
27
|
-
activesupport (= 3.2.15)
|
28
|
-
arel (~> 3.0.2)
|
29
|
-
tzinfo (~> 0.3.29)
|
30
|
-
activesupport (3.2.15)
|
27
|
+
activemodel (4.0.0)
|
28
|
+
activesupport (= 4.0.0)
|
29
|
+
builder (~> 3.1.0)
|
30
|
+
activerecord (4.0.0)
|
31
|
+
activemodel (= 4.0.0)
|
32
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
33
|
+
activesupport (= 4.0.0)
|
34
|
+
arel (~> 4.0.0)
|
35
|
+
activerecord-deprecated_finders (1.0.3)
|
36
|
+
activesupport (4.0.0)
|
31
37
|
i18n (~> 0.6, >= 0.6.4)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
+
minitest (~> 4.2)
|
39
|
+
multi_json (~> 1.3)
|
40
|
+
thread_safe (~> 0.1)
|
41
|
+
tzinfo (~> 0.3.37)
|
42
|
+
arel (4.0.1)
|
43
|
+
atomic (1.1.14)
|
44
|
+
builder (3.1.4)
|
45
|
+
coderay (1.0.9)
|
38
46
|
i18n (0.6.5)
|
39
|
-
journey (1.0.4)
|
40
47
|
json (1.8.1)
|
41
|
-
|
42
|
-
|
43
|
-
|
48
|
+
method_source (0.8.2)
|
49
|
+
minitest (4.7.5)
|
50
|
+
minitest-colorize (0.0.5)
|
51
|
+
minitest (>= 2.0)
|
44
52
|
multi_json (1.8.2)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
rack (>= 0.4)
|
52
|
-
rack-ssl (1.3.3)
|
53
|
-
rack
|
54
|
-
rack-test (0.6.2)
|
55
|
-
rack (>= 1.0)
|
56
|
-
railties (3.2.15)
|
57
|
-
actionpack (= 3.2.15)
|
58
|
-
activesupport (= 3.2.15)
|
59
|
-
rack-ssl (~> 1.3.2)
|
60
|
-
rake (>= 0.8.7)
|
61
|
-
rdoc (~> 3.4)
|
62
|
-
thor (>= 0.14.6, < 2.0)
|
53
|
+
pry (0.9.12.2)
|
54
|
+
coderay (~> 1.0.5)
|
55
|
+
method_source (~> 0.8)
|
56
|
+
slop (~> 3.4)
|
57
|
+
pry-nav (0.2.3)
|
58
|
+
pry (~> 0.9.10)
|
63
59
|
rake (10.1.0)
|
64
|
-
rdoc (
|
60
|
+
rdoc (4.0.1)
|
65
61
|
json (~> 1.4)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
tilt (~> 1.1, != 1.3.0)
|
71
|
-
sqlite3 (1.3.7)
|
72
|
-
test_declarative (0.0.5)
|
73
|
-
thor (0.18.1)
|
74
|
-
tilt (1.4.1)
|
62
|
+
slop (3.4.6)
|
63
|
+
sqlite3 (1.3.8)
|
64
|
+
thread_safe (0.1.3)
|
65
|
+
atomic
|
75
66
|
tzinfo (0.3.38)
|
76
67
|
|
77
68
|
PLATFORMS
|
78
|
-
java
|
79
69
|
ruby
|
80
70
|
|
81
71
|
DEPENDENCIES
|
82
|
-
database_cleaner
|
72
|
+
database_cleaner!
|
83
73
|
globalize!
|
84
|
-
|
85
|
-
|
74
|
+
minitest
|
75
|
+
minitest-colorize
|
76
|
+
paper_trail!
|
77
|
+
pry
|
78
|
+
pry-nav
|
79
|
+
rake
|
80
|
+
rdoc
|
86
81
|
sqlite3
|
87
|
-
test_declarative
|
data/lib/globalize.rb
CHANGED
@@ -2,7 +2,6 @@ require 'active_record'
|
|
2
2
|
require 'patches/active_record/xml_attribute_serializer'
|
3
3
|
require 'patches/active_record/query_method'
|
4
4
|
require 'patches/active_record/uniqueness_validator'
|
5
|
-
require 'patches/active_record/relation'
|
6
5
|
|
7
6
|
module Globalize
|
8
7
|
autoload :ActiveRecord, 'globalize/active_record'
|
@@ -8,5 +8,6 @@ module Globalize
|
|
8
8
|
autoload :InstanceMethods, 'globalize/active_record/instance_methods'
|
9
9
|
autoload :Migration, 'globalize/active_record/migration'
|
10
10
|
autoload :Translation, 'globalize/active_record/translation'
|
11
|
+
autoload :Relation, 'globalize/active_record/relation'
|
11
12
|
end
|
12
13
|
end
|
@@ -138,7 +138,29 @@ module Globalize
|
|
138
138
|
record
|
139
139
|
end
|
140
140
|
|
141
|
-
|
141
|
+
private
|
142
|
+
|
143
|
+
# Override the default relation method in order to return a subclass
|
144
|
+
# of ActiveRecord::Relation with custom finder methods for translated
|
145
|
+
# attributes.
|
146
|
+
def relation
|
147
|
+
relation = relation_class.new(self, arel_table)
|
148
|
+
|
149
|
+
if finder_needs_type_condition?
|
150
|
+
relation.where(type_condition).create_with(inheritance_column.to_sym => sti_name)
|
151
|
+
else
|
152
|
+
relation
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# Use pattern defined in FriendlyId (4.x) to avoid conflict.
|
157
|
+
def relation_class
|
158
|
+
@relation_class ||= Class.new(Relation).tap do |klass|
|
159
|
+
const_set('GlobalizeActiveRecordRelation', klass)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
protected
|
142
164
|
|
143
165
|
def translated_attr_accessor(name)
|
144
166
|
define_method(:"#{name}=") do |value|
|
@@ -68,7 +68,7 @@ module Globalize
|
|
68
68
|
|
69
69
|
def create_translation_table
|
70
70
|
connection.create_table(translations_table_name) do |t|
|
71
|
-
t.references table_name.sub(/^#{table_name_prefix}/, '').singularize
|
71
|
+
t.references table_name.sub(/^#{table_name_prefix}/, '').singularize
|
72
72
|
t.string :locale, :null => false
|
73
73
|
t.timestamps
|
74
74
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Globalize
|
2
|
+
module ActiveRecord
|
3
|
+
class Relation < ::ActiveRecord::Relation
|
4
|
+
|
5
|
+
if ::ActiveRecord::VERSION::STRING >= "3.2.1"
|
6
|
+
def where_values_hash
|
7
|
+
equalities = with_default_scope.where_values.grep(Arel::Nodes::Equality).find_all { |node|
|
8
|
+
node.left.relation.name == translations_table_name
|
9
|
+
}
|
10
|
+
|
11
|
+
super.merge(Hash[equalities.map { |where| [where.left.name, where.right] }]).with_indifferent_access
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/globalize/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: globalize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Fuchs
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2013-
|
17
|
+
date: 2013-11-07 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: activerecord
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- lib/globalize/active_record/exceptions.rb
|
142
142
|
- lib/globalize/active_record/instance_methods.rb
|
143
143
|
- lib/globalize/active_record/migration.rb
|
144
|
+
- lib/globalize/active_record/relation.rb
|
144
145
|
- lib/globalize/active_record/translation.rb
|
145
146
|
- lib/globalize/active_record.rb
|
146
147
|
- lib/globalize/interpolation.rb
|
@@ -151,7 +152,6 @@ files:
|
|
151
152
|
- lib/i18n/missing_translations_log_handler.rb
|
152
153
|
- lib/i18n/missing_translations_raise_handler.rb
|
153
154
|
- lib/patches/active_record/query_method.rb
|
154
|
-
- lib/patches/active_record/relation.rb
|
155
155
|
- lib/patches/active_record/uniqueness_validator.rb
|
156
156
|
- lib/patches/active_record/xml_attribute_serializer.rb
|
157
157
|
- Gemfile
|
@@ -178,9 +178,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
178
|
version: '0'
|
179
179
|
requirements: []
|
180
180
|
rubyforge_project:
|
181
|
-
rubygems_version: 2.
|
181
|
+
rubygems_version: 2.0.3
|
182
182
|
signing_key:
|
183
183
|
specification_version: 4
|
184
184
|
summary: Rails I18n de-facto standard library for ActiveRecord model/data translation
|
185
185
|
test_files: []
|
186
|
-
has_rdoc:
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
class Relation
|
3
|
-
if ::ActiveRecord::VERSION::STRING >= "3.2.1"
|
4
|
-
def where_values_hash
|
5
|
-
_translations_table_name = klass.respond_to?(:translations_table_name) ? klass.translations_table_name : nil
|
6
|
-
|
7
|
-
equalities = with_default_scope.where_values.grep(Arel::Nodes::Equality).find_all { |node|
|
8
|
-
[table_name, _translations_table_name].compact.include? node.left.relation.name
|
9
|
-
}
|
10
|
-
|
11
|
-
Hash[equalities.map { |where| [where.left.name, where.right] }].with_indifferent_access
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|