vexile 1.0.7 → 1.0.8

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
2
  SHA1:
3
- metadata.gz: 3ad9587fbca289149c8be8a608ec01b0910268cd
4
- data.tar.gz: dedce8656b1cb4ade0896ef501663347a32f46ff
3
+ metadata.gz: 039b9f7d26db4200534c252b5279ab14d562b0f5
4
+ data.tar.gz: c7c1b580fe37ceeea4068b2d89d845c2a0e38585
5
5
  SHA512:
6
- metadata.gz: d7bf3e3ed015171568a71bc256d4d06eae7f26b295bced408a1fbe3a84110c1a8fc8f30f99bfe489bdf05f3f9e86ce3000c993ed2773cbb8d61e6578ed84a4d2
7
- data.tar.gz: 34748f8d92c79b90176b059ebc52d96d0ea4eb870f858187b27004815312c8dee9cf6efaa378a278e272960897d2fc57f117ac590d1e1a4e776f324e6f9d7f2a
6
+ metadata.gz: d9dfbd08bb0ed03e9209b0e494ad81872a50a0e9613fa234c975cff508309128af9e5176221c282cb0a0a4eb139a1b1e8dac4c23195b4f32e6074a09e81a166e
7
+ data.tar.gz: 12c60b62e77c62c9050ce9c520753ae2b364e13a90b5ef20a148179ecb318e74f1760d4101ab86b6dfc76f92df8037681d799f6503a2ca301695c8de699554d8
@@ -0,0 +1,16 @@
1
+ en:
2
+ errors:
3
+ messages:
4
+ invalid_url: invalid url
5
+ incorrect_count:
6
+ one: should have exaclty %{count} elements
7
+ many: should have exactly %{count} elements
8
+ too_few:
9
+ one: should have at least %{count} element
10
+ many: should have at least %{count} elements
11
+ too_many:
12
+ one: should have at most %{count} element
13
+ many: should have at most %{count} elements
14
+ uncountable: value is uncountable
15
+ recursivelu_invalid: "is invalid in %{in} : %{messages}"
16
+
@@ -5,8 +5,11 @@ require "vexile/validators/size_validator"
5
5
  require "vexile/validators/url_validator"
6
6
  require 'active_support/inflector'
7
7
  require 'active_support/concern'
8
+ require 'i18n'
8
9
  require 'bzproxies'
9
10
 
11
+ I18n.load_path += Dir.glob( File.dirname(__FILE__) + "/locales/*.{rb,yml}" )
12
+
10
13
  module Vexile
11
14
  class << self
12
15
  attr_accessor :klasses
@@ -4,10 +4,16 @@ class RecursiveValidator < ActiveModel::EachValidator
4
4
  if param_proxy
5
5
  if param_proxy.respond_to? :each
6
6
  param_proxy.each do |sub_proxy|
7
- record.errors.add attribute, "is invalid in #{sub_proxy} : #{sub_proxy.errors.messages}" if !sub_proxy.valid?
7
+ if !sub_proxy.valid?
8
+ message = I18n.translate('errors.messages.recursively_invalid', :in => sub_proxy, :messages => sub_proxy.errors.messages)
9
+ record.errors.add attribute, message
10
+ end
8
11
  end
9
12
  else
10
- record.errors.add attribute, "is invalid in #{param_proxy} : #{param_proxy.errors.messages}" if !param_proxy.valid?
13
+ if !param_proxy.valid?
14
+ message = I18n.translate('errors.messages.recursively_invalid', :in => param_proxy, :messages => param_proxy.errors.messages)
15
+ record.errors.add attribute, message
16
+ end
11
17
  end
12
18
  end
13
19
  end
@@ -3,18 +3,18 @@ class SizeValidator < ActiveModel::EachValidator
3
3
  real_value = record.__send__(attribute)
4
4
  if real_value.respond_to? :size
5
5
  if @options[:with] and (real_value.size != @options[:with].to_i)
6
- record.errors.add attribute, "should have #{@options[:with]} element(s)"
6
+ record.errors.add attribute, I18n.translate('errors.messages.incorrect_count', :count => @options[:with])
7
7
  else
8
8
  if @options[:min] and (real_value.size < @options[:min].to_i)
9
- record.errors.add attribute, "should be bigger than #{@options[:min]} element(s)"
9
+ record.errors.add attribute, I18n.translate('errors.messages.too_few', :count => @options[:min])
10
10
  end
11
11
  if @options[:max] and (real_value.size > @options[:max].to_i)
12
- record.errors.add attribute, "should be shorter than #{@options[:max]} element(s)"
12
+ record.errors.add attribute, I18n.translate('errors.messages.too_many', :count => @options[:max])
13
13
  end
14
14
  end
15
15
  else
16
16
  if (@options[:with] and (@options[:with].to_i != 0)) || @options[:min]
17
- record.errors.add attribute, "is blank or could not be counted"
17
+ record.errors.add attribute, I18n.translate('errors.messages.uncountable')
18
18
  end
19
19
  end
20
20
  end
@@ -7,7 +7,7 @@ class UrlValidator < ActiveModel::EachValidator
7
7
  raise ::Addressable::URI::InvalidURIError
8
8
  end
9
9
  rescue ::Addressable::URI::InvalidURIError
10
- record.errors[attribute] << "Invalid URL"
10
+ record.errors[attribute] << I18n.translate('errors.messages.invalid_url')
11
11
  end
12
12
  end
13
13
  end
@@ -1,3 +1,3 @@
1
1
  module Vexile
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
@@ -3,5 +3,7 @@ require 'rubygems'
3
3
  require 'bundler/setup'
4
4
  require 'vexile'
5
5
 
6
+ I18n.enforce_available_locales = true
7
+
6
8
  RSpec.configure do |config|
7
9
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vexile
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kostrov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-05 00:00:00.000000000 Z
11
+ date: 2014-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bzproxies
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.1.11
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.1.11
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: addressable
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Auto generating ActiveModel validations for hashes
@@ -86,13 +86,14 @@ executables: []
86
86
  extensions: []
87
87
  extra_rdoc_files: []
88
88
  files:
89
- - .gitignore
90
- - .rspec
91
- - .travis.yml
89
+ - ".gitignore"
90
+ - ".rspec"
91
+ - ".travis.yml"
92
92
  - Gemfile
93
93
  - LICENSE
94
94
  - README.md
95
95
  - Rakefile
96
+ - lib/locales/en.yml
96
97
  - lib/vexile.rb
97
98
  - lib/vexile/validators/recursive_validator.rb
98
99
  - lib/vexile/validators/size_validator.rb
@@ -111,20 +112,21 @@ require_paths:
111
112
  - lib
112
113
  required_ruby_version: !ruby/object:Gem::Requirement
113
114
  requirements:
114
- - - '>='
115
+ - - ">="
115
116
  - !ruby/object:Gem::Version
116
117
  version: '0'
117
118
  required_rubygems_version: !ruby/object:Gem::Requirement
118
119
  requirements:
119
- - - '>='
120
+ - - ">="
120
121
  - !ruby/object:Gem::Version
121
122
  version: '0'
122
123
  requirements: []
123
124
  rubyforge_project:
124
- rubygems_version: 2.0.6
125
+ rubygems_version: 2.2.1
125
126
  signing_key:
126
127
  specification_version: 4
127
128
  summary: ActiveModel validations for hashes
128
129
  test_files:
129
130
  - spec/main_spec.rb
130
131
  - spec/spec_helper.rb
132
+ has_rdoc: