rs_russian 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile.lock +9 -9
- data/lib/russian/active_model_ext/custom_error_message.rb +31 -53
- data/lib/russian/version.rb +1 -1
- data/russian.gemspec +1 -1
- metadata +22 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1115b061a56c17e49b2669ebed20e3e1c3204598
|
4
|
+
data.tar.gz: daac96ea23fb9044af33f4d1629daca1289e9d4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 554ca6cc31d9403ddfd36c09eb5dd56785e706c95517c034a99ea716ac616f61d819d031eec5f735c57f570aeccaebbbbc052e222365a67a589eba6ba8143b5d
|
7
|
+
data.tar.gz: 4612f146f776c494ba2f4dba4526df6c50bf502667e36204de079153f9cfea5b88aab3fe2d370475932c3ce2049380fe87d67873709a7bfd8c1b775be6c98d72
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.5
|
data/Gemfile.lock
CHANGED
@@ -1,24 +1,25 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rs_russian (0.8.
|
4
|
+
rs_russian (0.8.1)
|
5
|
+
activesupport (>= 3.0.0, < 5.0.0)
|
5
6
|
i18n (>= 0.6.0, < 0.8.0)
|
6
7
|
unicode (~> 0.4.4)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
10
11
|
specs:
|
11
|
-
activesupport (4.
|
12
|
-
i18n (~> 0.
|
12
|
+
activesupport (4.2.0)
|
13
|
+
i18n (~> 0.7)
|
13
14
|
json (~> 1.7, >= 1.7.7)
|
14
15
|
minitest (~> 5.1)
|
15
|
-
thread_safe (~> 0.
|
16
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
16
17
|
tzinfo (~> 1.1)
|
17
18
|
diff-lcs (1.2.5)
|
18
|
-
i18n (0.7.0
|
19
|
+
i18n (0.7.0)
|
19
20
|
json (1.8.1)
|
20
|
-
minitest (5.
|
21
|
-
rake (10.
|
21
|
+
minitest (5.5.0)
|
22
|
+
rake (10.4.2)
|
22
23
|
rspec (2.99.0)
|
23
24
|
rspec-core (~> 2.99.0)
|
24
25
|
rspec-expectations (~> 2.99.0)
|
@@ -30,13 +31,12 @@ GEM
|
|
30
31
|
thread_safe (0.3.4)
|
31
32
|
tzinfo (1.2.2)
|
32
33
|
thread_safe (~> 0.1)
|
33
|
-
unicode (0.4.4.
|
34
|
+
unicode (0.4.4.2)
|
34
35
|
|
35
36
|
PLATFORMS
|
36
37
|
ruby
|
37
38
|
|
38
39
|
DEPENDENCIES
|
39
|
-
activesupport (>= 3.0.0, < 5.0.0)
|
40
40
|
bundler (~> 1.7)
|
41
41
|
rake
|
42
42
|
rs_russian!
|
@@ -8,63 +8,41 @@ if defined?(ActiveModel::Errors)
|
|
8
8
|
# Non-base messages are prefixed with the attribute name as usual UNLESS they begin with '^'
|
9
9
|
# in which case the attribute name is omitted.
|
10
10
|
# E.g. validates_acceptance_of :accepted_terms, :message => '^Please accept the terms of service'
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
#
|
39
|
-
# company = Company.create(:address => '123 First St.')
|
40
|
-
# company.errors.full_messages # =>
|
41
|
-
# ["Name is too short (minimum is 5 characters)", "Name can't be blank", "Address can't be blank"]
|
42
|
-
def full_messages
|
43
|
-
full_messages = []
|
44
|
-
|
45
|
-
each do |attribute, messages|
|
46
|
-
messages = Array.wrap(messages)
|
47
|
-
next if messages.empty?
|
48
|
-
|
49
|
-
if attribute == :base
|
50
|
-
messages.each {|m| full_messages << m }
|
51
|
-
else
|
52
|
-
attr_name = attribute.to_s.gsub('.', '_').humanize
|
53
|
-
attr_name = @base.class.human_attribute_name(attribute, :default => attr_name)
|
54
|
-
options = { :attribute => attr_name, :default => "%{attribute} %{message}" }
|
55
|
-
|
56
|
-
messages.each do |m|
|
57
|
-
if m =~ /^\^/
|
58
|
-
full_messages << m[1..-1]
|
11
|
+
|
12
|
+
def full_message(attribute, message)
|
13
|
+
return message if attribute == :base
|
14
|
+
attr_name = attribute.to_s.tr('.', '_').humanize
|
15
|
+
attr_name = @base.class.human_attribute_name(attribute, default: attr_name)
|
16
|
+
|
17
|
+
if message =~ /^\^/
|
18
|
+
message[1..-1]
|
19
|
+
else
|
20
|
+
I18n.t(:"errors.format", {
|
21
|
+
default: "%{attribute} %{message}",
|
22
|
+
attribute: attr_name,
|
23
|
+
message: message
|
24
|
+
})
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_hash(full_messages = false)
|
29
|
+
if full_messages
|
30
|
+
self.messages.each_with_object({}) do |(attribute, array), messages|
|
31
|
+
messages[attribute] = array.map { |message| full_message(attribute, message) }
|
32
|
+
end
|
33
|
+
else
|
34
|
+
self.messages.dup.map do |k, vs|
|
35
|
+
m = vs.map do |v|
|
36
|
+
if v =~ /^\^/
|
37
|
+
v[1..-1]
|
59
38
|
else
|
60
|
-
|
39
|
+
v
|
61
40
|
end
|
62
41
|
end
|
63
|
-
|
42
|
+
{k => m}
|
43
|
+
end.reduce(:merge)
|
64
44
|
end
|
65
|
-
|
66
|
-
full_messages
|
67
45
|
end
|
68
46
|
end
|
69
47
|
end
|
70
|
-
end
|
48
|
+
end
|
data/lib/russian/version.rb
CHANGED
data/russian.gemspec
CHANGED
@@ -20,9 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency 'i18n', [">= 0.6.0", "< 0.8.0"]
|
22
22
|
spec.add_dependency 'unicode', '~> 0.4.4'
|
23
|
+
spec.add_dependency 'activesupport', ['>= 3.0.0', '< 5.0.0']
|
23
24
|
|
24
25
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
25
26
|
spec.add_development_dependency 'rake'
|
26
27
|
spec.add_development_dependency 'rspec', '~> 2.14'
|
27
|
-
spec.add_development_dependency 'activesupport', ['>= 3.0.0', '< 5.0.0']
|
28
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rs_russian
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- glebtv
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-12-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
@@ -45,6 +45,26 @@ dependencies:
|
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.4.4
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: activesupport
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.0.0
|
55
|
+
- - "<"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 5.0.0
|
58
|
+
type: :runtime
|
59
|
+
prerelease: false
|
60
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 3.0.0
|
65
|
+
- - "<"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 5.0.0
|
48
68
|
- !ruby/object:Gem::Dependency
|
49
69
|
name: bundler
|
50
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,26 +107,6 @@ dependencies:
|
|
87
107
|
- - "~>"
|
88
108
|
- !ruby/object:Gem::Version
|
89
109
|
version: '2.14'
|
90
|
-
- !ruby/object:Gem::Dependency
|
91
|
-
name: activesupport
|
92
|
-
requirement: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 3.0.0
|
97
|
-
- - "<"
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
version: 5.0.0
|
100
|
-
type: :development
|
101
|
-
prerelease: false
|
102
|
-
version_requirements: !ruby/object:Gem::Requirement
|
103
|
-
requirements:
|
104
|
-
- - ">="
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
version: 3.0.0
|
107
|
-
- - "<"
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 5.0.0
|
110
110
|
description: Russian language support for Ruby and Rails
|
111
111
|
email:
|
112
112
|
- glebtv@gmail.com
|