hermod 2.5.0 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +7 -2
- data/Jenkinsfile +1 -1
- data/gemfiles/activesupport-6.0 +6 -0
- data/hermod.gemspec +1 -1
- data/lib/hermod/validators/allowed_values.rb +2 -2
- data/lib/hermod/validators/attributes.rb +10 -8
- data/lib/hermod/validators/base.rb +3 -6
- data/lib/hermod/validators/non_negative.rb +2 -2
- data/lib/hermod/validators/non_zero.rb +2 -2
- data/lib/hermod/validators/range.rb +2 -2
- data/lib/hermod/validators/regular_expression.rb +2 -2
- data/lib/hermod/validators/type_checker.rb +2 -2
- data/lib/hermod/validators/value_presence.rb +2 -2
- data/lib/hermod/validators/whole_units.rb +2 -2
- data/lib/hermod/version.rb +1 -1
- data/spec/hermod/validators/base_spec.rb +1 -1
- data/spec/hermod/xml_section_builder/string_node_spec.rb +13 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1af9ca7e6027368f2615529ae3f56b58171ee2597ce575a88ffc63e127c2c623
|
4
|
+
data.tar.gz: 36952a0ca5738aa2dcd1e449aef92a8d4b32b9eac5efa7fa5690f8fd8343b2bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af62bdb50c430197615ed0872d0c1bc9077167b7fcb4caedd7f7856064224b5c479a830dc1c756cf1f5bfe9e8d4d28edfbd8508fe0a951881fc2f921e484ba5d
|
7
|
+
data.tar.gz: d167424a6e95f53df15188b30b84ee0b7a82b581286f7c2a06c66d2fb451dbfda8eea3c65c87cbe1b553f297171e6d4ad0b84891e720b1578a5c0715cbf1c6d7
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -7,13 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [2.5.1] - 2019-08-26
|
11
|
+
### Added
|
12
|
+
- Support Rails 6.0
|
13
|
+
|
10
14
|
## [2.5.0] - 2019-07-25
|
11
15
|
### Added
|
12
|
-
- Adds Jenkins build
|
16
|
+
- Adds Jenkins build
|
13
17
|
- Upgrades bundler and ruby version file
|
14
18
|
|
15
19
|
## [2.4.1] - 2019-07-22
|
16
|
-
### Added
|
20
|
+
### Added
|
21
|
+
- Resolve BigDecimal deprecation warnings
|
17
22
|
|
18
23
|
## [2.0.0] - Unknown
|
19
24
|
|
data/Jenkinsfile
CHANGED
data/hermod.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.required_ruby_version = ">= 2.0.0"
|
24
24
|
|
25
25
|
spec.add_runtime_dependency "libxml-ruby", "~> 2.7", ">= 2.7.0"
|
26
|
-
spec.add_runtime_dependency "activesupport", "> 3.2", "<
|
26
|
+
spec.add_runtime_dependency "activesupport", "> 3.2", "< 7"
|
27
27
|
|
28
28
|
spec.add_development_dependency "bundler", "~> 2.0"
|
29
29
|
spec.add_development_dependency "rake", "~> 11.1"
|
@@ -13,11 +13,11 @@ module Hermod
|
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def test
|
16
|
+
def test(value, attributes)
|
17
17
|
value.blank? || allowed_values.include?(value)
|
18
18
|
end
|
19
19
|
|
20
|
-
def message
|
20
|
+
def message(value, attributes)
|
21
21
|
list_of_values = allowed_values.to_sentence(last_word_connector: ", or ", two_words_connector: " or ")
|
22
22
|
"must be one of #{list_of_values}, not #{value}"
|
23
23
|
end
|
@@ -13,16 +13,18 @@ module Hermod
|
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
bad_attributes == []
|
16
|
+
def bad_attributes(attributes)
|
17
|
+
attributes.map do |attribute, _|
|
18
|
+
attribute unless allowed_attributes.include? attribute
|
19
|
+
end.compact
|
22
20
|
end
|
23
21
|
|
24
|
-
def
|
25
|
-
|
22
|
+
def test(value, attributes)
|
23
|
+
bad_attributes(attributes) == []
|
24
|
+
end
|
25
|
+
|
26
|
+
def message(value, attributes)
|
27
|
+
"has attributes it doesn't accept: #{bad_attributes(attributes).to_sentence}"
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
@@ -3,16 +3,13 @@ require 'active_support/core_ext/array/conversions'
|
|
3
3
|
module Hermod
|
4
4
|
module Validators
|
5
5
|
class Base
|
6
|
-
attr_reader :value, :attributes
|
7
|
-
|
8
6
|
# Public: Runs the test for the validator returning true if it passes and
|
9
7
|
# raising if it fails
|
10
8
|
#
|
11
9
|
# Raises a Hermod::InvalidInputError if the test fails
|
12
10
|
# Returns true if it succeeds
|
13
11
|
def valid?(value, attributes)
|
14
|
-
|
15
|
-
!!test || raise(InvalidInputError, message)
|
12
|
+
!!test(value, attributes) || raise(InvalidInputError, message(value, attributes))
|
16
13
|
end
|
17
14
|
|
18
15
|
private
|
@@ -21,14 +18,14 @@ module Hermod
|
|
21
18
|
# validator
|
22
19
|
#
|
23
20
|
# Returns a boolean
|
24
|
-
def test
|
21
|
+
def test(value, attributes)
|
25
22
|
raise NotImplementedError
|
26
23
|
end
|
27
24
|
|
28
25
|
# Private: override in subclasses to provide a more useful error message
|
29
26
|
#
|
30
27
|
# Returns a string
|
31
|
-
def message
|
28
|
+
def message(value, attributes)
|
32
29
|
"is invalid"
|
33
30
|
end
|
34
31
|
end
|
@@ -17,11 +17,11 @@ module Hermod
|
|
17
17
|
# because those are checked by the ValuePresence validator if necessary.
|
18
18
|
#
|
19
19
|
# Returns a boolean
|
20
|
-
def test
|
20
|
+
def test(value, attributes)
|
21
21
|
value.blank? || value =~ pattern
|
22
22
|
end
|
23
23
|
|
24
|
-
def message
|
24
|
+
def message(value, attributes)
|
25
25
|
"#{value.inspect} does not match #{pattern.inspect}"
|
26
26
|
end
|
27
27
|
end
|
@@ -23,11 +23,11 @@ module Hermod
|
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
-
def test
|
26
|
+
def test(value, attributes)
|
27
27
|
value.blank? || checker.call(value)
|
28
28
|
end
|
29
29
|
|
30
|
-
def message
|
30
|
+
def message(value, attributes)
|
31
31
|
expected_class_name = expected_class.name.downcase
|
32
32
|
join_word = (%w(a e i o u).include?(expected_class_name[0]) ? "an" : "a")
|
33
33
|
"must be #{join_word} #{expected_class_name}"
|
data/lib/hermod/version.rb
CHANGED
@@ -72,6 +72,19 @@ module Hermod
|
|
72
72
|
ex.message.must_equal "mood must be one of Happy, Sad, or Hangry, not Jubilant"
|
73
73
|
end
|
74
74
|
|
75
|
+
it "should be thread safe for validation" do
|
76
|
+
subject1 = StringXml.new do |string_xml|
|
77
|
+
string_xml.greeting "Hello"
|
78
|
+
end
|
79
|
+
|
80
|
+
Thread.new do
|
81
|
+
subject1.mood "Hangry"
|
82
|
+
end
|
83
|
+
|
84
|
+
ex = proc { subject.mood "Jubilant" }.must_raise InvalidInputError
|
85
|
+
ex.message.must_equal "mood must be one of Happy, Sad, or Hangry, not Jubilant"
|
86
|
+
end
|
87
|
+
|
75
88
|
it "should use the given keys for attributes" do
|
76
89
|
subject.title "Sir", masculine: "no"
|
77
90
|
attributes_for_node("Title").keys.first.must_equal "Male"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hermod
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harry Mills
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libxml-ruby
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: '3.2'
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '7'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: '3.2'
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
52
|
+
version: '7'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: bundler
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- gemfiles/activesupport-4.0
|
151
151
|
- gemfiles/activesupport-4.2
|
152
152
|
- gemfiles/activesupport-5.0
|
153
|
+
- gemfiles/activesupport-6.0
|
153
154
|
- hermod.gemspec
|
154
155
|
- lib/hermod.rb
|
155
156
|
- lib/hermod/input_mutator.rb
|