shaped 0.7.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +21 -0
- data/.release_assistant.yml +3 -0
- data/.rubocop.yml +5 -144
- data/.ruby-version +1 -1
- data/CHANGELOG.md +28 -0
- data/Gemfile +13 -4
- data/Gemfile.lock +78 -52
- data/README.md +26 -9
- data/bin/_guard-core +1 -1
- data/bin/guard +1 -1
- data/bin/release +26 -13
- data/bin/rspec +1 -1
- data/bin/rubocop +1 -1
- data/lib/shaped.rb +1 -1
- data/lib/shaped/shapes/callable.rb +1 -0
- data/lib/shaped/shapes/class.rb +0 -7
- data/lib/shaped/version.rb +1 -1
- data/shaped.gemspec +1 -1
- metadata +9 -8
- data/.travis.yml +0 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6143eccfe138c04a8f24b48656b48782cd73a7f2718e5a318e8e2324cc789457
|
|
4
|
+
data.tar.gz: 57add2258d7c1645da116791e3a758e25adc526d270b1ed634d845c91f2972d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e2758a27c09aebe1834d6c7d31568bd13a92ad33cefa841159bd57b0d85576132c997e078d51c3b513ec0f53db32cfc4a6ddca12e89e2587862eac86904b328b
|
|
7
|
+
data.tar.gz: 994f60c94a7417c08e9b4e3c42038e3cc2e43d180eb39c574a5d89ef3fee14503f2cb0fc1a0b54e28e329f6e9d82cdecdcf7a9a5d9dcc6ad724131d0fa5d4d06
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: Run Tests, Linters, Etc.
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v2
|
|
13
|
+
- uses: ruby/setup-ruby@v1
|
|
14
|
+
with:
|
|
15
|
+
bundler-cache: true
|
|
16
|
+
- name: Run Rubocop
|
|
17
|
+
run: bin/rubocop --format clang
|
|
18
|
+
- name: Run RSpec tests
|
|
19
|
+
run: bin/rspec --format progress
|
|
20
|
+
- name: Ensure no git diff
|
|
21
|
+
run: git diff --exit-code && git diff-index --quiet --cached HEAD
|
data/.rubocop.yml
CHANGED
|
@@ -1,144 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
-
|
|
5
|
-
|
|
6
|
-
- bin/{annotate,brakeman,bundle,database_consistency,pallets,rubocop,sidekiq}
|
|
7
|
-
- db/schema.rb
|
|
8
|
-
- lib/tasks/auto_annotate_models.rake
|
|
9
|
-
- node_modules/**/*
|
|
10
|
-
TargetRubyVersion: 2.7
|
|
11
|
-
Bundler/GemComment:
|
|
12
|
-
Enabled: false
|
|
13
|
-
Layout/ArgumentAlignment:
|
|
14
|
-
EnforcedStyle: with_fixed_indentation
|
|
15
|
-
Layout/ClassStructure:
|
|
16
|
-
ExpectedOrder:
|
|
17
|
-
- module_inclusion
|
|
18
|
-
- constants
|
|
19
|
-
- public_class_methods
|
|
20
|
-
- initializer
|
|
21
|
-
- public_methods
|
|
22
|
-
- protected_methods
|
|
23
|
-
- private_methods
|
|
24
|
-
Layout/DotPosition:
|
|
25
|
-
EnforcedStyle: trailing
|
|
26
|
-
Layout/FirstArgumentIndentation:
|
|
27
|
-
Enabled: false # this rule doesn't play nicely with the way that I like to use `memoize`
|
|
28
|
-
Layout/FirstArrayElementIndentation:
|
|
29
|
-
EnforcedStyle: consistent
|
|
30
|
-
Layout/LineLength:
|
|
31
|
-
IgnoredPatterns:
|
|
32
|
-
# ignore line length if the line is a comment without any spaces; it's probably not something we
|
|
33
|
-
# can fix (e.g. a long file path)
|
|
34
|
-
- !ruby/regexp /^ *#? [\S]+$/
|
|
35
|
-
Max: 100
|
|
36
|
-
Layout/MultilineMethodCallIndentation:
|
|
37
|
-
EnforcedStyle: indented
|
|
38
|
-
Layout/SpaceBeforeBlockBraces:
|
|
39
|
-
Enabled: false
|
|
40
|
-
Layout/SpaceBeforeSemicolon:
|
|
41
|
-
Enabled: false
|
|
42
|
-
Layout/SpaceInsideHashLiteralBraces:
|
|
43
|
-
EnforcedStyle: space
|
|
44
|
-
Lint/ConstantResolution:
|
|
45
|
-
Enabled: false
|
|
46
|
-
Lint/RedundantSplatExpansion:
|
|
47
|
-
Enabled: false
|
|
48
|
-
Metrics/AbcSize:
|
|
49
|
-
Enabled: false
|
|
50
|
-
Metrics/BlockLength:
|
|
51
|
-
Enabled: false
|
|
52
|
-
Metrics/ClassLength:
|
|
53
|
-
Enabled: false
|
|
54
|
-
Metrics/MethodLength:
|
|
55
|
-
Max: 30
|
|
56
|
-
Naming/RescuedExceptionsVariableName:
|
|
57
|
-
Enabled: false
|
|
58
|
-
Style/BlockDelimiters:
|
|
59
|
-
Enabled: false
|
|
60
|
-
Style/ClassAndModuleChildren:
|
|
61
|
-
EnforcedStyle: compact
|
|
62
|
-
Style/CollectionMethods:
|
|
63
|
-
Enabled: false
|
|
64
|
-
Style/ConstantVisibility:
|
|
65
|
-
Enabled: false
|
|
66
|
-
Style/Copyright:
|
|
67
|
-
Enabled: false
|
|
68
|
-
Style/DisableCopsWithinSourceCodeDirective:
|
|
69
|
-
Enabled: false
|
|
70
|
-
Style/Documentation:
|
|
71
|
-
Enabled: false
|
|
72
|
-
Style/DocumentationMethod:
|
|
73
|
-
Enabled: false
|
|
74
|
-
Style/EmptyCaseCondition:
|
|
75
|
-
Enabled: false
|
|
76
|
-
Style/FrozenStringLiteralComment:
|
|
77
|
-
Enabled: true
|
|
78
|
-
Style/GlobalVars:
|
|
79
|
-
Enabled: false
|
|
80
|
-
Style/GuardClause:
|
|
81
|
-
Enabled: false
|
|
82
|
-
Style/IfUnlessModifier:
|
|
83
|
-
Enabled: false
|
|
84
|
-
Style/InlineComment:
|
|
85
|
-
Enabled: false
|
|
86
|
-
Style/Lambda:
|
|
87
|
-
Enabled: false
|
|
88
|
-
Style/MethodCallWithArgsParentheses:
|
|
89
|
-
IgnoredMethods:
|
|
90
|
-
- add_runtime_dependency
|
|
91
|
-
- desc
|
|
92
|
-
- fail
|
|
93
|
-
- file
|
|
94
|
-
- gem
|
|
95
|
-
- head
|
|
96
|
-
- include
|
|
97
|
-
- integer
|
|
98
|
-
- load
|
|
99
|
-
- p
|
|
100
|
-
- print
|
|
101
|
-
- puts
|
|
102
|
-
- render
|
|
103
|
-
- require
|
|
104
|
-
- require_relative
|
|
105
|
-
- ruby
|
|
106
|
-
- run
|
|
107
|
-
- string
|
|
108
|
-
- source
|
|
109
|
-
Style/MissingElse:
|
|
110
|
-
Enabled: false
|
|
111
|
-
Style/NegatedIf:
|
|
112
|
-
Enabled: false
|
|
113
|
-
Style/ImplicitRuntimeError:
|
|
114
|
-
Enabled: false
|
|
115
|
-
Style/MethodCalledOnDoEndBlock:
|
|
116
|
-
Enabled: false
|
|
117
|
-
Style/NumericPredicate:
|
|
118
|
-
Enabled: false
|
|
119
|
-
Style/ParenthesesAroundCondition:
|
|
120
|
-
Enabled: false
|
|
121
|
-
Style/RescueModifier:
|
|
122
|
-
Enabled: false
|
|
123
|
-
Style/RescueStandardError:
|
|
124
|
-
Enabled: false
|
|
125
|
-
Style/ReturnNil:
|
|
126
|
-
Enabled: false
|
|
127
|
-
Style/RegexpLiteral:
|
|
128
|
-
Enabled: false
|
|
129
|
-
Style/Semicolon:
|
|
130
|
-
Enabled: false
|
|
131
|
-
Style/SignalException:
|
|
132
|
-
Enabled: false
|
|
133
|
-
Style/StderrPuts:
|
|
134
|
-
Enabled: false
|
|
135
|
-
Style/StringHashKeys:
|
|
136
|
-
Enabled: false
|
|
137
|
-
Style/TernaryParentheses:
|
|
138
|
-
Enabled: false
|
|
139
|
-
Style/TrailingCommaInArguments:
|
|
140
|
-
EnforcedStyleForMultiline: comma
|
|
141
|
-
Style/TrailingCommaInArrayLiteral:
|
|
142
|
-
EnforcedStyleForMultiline: comma
|
|
143
|
-
Style/TrailingCommaInHashLiteral:
|
|
144
|
-
EnforcedStyleForMultiline: comma
|
|
1
|
+
inherit_gem:
|
|
2
|
+
runger_style:
|
|
3
|
+
- rulesets/default.yml # gem 'rubocop'
|
|
4
|
+
- rulesets/performance.yml # gem 'rubocop-performance'
|
|
5
|
+
- rulesets/rspec.yml # gem 'rubocop-rspec'
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.7.
|
|
1
|
+
2.7.2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## v0.8.2 (2021-02-01)
|
|
2
|
+
### Internal
|
|
3
|
+
- Update release_assistant
|
|
4
|
+
|
|
5
|
+
## v0.8.1 (2021-02-01)
|
|
6
|
+
### Internal
|
|
7
|
+
- Use `release_assistant` gem to manage the release process
|
|
8
|
+
|
|
9
|
+
## v0.8.0 (2021-01-31)
|
|
10
|
+
### Added
|
|
11
|
+
- Accept `Method` as a `Callable` shape definition
|
|
12
|
+
|
|
13
|
+
### Internal
|
|
14
|
+
- Bump Ruby version from 2.7.0 to 2.7.2
|
|
15
|
+
- Move from Travis to GitHub Actions
|
|
16
|
+
|
|
17
|
+
## v0.7.3 (2021-01-07)
|
|
18
|
+
### Removed
|
|
19
|
+
- Removed `::name` method for anonymous validator class in `Shaped::Shapes::Class`
|
|
20
|
+
|
|
21
|
+
## v0.7.2 (2020-07-13)
|
|
22
|
+
### Dependencies
|
|
23
|
+
- Bump `rubocop` to 0.88.0 and `runger_style` to 0.2.3
|
|
24
|
+
|
|
25
|
+
## v0.7.1 (2020-07-02)
|
|
26
|
+
### Internal
|
|
27
|
+
- Source Rubocop rules/config from `runger_style` gem
|
|
28
|
+
|
|
1
29
|
## v0.7.0 (2020-06-24)
|
|
2
30
|
### BREAKING CHANGES
|
|
3
31
|
- Rename the `Or` shape to `Any`
|
data/Gemfile
CHANGED
|
@@ -5,10 +5,19 @@ source 'https://rubygems.org'
|
|
|
5
5
|
# Specify your gem's dependencies in shaped.gemspec
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
gem '
|
|
10
|
-
gem '
|
|
11
|
-
gem '
|
|
8
|
+
group :development, :test do
|
|
9
|
+
gem 'amazing_print'
|
|
10
|
+
gem 'pry-byebug'
|
|
11
|
+
gem 'rake'
|
|
12
|
+
gem 'rubocop', require: false
|
|
13
|
+
gem 'rubocop-performance', require: false
|
|
14
|
+
gem 'rubocop-rspec', require: false
|
|
15
|
+
gem 'runger_style', github: 'davidrunger/runger_style', require: false
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
group :development do
|
|
19
|
+
gem 'release_assistant', require: false, github: 'davidrunger/release_assistant'
|
|
20
|
+
end
|
|
12
21
|
|
|
13
22
|
group :test do
|
|
14
23
|
gem 'codecov', require: false
|
data/Gemfile.lock
CHANGED
|
@@ -7,35 +7,50 @@ GIT
|
|
|
7
7
|
guard-compat (~> 1.1)
|
|
8
8
|
rspec (>= 2.99.0, < 4.0)
|
|
9
9
|
|
|
10
|
+
GIT
|
|
11
|
+
remote: https://github.com/davidrunger/release_assistant.git
|
|
12
|
+
revision: a3d2011880ff9ae6cc08afc9a59050cd33790df5
|
|
13
|
+
specs:
|
|
14
|
+
release_assistant (0.3.2.alpha)
|
|
15
|
+
activesupport (~> 6.0)
|
|
16
|
+
colorize (~> 0.8)
|
|
17
|
+
memoist (~> 0.16)
|
|
18
|
+
slop (~> 4.8)
|
|
19
|
+
|
|
20
|
+
GIT
|
|
21
|
+
remote: https://github.com/davidrunger/runger_style.git
|
|
22
|
+
revision: bfa1eb8c633b60cb41fcd47627dcce5ca4f5ca59
|
|
23
|
+
specs:
|
|
24
|
+
runger_style (0.2.17.alpha)
|
|
25
|
+
|
|
10
26
|
PATH
|
|
11
27
|
remote: .
|
|
12
28
|
specs:
|
|
13
|
-
shaped (0.
|
|
29
|
+
shaped (0.8.2)
|
|
14
30
|
activemodel (~> 6.0)
|
|
15
31
|
activesupport (~> 6.0)
|
|
16
32
|
|
|
17
33
|
GEM
|
|
18
34
|
remote: https://rubygems.org/
|
|
19
35
|
specs:
|
|
20
|
-
activemodel (6.
|
|
21
|
-
activesupport (= 6.
|
|
22
|
-
activesupport (6.
|
|
36
|
+
activemodel (6.1.1)
|
|
37
|
+
activesupport (= 6.1.1)
|
|
38
|
+
activesupport (6.1.1)
|
|
23
39
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
24
|
-
i18n (>=
|
|
25
|
-
minitest (
|
|
26
|
-
tzinfo (~>
|
|
27
|
-
zeitwerk (~> 2.
|
|
28
|
-
amazing_print (1.2.
|
|
29
|
-
ast (2.4.
|
|
40
|
+
i18n (>= 1.6, < 2)
|
|
41
|
+
minitest (>= 5.1)
|
|
42
|
+
tzinfo (~> 2.0)
|
|
43
|
+
zeitwerk (~> 2.3)
|
|
44
|
+
amazing_print (1.2.2)
|
|
45
|
+
ast (2.4.2)
|
|
30
46
|
byebug (11.1.3)
|
|
31
|
-
codecov (0.
|
|
32
|
-
|
|
33
|
-
simplecov
|
|
34
|
-
url
|
|
47
|
+
codecov (0.4.2)
|
|
48
|
+
simplecov (>= 0.15, < 0.22)
|
|
35
49
|
coderay (1.1.3)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
50
|
+
colorize (0.8.1)
|
|
51
|
+
concurrent-ruby (1.1.8)
|
|
52
|
+
diff-lcs (1.4.4)
|
|
53
|
+
docile (1.3.5)
|
|
39
54
|
ffi (1.13.1)
|
|
40
55
|
formatador (0.2.5)
|
|
41
56
|
guard (2.16.2)
|
|
@@ -48,21 +63,21 @@ GEM
|
|
|
48
63
|
shellany (~> 0.0)
|
|
49
64
|
thor (>= 0.18.1)
|
|
50
65
|
guard-compat (1.2.1)
|
|
51
|
-
i18n (1.8.
|
|
66
|
+
i18n (1.8.8)
|
|
52
67
|
concurrent-ruby (~> 1.0)
|
|
53
|
-
json (2.3.0)
|
|
54
68
|
listen (3.2.1)
|
|
55
69
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
56
70
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
57
71
|
lumberjack (1.2.5)
|
|
72
|
+
memoist (0.16.2)
|
|
58
73
|
method_source (1.0.0)
|
|
59
|
-
minitest (5.14.
|
|
74
|
+
minitest (5.14.3)
|
|
60
75
|
nenv (0.3.0)
|
|
61
76
|
notiffany (0.1.3)
|
|
62
77
|
nenv (~> 0.1)
|
|
63
78
|
shellany (~> 0.0)
|
|
64
|
-
parallel (1.
|
|
65
|
-
parser (
|
|
79
|
+
parallel (1.20.1)
|
|
80
|
+
parser (3.0.0.0)
|
|
66
81
|
ast (~> 2.4.1)
|
|
67
82
|
pry (0.13.1)
|
|
68
83
|
coderay (~> 1.1)
|
|
@@ -71,49 +86,56 @@ GEM
|
|
|
71
86
|
byebug (~> 11.0)
|
|
72
87
|
pry (~> 0.13.0)
|
|
73
88
|
rainbow (3.0.0)
|
|
74
|
-
rake (13.0.
|
|
89
|
+
rake (13.0.3)
|
|
75
90
|
rb-fsevent (0.10.4)
|
|
76
91
|
rb-inotify (0.10.1)
|
|
77
92
|
ffi (~> 1.0)
|
|
78
|
-
regexp_parser (
|
|
93
|
+
regexp_parser (2.0.3)
|
|
79
94
|
rexml (3.2.4)
|
|
80
|
-
rspec (3.
|
|
81
|
-
rspec-core (~> 3.
|
|
82
|
-
rspec-expectations (~> 3.
|
|
83
|
-
rspec-mocks (~> 3.
|
|
84
|
-
rspec-core (3.
|
|
85
|
-
rspec-support (~> 3.
|
|
86
|
-
rspec-expectations (3.
|
|
95
|
+
rspec (3.10.0)
|
|
96
|
+
rspec-core (~> 3.10.0)
|
|
97
|
+
rspec-expectations (~> 3.10.0)
|
|
98
|
+
rspec-mocks (~> 3.10.0)
|
|
99
|
+
rspec-core (3.10.1)
|
|
100
|
+
rspec-support (~> 3.10.0)
|
|
101
|
+
rspec-expectations (3.10.1)
|
|
87
102
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
88
|
-
rspec-support (~> 3.
|
|
89
|
-
rspec-mocks (3.
|
|
103
|
+
rspec-support (~> 3.10.0)
|
|
104
|
+
rspec-mocks (3.10.1)
|
|
90
105
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
91
|
-
rspec-support (~> 3.
|
|
92
|
-
rspec-support (3.
|
|
93
|
-
rubocop (
|
|
106
|
+
rspec-support (~> 3.10.0)
|
|
107
|
+
rspec-support (3.10.1)
|
|
108
|
+
rubocop (1.9.1)
|
|
94
109
|
parallel (~> 1.10)
|
|
95
|
-
parser (>=
|
|
110
|
+
parser (>= 3.0.0.0)
|
|
96
111
|
rainbow (>= 2.2.2, < 4.0)
|
|
97
|
-
regexp_parser (>= 1.
|
|
112
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
98
113
|
rexml
|
|
99
|
-
rubocop-ast (>=
|
|
114
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
|
100
115
|
ruby-progressbar (~> 1.7)
|
|
101
|
-
unicode-display_width (>= 1.4.0, <
|
|
102
|
-
rubocop-ast (
|
|
103
|
-
parser (>= 2.7.
|
|
104
|
-
|
|
116
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
117
|
+
rubocop-ast (1.4.1)
|
|
118
|
+
parser (>= 2.7.1.5)
|
|
119
|
+
rubocop-performance (1.9.2)
|
|
120
|
+
rubocop (>= 0.90.0, < 2.0)
|
|
121
|
+
rubocop-ast (>= 0.4.0)
|
|
122
|
+
rubocop-rspec (2.1.0)
|
|
123
|
+
rubocop (~> 1.0)
|
|
124
|
+
rubocop-ast (>= 1.1.0)
|
|
125
|
+
ruby-progressbar (1.11.0)
|
|
105
126
|
shellany (0.0.1)
|
|
106
|
-
simplecov (0.
|
|
127
|
+
simplecov (0.21.2)
|
|
107
128
|
docile (~> 1.1)
|
|
108
129
|
simplecov-html (~> 0.11)
|
|
109
|
-
|
|
130
|
+
simplecov_json_formatter (~> 0.1)
|
|
131
|
+
simplecov-html (0.12.3)
|
|
132
|
+
simplecov_json_formatter (0.1.2)
|
|
133
|
+
slop (4.8.2)
|
|
110
134
|
thor (1.0.1)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
url (0.3.2)
|
|
116
|
-
zeitwerk (2.3.0)
|
|
135
|
+
tzinfo (2.0.4)
|
|
136
|
+
concurrent-ruby (~> 1.0)
|
|
137
|
+
unicode-display_width (2.0.0)
|
|
138
|
+
zeitwerk (2.4.2)
|
|
117
139
|
|
|
118
140
|
PLATFORMS
|
|
119
141
|
ruby
|
|
@@ -124,9 +146,13 @@ DEPENDENCIES
|
|
|
124
146
|
guard-espect!
|
|
125
147
|
pry-byebug
|
|
126
148
|
rake
|
|
149
|
+
release_assistant!
|
|
127
150
|
rspec
|
|
128
151
|
rubocop
|
|
152
|
+
rubocop-performance
|
|
153
|
+
rubocop-rspec
|
|
154
|
+
runger_style!
|
|
129
155
|
shaped!
|
|
130
156
|
|
|
131
157
|
BUNDLED WITH
|
|
132
|
-
2.1.
|
|
158
|
+
2.1.4
|
data/README.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
[](https://codecov.io/gh/davidrunger/shaped)
|
|
2
|
-
[](https://travis-ci.com/davidrunger/shaped)
|
|
3
2
|
[](https://dependabot.com)
|
|
4
3
|
[](https://badge.fury.io/rb/shaped)
|
|
5
4
|
|
|
@@ -240,6 +239,23 @@ shape.matched_by?(5) # fails the `#even?` check
|
|
|
240
239
|
shape.matched_by?(10) # fails the `#cover?` check (10 is too high)
|
|
241
240
|
# => false
|
|
242
241
|
```
|
|
242
|
+
|
|
243
|
+
If you'd like to provide a named method rather than an anonymous proc/lambda, you can do that, too:
|
|
244
|
+
|
|
245
|
+
```rb
|
|
246
|
+
def number_is_greater_than_thirty?(number)
|
|
247
|
+
number > 30
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
shape = Shaped::Shape(method(:number_is_greater_than_thirty?))
|
|
251
|
+
|
|
252
|
+
shape.matched_by?(31)
|
|
253
|
+
# => true
|
|
254
|
+
|
|
255
|
+
shape.matched_by?(29)
|
|
256
|
+
# => false
|
|
257
|
+
```
|
|
258
|
+
|
|
243
259
|
You can also provide an instance of a custom class that implements a `#call` instance method:
|
|
244
260
|
|
|
245
261
|
```rb
|
|
@@ -386,14 +402,15 @@ rake install`.
|
|
|
386
402
|
|
|
387
403
|
# For maintainers
|
|
388
404
|
|
|
389
|
-
To release a new version
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
405
|
+
To release a new version, run `bin/release` with an appropriate `--type` option, e.g.:
|
|
406
|
+
|
|
407
|
+
```
|
|
408
|
+
bin/release --type minor
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
(This uses the [`release_assistant` gem][release_assistant].)
|
|
412
|
+
|
|
413
|
+
[release_assistant]: https://github.com/davidrunger/release_assistant/
|
|
397
414
|
|
|
398
415
|
# License
|
|
399
416
|
|
data/bin/_guard-core
CHANGED
|
@@ -17,7 +17,7 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path(
|
|
|
17
17
|
bundle_binstub = File.expand_path('bundle', __dir__)
|
|
18
18
|
|
|
19
19
|
if File.file?(bundle_binstub)
|
|
20
|
-
if
|
|
20
|
+
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
|
|
21
21
|
load(bundle_binstub)
|
|
22
22
|
else
|
|
23
23
|
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
data/bin/guard
CHANGED
|
@@ -17,7 +17,7 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path(
|
|
|
17
17
|
bundle_binstub = File.expand_path('bundle', __dir__)
|
|
18
18
|
|
|
19
19
|
if File.file?(bundle_binstub)
|
|
20
|
-
if
|
|
20
|
+
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
|
|
21
21
|
load(bundle_binstub)
|
|
22
22
|
else
|
|
23
23
|
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
data/bin/release
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'release' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
exit 1;
|
|
14
|
-
fi
|
|
11
|
+
require 'pathname'
|
|
12
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
|
13
|
+
Pathname.new(__FILE__).realpath)
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
bundle_binstub = File.expand_path('bundle', __dir__)
|
|
16
|
+
|
|
17
|
+
if File.file?(bundle_binstub)
|
|
18
|
+
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
|
|
19
|
+
load(bundle_binstub)
|
|
20
|
+
else
|
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
require 'rubygems'
|
|
27
|
+
require 'bundler/setup'
|
|
28
|
+
|
|
29
|
+
load Gem.bin_path('release_assistant', 'release')
|
data/bin/rspec
CHANGED
|
@@ -18,7 +18,7 @@ ENV['BUNDLE_GEMFILE'] ||=
|
|
|
18
18
|
bundle_binstub = File.expand_path('bundle', __dir__)
|
|
19
19
|
|
|
20
20
|
if File.file?(bundle_binstub)
|
|
21
|
-
if
|
|
21
|
+
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
|
|
22
22
|
load(bundle_binstub)
|
|
23
23
|
else
|
|
24
24
|
abort(<<~ERROR)
|
data/bin/rubocop
CHANGED
|
@@ -14,7 +14,7 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', Pathname.new(__FILE_
|
|
|
14
14
|
bundle_binstub = File.expand_path('bundle', __dir__)
|
|
15
15
|
|
|
16
16
|
if File.file?(bundle_binstub)
|
|
17
|
-
if
|
|
17
|
+
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
|
|
18
18
|
load(bundle_binstub)
|
|
19
19
|
else
|
|
20
20
|
abort(<<~ERROR)
|
data/lib/shaped.rb
CHANGED
|
@@ -6,7 +6,7 @@ module Shaped::Shapes ; end
|
|
|
6
6
|
require 'active_support/all'
|
|
7
7
|
require 'active_model'
|
|
8
8
|
require_relative './shaped/shape.rb'
|
|
9
|
-
Dir[File.dirname(__FILE__)
|
|
9
|
+
Dir["#{File.dirname(__FILE__)}/**/*.rb"].sort.each { |file| require file }
|
|
10
10
|
|
|
11
11
|
module Shaped
|
|
12
12
|
# rubocop:disable Naming/MethodName, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
@@ -11,6 +11,7 @@ class Shaped::Shapes::Callable < Shaped::Shape
|
|
|
11
11
|
|
|
12
12
|
def to_s
|
|
13
13
|
case @callable
|
|
14
|
+
when Method then "Method defined at #{@callable.source_location.map(&:to_s).join(':')}"
|
|
14
15
|
when Proc then "Proc test defined at #{@callable.source_location.map(&:to_s).join(':')}"
|
|
15
16
|
else "#call test defined at #{@callable.method(:call).source_location.map(&:to_s).join(':')}"
|
|
16
17
|
end
|
data/lib/shaped/shapes/class.rb
CHANGED
|
@@ -34,13 +34,6 @@ class Shaped::Shapes::Class < Shaped::Shape
|
|
|
34
34
|
attr_accessor :value
|
|
35
35
|
|
|
36
36
|
validates :value, validations
|
|
37
|
-
|
|
38
|
-
class << self
|
|
39
|
-
# ActiveModel requires the class to have a `name`
|
|
40
|
-
def name
|
|
41
|
-
'Shaped::Shapes::Class::AnonymousValidator'
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
37
|
end
|
|
45
38
|
end
|
|
46
39
|
|
data/lib/shaped/version.rb
CHANGED
data/shaped.gemspec
CHANGED
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
|
12
12
|
spec.description = 'Validate the "shape" of Ruby objects.'
|
|
13
13
|
spec.homepage = 'https://github.com/davidrunger/shaped'
|
|
14
14
|
spec.license = 'MIT'
|
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.
|
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
|
|
16
16
|
|
|
17
17
|
spec.metadata['homepage_uri'] = spec.homepage
|
|
18
18
|
spec.metadata['source_code_uri'] = 'https://github.com/davidrunger/shaped'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shaped
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Runger
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-02-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activemodel
|
|
@@ -45,11 +45,12 @@ executables: []
|
|
|
45
45
|
extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
|
47
47
|
files:
|
|
48
|
+
- ".github/workflows/ruby.yml"
|
|
48
49
|
- ".gitignore"
|
|
50
|
+
- ".release_assistant.yml"
|
|
49
51
|
- ".rspec"
|
|
50
52
|
- ".rubocop.yml"
|
|
51
53
|
- ".ruby-version"
|
|
52
|
-
- ".travis.yml"
|
|
53
54
|
- CHANGELOG.md
|
|
54
55
|
- Gemfile
|
|
55
56
|
- Gemfile.lock
|
|
@@ -82,7 +83,7 @@ metadata:
|
|
|
82
83
|
homepage_uri: https://github.com/davidrunger/shaped
|
|
83
84
|
source_code_uri: https://github.com/davidrunger/shaped
|
|
84
85
|
changelog_uri: https://github.com/davidrunger/shaped/blob/master/CHANGELOG.md
|
|
85
|
-
post_install_message:
|
|
86
|
+
post_install_message:
|
|
86
87
|
rdoc_options: []
|
|
87
88
|
require_paths:
|
|
88
89
|
- lib
|
|
@@ -90,15 +91,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
90
91
|
requirements:
|
|
91
92
|
- - ">="
|
|
92
93
|
- !ruby/object:Gem::Version
|
|
93
|
-
version: 2.
|
|
94
|
+
version: 2.7.0
|
|
94
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
96
|
requirements:
|
|
96
97
|
- - ">="
|
|
97
98
|
- !ruby/object:Gem::Version
|
|
98
99
|
version: '0'
|
|
99
100
|
requirements: []
|
|
100
|
-
rubygems_version: 3.1.
|
|
101
|
-
signing_key:
|
|
101
|
+
rubygems_version: 3.1.4
|
|
102
|
+
signing_key:
|
|
102
103
|
specification_version: 4
|
|
103
104
|
summary: Validate the "shape" of Ruby objects.
|
|
104
105
|
test_files: []
|
data/.travis.yml
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
language: ruby
|
|
3
|
-
os: linux
|
|
4
|
-
dist: bionic
|
|
5
|
-
cache: bundler
|
|
6
|
-
rvm:
|
|
7
|
-
- 2.7.0
|
|
8
|
-
notifications:
|
|
9
|
-
email:
|
|
10
|
-
on_success: never
|
|
11
|
-
on_failure: always
|
|
12
|
-
script:
|
|
13
|
-
- bin/rubocop $(git ls-tree -r HEAD --name-only) --force-exclusion --format clang
|
|
14
|
-
- bin/rspec
|