hermod 1.2.9 → 2.1.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
2
  SHA1:
3
- metadata.gz: 7d8938fb835c7fc982575070b443eb433cdf7408
4
- data.tar.gz: fd8de6d1e6e0cd07a127af7a50e14e7bdc0975a9
3
+ metadata.gz: f734b2b05f6e0c454ade409a61f9eb18da49d9ca
4
+ data.tar.gz: b5feefa69f5f93cc380c7841248b2a30b947b43e
5
5
  SHA512:
6
- metadata.gz: fc8e8a82158701a208e534b9a743f0b7ebb73c3dd97227c7413ffb6e62e2787593a6be48e6af1a132714563edbecfdf4dd24ca47e924c8973c3395d26a3c891f
7
- data.tar.gz: 7aae32bbde17ae4497b7f657c69baf8a493efa060faa4f6d2d9765606d039091ce04a07ed63c593c9548e277a73126da76486754d306ca72d00cbc142de32e1c
6
+ metadata.gz: 0caa25fac9dc0cc74b4f624b480bb7d900f6d625910af7c39758e62ca1d217b96643e8733deefd63a781c41c77460fb6058ee23d75c20d82f22c8c773bc4b4a1
7
+ data.tar.gz: d680e1797b1316cd5af0ed76b7d4f0c74f25c7147e2e51b99fb7e8d1c0387d6ca0c39b38d3bdd59e90cf14f22e40ca6d4c8634993a0bb289fcffa53bdbeadb5d
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+ gemfiles/*.lock
data/.travis.yml CHANGED
@@ -1,3 +1,10 @@
1
1
  language: ruby
2
+ bundler_args: --without test
2
3
  rvm:
3
- - 2.1.2
4
+ - 2.1.6
5
+ - 2.2.2
6
+ - ruby-head
7
+ gemfile:
8
+ - gemfiles/activesupport-3.2
9
+ - gemfiles/activesupport-4.0
10
+ - gemfiles/activesupport-4.2
data/Gemfile CHANGED
@@ -3,7 +3,11 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in xml-section.gemspec
4
4
  gemspec
5
5
 
6
- gem "pry-byebug", "~> 1.3.3", platform: [:mri_20, :mri_21]
7
- gem "pry-debugger", "~> 0.2.3", platform: :mri_19
8
- gem "pry-doc", "~> 0.6.0"
9
- gem "bond", "~> 0.5.1"
6
+ group :test do
7
+ gem "guard", "~> 2.6.1"
8
+ gem "guard-minitest", "~> 2.3.1"
9
+ gem "pry-byebug", "~> 1.3.3", platform: [:mri_20, :mri_21]
10
+ gem "pry-debugger", "~> 0.2.3", platform: :mri_19
11
+ gem "pry-doc", "~> 0.6.0"
12
+ gem "bond", "~> 0.5.1"
13
+ end
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Code
4
4
  Climate](https://codeclimate.com/github/fac/hermod/badges/gpa.svg)](https://codeclimate.com/github/fac/hermod)
5
+ [![Build Status](https://travis-ci.org/fac/hermod.svg?branch=master)](https://travis-ci.org/fac/hermod)
5
6
 
6
7
  This gem makes it easier to talk to HMRC through the [Government Gateway][1] by
7
8
  providing a DSL you can use to create Ruby classes to build the XML required in
@@ -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", "~> 3.2"
@@ -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", "~> 4.0"
@@ -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", "~> 4.2"
data/hermod.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.required_ruby_version = ">= 1.9.3"
23
+ spec.required_ruby_version = ">= 2.0.0"
24
24
 
25
25
  spec.add_runtime_dependency "libxml-ruby", "~> 2.7", ">= 2.7.0"
26
26
  spec.add_runtime_dependency "activesupport", "> 3.2", "< 5"
@@ -29,7 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "rake", "~> 10.3"
30
30
  spec.add_development_dependency "minitest", "~> 5.3"
31
31
  spec.add_development_dependency "minitest-reporters", "~> 1.0", ">= 1.0.16"
32
- spec.add_development_dependency "guard", "~> 2.6", ">= 2.6.1"
33
- spec.add_development_dependency "guard-minitest", "~> 2.3", ">= 2.3.1"
34
32
  spec.add_development_dependency "nokogiri", "~> 1.5"
35
33
  end
@@ -6,8 +6,12 @@ module Hermod
6
6
  @mutator_proc = mutator_proc
7
7
  end
8
8
 
9
- def mutate!(values, attributes)
10
- mutator_proc.call(values, attributes)
9
+ def mutate!(values, attributes, instance)
10
+ if mutator_proc.arity == 2
11
+ mutator_proc.call(values, attributes)
12
+ else
13
+ mutator_proc.call(values, attributes, instance)
14
+ end
11
15
  end
12
16
  end
13
17
  end
@@ -1,3 +1,3 @@
1
1
  module Hermod
2
- VERSION = "1.2.9"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -192,7 +192,7 @@ module Hermod
192
192
  xml_name = options.fetch(:xml_name, name.to_s.camelize)
193
193
 
194
194
  @new_class.send :define_method, name do |value, attributes = {}|
195
- mutators.each { |mutator| value, attributes = mutator.mutate!(value, attributes) }
195
+ mutators.each { |mutator| value, attributes = mutator.mutate!(value, attributes, self) }
196
196
  begin
197
197
  validators.each { |validator| validator.valid?(value, attributes) }
198
198
  rescue InvalidInputError => ex
@@ -11,6 +11,17 @@ module Hermod
11
11
  builder.string_node :gender, input_mutator: (lambda do |value, attributes|
12
12
  [value == "Male" ? "M" : "F", attributes]
13
13
  end)
14
+ builder.string_node :status, input_mutator: (lambda do |value, attributes, instance|
15
+ adjective = case instance.nodes[:mood].first.value
16
+ when "Happy"
17
+ "joyously"
18
+ when "Sad"
19
+ "dejectedly"
20
+ when "Hangry"
21
+ "furiously"
22
+ end
23
+ ["#{value} #{adjective}", attributes]
24
+ end)
14
25
  builder.string_node :mood, allowed_values: %w(Happy Sad Hangry)
15
26
  end
16
27
 
@@ -45,6 +56,12 @@ module Hermod
45
56
  value_of_node("Gender").must_equal "M"
46
57
  end
47
58
 
59
+ it "should allow input_mutators to access nodes the instance" do
60
+ subject.mood "Hangry"
61
+ subject.status "Eating cookies"
62
+ value_of_node("Status").must_equal "Eating cookies furiously"
63
+ end
64
+
48
65
  it "should restrict values to those in the list of allowed values if such a list is provided" do
49
66
  subject.mood "Hangry"
50
67
  value_of_node("Mood").must_equal "Hangry"
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: 1.2.9
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Mills
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-14 00:00:00.000000000 Z
11
+ date: 2015-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libxml-ruby
@@ -112,46 +112,6 @@ dependencies:
112
112
  - - ">="
113
113
  - !ruby/object:Gem::Version
114
114
  version: 1.0.16
115
- - !ruby/object:Gem::Dependency
116
- name: guard
117
- requirement: !ruby/object:Gem::Requirement
118
- requirements:
119
- - - "~>"
120
- - !ruby/object:Gem::Version
121
- version: '2.6'
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: 2.6.1
125
- type: :development
126
- prerelease: false
127
- version_requirements: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '2.6'
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- version: 2.6.1
135
- - !ruby/object:Gem::Dependency
136
- name: guard-minitest
137
- requirement: !ruby/object:Gem::Requirement
138
- requirements:
139
- - - "~>"
140
- - !ruby/object:Gem::Version
141
- version: '2.3'
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: 2.3.1
145
- type: :development
146
- prerelease: false
147
- version_requirements: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - "~>"
150
- - !ruby/object:Gem::Version
151
- version: '2.3'
152
- - - ">="
153
- - !ruby/object:Gem::Version
154
- version: 2.3.1
155
115
  - !ruby/object:Gem::Dependency
156
116
  name: nokogiri
157
117
  requirement: !ruby/object:Gem::Requirement
@@ -183,6 +143,9 @@ files:
183
143
  - LICENSE
184
144
  - README.md
185
145
  - Rakefile
146
+ - gemfiles/activesupport-3.2
147
+ - gemfiles/activesupport-4.0
148
+ - gemfiles/activesupport-4.2
186
149
  - hermod.gemspec
187
150
  - lib/hermod.rb
188
151
  - lib/hermod/input_mutator.rb
@@ -233,7 +196,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
233
196
  requirements:
234
197
  - - ">="
235
198
  - !ruby/object:Gem::Version
236
- version: 1.9.3
199
+ version: 2.0.0
237
200
  required_rubygems_version: !ruby/object:Gem::Requirement
238
201
  requirements:
239
202
  - - ">="
@@ -241,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
204
  version: '0'
242
205
  requirements: []
243
206
  rubyforge_project:
244
- rubygems_version: 2.2.3
207
+ rubygems_version: 2.4.8
245
208
  signing_key:
246
209
  specification_version: 4
247
210
  summary: A Ruby library for talking to the HMRC Government Gateway.