definition 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +43 -0
- data/.gitignore +0 -1
- data/Changelog.md +5 -1
- data/Gemfile.lock +153 -0
- data/README.md +2 -2
- data/config/locales/en.yml +1 -0
- data/definition.gemspec +2 -1
- data/lib/definition/types/keys.rb +13 -3
- data/lib/definition/version.rb +1 -1
- metadata +25 -11
- data/.travis.yml +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c7bb937fe678e70bbb9427ca24b8153471294150a657388b913aa095c0b5864
|
4
|
+
data.tar.gz: 579e9943b959417867e641284c0b94cde45ceb56c9d3738a98a37b6f100cd854
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7319c413e131eeef99ac40eb4b57cead39f27d86912651049bbe3276a333fc8aedafa77f08e13ce4fca4e973baf02e48a6ab49b07cbafb561f04fd3cf3224055
|
7
|
+
data.tar.gz: 34ffc1084ad2d22fb38248d9e88f9d4b13349c94e7376ec94eabd6765ff6986230612dc0f864f0b900fd56203cb8fb5f415889b47ab6427f0c85b1acf8ada029
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Use the latest 2.1 version of CircleCI pipeline process engine.
|
2
|
+
# See: https://circleci.com/docs/2.0/configuration-reference
|
3
|
+
version: 2.1
|
4
|
+
|
5
|
+
# Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects.
|
6
|
+
# See: https://circleci.com/docs/2.0/orb-intro/
|
7
|
+
orbs:
|
8
|
+
ruby: circleci/ruby@1.2.0
|
9
|
+
|
10
|
+
# Define a job to be invoked later in a workflow.
|
11
|
+
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
parameters:
|
15
|
+
image:
|
16
|
+
type: string
|
17
|
+
docker:
|
18
|
+
- image: << parameters.image>>
|
19
|
+
steps:
|
20
|
+
- checkout
|
21
|
+
- ruby/install-deps
|
22
|
+
- ruby/rspec-test
|
23
|
+
checking:
|
24
|
+
docker:
|
25
|
+
- image: 'cimg/ruby:2.7'
|
26
|
+
steps:
|
27
|
+
- checkout
|
28
|
+
- ruby/install-deps
|
29
|
+
- ruby/rubocop-check:
|
30
|
+
format: progress
|
31
|
+
label: Inspecting with Rubocop
|
32
|
+
|
33
|
+
# Invoke jobs via workflows
|
34
|
+
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
|
35
|
+
workflows:
|
36
|
+
test: # This is the name of the workflow, feel free to change it to better match your workflow.
|
37
|
+
# Inside the workflow, you define the jobs you want to run.
|
38
|
+
jobs:
|
39
|
+
- test:
|
40
|
+
matrix:
|
41
|
+
parameters:
|
42
|
+
image: ["cimg/ruby:2.5", "cimg/ruby:2.6", "cimg/ruby:2.7", "circleci/jruby:9.3.1-jdk11", "circleci/jruby:9.2.20-jdk11"]
|
43
|
+
- checking
|
data/.gitignore
CHANGED
data/Changelog.md
CHANGED
@@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
-
## [0.
|
7
|
+
## [0.6.1] - 2020-03-21
|
8
|
+
### Fixed
|
9
|
+
- The `Keys` definition crashed with an error if the input was not a Hash
|
10
|
+
|
11
|
+
## [0.6.0] - 2020-03-21
|
8
12
|
### Added
|
9
13
|
- Added include method to Keys Definition that allows to inline other `Keys` Definitions into each other
|
10
14
|
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
definition (0.6.1)
|
5
|
+
activesupport
|
6
|
+
i18n
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (6.1.4.1)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 1.6, < 2)
|
14
|
+
minitest (>= 5.1)
|
15
|
+
tzinfo (~> 2.0)
|
16
|
+
zeitwerk (~> 2.3)
|
17
|
+
approvals (0.0.25)
|
18
|
+
nokogiri (~> 1.8)
|
19
|
+
thor (~> 1.0)
|
20
|
+
ast (2.4.2)
|
21
|
+
awesome_print (1.9.2)
|
22
|
+
benchmark-ips (2.9.2)
|
23
|
+
coderay (1.1.3)
|
24
|
+
concurrent-ruby (1.1.9)
|
25
|
+
diff-lcs (1.4.4)
|
26
|
+
ffi (1.15.4)
|
27
|
+
ffi (1.15.4-java)
|
28
|
+
formatador (0.3.0)
|
29
|
+
fuubar (2.5.1)
|
30
|
+
rspec-core (~> 3.0)
|
31
|
+
ruby-progressbar (~> 1.4)
|
32
|
+
guard (2.18.0)
|
33
|
+
formatador (>= 0.2.4)
|
34
|
+
listen (>= 2.7, < 4.0)
|
35
|
+
lumberjack (>= 1.0.12, < 2.0)
|
36
|
+
nenv (~> 0.1)
|
37
|
+
notiffany (~> 0.0)
|
38
|
+
pry (>= 0.13.0)
|
39
|
+
shellany (~> 0.0)
|
40
|
+
thor (>= 0.18.1)
|
41
|
+
guard-compat (1.2.1)
|
42
|
+
guard-rspec (4.7.3)
|
43
|
+
guard (~> 2.1)
|
44
|
+
guard-compat (~> 1.1)
|
45
|
+
rspec (>= 2.99.0, < 4.0)
|
46
|
+
i18n (1.8.11)
|
47
|
+
concurrent-ruby (~> 1.0)
|
48
|
+
jar-dependencies (0.4.1)
|
49
|
+
jaro_winkler (1.5.4)
|
50
|
+
jaro_winkler (1.5.4-java)
|
51
|
+
listen (3.7.0)
|
52
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
53
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
54
|
+
lumberjack (1.2.8)
|
55
|
+
method_source (1.0.0)
|
56
|
+
mini_portile2 (2.6.1)
|
57
|
+
minitest (5.14.4)
|
58
|
+
nenv (0.3.0)
|
59
|
+
nokogiri (1.12.5)
|
60
|
+
mini_portile2 (~> 2.6.1)
|
61
|
+
racc (~> 1.4)
|
62
|
+
nokogiri (1.12.5-java)
|
63
|
+
racc (~> 1.4)
|
64
|
+
nokogiri (1.12.5-x86_64-linux)
|
65
|
+
racc (~> 1.4)
|
66
|
+
notiffany (0.1.3)
|
67
|
+
nenv (~> 0.1)
|
68
|
+
shellany (~> 0.0)
|
69
|
+
parallel (1.21.0)
|
70
|
+
parser (3.0.3.2)
|
71
|
+
ast (~> 2.4.1)
|
72
|
+
pry (0.14.1)
|
73
|
+
coderay (~> 1.1)
|
74
|
+
method_source (~> 1.0)
|
75
|
+
pry (0.14.1-java)
|
76
|
+
coderay (~> 1.1)
|
77
|
+
method_source (~> 1.0)
|
78
|
+
spoon (~> 0.0)
|
79
|
+
psych (4.0.2)
|
80
|
+
psych (4.0.2-java)
|
81
|
+
jar-dependencies (>= 0.1.7)
|
82
|
+
racc (1.6.0)
|
83
|
+
racc (1.6.0-java)
|
84
|
+
rainbow (3.0.0)
|
85
|
+
rake (13.0.6)
|
86
|
+
rb-fsevent (0.11.0)
|
87
|
+
rb-inotify (0.10.1)
|
88
|
+
ffi (~> 1.0)
|
89
|
+
rspec (3.10.0)
|
90
|
+
rspec-core (~> 3.10.0)
|
91
|
+
rspec-expectations (~> 3.10.0)
|
92
|
+
rspec-mocks (~> 3.10.0)
|
93
|
+
rspec-core (3.10.1)
|
94
|
+
rspec-support (~> 3.10.0)
|
95
|
+
rspec-expectations (3.10.1)
|
96
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
97
|
+
rspec-support (~> 3.10.0)
|
98
|
+
rspec-its (1.3.0)
|
99
|
+
rspec-core (>= 3.0.0)
|
100
|
+
rspec-expectations (>= 3.0.0)
|
101
|
+
rspec-mocks (3.10.2)
|
102
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
103
|
+
rspec-support (~> 3.10.0)
|
104
|
+
rspec-support (3.10.3)
|
105
|
+
rspec_junit_formatter (0.4.1)
|
106
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
107
|
+
rubocop (0.66.0)
|
108
|
+
jaro_winkler (~> 1.5.1)
|
109
|
+
parallel (~> 1.10)
|
110
|
+
parser (>= 2.5, != 2.5.1.1)
|
111
|
+
psych (>= 3.1.0)
|
112
|
+
rainbow (>= 2.2.2, < 4.0)
|
113
|
+
ruby-progressbar (~> 1.7)
|
114
|
+
unicode-display_width (>= 1.4.0, < 1.6)
|
115
|
+
rubocop-rspec (1.32.0)
|
116
|
+
rubocop (>= 0.60.0)
|
117
|
+
rubocop_runner (2.2.0)
|
118
|
+
ruby-progressbar (1.11.0)
|
119
|
+
shellany (0.0.1)
|
120
|
+
spoon (0.0.6)
|
121
|
+
ffi
|
122
|
+
thor (1.1.0)
|
123
|
+
timecop (0.9.4)
|
124
|
+
tzinfo (2.0.4)
|
125
|
+
concurrent-ruby (~> 1.0)
|
126
|
+
unicode-display_width (1.5.0)
|
127
|
+
zeitwerk (2.5.1)
|
128
|
+
|
129
|
+
PLATFORMS
|
130
|
+
ruby
|
131
|
+
universal-java-11
|
132
|
+
x86_64-linux
|
133
|
+
|
134
|
+
DEPENDENCIES
|
135
|
+
approvals (~> 0.0)
|
136
|
+
awesome_print
|
137
|
+
benchmark-ips
|
138
|
+
definition!
|
139
|
+
fuubar
|
140
|
+
guard
|
141
|
+
guard-rspec
|
142
|
+
pry
|
143
|
+
rake (~> 13.0)
|
144
|
+
rspec (~> 3.0)
|
145
|
+
rspec-its (~> 1.2)
|
146
|
+
rspec_junit_formatter
|
147
|
+
rubocop (= 0.66.0)
|
148
|
+
rubocop-rspec (= 1.32.0)
|
149
|
+
rubocop_runner
|
150
|
+
timecop
|
151
|
+
|
152
|
+
BUNDLED WITH
|
153
|
+
2.2.33
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Definition
|
2
2
|
|
3
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://circleci.com/gh/Goltergaul/definition.svg?style=svg)][circleci]
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/definition.svg)][rubygems]
|
5
5
|
|
6
6
|
Simple and composable validation and coercion of data structures. It also includes a ValueObject for convenience.
|
@@ -423,5 +423,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
423
423
|
|
424
424
|
Bug reports and pull requests are welcome on GitHub at https://github.com/Goltergaul/definition.
|
425
425
|
|
426
|
-
[
|
426
|
+
[circleci]: https://circleci.com/gh/Goltergaul/definition
|
427
427
|
[rubygems]: https://rubygems.org/gems/definition
|
data/config/locales/en.yml
CHANGED
data/definition.gemspec
CHANGED
@@ -31,9 +31,10 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency "guard"
|
32
32
|
spec.add_development_dependency "guard-rspec"
|
33
33
|
spec.add_development_dependency "pry"
|
34
|
-
spec.add_development_dependency "rake", "~>
|
34
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
35
35
|
spec.add_development_dependency "rspec", "~> 3.0"
|
36
36
|
spec.add_development_dependency "rspec-its", "~> 1.2"
|
37
|
+
spec.add_development_dependency "rspec_junit_formatter"
|
37
38
|
spec.add_development_dependency "rubocop", "0.66.0"
|
38
39
|
spec.add_development_dependency "rubocop-rspec", "1.32.0"
|
39
40
|
spec.add_development_dependency "rubocop_runner"
|
@@ -84,9 +84,15 @@ module Definition
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def conform
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
if valid_input_type?
|
88
|
+
add_extra_key_errors unless definition.ignore_extra_keys
|
89
|
+
add_missing_key_errors
|
90
|
+
values = conform_all_keys
|
91
|
+
else
|
92
|
+
errors.push(ConformError.new(definition,
|
93
|
+
"#{definition.name} is not a Hash",
|
94
|
+
i18n_key: "keys.not_a_hash"))
|
95
|
+
end
|
90
96
|
|
91
97
|
ConformResult.new(values, errors: errors)
|
92
98
|
end
|
@@ -95,6 +101,10 @@ module Definition
|
|
95
101
|
|
96
102
|
attr_accessor :errors
|
97
103
|
|
104
|
+
def valid_input_type?
|
105
|
+
value.is_a?(Hash)
|
106
|
+
end
|
107
|
+
|
98
108
|
def add_extra_key_errors
|
99
109
|
extra_keys = value.keys - all_keys
|
100
110
|
return if extra_keys.empty?
|
data/lib/definition/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: definition
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Goltermann
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
145
|
+
version: '13.0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
152
|
+
version: '13.0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: rspec
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +178,20 @@ dependencies:
|
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '1.2'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: rspec_junit_formatter
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: rubocop
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -234,7 +248,7 @@ dependencies:
|
|
234
248
|
- - ">="
|
235
249
|
- !ruby/object:Gem::Version
|
236
250
|
version: '0'
|
237
|
-
description:
|
251
|
+
description:
|
238
252
|
email:
|
239
253
|
- dominik@goltermann.cc
|
240
254
|
executables: []
|
@@ -242,12 +256,13 @@ extensions: []
|
|
242
256
|
extra_rdoc_files: []
|
243
257
|
files:
|
244
258
|
- ".approvals"
|
259
|
+
- ".circleci/config.yml"
|
245
260
|
- ".gitignore"
|
246
261
|
- ".rspec"
|
247
262
|
- ".rubocop.yml"
|
248
|
-
- ".travis.yml"
|
249
263
|
- Changelog.md
|
250
264
|
- Gemfile
|
265
|
+
- Gemfile.lock
|
251
266
|
- Guardfile
|
252
267
|
- LICENSE
|
253
268
|
- README.md
|
@@ -283,7 +298,7 @@ homepage: https://github.com/Goltergaul/definition
|
|
283
298
|
licenses:
|
284
299
|
- MIT
|
285
300
|
metadata: {}
|
286
|
-
post_install_message:
|
301
|
+
post_install_message:
|
287
302
|
rdoc_options: []
|
288
303
|
require_paths:
|
289
304
|
- lib
|
@@ -298,9 +313,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
298
313
|
- !ruby/object:Gem::Version
|
299
314
|
version: '0'
|
300
315
|
requirements: []
|
301
|
-
|
302
|
-
|
303
|
-
signing_key:
|
316
|
+
rubygems_version: 3.1.2
|
317
|
+
signing_key:
|
304
318
|
specification_version: 4
|
305
319
|
summary: Simple and composable validation and coercion of data structures inspired
|
306
320
|
by clojure specs
|
data/.travis.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- jruby-9.1.17.0 # ruby 2.3
|
4
|
-
- jruby-9.2.11.1 # ruby 2.5.7
|
5
|
-
- 2.3.0
|
6
|
-
- 2.7.0
|
7
|
-
jobs:
|
8
|
-
include:
|
9
|
-
- stage: linting
|
10
|
-
rvm: 2.7.0
|
11
|
-
script: bundle exec rake rubocop
|
12
|
-
- stage: benchmark
|
13
|
-
script: bundle exec ruby benchmark/complex_example.rb
|
14
|
-
rvm: 2.7.0
|
15
|
-
- script: bundle exec ruby benchmark/coercion.rb
|
16
|
-
rvm: 2.7.0
|
17
|
-
- script: bundle exec ruby benchmark/validation_only.rb
|
18
|
-
rvm: 2.7.0
|