globalize-validations 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fb9bb8432b00243438c0c1934768912b738d4fee
4
- data.tar.gz: a585a262096b2042bad4f8c4b6f05ff8c4fef25b
2
+ SHA256:
3
+ metadata.gz: 1894b17350f0f763385c3e6c32113b04d38f91ee24103f62b4b4c5ee81ee7120
4
+ data.tar.gz: 9fcd2368dde05495a6f5f1d2a3607285e54eb6070c9f661964959ae05e9e5024
5
5
  SHA512:
6
- metadata.gz: a59b6a5a2fd5ed0f5ecfc1d169b83c664ac487486745bada3c594c36a84a8c1b624a73947b0ae093e7d172c92317234f684ea2ba4f873d1a09555de68dd45ca4
7
- data.tar.gz: 98899d92fbc90baee4a88556e4623bd9b46756f54fb84e8ad59dd79c99ba5946300ee1471ef72afa1667076c58bf07398a16508cf141878ae8b3533b3fa1eae4
6
+ metadata.gz: 0a885e7d21b7a78392559ba8a78565159b41001bc7838c9bde683e31f26687b8097024fbdcba46adf4ac145f5de92432cb6bae2411ce6b72bd4b0ba74c5f0530
7
+ data.tar.gz: 6c1336a3adc1143bdbd17615df563ef92d6366df4e7a369696ec6e9d8e8ad218ce752dd2d819224699513a0b340b838a0be6818354bfbde75844239ff7bf8e7f
data/README.md CHANGED
@@ -1,16 +1,12 @@
1
1
  [![Code Climate](https://codeclimate.com/github/BookingSync/globalize-validations.png)](https://codeclimate.com/github/BookingSync/globalize-validations)
2
- [![Build Status](https://travis-ci.org/BookingSync/globalize-validations.png?branch=master)](https://travis-ci.org/BookingSync/globalize-validations)
2
+ [![CI](https://github.com/BookingSync/globalize-validations/actions/workflows/ci.yml/badge.svg)](https://github.com/BookingSync/globalize-validations/actions/workflows/ci.yml)
3
3
 
4
4
  # Globalize-Validations
5
5
 
6
6
  Globalize Validations validates your translated attributes for each given locales.
7
7
  The errors are added to the globalize attributes accessor names (example `title_en`).
8
8
 
9
- `globalize-validations` is compatible with Rails 3.x, Rails 4.0.x and Rails 4.1.x.
10
-
11
- ## Requirements
12
-
13
- Globalize `>= 3.0.0`, Globalize-Accessors `>= 0.1.3` and Ruby `>= 1.9.3`.
9
+ `globalize-validations` is compatible with Rails 5.2, Rails 6.x and Rails 7.0.x.
14
10
 
15
11
  ## Documentation
16
12
 
@@ -12,11 +12,12 @@ module Globalize
12
12
  return unless Globalize.locale == I18n.locale
13
13
 
14
14
  # Define which locales to validate against
15
- locales = if self.globalize_validations_locales.respond_to?(:call)
16
- self.globalize_validations_locales.call(self)
15
+ locales = if globalize_validations_locales.respond_to?(:call)
16
+ globalize_validations_locales.call(self)
17
17
  else
18
- self.globalize_validations_locales
18
+ globalize_validations_locales
19
19
  end
20
+ locales ||= []
20
21
 
21
22
  globalized_errors = globalized_errors_for_locales(translated_attribute_names, locales)
22
23
 
@@ -30,8 +31,8 @@ module Globalize
30
31
 
31
32
  # Return all translated attributes with errors for the given locales,
32
33
  # including their error messages
33
- def globalized_errors_for_locales(attribute_names, locales)
34
- locales.map!(&:to_s)
34
+ def globalized_errors_for_locales(attribute_names, source_locales)
35
+ locales = source_locales.map(&:to_s)
35
36
  additional_locales = locales - [I18n.locale.to_s]
36
37
 
37
38
  {}.tap do |globalized_errors|
@@ -57,8 +58,8 @@ module Globalize
57
58
  def globalized_errors_for_locale(translated_attribute_names, locale)
58
59
  {}.tap do |globalized_errors|
59
60
  translated_attribute_names.each do |attribute|
60
- if (error = errors.messages.delete(attribute.to_sym)).present?
61
- globalized_errors["#{attribute}_#{locale}".to_sym] = error
61
+ if (error = errors.delete(attribute.to_sym)).present?
62
+ globalized_errors["#{attribute}_#{locale.to_s.underscore}".to_sym] = error
62
63
  end
63
64
  end
64
65
  end
@@ -3,7 +3,7 @@ module Globalize
3
3
  module Model
4
4
  # Enables validations for all available locales
5
5
  #
6
- # # @param options [Hash] Configuration options for globalize-validations.
6
+ # @param options [Hash] Configuration options for globalize-validations.
7
7
  # They are inherited by subclasses, but can be overwritten in the subclass.
8
8
  # @option options [Symbol] locales: locales against which the object will be validated,
9
9
  # default is the Model's globalize_locales.
@@ -1,5 +1,5 @@
1
1
  module Globalize
2
2
  module Validations
3
- VERSION = '0.0.1'
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,101 +1,101 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: globalize-validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien Grosjean
8
8
  - Braulio Martinez LM
9
9
  - Adrian Mugnolo
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-07-27 00:00:00.000000000 Z
13
+ date: 2021-09-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: globalize
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - "~>"
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '3'
21
+ version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - "~>"
26
+ - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: '3'
28
+ version: '0'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: globalize-accessors
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - "~>"
33
+ - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: '0.1'
35
+ version: '0'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - "~>"
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: '0.1'
42
+ version: '0'
43
43
  - !ruby/object:Gem::Dependency
44
- name: bundler
44
+ name: activerecord
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - "~>"
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '1.3'
50
- type: :development
49
+ version: '0'
50
+ type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - "~>"
54
+ - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: '1.3'
56
+ version: '0'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: rake
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - "~>"
61
+ - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: '0.9'
63
+ version: '0'
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - "~>"
68
+ - - ">="
69
69
  - !ruby/object:Gem::Version
70
- version: '0.9'
70
+ version: '0'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: sqlite3
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - "~>"
75
+ - - ">="
76
76
  - !ruby/object:Gem::Version
77
- version: '1.3'
77
+ version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - "~>"
82
+ - - ">="
83
83
  - !ruby/object:Gem::Version
84
- version: '1.3'
84
+ version: '0'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: minitest
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - "~>"
89
+ - - ">="
90
90
  - !ruby/object:Gem::Version
91
- version: '4.2'
91
+ version: '0'
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - "~>"
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
- version: '4.2'
98
+ version: '0'
99
99
  description: Validates translated attributes accessed with globalized accessors
100
100
  email:
101
101
  - dev@bookingsync.com
@@ -116,7 +116,7 @@ homepage: https://github.com/BookingSync/globalize-validations
116
116
  licenses:
117
117
  - MIT
118
118
  metadata: {}
119
- post_install_message:
119
+ post_install_message:
120
120
  rdoc_options: []
121
121
  require_paths:
122
122
  - lib
@@ -131,10 +131,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  requirements: []
134
- rubyforge_project:
135
- rubygems_version: 2.2.2
136
- signing_key:
134
+ rubygems_version: 3.1.2
135
+ signing_key:
137
136
  specification_version: 4
138
137
  summary: Validates translated attributes accessed with globalized accessors
139
138
  test_files: []
140
- has_rdoc: