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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 652870a795e31ffd24407d314cf997c6ff85ce15f3c9078ed4bd7ae550ca6529
4
- data.tar.gz: 4fd45beae242cdb967f50799d11caf7fab88ce3254a59b6391a4f52dddd254b8
3
+ metadata.gz: 1af9ca7e6027368f2615529ae3f56b58171ee2597ce575a88ffc63e127c2c623
4
+ data.tar.gz: 36952a0ca5738aa2dcd1e449aef92a8d4b32b9eac5efa7fa5690f8fd8343b2bf
5
5
  SHA512:
6
- metadata.gz: b43d2fe41563423861f21b994e0ecb6d826fae8e1529724ab4943864e86a9dcd4d08ba9c23571c83bc6ba85e2c76e5acd87a42ff7ce6c28cb6d132044156d2d9
7
- data.tar.gz: 90700da84b912ce6ecbdd83b3ea5cfa8cc415201a852279b54856bf90747c19853473500fb41f15a89dd1715df85314f1a5cd5783baa8c9d0be89f687eb36fba
6
+ metadata.gz: af62bdb50c430197615ed0872d0c1bc9077167b7fcb4caedd7f7856064224b5c479a830dc1c756cf1f5bfe9e8d4d28edfbd8508fe0a951881fc2f921e484ba5d
7
+ data.tar.gz: d167424a6e95f53df15188b30b84ee0b7a82b581286f7c2a06c66d2fb451dbfda8eea3c65c87cbe1b553f297171e6d4ad0b84891e720b1578a5c0715cbf1c6d7
@@ -8,3 +8,5 @@ gemfile:
8
8
  - gemfiles/activesupport-4.0
9
9
  - gemfiles/activesupport-4.2
10
10
  - gemfiles/activesupport-5.0
11
+ - gemfiles/activesupport-6.0
12
+
@@ -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 Resolve BigDecimal deprecation warnings
20
+ ### Added
21
+ - Resolve BigDecimal deprecation warnings
17
22
 
18
23
  ## [2.0.0] - Unknown
19
24
 
@@ -6,6 +6,6 @@ freeagentGem(
6
6
  node: 'smartos',
7
7
  slack: [channel: '#tax-eng-ci'],
8
8
  remote: "https://rubygems.org",
9
- key: "rubygems_api_key",
9
+ key: "rubygems",
10
10
  pushTag: true,
11
11
  forcePush: true )
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in xml-section.gemspec
4
+ gemspec :path => "../"
5
+
6
+ gem "activesupport", "~> 6.0"
@@ -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", "< 6"
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 test
17
- @bad_attributes = [] # reset this for each time the validator is used
18
- attributes.each do |attribute, _|
19
- bad_attributes << attribute unless allowed_attributes.include? attribute
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 message
25
- "has attributes it doesn't accept: #{bad_attributes.to_sentence}"
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
- @value, @attributes = value, attributes
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
@@ -7,11 +7,11 @@ module Hermod
7
7
 
8
8
  private
9
9
 
10
- def test
10
+ def test(value, attributes)
11
11
  value.blank? || value >= 0
12
12
  end
13
13
 
14
- def message
14
+ def message(value, attributes)
15
15
  "cannot be negative"
16
16
  end
17
17
  end
@@ -7,11 +7,11 @@ module Hermod
7
7
 
8
8
  private
9
9
 
10
- def test
10
+ def test(value, attributes)
11
11
  value.blank? || value.to_i != 0
12
12
  end
13
13
 
14
- def message
14
+ def message(value, attributes)
15
15
  "cannot be zero"
16
16
  end
17
17
  end
@@ -16,11 +16,11 @@ module Hermod
16
16
 
17
17
  private
18
18
 
19
- def test
19
+ def test(value, attributes)
20
20
  value.blank? || range.cover?(value)
21
21
  end
22
22
 
23
- def message
23
+ def message(value, attributes)
24
24
  "must be between #{range.min} and #{range.max}"
25
25
  end
26
26
  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}"
@@ -7,11 +7,11 @@ module Hermod
7
7
 
8
8
  private
9
9
 
10
- def test
10
+ def test(value, attributes)
11
11
  value.present?
12
12
  end
13
13
 
14
- def message
14
+ def message(value, attributes)
15
15
  "isn't optional but no value was provided"
16
16
  end
17
17
  end
@@ -8,11 +8,11 @@ module Hermod
8
8
 
9
9
  private
10
10
 
11
- def test
11
+ def test(value, attributes)
12
12
  value.blank? || value == value.to_i
13
13
  end
14
14
 
15
- def message
15
+ def message(value, attributes)
16
16
  "must be in whole units"
17
17
  end
18
18
  end
@@ -1,3 +1,3 @@
1
1
  module Hermod
2
- VERSION = "2.5.0"
2
+ VERSION = "2.5.1"
3
3
  end
@@ -13,7 +13,7 @@ module Hermod
13
13
 
14
14
  it "has a default error message" do
15
15
  class TestValidator < Base
16
- def test
16
+ def test(value, attributes)
17
17
  false
18
18
  end
19
19
  end
@@ -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.0
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-07-25 00:00:00.000000000 Z
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: '6'
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: '6'
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