globalize 4.0.0.alpha.2 → 4.0.0.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/Gemfile.lock +10 -29
- data/lib/globalize.rb +0 -1
- data/lib/globalize/active_record.rb +1 -1
- data/lib/globalize/active_record/class_methods.rb +10 -11
- data/lib/globalize/active_record/{relation.rb → query_methods.rb} +19 -6
- metadata +4 -5
- data/lib/patches/active_record/relation.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd7e2e9e5d23a8dd6696722ddd3dfabc200f07e1
|
4
|
+
data.tar.gz: 340c3919bd3bdb8a5a3f821c12189d29df20e181
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53351f2d7268b5e183410c58331205e9f704a24f6e5e2df95813117c0915d62c5ba9dbca33531bff572c80672a315e1add169bbdc2e2686b68abc51f45815d6e
|
7
|
+
data.tar.gz: c411ea171a017727cf07d2bd6dcc4e83c71f88700f4cde510684a88422e6eda44bf2af10e43d9c87a4b2de54d089d546e334cb81930128bd8259bb1808e337df
|
data/Gemfile
CHANGED
@@ -7,6 +7,10 @@ gem 'paper_trail', github: 'airblade/paper_trail', branch: 'master'
|
|
7
7
|
# Per https://github.com/bmabey/database_cleaner/issues/224
|
8
8
|
gem 'database_cleaner', github: 'bmabey/database_cleaner', branch: 'master'
|
9
9
|
|
10
|
+
platforms :rbx do
|
11
|
+
gem 'rubysl', '~> 2.0'
|
12
|
+
end
|
13
|
+
|
10
14
|
group :test do
|
11
15
|
gem 'pry'
|
12
16
|
gem 'pry-nav'
|
data/Gemfile.lock
CHANGED
@@ -1,39 +1,23 @@
|
|
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
|
-
|
16
1
|
PATH
|
17
2
|
remote: .
|
18
3
|
specs:
|
19
|
-
globalize (4.0.0.alpha.
|
4
|
+
globalize (4.0.0.alpha.3)
|
20
5
|
activemodel (>= 4.0.0)
|
21
6
|
activerecord (>= 4.0.0)
|
22
|
-
paper_trail (~> 3.0.0.beta)
|
23
7
|
|
24
8
|
GEM
|
25
9
|
remote: https://rubygems.org/
|
26
10
|
specs:
|
27
|
-
activemodel (4.0.
|
28
|
-
activesupport (= 4.0.
|
11
|
+
activemodel (4.0.1)
|
12
|
+
activesupport (= 4.0.1)
|
29
13
|
builder (~> 3.1.0)
|
30
|
-
activerecord (4.0.
|
31
|
-
activemodel (= 4.0.
|
14
|
+
activerecord (4.0.1)
|
15
|
+
activemodel (= 4.0.1)
|
32
16
|
activerecord-deprecated_finders (~> 1.0.2)
|
33
|
-
activesupport (= 4.0.
|
17
|
+
activesupport (= 4.0.1)
|
34
18
|
arel (~> 4.0.0)
|
35
19
|
activerecord-deprecated_finders (1.0.3)
|
36
|
-
activesupport (4.0.
|
20
|
+
activesupport (4.0.1)
|
37
21
|
i18n (~> 0.6, >= 0.6.4)
|
38
22
|
minitest (~> 4.2)
|
39
23
|
multi_json (~> 1.3)
|
@@ -41,10 +25,10 @@ GEM
|
|
41
25
|
tzinfo (~> 0.3.37)
|
42
26
|
arel (4.0.1)
|
43
27
|
atomic (1.1.14)
|
44
|
-
atomic (1.1.14-java)
|
45
28
|
builder (3.1.4)
|
46
29
|
coderay (1.0.9)
|
47
|
-
|
30
|
+
database_cleaner (1.2.0)
|
31
|
+
ffi (1.9.3-java)
|
48
32
|
i18n (0.6.5)
|
49
33
|
json (1.8.1)
|
50
34
|
json (1.8.1-java)
|
@@ -73,8 +57,6 @@ GEM
|
|
73
57
|
sqlite3 (1.3.7)
|
74
58
|
thread_safe (0.1.3)
|
75
59
|
atomic
|
76
|
-
thread_safe (0.1.3-java)
|
77
|
-
atomic
|
78
60
|
tzinfo (0.3.38)
|
79
61
|
|
80
62
|
PLATFORMS
|
@@ -82,11 +64,10 @@ PLATFORMS
|
|
82
64
|
ruby
|
83
65
|
|
84
66
|
DEPENDENCIES
|
85
|
-
database_cleaner
|
67
|
+
database_cleaner (>= 1.2.0)
|
86
68
|
globalize!
|
87
69
|
minitest
|
88
70
|
minitest-colorize
|
89
|
-
paper_trail!
|
90
71
|
pry
|
91
72
|
pry-nav
|
92
73
|
rake
|
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,6 +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 :
|
11
|
+
autoload :QueryMethods, 'globalize/active_record/query_methods'
|
12
12
|
end
|
13
13
|
end
|
@@ -58,16 +58,6 @@ module Globalize
|
|
58
58
|
"#{translation_class.table_name}.#{name}"
|
59
59
|
end
|
60
60
|
|
61
|
-
def relation
|
62
|
-
relation = Relation.new(self, arel_table)
|
63
|
-
|
64
|
-
if finder_needs_type_condition?
|
65
|
-
relation.where(type_condition).create_with(inheritance_column.to_sym => sti_name)
|
66
|
-
else
|
67
|
-
relation
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
61
|
def respond_to_missing?(method_id, include_private = false)
|
72
62
|
supported_on_missing?(method_id) || super
|
73
63
|
end
|
@@ -135,7 +125,16 @@ module Globalize
|
|
135
125
|
record
|
136
126
|
end
|
137
127
|
|
138
|
-
|
128
|
+
private
|
129
|
+
|
130
|
+
# Override the default relation method in order to return a subclass
|
131
|
+
# of ActiveRecord::Relation with custom finder methods for translated
|
132
|
+
# attributes.
|
133
|
+
def relation
|
134
|
+
super.extending!(QueryMethods)
|
135
|
+
end
|
136
|
+
|
137
|
+
protected
|
139
138
|
|
140
139
|
def translated_attr_accessor(name)
|
141
140
|
define_method(:"#{name}=") do |value|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Globalize
|
2
2
|
module ActiveRecord
|
3
|
-
|
3
|
+
module QueryMethods
|
4
4
|
|
5
5
|
attr_accessor :translations_reload_needed
|
6
6
|
|
@@ -8,7 +8,7 @@ module Globalize
|
|
8
8
|
def not(opts, *rest)
|
9
9
|
if parsed = @scope.parse_translated_conditions(opts)
|
10
10
|
@scope.translations_reload_needed = true
|
11
|
-
@scope.
|
11
|
+
@scope.with_translations_in_fallbacks.where.not(parsed, *rest)
|
12
12
|
else
|
13
13
|
super
|
14
14
|
end
|
@@ -20,7 +20,7 @@ module Globalize
|
|
20
20
|
WhereChain.new(spawn)
|
21
21
|
elsif parsed = parse_translated_conditions(opts)
|
22
22
|
self.translations_reload_needed = true
|
23
|
-
super(parsed, *rest).
|
23
|
+
super(parsed, *rest).with_translations_in_fallbacks
|
24
24
|
else
|
25
25
|
super
|
26
26
|
end
|
@@ -28,7 +28,7 @@ module Globalize
|
|
28
28
|
|
29
29
|
def exists?(conditions = :none)
|
30
30
|
if parsed = parse_translated_conditions(conditions)
|
31
|
-
|
31
|
+
with_translations_in_fallbacks.exists?(parsed)
|
32
32
|
else
|
33
33
|
super
|
34
34
|
end
|
@@ -47,8 +47,8 @@ module Globalize
|
|
47
47
|
END_RUBY
|
48
48
|
end
|
49
49
|
|
50
|
-
def
|
51
|
-
with_translations(Globalize.
|
50
|
+
def with_translations_in_fallbacks
|
51
|
+
with_translations(Globalize.fallbacks)
|
52
52
|
end
|
53
53
|
|
54
54
|
def parse_translated_conditions(opts)
|
@@ -58,6 +58,19 @@ module Globalize
|
|
58
58
|
opts
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
def where_values_hash
|
63
|
+
equalities = with_default_scope.where_values.grep(Arel::Nodes::Equality).find_all { |node|
|
64
|
+
node.left.relation.name == translations_table_name
|
65
|
+
}
|
66
|
+
|
67
|
+
binds = Hash[bind_values.find_all(&:first).map { |column, v| [column.name, v] }]
|
68
|
+
|
69
|
+
super.merge(Hash[equalities.map { |where|
|
70
|
+
name = where.left.name
|
71
|
+
[name, binds.fetch(name.to_s) { where.right }]
|
72
|
+
}])
|
73
|
+
end
|
61
74
|
end
|
62
75
|
end
|
63
76
|
end
|
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: 4.0.0.alpha.
|
4
|
+
version: 4.0.0.alpha.3
|
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-12-18 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: activerecord
|
@@ -155,7 +155,7 @@ files:
|
|
155
155
|
- lib/globalize/active_record/exceptions.rb
|
156
156
|
- lib/globalize/active_record/instance_methods.rb
|
157
157
|
- lib/globalize/active_record/migration.rb
|
158
|
-
- lib/globalize/active_record/
|
158
|
+
- lib/globalize/active_record/query_methods.rb
|
159
159
|
- lib/globalize/active_record/translation.rb
|
160
160
|
- lib/globalize/active_record.rb
|
161
161
|
- lib/globalize/interpolation.rb
|
@@ -165,7 +165,6 @@ files:
|
|
165
165
|
- lib/i18n/missing_translations_log_handler.rb
|
166
166
|
- lib/i18n/missing_translations_raise_handler.rb
|
167
167
|
- lib/patches/active_record/query_method.rb
|
168
|
-
- lib/patches/active_record/relation.rb
|
169
168
|
- lib/patches/active_record/uniqueness_validator.rb
|
170
169
|
- lib/patches/active_record/xml_attribute_serializer.rb
|
171
170
|
- Gemfile
|
@@ -192,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
191
|
version: 1.3.1
|
193
192
|
requirements: []
|
194
193
|
rubyforge_project: '[none]'
|
195
|
-
rubygems_version: 2.
|
194
|
+
rubygems_version: 2.0.14
|
196
195
|
signing_key:
|
197
196
|
specification_version: 4
|
198
197
|
summary: Rails I18n de-facto standard library for ActiveRecord model/data translation
|
@@ -1,20 +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
|
-
binds = Hash[bind_values.find_all(&:first).map { |column, v| [column.name, v] }]
|
12
|
-
|
13
|
-
Hash[equalities.map { |where|
|
14
|
-
name = where.left.name
|
15
|
-
[name, binds.fetch(name.to_s) { where.right } ]
|
16
|
-
}].with_indifferent_access
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|