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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7415d0b0223d5ace130c535aaee60e36929a4c7d
4
- data.tar.gz: b4b6553f95f6f662aab9036c96b66ad0d7cac875
3
+ metadata.gz: b12c925d8338f75e9dfa650c3f12b1305bd6ccfb
4
+ data.tar.gz: d538a66932ea892300d07134c3198ae7a99a731f
5
5
  SHA512:
6
- metadata.gz: 79141074b2c0943e9af5d02a1cb2c44bee1394f061398fc338d762891799b0d952ebe3e1a0ae25911759e00afb66c52227f20cac4907fe6af472f82d39a21307
7
- data.tar.gz: e4d92686bcbd19736730327ef01f478d179fa0c60229dc4b17e038e274e66216f30e69845d6b29d409c091a36ebe4bb29eca08dfb2b00fc1672ae5adf36b34d6
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 (3.0.0)
5
- activemodel (>= 3.0.0)
6
- activerecord (>= 3.0.0)
7
- paper_trail (~> 2)
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
- actionpack (3.2.15)
13
- activemodel (= 3.2.15)
14
- activesupport (= 3.2.15)
15
- builder (~> 3.0.0)
16
- erubis (~> 2.7.0)
17
- journey (~> 1.0.4)
18
- rack (~> 1.4.5)
19
- rack-cache (~> 1.2)
20
- rack-test (~> 0.6.1)
21
- sprockets (~> 2.2.1)
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
- multi_json (~> 1.0)
33
- arel (3.0.2)
34
- builder (3.0.4)
35
- database_cleaner (0.6.7)
36
- erubis (2.7.0)
37
- hike (1.2.3)
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
- metaclass (0.0.1)
42
- mocha (0.14.0)
43
- metaclass (~> 0.0.1)
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
- paper_trail (2.7.2)
46
- activerecord (~> 3.0)
47
- railties (~> 3.0)
48
- pathname_local (0.0.2)
49
- rack (1.4.5)
50
- rack-cache (1.2)
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 (3.12.2)
60
+ rdoc (4.0.1)
65
61
  json (~> 1.4)
66
- sprockets (2.2.2)
67
- hike (~> 1.2)
68
- multi_json (~> 1.0)
69
- rack (~> 1.0)
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 (~> 0.6.0)
72
+ database_cleaner!
83
73
  globalize!
84
- mocha
85
- pathname_local
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
- protected
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, :null => false
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
@@ -1,3 +1,3 @@
1
1
  module Globalize
2
- Version = '3.0.0'
2
+ Version = '3.0.1'
3
3
  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: 3.0.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-10-24 00:00:00.000000000 Z
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.1.0
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