shaped 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 21fd29373698c83855364dd4e9dec36d55d99f5ed4f7c3922d95241f8198dc7b
4
+ data.tar.gz: 0ec1c71a7d37bc7a6a294f240e9a570a348b1fdee8364fbd405f4d79cd38ddaf
5
+ SHA512:
6
+ metadata.gz: 92f598d534e5162093a978d4787d4f428f874ccacb2390d925dfe66de94e71a8f17933aa2b13ff258d66d15f72a04789e4355c72dc27ef60542cf81d2db5d52c
7
+ data.tar.gz: cd4a04e7b0485a8e420f017f905b5568eab443482b95b36057cc4a0c0536e01f871363439665936042e52e7a724e9dc69132266e07d7de0993c2a3e84f0fc884
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,142 @@
1
+ AllCops:
2
+ EnabledByDefault: true
3
+ Exclude:
4
+ - !ruby/regexp /\/db\/migrate/201[1-8].*\.rb\z/
5
+ # auto-generated files; best to leave as-is
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/RedundantSplatExpansion:
45
+ Enabled: false
46
+ Metrics/AbcSize:
47
+ Enabled: false
48
+ Metrics/BlockLength:
49
+ Enabled: false
50
+ Metrics/ClassLength:
51
+ Enabled: false
52
+ Metrics/MethodLength:
53
+ Max: 30
54
+ Naming/RescuedExceptionsVariableName:
55
+ Enabled: false
56
+ Style/BlockDelimiters:
57
+ Enabled: false
58
+ Style/ClassAndModuleChildren:
59
+ EnforcedStyle: compact
60
+ Style/CollectionMethods:
61
+ Enabled: false
62
+ Style/ConstantVisibility:
63
+ Enabled: false
64
+ Style/Copyright:
65
+ Enabled: false
66
+ Style/DisableCopsWithinSourceCodeDirective:
67
+ Enabled: false
68
+ Style/Documentation:
69
+ Enabled: false
70
+ Style/DocumentationMethod:
71
+ Enabled: false
72
+ Style/EmptyCaseCondition:
73
+ Enabled: false
74
+ Style/FrozenStringLiteralComment:
75
+ Enabled: true
76
+ Style/GlobalVars:
77
+ Enabled: false
78
+ Style/GuardClause:
79
+ Enabled: false
80
+ Style/IfUnlessModifier:
81
+ Enabled: false
82
+ Style/InlineComment:
83
+ Enabled: false
84
+ Style/Lambda:
85
+ Enabled: false
86
+ Style/MethodCallWithArgsParentheses:
87
+ IgnoredMethods:
88
+ - add_runtime_dependency
89
+ - desc
90
+ - fail
91
+ - file
92
+ - gem
93
+ - head
94
+ - include
95
+ - integer
96
+ - load
97
+ - p
98
+ - print
99
+ - puts
100
+ - render
101
+ - require
102
+ - require_relative
103
+ - ruby
104
+ - run
105
+ - string
106
+ - source
107
+ Style/MissingElse:
108
+ Enabled: false
109
+ Style/NegatedIf:
110
+ Enabled: false
111
+ Style/ImplicitRuntimeError:
112
+ Enabled: false
113
+ Style/MethodCalledOnDoEndBlock:
114
+ Enabled: false
115
+ Style/NumericPredicate:
116
+ Enabled: false
117
+ Style/ParenthesesAroundCondition:
118
+ Enabled: false
119
+ Style/RescueModifier:
120
+ Enabled: false
121
+ Style/RescueStandardError:
122
+ Enabled: false
123
+ Style/ReturnNil:
124
+ Enabled: false
125
+ Style/RegexpLiteral:
126
+ Enabled: false
127
+ Style/Semicolon:
128
+ Enabled: false
129
+ Style/SignalException:
130
+ Enabled: false
131
+ Style/StderrPuts:
132
+ Enabled: false
133
+ Style/StringHashKeys:
134
+ Enabled: false
135
+ Style/TernaryParentheses:
136
+ Enabled: false
137
+ Style/TrailingCommaInArguments:
138
+ EnforcedStyleForMultiline: comma
139
+ Style/TrailingCommaInArrayLiteral:
140
+ EnforcedStyleForMultiline: comma
141
+ Style/TrailingCommaInHashLiteral:
142
+ EnforcedStyleForMultiline: comma
@@ -0,0 +1 @@
1
+ 2.7.0
@@ -0,0 +1,14 @@
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
@@ -0,0 +1,135 @@
1
+ ## v0.6.1 (2020-06-20)
2
+ ### Docs
3
+ - Add Travis build status badge to README.md
4
+
5
+ ## v0.6.0 (2020-06-19)
6
+ ### Fixed
7
+ - Fix bug that would occur in the `Shaped::Shape(...)` constructor when provided with a falsy first
8
+ argument.
9
+
10
+ ## v0.5.8 (2020-06-19)
11
+ ### Docs
12
+ - Document ActiveModel-style validations (which are available for `Shaped::Shapes::Class`)
13
+
14
+ ## v0.5.7 (2020-06-19)
15
+ ### Docs
16
+ - Wrap lines in README.md to a max of 100 characters
17
+
18
+ ## v0.5.6 (2020-06-19)
19
+ ### Docs
20
+ - Add a table of contents to README.md
21
+
22
+ ## v0.5.5 (2020-06-19)
23
+ ### Docs
24
+ - Add `require 'shaped'` to first example in README.md
25
+
26
+ ## v0.5.4 (2020-06-19)
27
+ ### Specs
28
+ - Fix typo in test (`@number.event?` => `@number.even?`)
29
+
30
+ ## v0.5.3 (2020-06-19)
31
+ ### Docs
32
+ - Fill out the "Usage" section of README.md
33
+
34
+ ## v0.5.2 (2020-06-19)
35
+ ### Docs
36
+ - Don't say in installation instructions to list gem in test section of Gemfile.
37
+
38
+ ## v0.5.1 (2020-06-19)
39
+ ### Docs
40
+ - Update description(s) to reflect broadened scope of the gem
41
+
42
+ ## v0.5.0 (2020-06-19)
43
+ ### Added
44
+ - Add a `Shaped::Shapes::Callable` shape, which is a shape that is defined by any object that
45
+ responds to `#call` (e.g. a proc or an instance of a class that defines a `#call` instance
46
+ method). This allows for essentially total flexibility in defining/describing the "shape" of an
47
+ object.
48
+
49
+ ## v0.4.0 (2020-06-18)
50
+ ### Added
51
+ - Add the ability to specify ActiveModel-style validations for `Shaped::Shape::Class`es
52
+
53
+ ## v0.3.2 (2020-06-18)
54
+ ### Tests
55
+ - Add tests for invalid `Array` and `Or` shape definitions
56
+
57
+ ## v0.3.1 (2020-06-18)
58
+ ### Maintenance
59
+ - Added test coverage tracking via `simplecov` and `codecov`
60
+
61
+ ## 0.3.0 - 2020-06-18
62
+ ### Breaking changes
63
+ - Major refactor! See details below.
64
+
65
+ ### Removed
66
+ - Remove detailed descriptions of errors ("match failure reasons")
67
+ - Remove `Array` and `Hash` refinements (`#has_shape?`)
68
+ - Removed `Shaped::Array(...)` and `Shaped::Hash(...)` constructor methods. Now, all shapes are
69
+ created via a single, unified `Shaped::Shape(...)` method that determines which type of shape to
70
+ build based on the class of the argument.
71
+ - Removed `Shaped.lax_mode` and `Shaped.strict_mode` settings. What was previously called `lax_mode`
72
+ is now the default, meaning that an empty array will always be considered to match any
73
+ `Shaped::Shapes::Array`.
74
+
75
+ ### Added
76
+ - Added new shape/matcher types (plus preexisting but relocated `Shaped::Shapes::Array` and
77
+ `Shaped::Shapes::Hash`):
78
+ 1. `Shaped::Shapes::Class`
79
+ 2. `Shaped::Shapes::Equality`
80
+ 3. `Shaped::Shapes::Or`
81
+ - All hashes and arrays in shape definitions are parsed "recursively" as shape definitions. For
82
+ example, instead of:
83
+
84
+ ```rb
85
+ Shaped::Array([
86
+ Shaped::Hash(
87
+ name: String,
88
+ emails: Shaped::Hash(
89
+ personal: Shaped::Array([String]),
90
+ work: Shaped::Array([String]),
91
+ ),
92
+ favorite_numbers: Shaped::Array([Numeric]),
93
+ ),
94
+ ])
95
+ ```
96
+
97
+ ...one can now simply do:
98
+
99
+ ```rb
100
+ Shaped::Array([
101
+ {
102
+ name: String,
103
+ emails: {
104
+ personal: [String],
105
+ work: [String],
106
+ },
107
+ favorite_numbers: [Numeric],
108
+ }
109
+ ])
110
+ ```
111
+
112
+ ### Dependencies
113
+ - Added `activesupport` as a dependency
114
+
115
+ ## 0.2.1 - 2020-06-16
116
+ ### Changed
117
+ - Rename `Shaped::Array#descriptor` and `Shaped::Hash#descriptor` methods to `#to_s`
118
+
119
+ ## 0.2.0 - 2020-06-16
120
+ ### Added
121
+ - Add `Shaped::Array` method and class
122
+ - Add `Array` refinement
123
+ - Add `Shaped::MatchFailureReason` and `Shaped::Array#match_failure_reason`
124
+ - Add `Shaped::Hash` method and class
125
+ - Add `Hash` refinement
126
+ - Allow composing Hash and Array shape matchers together
127
+
128
+ ### Fixed
129
+ - Fix potential memory leak in long-lived `Shaped::Array` instances
130
+
131
+ ### Tests
132
+ - Move `Shaped::Array#match_failure_reason` specs to the correct file
133
+
134
+ ## 0.1.0 - 2020-06-16
135
+ - Initial release of Shaped! Validate the shape of Ruby hashes and/or arrays.
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in shaped.gemspec
6
+ gemspec
7
+
8
+ gem 'amazing_print'
9
+ gem 'pry-byebug'
10
+ gem 'rake'
11
+ gem 'rubocop'
12
+
13
+ group :test do
14
+ gem 'codecov', require: false
15
+ gem 'guard-espect', require: false, github: 'davidrunger/guard-espect'
16
+ gem 'rspec'
17
+ end
@@ -0,0 +1,132 @@
1
+ GIT
2
+ remote: https://github.com/davidrunger/guard-espect.git
3
+ revision: 8d7f8594d120f4fa815eb20d79aeb962af8e83df
4
+ specs:
5
+ guard-espect (4.7.3)
6
+ guard (~> 2.1)
7
+ guard-compat (~> 1.1)
8
+ rspec (>= 2.99.0, < 4.0)
9
+
10
+ PATH
11
+ remote: .
12
+ specs:
13
+ shaped (0.6.1)
14
+ activemodel (~> 6.0)
15
+ activesupport (~> 6.0)
16
+
17
+ GEM
18
+ remote: https://rubygems.org/
19
+ specs:
20
+ activemodel (6.0.3.2)
21
+ activesupport (= 6.0.3.2)
22
+ activesupport (6.0.3.2)
23
+ concurrent-ruby (~> 1.0, >= 1.0.2)
24
+ i18n (>= 0.7, < 2)
25
+ minitest (~> 5.1)
26
+ tzinfo (~> 1.1)
27
+ zeitwerk (~> 2.2, >= 2.2.2)
28
+ amazing_print (1.2.1)
29
+ ast (2.4.1)
30
+ byebug (11.1.3)
31
+ codecov (0.1.17)
32
+ json
33
+ simplecov
34
+ url
35
+ coderay (1.1.3)
36
+ concurrent-ruby (1.1.6)
37
+ diff-lcs (1.3)
38
+ docile (1.3.2)
39
+ ffi (1.13.1)
40
+ formatador (0.2.5)
41
+ guard (2.16.2)
42
+ formatador (>= 0.2.4)
43
+ listen (>= 2.7, < 4.0)
44
+ lumberjack (>= 1.0.12, < 2.0)
45
+ nenv (~> 0.1)
46
+ notiffany (~> 0.0)
47
+ pry (>= 0.9.12)
48
+ shellany (~> 0.0)
49
+ thor (>= 0.18.1)
50
+ guard-compat (1.2.1)
51
+ i18n (1.8.3)
52
+ concurrent-ruby (~> 1.0)
53
+ json (2.3.0)
54
+ listen (3.2.1)
55
+ rb-fsevent (~> 0.10, >= 0.10.3)
56
+ rb-inotify (~> 0.9, >= 0.9.10)
57
+ lumberjack (1.2.5)
58
+ method_source (1.0.0)
59
+ minitest (5.14.1)
60
+ nenv (0.3.0)
61
+ notiffany (0.1.3)
62
+ nenv (~> 0.1)
63
+ shellany (~> 0.0)
64
+ parallel (1.19.1)
65
+ parser (2.7.1.3)
66
+ ast (~> 2.4.0)
67
+ pry (0.13.1)
68
+ coderay (~> 1.1)
69
+ method_source (~> 1.0)
70
+ pry-byebug (3.9.0)
71
+ byebug (~> 11.0)
72
+ pry (~> 0.13.0)
73
+ rainbow (3.0.0)
74
+ rake (12.3.3)
75
+ rb-fsevent (0.10.4)
76
+ rb-inotify (0.10.1)
77
+ ffi (~> 1.0)
78
+ regexp_parser (1.7.1)
79
+ rexml (3.2.4)
80
+ rspec (3.9.0)
81
+ rspec-core (~> 3.9.0)
82
+ rspec-expectations (~> 3.9.0)
83
+ rspec-mocks (~> 3.9.0)
84
+ rspec-core (3.9.2)
85
+ rspec-support (~> 3.9.3)
86
+ rspec-expectations (3.9.2)
87
+ diff-lcs (>= 1.2.0, < 2.0)
88
+ rspec-support (~> 3.9.0)
89
+ rspec-mocks (3.9.1)
90
+ diff-lcs (>= 1.2.0, < 2.0)
91
+ rspec-support (~> 3.9.0)
92
+ rspec-support (3.9.3)
93
+ rubocop (0.85.1)
94
+ parallel (~> 1.10)
95
+ parser (>= 2.7.0.1)
96
+ rainbow (>= 2.2.2, < 4.0)
97
+ regexp_parser (>= 1.7)
98
+ rexml
99
+ rubocop-ast (>= 0.0.3)
100
+ ruby-progressbar (~> 1.7)
101
+ unicode-display_width (>= 1.4.0, < 2.0)
102
+ rubocop-ast (0.0.3)
103
+ parser (>= 2.7.0.1)
104
+ ruby-progressbar (1.10.1)
105
+ shellany (0.0.1)
106
+ simplecov (0.18.5)
107
+ docile (~> 1.1)
108
+ simplecov-html (~> 0.11)
109
+ simplecov-html (0.12.2)
110
+ thor (1.0.1)
111
+ thread_safe (0.3.6)
112
+ tzinfo (1.2.7)
113
+ thread_safe (~> 0.1)
114
+ unicode-display_width (1.7.0)
115
+ url (0.3.2)
116
+ zeitwerk (2.3.0)
117
+
118
+ PLATFORMS
119
+ ruby
120
+
121
+ DEPENDENCIES
122
+ amazing_print
123
+ codecov
124
+ guard-espect!
125
+ pry-byebug
126
+ rake
127
+ rspec
128
+ rubocop
129
+ shaped!
130
+
131
+ BUNDLED WITH
132
+ 2.1.2