globalize 5.0.1 → 5.1.0
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/CHANGELOG.md +12 -0
- data/Gemfile +19 -5
- data/Gemfile.lock +101 -55
- data/{readme.md → README.md} +128 -35
- data/Rakefile +33 -0
- data/lib/globalize/active_record/act_macro.rb +29 -3
- data/lib/globalize/active_record/adapter.rb +10 -11
- data/lib/globalize/active_record/adapter_dirty.rb +54 -0
- data/lib/globalize/active_record/class_methods.rb +19 -6
- data/lib/globalize/active_record/exceptions.rb +1 -7
- data/lib/globalize/active_record/instance_methods.rb +55 -35
- data/lib/globalize/active_record/migration.rb +57 -30
- data/lib/globalize/active_record/query_methods.rb +42 -17
- data/lib/globalize/active_record.rb +1 -0
- data/lib/globalize/version.rb +1 -1
- data/lib/globalize.rb +12 -6
- data/lib/patches/active_record/persistence.rb +6 -15
- data/lib/patches/active_record/query_method.rb +2 -34
- data/lib/patches/active_record/rails4/query_method.rb +35 -0
- data/lib/patches/active_record/rails4/serialization.rb +22 -0
- data/lib/patches/active_record/rails4/uniqueness_validator.rb +42 -0
- data/lib/patches/active_record/rails5/uniqueness_validator.rb +47 -0
- data/lib/patches/active_record/rails5_1/serialization.rb +22 -0
- data/lib/patches/active_record/rails5_1/uniqueness_validator.rb +45 -0
- data/lib/patches/active_record/relation.rb +12 -0
- data/lib/patches/active_record/serialization.rb +5 -24
- data/lib/patches/active_record/uniqueness_validator.rb +7 -39
- data/lib/patches/active_record/xml_attribute_serializer.rb +19 -9
- metadata +28 -22
- data/globalize.gemspec +0 -29
data/lib/globalize.rb
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
require 'request_store'
|
|
1
2
|
require 'active_record'
|
|
2
3
|
require 'patches/active_record/xml_attribute_serializer'
|
|
3
4
|
require 'patches/active_record/query_method'
|
|
5
|
+
require 'patches/active_record/relation'
|
|
4
6
|
require 'patches/active_record/serialization'
|
|
5
7
|
require 'patches/active_record/uniqueness_validator'
|
|
6
8
|
require 'patches/active_record/persistence'
|
|
7
9
|
|
|
8
|
-
|
|
9
10
|
module Globalize
|
|
10
11
|
autoload :ActiveRecord, 'globalize/active_record'
|
|
11
12
|
autoload :Interpolation, 'globalize/interpolation'
|
|
@@ -52,18 +53,23 @@ module Globalize
|
|
|
52
53
|
i18n_fallbacks? ? I18n.fallbacks[for_locale] : [for_locale.to_sym]
|
|
53
54
|
end
|
|
54
55
|
|
|
56
|
+
# Thread-safe global storage
|
|
57
|
+
def storage
|
|
58
|
+
RequestStore.store
|
|
59
|
+
end
|
|
60
|
+
|
|
55
61
|
protected
|
|
56
62
|
|
|
57
63
|
def read_locale
|
|
58
|
-
|
|
64
|
+
storage[:globalize_locale]
|
|
59
65
|
end
|
|
60
66
|
|
|
61
67
|
def set_locale(locale)
|
|
62
|
-
|
|
68
|
+
storage[:globalize_locale] = locale.try(:to_sym)
|
|
63
69
|
end
|
|
64
70
|
|
|
65
71
|
def read_fallbacks
|
|
66
|
-
|
|
72
|
+
storage[:globalize_fallbacks] || HashWithIndifferentAccess.new
|
|
67
73
|
end
|
|
68
74
|
|
|
69
75
|
def set_fallbacks(locales)
|
|
@@ -73,12 +79,12 @@ module Globalize
|
|
|
73
79
|
fallback_hash[key] = value.presence || [key]
|
|
74
80
|
end if locales.present?
|
|
75
81
|
|
|
76
|
-
|
|
82
|
+
storage[:globalize_fallbacks] = fallback_hash
|
|
77
83
|
end
|
|
78
84
|
end
|
|
79
85
|
end
|
|
80
86
|
|
|
81
|
-
ActiveRecord::Base.
|
|
87
|
+
ActiveRecord::Base.class_attribute :globalize_serialized_attributes, instance_writer: false
|
|
82
88
|
ActiveRecord::Base.globalize_serialized_attributes = {}
|
|
83
89
|
|
|
84
90
|
ActiveRecord::Base.extend(Globalize::ActiveRecord::ActMacro)
|
|
@@ -1,26 +1,17 @@
|
|
|
1
|
-
module
|
|
1
|
+
module Globalize
|
|
2
2
|
module Persistence
|
|
3
3
|
# Updates the associated record with values matching those of the instance attributes.
|
|
4
4
|
# Returns the number of affected rows.
|
|
5
5
|
def _update_record(attribute_names = self.attribute_names)
|
|
6
6
|
attribute_names_without_translated = attribute_names.select{ |k| not respond_to?('translated?') or not translated?(k) }
|
|
7
|
-
|
|
8
|
-
if attributes_values.empty?
|
|
9
|
-
0
|
|
10
|
-
else
|
|
11
|
-
self.class.unscoped._update_record attributes_values, id, id_was
|
|
12
|
-
end
|
|
7
|
+
super(attribute_names_without_translated)
|
|
13
8
|
end
|
|
14
9
|
|
|
15
10
|
def _create_record(attribute_names = self.attribute_names)
|
|
16
11
|
attribute_names_without_translated = attribute_names.select{ |k| not respond_to?('translated?') or not translated?(k) }
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
new_id = self.class.unscoped.insert attributes_values
|
|
20
|
-
self.id ||= new_id if self.class.primary_key
|
|
21
|
-
|
|
22
|
-
@new_record = false
|
|
23
|
-
id
|
|
12
|
+
super(attribute_names_without_translated)
|
|
24
13
|
end
|
|
25
14
|
end
|
|
26
|
-
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
ActiveRecord::Persistence.send(:prepend, Globalize::Persistence)
|
|
@@ -1,35 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
module ActiveRecord
|
|
4
|
-
module AttributeMethods
|
|
5
|
-
module Query
|
|
6
|
-
def query_attribute(attr_name)
|
|
7
|
-
unless value = read_attribute(attr_name)
|
|
8
|
-
false
|
|
9
|
-
else
|
|
10
|
-
column = self.class.columns_hash[attr_name]
|
|
11
|
-
if column.nil?
|
|
12
|
-
|
|
13
|
-
# TODO submit a rails patch
|
|
14
|
-
|
|
15
|
-
# not sure what active_record tests say but i guess this should mean:
|
|
16
|
-
# call to_i and check zero? if the value is a Numeric or starts with
|
|
17
|
-
# a digit, so it can meaningfully be typecasted by to_i
|
|
18
|
-
|
|
19
|
-
# if Numeric === value || value !~ /[^0-9]/
|
|
20
|
-
if Numeric === value || value.to_s =~ /^[0-9]/
|
|
21
|
-
!value.to_i.zero?
|
|
22
|
-
else
|
|
23
|
-
return false if ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(value)
|
|
24
|
-
!value.blank?
|
|
25
|
-
end
|
|
26
|
-
elsif column.number?
|
|
27
|
-
!value.zero?
|
|
28
|
-
else
|
|
29
|
-
!value.blank?
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
1
|
+
if ::ActiveRecord::VERSION::STRING < "5.0.0"
|
|
2
|
+
require_relative 'rails4/query_method'
|
|
35
3
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'active_record/attribute_methods/query'
|
|
2
|
+
|
|
3
|
+
module ActiveRecord
|
|
4
|
+
module AttributeMethods
|
|
5
|
+
module Query
|
|
6
|
+
def query_attribute(attr_name)
|
|
7
|
+
unless value = read_attribute(attr_name)
|
|
8
|
+
false
|
|
9
|
+
else
|
|
10
|
+
column = self.class.columns_hash[attr_name]
|
|
11
|
+
if column.nil?
|
|
12
|
+
|
|
13
|
+
# TODO submit a rails patch
|
|
14
|
+
|
|
15
|
+
# not sure what active_record tests say but i guess this should mean:
|
|
16
|
+
# call to_i and check zero? if the value is a Numeric or starts with
|
|
17
|
+
# a digit, so it can meaningfully be typecasted by to_i
|
|
18
|
+
|
|
19
|
+
# if Numeric === value || value !~ /[^0-9]/
|
|
20
|
+
if Numeric === value || value.to_s =~ /^[0-9]/
|
|
21
|
+
!value.to_i.zero?
|
|
22
|
+
else
|
|
23
|
+
return false if ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(value)
|
|
24
|
+
!value.blank?
|
|
25
|
+
end
|
|
26
|
+
elsif column.number?
|
|
27
|
+
!value.zero?
|
|
28
|
+
else
|
|
29
|
+
!value.blank?
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Globalize
|
|
2
|
+
module AttributeMethods
|
|
3
|
+
module Serialization
|
|
4
|
+
def serialize(attr_name, class_name_or_coder = Object)
|
|
5
|
+
super(attr_name, class_name_or_coder)
|
|
6
|
+
|
|
7
|
+
coder = if class_name_or_coder == ::JSON
|
|
8
|
+
::ActiveRecord::Coders::JSON
|
|
9
|
+
elsif [:load, :dump].all? { |x| class_name_or_coder.respond_to?(x) }
|
|
10
|
+
class_name_or_coder
|
|
11
|
+
else
|
|
12
|
+
::ActiveRecord::Coders::YAMLColumn.new(class_name_or_coder)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
self.globalize_serialized_attributes = globalize_serialized_attributes.dup
|
|
16
|
+
self.globalize_serialized_attributes[attr_name] = coder
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
ActiveRecord::AttributeMethods::Serialization::ClassMethods.send(:prepend, Globalize::AttributeMethods::Serialization)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require 'active_record/validations/uniqueness.rb'
|
|
2
|
+
|
|
3
|
+
module Globalize
|
|
4
|
+
module UniquenessValidatorOverride
|
|
5
|
+
def validate_each(record, attribute, value)
|
|
6
|
+
klass = record.class
|
|
7
|
+
if klass.translates? && klass.translated?(attribute)
|
|
8
|
+
finder_class = klass.translation_class
|
|
9
|
+
table = finder_class.arel_table
|
|
10
|
+
|
|
11
|
+
relation = build_relation(finder_class, table, attribute, value).and(table[:locale].eq(Globalize.locale))
|
|
12
|
+
relation = relation.and(table[klass.reflect_on_association(:translations).foreign_key].not_eq(record.send(:id))) if record.persisted?
|
|
13
|
+
|
|
14
|
+
translated_scopes = Array(options[:scope]) & klass.translated_attribute_names
|
|
15
|
+
untranslated_scopes = Array(options[:scope]) - translated_scopes
|
|
16
|
+
|
|
17
|
+
untranslated_scopes.each do |scope_item|
|
|
18
|
+
scope_value = record.send(scope_item)
|
|
19
|
+
reflection = klass.reflect_on_association(scope_item)
|
|
20
|
+
if reflection
|
|
21
|
+
scope_value = record.send(reflection.foreign_key)
|
|
22
|
+
scope_item = reflection.foreign_key
|
|
23
|
+
end
|
|
24
|
+
relation = relation.and(find_finder_class_for(record).arel_table[scope_item].eq(scope_value))
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
translated_scopes.each do |scope_item|
|
|
28
|
+
scope_value = record.send(scope_item)
|
|
29
|
+
relation = relation.and(table[scope_item].eq(scope_value))
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
if klass.unscoped.with_translations.where(relation).exists?
|
|
33
|
+
record.errors.add(attribute, :taken, options.except(:case_sensitive, :scope).merge(:value => value))
|
|
34
|
+
end
|
|
35
|
+
else
|
|
36
|
+
super
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
ActiveRecord::Validations::UniquenessValidator.send :prepend, Globalize::UniquenessValidatorOverride
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module Globalize
|
|
2
|
+
module Validations
|
|
3
|
+
module UniquenessValidator
|
|
4
|
+
def validate_each(record, attribute, value)
|
|
5
|
+
klass = record.class
|
|
6
|
+
if klass.translates? && klass.translated?(attribute)
|
|
7
|
+
finder_class = klass.translation_class
|
|
8
|
+
finder_table = finder_class.arel_table
|
|
9
|
+
relation = build_relation(finder_class, finder_table, attribute, value).where(locale: Globalize.locale)
|
|
10
|
+
relation = relation.where.not(klass.reflect_on_association(:translations).foreign_key => record.send(:id)) if record.persisted?
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
translated_scopes = Array(options[:scope]) & klass.translated_attribute_names
|
|
14
|
+
untranslated_scopes = Array(options[:scope]) - translated_scopes
|
|
15
|
+
|
|
16
|
+
relation = relation.joins(:globalized_model) if untranslated_scopes.present?
|
|
17
|
+
untranslated_scopes.each do |scope_item|
|
|
18
|
+
scope_value = record.send(scope_item)
|
|
19
|
+
reflection = klass.reflect_on_association(scope_item)
|
|
20
|
+
if reflection
|
|
21
|
+
scope_value = record.send(reflection.foreign_key)
|
|
22
|
+
scope_item = reflection.foreign_key
|
|
23
|
+
end
|
|
24
|
+
relation = relation.where(find_finder_class_for(record).table_name => { scope_item => scope_value })
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
translated_scopes.each do |scope_item|
|
|
28
|
+
scope_value = record.send(scope_item)
|
|
29
|
+
relation = relation.where(scope_item => scope_value)
|
|
30
|
+
end
|
|
31
|
+
relation = relation.merge(options[:conditions]) if options[:conditions]
|
|
32
|
+
|
|
33
|
+
# if klass.unscoped.with_translations.where(relation).exists?
|
|
34
|
+
if relation.exists?
|
|
35
|
+
error_options = options.except(:case_sensitive, :scope, :conditions)
|
|
36
|
+
error_options[:value] = value
|
|
37
|
+
record.errors.add(attribute, :taken, error_options)
|
|
38
|
+
end
|
|
39
|
+
else
|
|
40
|
+
super(record, attribute, value)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
ActiveRecord::Validations::UniquenessValidator.prepend Globalize::Validations::UniquenessValidator
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Globalize
|
|
2
|
+
module AttributeMethods
|
|
3
|
+
module Serialization
|
|
4
|
+
def serialize(attr_name, class_name_or_coder = Object)
|
|
5
|
+
super(attr_name, class_name_or_coder)
|
|
6
|
+
|
|
7
|
+
coder = if class_name_or_coder == ::JSON
|
|
8
|
+
::ActiveRecord::Coders::JSON
|
|
9
|
+
elsif [:load, :dump].all? { |x| class_name_or_coder.respond_to?(x) }
|
|
10
|
+
class_name_or_coder
|
|
11
|
+
else
|
|
12
|
+
::ActiveRecord::Coders::YAMLColumn.new(attr_name, class_name_or_coder)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
self.globalize_serialized_attributes = globalize_serialized_attributes.dup
|
|
16
|
+
self.globalize_serialized_attributes[attr_name] = coder
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
ActiveRecord::AttributeMethods::Serialization::ClassMethods.send(:prepend, Globalize::AttributeMethods::Serialization)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module Globalize
|
|
2
|
+
module Validations
|
|
3
|
+
module UniquenessValidator
|
|
4
|
+
def validate_each(record, attribute, value)
|
|
5
|
+
klass = record.class
|
|
6
|
+
if klass.translates? && klass.translated?(attribute)
|
|
7
|
+
finder_class = klass.translation_class
|
|
8
|
+
relation = build_relation(finder_class, attribute, value).where(locale: Globalize.locale)
|
|
9
|
+
relation = relation.where.not(klass.reflect_on_association(:translations).foreign_key => record.send(:id)) if record.persisted?
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
translated_scopes = Array(options[:scope]) & klass.translated_attribute_names
|
|
13
|
+
untranslated_scopes = Array(options[:scope]) - translated_scopes
|
|
14
|
+
|
|
15
|
+
relation = relation.joins(:globalized_model) if untranslated_scopes.present?
|
|
16
|
+
untranslated_scopes.each do |scope_item|
|
|
17
|
+
scope_value = record.send(scope_item)
|
|
18
|
+
reflection = klass.reflect_on_association(scope_item)
|
|
19
|
+
if reflection
|
|
20
|
+
scope_value = record.send(reflection.foreign_key)
|
|
21
|
+
scope_item = reflection.foreign_key
|
|
22
|
+
end
|
|
23
|
+
relation = relation.where(find_finder_class_for(record).table_name => { scope_item => scope_value })
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
translated_scopes.each do |scope_item|
|
|
27
|
+
scope_value = record.send(scope_item)
|
|
28
|
+
relation = relation.where(scope_item => scope_value)
|
|
29
|
+
end
|
|
30
|
+
relation = relation.merge(options[:conditions]) if options[:conditions]
|
|
31
|
+
|
|
32
|
+
if relation.exists?
|
|
33
|
+
error_options = options.except(:case_sensitive, :scope, :conditions)
|
|
34
|
+
error_options[:value] = value
|
|
35
|
+
record.errors.add(attribute, :taken, error_options)
|
|
36
|
+
end
|
|
37
|
+
else
|
|
38
|
+
super(record, attribute, value)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
ActiveRecord::Validations::UniquenessValidator.prepend Globalize::Validations::UniquenessValidator
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
if ::ActiveRecord::VERSION::STRING >= "5.0.0"
|
|
2
|
+
module Globalize
|
|
3
|
+
module Relation
|
|
4
|
+
def where_values_hash(relation_table_name = table_name)
|
|
5
|
+
return super unless respond_to?(:translations_table_name)
|
|
6
|
+
super.merge(super(translations_table_name))
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
ActiveRecord::Relation.prepend Globalize::Relation
|
|
12
|
+
end
|
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
module ClassMethods
|
|
7
|
-
def serialize_with_globalize(attr_name, class_name_or_coder = Object)
|
|
8
|
-
serialize_without_globalize(attr_name, class_name_or_coder)
|
|
9
|
-
|
|
10
|
-
coder = if class_name_or_coder == ::JSON
|
|
11
|
-
Coders::JSON
|
|
12
|
-
elsif [:load, :dump].all? { |x| class_name_or_coder.respond_to?(x) }
|
|
13
|
-
class_name_or_coder
|
|
14
|
-
else
|
|
15
|
-
Coders::YAMLColumn.new(class_name_or_coder)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
self.globalize_serialized_attributes[attr_name] = coder
|
|
19
|
-
end
|
|
20
|
-
alias_method_chain :serialize, :globalize
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
1
|
+
if ::ActiveRecord::VERSION::STRING < "5.1.0"
|
|
2
|
+
require_relative 'rails4/serialization'
|
|
3
|
+
else
|
|
4
|
+
require_relative 'rails5_1/serialization'
|
|
5
|
+
end
|
|
@@ -1,39 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
ActiveRecord::
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
table = finder_class.arel_table
|
|
9
|
-
|
|
10
|
-
relation = build_relation(finder_class, table, attribute, value).and(table[:locale].eq(Globalize.locale))
|
|
11
|
-
relation = relation.and(table[klass.reflect_on_association(:translations).foreign_key].not_eq(record.send(:id))) if record.persisted?
|
|
12
|
-
|
|
13
|
-
translated_scopes = Array(options[:scope]) & klass.translated_attribute_names
|
|
14
|
-
untranslated_scopes = Array(options[:scope]) - translated_scopes
|
|
15
|
-
|
|
16
|
-
untranslated_scopes.each do |scope_item|
|
|
17
|
-
scope_value = record.send(scope_item)
|
|
18
|
-
reflection = klass.reflect_on_association(scope_item)
|
|
19
|
-
if reflection
|
|
20
|
-
scope_value = record.send(reflection.foreign_key)
|
|
21
|
-
scope_item = reflection.foreign_key
|
|
22
|
-
end
|
|
23
|
-
relation = relation.and(find_finder_class_for(record).arel_table[scope_item].eq(scope_value))
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
translated_scopes.each do |scope_item|
|
|
27
|
-
scope_value = record.send(scope_item)
|
|
28
|
-
relation = relation.and(table[scope_item].eq(scope_value))
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
if klass.unscoped.with_translations.where(relation).exists?
|
|
32
|
-
record.errors.add(attribute, :taken, options.except(:case_sensitive, :scope).merge(:value => value))
|
|
33
|
-
end
|
|
34
|
-
else
|
|
35
|
-
validate_each_without_translations(record, attribute, value)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
alias_method_chain :validate_each, :translations
|
|
39
|
-
end
|
|
1
|
+
if ::ActiveRecord::VERSION::STRING < "5.0.0"
|
|
2
|
+
require_relative 'rails4/uniqueness_validator'
|
|
3
|
+
elsif ::ActiveRecord::VERSION::STRING < "5.1.0"
|
|
4
|
+
require_relative 'rails5/uniqueness_validator'
|
|
5
|
+
else
|
|
6
|
+
require_relative 'rails5_1/uniqueness_validator'
|
|
7
|
+
end
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
begin
|
|
2
|
+
require 'active_record/serializers/xml_serializer'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
end
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
module Globalize
|
|
7
|
+
module XmlSerializer
|
|
8
|
+
module Attribute
|
|
9
|
+
def compute_type
|
|
10
|
+
klass = @serializable.class
|
|
11
|
+
if klass.translates? && klass.translated_attribute_names.include?(name.to_sym)
|
|
12
|
+
:string
|
|
13
|
+
else
|
|
14
|
+
super
|
|
15
|
+
end
|
|
16
|
+
end
|
|
10
17
|
end
|
|
11
18
|
end
|
|
12
|
-
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
if defined?(ActiveRecord::XmlSerializer)
|
|
22
|
+
ActiveRecord::XmlSerializer::Attribute.send(:prepend, Globalize::XmlSerializer::Attribute)
|
|
13
23
|
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: 5.0
|
|
4
|
+
version: 5.1.0
|
|
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:
|
|
17
|
+
date: 2018-01-15 00:00:00.000000000 Z
|
|
18
18
|
dependencies:
|
|
19
19
|
- !ruby/object:Gem::Dependency
|
|
20
20
|
name: activerecord
|
|
@@ -22,56 +22,56 @@ dependencies:
|
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 4.2
|
|
25
|
+
version: '4.2'
|
|
26
26
|
- - "<"
|
|
27
27
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: '
|
|
28
|
+
version: '5.2'
|
|
29
29
|
type: :runtime
|
|
30
30
|
prerelease: false
|
|
31
31
|
version_requirements: !ruby/object:Gem::Requirement
|
|
32
32
|
requirements:
|
|
33
33
|
- - ">="
|
|
34
34
|
- !ruby/object:Gem::Version
|
|
35
|
-
version: 4.2
|
|
35
|
+
version: '4.2'
|
|
36
36
|
- - "<"
|
|
37
37
|
- !ruby/object:Gem::Version
|
|
38
|
-
version: '
|
|
38
|
+
version: '5.2'
|
|
39
39
|
- !ruby/object:Gem::Dependency
|
|
40
40
|
name: activemodel
|
|
41
41
|
requirement: !ruby/object:Gem::Requirement
|
|
42
42
|
requirements:
|
|
43
43
|
- - ">="
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: 4.2
|
|
45
|
+
version: '4.2'
|
|
46
46
|
- - "<"
|
|
47
47
|
- !ruby/object:Gem::Version
|
|
48
|
-
version: '
|
|
48
|
+
version: '5.2'
|
|
49
49
|
type: :runtime
|
|
50
50
|
prerelease: false
|
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
|
52
52
|
requirements:
|
|
53
53
|
- - ">="
|
|
54
54
|
- !ruby/object:Gem::Version
|
|
55
|
-
version: 4.2
|
|
55
|
+
version: '4.2'
|
|
56
56
|
- - "<"
|
|
57
57
|
- !ruby/object:Gem::Version
|
|
58
|
-
version: '
|
|
58
|
+
version: '5.2'
|
|
59
59
|
- !ruby/object:Gem::Dependency
|
|
60
|
-
name:
|
|
60
|
+
name: request_store
|
|
61
61
|
requirement: !ruby/object:Gem::Requirement
|
|
62
62
|
requirements:
|
|
63
63
|
- - "~>"
|
|
64
64
|
- !ruby/object:Gem::Version
|
|
65
|
-
version: 1.
|
|
66
|
-
type: :
|
|
65
|
+
version: '1.0'
|
|
66
|
+
type: :runtime
|
|
67
67
|
prerelease: false
|
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
|
69
69
|
requirements:
|
|
70
70
|
- - "~>"
|
|
71
71
|
- !ruby/object:Gem::Version
|
|
72
|
-
version: 1.
|
|
72
|
+
version: '1.0'
|
|
73
73
|
- !ruby/object:Gem::Dependency
|
|
74
|
-
name:
|
|
74
|
+
name: database_cleaner
|
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
|
76
76
|
requirements:
|
|
77
77
|
- - ">="
|
|
@@ -85,7 +85,7 @@ dependencies:
|
|
|
85
85
|
- !ruby/object:Gem::Version
|
|
86
86
|
version: '0'
|
|
87
87
|
- !ruby/object:Gem::Dependency
|
|
88
|
-
name: minitest
|
|
88
|
+
name: minitest
|
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
|
90
90
|
requirements:
|
|
91
91
|
- - ">="
|
|
@@ -99,7 +99,7 @@ dependencies:
|
|
|
99
99
|
- !ruby/object:Gem::Version
|
|
100
100
|
version: '0'
|
|
101
101
|
- !ruby/object:Gem::Dependency
|
|
102
|
-
name:
|
|
102
|
+
name: minitest-reporters
|
|
103
103
|
requirement: !ruby/object:Gem::Requirement
|
|
104
104
|
requirements:
|
|
105
105
|
- - ">="
|
|
@@ -151,12 +151,13 @@ files:
|
|
|
151
151
|
- Gemfile
|
|
152
152
|
- Gemfile.lock
|
|
153
153
|
- LICENSE
|
|
154
|
+
- README.md
|
|
154
155
|
- Rakefile
|
|
155
|
-
- globalize.gemspec
|
|
156
156
|
- lib/globalize.rb
|
|
157
157
|
- lib/globalize/active_record.rb
|
|
158
158
|
- lib/globalize/active_record/act_macro.rb
|
|
159
159
|
- lib/globalize/active_record/adapter.rb
|
|
160
|
+
- lib/globalize/active_record/adapter_dirty.rb
|
|
160
161
|
- lib/globalize/active_record/attributes.rb
|
|
161
162
|
- lib/globalize/active_record/class_methods.rb
|
|
162
163
|
- lib/globalize/active_record/exceptions.rb
|
|
@@ -170,10 +171,16 @@ files:
|
|
|
170
171
|
- lib/i18n/missing_translations_raise_handler.rb
|
|
171
172
|
- lib/patches/active_record/persistence.rb
|
|
172
173
|
- lib/patches/active_record/query_method.rb
|
|
174
|
+
- lib/patches/active_record/rails4/query_method.rb
|
|
175
|
+
- lib/patches/active_record/rails4/serialization.rb
|
|
176
|
+
- lib/patches/active_record/rails4/uniqueness_validator.rb
|
|
177
|
+
- lib/patches/active_record/rails5/uniqueness_validator.rb
|
|
178
|
+
- lib/patches/active_record/rails5_1/serialization.rb
|
|
179
|
+
- lib/patches/active_record/rails5_1/uniqueness_validator.rb
|
|
180
|
+
- lib/patches/active_record/relation.rb
|
|
173
181
|
- lib/patches/active_record/serialization.rb
|
|
174
182
|
- lib/patches/active_record/uniqueness_validator.rb
|
|
175
183
|
- lib/patches/active_record/xml_attribute_serializer.rb
|
|
176
|
-
- readme.md
|
|
177
184
|
homepage: http://github.com/globalize/globalize
|
|
178
185
|
licenses:
|
|
179
186
|
- MIT
|
|
@@ -186,7 +193,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
186
193
|
requirements:
|
|
187
194
|
- - ">="
|
|
188
195
|
- !ruby/object:Gem::Version
|
|
189
|
-
version:
|
|
196
|
+
version: 2.0.0
|
|
190
197
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
198
|
requirements:
|
|
192
199
|
- - ">="
|
|
@@ -194,9 +201,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
194
201
|
version: '0'
|
|
195
202
|
requirements: []
|
|
196
203
|
rubyforge_project: "[none]"
|
|
197
|
-
rubygems_version: 2.
|
|
204
|
+
rubygems_version: 2.6.13
|
|
198
205
|
signing_key:
|
|
199
206
|
specification_version: 4
|
|
200
207
|
summary: Rails I18n de-facto standard library for ActiveRecord model/data translation
|
|
201
208
|
test_files: []
|
|
202
|
-
has_rdoc:
|
data/globalize.gemspec
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../lib/globalize/version', __FILE__)
|
|
2
|
-
|
|
3
|
-
Gem::Specification.new do |s|
|
|
4
|
-
s.name = 'globalize'
|
|
5
|
-
s.version = Globalize::Version
|
|
6
|
-
s.authors = ['Sven Fuchs', 'Joshua Harvey', 'Clemens Kofler', 'John-Paul Bader', 'Tomasz Stachewicz', 'Philip Arndt', 'Chris Salzberg']
|
|
7
|
-
s.email = 'nobody@globalize-rails.org'
|
|
8
|
-
s.homepage = 'http://github.com/globalize/globalize'
|
|
9
|
-
s.summary = 'Rails I18n de-facto standard library for ActiveRecord model/data translation'
|
|
10
|
-
s.description = "#{s.summary}."
|
|
11
|
-
s.license = "MIT"
|
|
12
|
-
|
|
13
|
-
s.files = Dir['{lib/**/*,[A-Z]*}']
|
|
14
|
-
s.platform = Gem::Platform::RUBY
|
|
15
|
-
s.require_path = 'lib'
|
|
16
|
-
s.rubyforge_project = '[none]'
|
|
17
|
-
|
|
18
|
-
s.add_dependency 'activerecord', '>= 4.2.0', '< 4.3'
|
|
19
|
-
s.add_dependency 'activemodel', '>= 4.2.0', '< 4.3'
|
|
20
|
-
|
|
21
|
-
s.add_development_dependency 'database_cleaner', '~> 1.4.0'
|
|
22
|
-
s.add_development_dependency 'minitest'
|
|
23
|
-
s.add_development_dependency 'minitest-reporters'
|
|
24
|
-
|
|
25
|
-
s.add_development_dependency 'sqlite3'
|
|
26
|
-
s.add_development_dependency 'rdoc'
|
|
27
|
-
|
|
28
|
-
s.add_development_dependency 'rake'
|
|
29
|
-
end
|