dry-logic 0.6.1 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +2 -5
  3. data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +10 -0
  4. data/.github/ISSUE_TEMPLATE/---bug-report.md +34 -0
  5. data/.github/ISSUE_TEMPLATE/---feature-request.md +18 -0
  6. data/.github/workflows/ci.yml +70 -0
  7. data/.github/workflows/docsite.yml +34 -0
  8. data/.github/workflows/sync_configs.yml +34 -0
  9. data/.gitignore +2 -1
  10. data/.rspec +1 -0
  11. data/.rubocop.yml +89 -0
  12. data/CHANGELOG.md +52 -3
  13. data/CODE_OF_CONDUCT.md +13 -0
  14. data/CONTRIBUTING.md +3 -3
  15. data/Gemfile +3 -0
  16. data/LICENSE +1 -1
  17. data/README.md +6 -6
  18. data/Rakefile +2 -0
  19. data/benchmarks/rule_application.rb +2 -0
  20. data/benchmarks/setup.rb +2 -0
  21. data/bin/console +1 -0
  22. data/docsite/source/index.html.md +54 -0
  23. data/docsite/source/operations.html.md +62 -0
  24. data/docsite/source/predicates.html.md +102 -0
  25. data/dry-logic.gemspec +8 -0
  26. data/examples/basic.rb +2 -0
  27. data/lib/dry-logic.rb +2 -0
  28. data/lib/dry/logic.rb +2 -0
  29. data/lib/dry/logic/appliable.rb +2 -0
  30. data/lib/dry/logic/evaluator.rb +2 -0
  31. data/lib/dry/logic/operations.rb +2 -0
  32. data/lib/dry/logic/operations/abstract.rb +5 -3
  33. data/lib/dry/logic/operations/and.rb +3 -1
  34. data/lib/dry/logic/operations/attr.rb +2 -0
  35. data/lib/dry/logic/operations/binary.rb +2 -0
  36. data/lib/dry/logic/operations/check.rb +3 -1
  37. data/lib/dry/logic/operations/each.rb +2 -0
  38. data/lib/dry/logic/operations/implication.rb +2 -0
  39. data/lib/dry/logic/operations/key.rb +4 -2
  40. data/lib/dry/logic/operations/negation.rb +2 -0
  41. data/lib/dry/logic/operations/or.rb +2 -0
  42. data/lib/dry/logic/operations/set.rb +2 -0
  43. data/lib/dry/logic/operations/unary.rb +2 -0
  44. data/lib/dry/logic/operations/xor.rb +2 -0
  45. data/lib/dry/logic/operators.rb +2 -0
  46. data/lib/dry/logic/predicates.rb +39 -21
  47. data/lib/dry/logic/result.rb +2 -0
  48. data/lib/dry/logic/rule.rb +5 -3
  49. data/lib/dry/logic/rule/interface.rb +2 -0
  50. data/lib/dry/logic/rule/predicate.rb +2 -0
  51. data/lib/dry/logic/rule_compiler.rb +2 -0
  52. data/lib/dry/logic/version.rb +3 -1
  53. data/spec/integration/result_spec.rb +2 -0
  54. data/spec/integration/rule_spec.rb +2 -0
  55. data/spec/shared/predicates.rb +2 -0
  56. data/spec/shared/rule.rb +2 -0
  57. data/spec/spec_helper.rb +6 -10
  58. data/spec/support/mutant.rb +2 -0
  59. data/spec/unit/operations/and_spec.rb +2 -0
  60. data/spec/unit/operations/attr_spec.rb +2 -0
  61. data/spec/unit/operations/check_spec.rb +2 -0
  62. data/spec/unit/operations/each_spec.rb +2 -0
  63. data/spec/unit/operations/implication_spec.rb +2 -0
  64. data/spec/unit/operations/key_spec.rb +2 -0
  65. data/spec/unit/operations/negation_spec.rb +2 -0
  66. data/spec/unit/operations/or_spec.rb +2 -0
  67. data/spec/unit/operations/set_spec.rb +2 -0
  68. data/spec/unit/operations/xor_spec.rb +2 -0
  69. data/spec/unit/predicates/array_spec.rb +2 -0
  70. data/spec/unit/predicates/attr_spec.rb +2 -0
  71. data/spec/unit/predicates/bool_spec.rb +3 -1
  72. data/spec/unit/predicates/bytesize_spec.rb +48 -0
  73. data/spec/unit/predicates/case_spec.rb +2 -0
  74. data/spec/unit/predicates/date_spec.rb +2 -0
  75. data/spec/unit/predicates/date_time_spec.rb +3 -1
  76. data/spec/unit/predicates/decimal_spec.rb +3 -1
  77. data/spec/unit/predicates/empty_spec.rb +2 -0
  78. data/spec/unit/predicates/eql_spec.rb +2 -0
  79. data/spec/unit/predicates/even_spec.rb +2 -0
  80. data/spec/unit/predicates/excluded_from_spec.rb +2 -0
  81. data/spec/unit/predicates/excludes_spec.rb +2 -0
  82. data/spec/unit/predicates/false_spec.rb +3 -1
  83. data/spec/unit/predicates/filled_spec.rb +2 -0
  84. data/spec/unit/predicates/float_spec.rb +2 -0
  85. data/spec/unit/predicates/format_spec.rb +12 -2
  86. data/spec/unit/predicates/gt_spec.rb +2 -0
  87. data/spec/unit/predicates/gteq_spec.rb +2 -0
  88. data/spec/unit/predicates/hash_spec.rb +40 -0
  89. data/spec/unit/predicates/included_in_spec.rb +2 -0
  90. data/spec/unit/predicates/int_spec.rb +2 -0
  91. data/spec/unit/predicates/key_spec.rb +2 -0
  92. data/spec/unit/predicates/lt_spec.rb +2 -0
  93. data/spec/unit/predicates/lteq_spec.rb +2 -0
  94. data/spec/unit/predicates/max_bytesize_spec.rb +39 -0
  95. data/spec/unit/predicates/max_size_spec.rb +2 -0
  96. data/spec/unit/predicates/min_bytesize_spec.rb +39 -0
  97. data/spec/unit/predicates/min_size_spec.rb +2 -0
  98. data/spec/unit/predicates/none_spec.rb +2 -0
  99. data/spec/unit/predicates/not_eql_spec.rb +2 -0
  100. data/spec/unit/predicates/number_spec.rb +2 -0
  101. data/spec/unit/predicates/odd_spec.rb +2 -0
  102. data/spec/unit/predicates/respond_to_spec.rb +31 -0
  103. data/spec/unit/predicates/size_spec.rb +2 -0
  104. data/spec/unit/predicates/str_spec.rb +2 -0
  105. data/spec/unit/predicates/time_spec.rb +3 -1
  106. data/spec/unit/predicates/true_spec.rb +3 -1
  107. data/spec/unit/predicates/type_spec.rb +2 -0
  108. data/spec/unit/predicates/uuid_v4_spec.rb +29 -0
  109. data/spec/unit/predicates_spec.rb +2 -0
  110. data/spec/unit/rule/predicate_spec.rb +2 -0
  111. data/spec/unit/rule_compiler_spec.rb +2 -0
  112. data/spec/unit/rule_spec.rb +6 -4
  113. metadata +30 -6
  114. data/.travis.yml +0 -31
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry/logic/predicates'
4
+
5
+ RSpec.describe Dry::Logic::Predicates do
6
+ describe '#uuid_v4?' do
7
+ let(:predicate_name) { :uuid_v4? }
8
+
9
+ context 'when value is a valid V4 UUID' do
10
+ let(:arguments_list) do
11
+ [['f2d26c57-e07c-4416-a749-57e937930e04']]
12
+ end
13
+
14
+ it_behaves_like 'a passing predicate'
15
+ end
16
+
17
+ context 'with value is not a valid V4 UUID' do
18
+ let(:arguments_list) do
19
+ [
20
+ ['f2d26c57-e07c-3416-a749-57e937930e04'], # wrong version number (3, not 4)
21
+ ['20633928-6a07-11e9-a923-1681be663d3e'], # UUID V1
22
+ ['not-a-uuid-at-all']
23
+ ]
24
+ end
25
+
26
+ it_behaves_like 'a failing predicate'
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dry/logic/predicates'
2
4
 
3
5
  RSpec.describe Predicates do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe Rule::Predicate do
2
4
  subject(:rule) { Rule::Predicate.build(predicate) }
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dry/logic/rule_compiler'
2
4
 
3
5
  RSpec.describe Dry::Logic::RuleCompiler, '#call' do
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe Dry::Logic::Rule do
2
- subject(:rule) { Rule.build(predicate, options) }
4
+ subject(:rule) { Rule.build(predicate, **options) }
3
5
 
4
6
  let(:predicate) { -> { true } }
5
7
  let(:options) { {} }
@@ -178,8 +180,8 @@ RSpec.describe Dry::Logic::Rule do
178
180
  end
179
181
 
180
182
  describe 'arbitrary arity' do
181
- let(:arity) { rand(20) }
182
- let(:curried) { arity.zero? ? 0 : rand(arity) }
183
+ let(:arity) { rand(1..20) }
184
+ let(:curried) { rand(arity) }
183
185
 
184
186
  let(:options) { { args: [1] * curried, arity: arity } }
185
187
  let(:predicate) { double(:predicate) }
@@ -202,7 +204,7 @@ RSpec.describe Dry::Logic::Rule do
202
204
  describe 'constants' do
203
205
  let(:options) { { args: [], arity: 0 } }
204
206
 
205
- fit 'accepts variable number of arguments' do
207
+ it 'accepts variable number of arguments' do
206
208
  expect(rule.method(:call).arity).to be(-1)
207
209
  expect(rule.method(:[]).arity).to be(-1)
208
210
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-logic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-18 00:00:00.000000000 Z
11
+ date: 2019-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -102,10 +102,17 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - ".codeclimate.yml"
105
+ - ".github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md"
106
+ - ".github/ISSUE_TEMPLATE/---bug-report.md"
107
+ - ".github/ISSUE_TEMPLATE/---feature-request.md"
108
+ - ".github/workflows/ci.yml"
109
+ - ".github/workflows/docsite.yml"
110
+ - ".github/workflows/sync_configs.yml"
105
111
  - ".gitignore"
106
112
  - ".rspec"
107
- - ".travis.yml"
113
+ - ".rubocop.yml"
108
114
  - CHANGELOG.md
115
+ - CODE_OF_CONDUCT.md
109
116
  - CONTRIBUTING.md
110
117
  - Gemfile
111
118
  - LICENSE
@@ -114,6 +121,9 @@ files:
114
121
  - benchmarks/rule_application.rb
115
122
  - benchmarks/setup.rb
116
123
  - bin/console
124
+ - docsite/source/index.html.md
125
+ - docsite/source/operations.html.md
126
+ - docsite/source/predicates.html.md
117
127
  - dry-logic.gemspec
118
128
  - examples/basic.rb
119
129
  - lib/dry-logic.rb
@@ -161,6 +171,7 @@ files:
161
171
  - spec/unit/predicates/array_spec.rb
162
172
  - spec/unit/predicates/attr_spec.rb
163
173
  - spec/unit/predicates/bool_spec.rb
174
+ - spec/unit/predicates/bytesize_spec.rb
164
175
  - spec/unit/predicates/case_spec.rb
165
176
  - spec/unit/predicates/date_spec.rb
166
177
  - spec/unit/predicates/date_time_spec.rb
@@ -176,23 +187,28 @@ files:
176
187
  - spec/unit/predicates/format_spec.rb
177
188
  - spec/unit/predicates/gt_spec.rb
178
189
  - spec/unit/predicates/gteq_spec.rb
190
+ - spec/unit/predicates/hash_spec.rb
179
191
  - spec/unit/predicates/included_in_spec.rb
180
192
  - spec/unit/predicates/includes_spec.rb
181
193
  - spec/unit/predicates/int_spec.rb
182
194
  - spec/unit/predicates/key_spec.rb
183
195
  - spec/unit/predicates/lt_spec.rb
184
196
  - spec/unit/predicates/lteq_spec.rb
197
+ - spec/unit/predicates/max_bytesize_spec.rb
185
198
  - spec/unit/predicates/max_size_spec.rb
199
+ - spec/unit/predicates/min_bytesize_spec.rb
186
200
  - spec/unit/predicates/min_size_spec.rb
187
201
  - spec/unit/predicates/none_spec.rb
188
202
  - spec/unit/predicates/not_eql_spec.rb
189
203
  - spec/unit/predicates/number_spec.rb
190
204
  - spec/unit/predicates/odd_spec.rb
205
+ - spec/unit/predicates/respond_to_spec.rb
191
206
  - spec/unit/predicates/size_spec.rb
192
207
  - spec/unit/predicates/str_spec.rb
193
208
  - spec/unit/predicates/time_spec.rb
194
209
  - spec/unit/predicates/true_spec.rb
195
210
  - spec/unit/predicates/type_spec.rb
211
+ - spec/unit/predicates/uuid_v4_spec.rb
196
212
  - spec/unit/predicates_spec.rb
197
213
  - spec/unit/rule/predicate_spec.rb
198
214
  - spec/unit/rule_compiler_spec.rb
@@ -200,7 +216,9 @@ files:
200
216
  homepage: https://github.com/dry-rb/dry-logic
201
217
  licenses:
202
218
  - MIT
203
- metadata: {}
219
+ metadata:
220
+ source_code_uri: https://github.com/dry-rb/dry-logic
221
+ changelog_uri: https://github.com/dry-rb/dry-logic/blob/master/CHANGELOG.md
204
222
  post_install_message:
205
223
  rdoc_options: []
206
224
  require_paths:
@@ -209,14 +227,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
209
227
  requirements:
210
228
  - - ">="
211
229
  - !ruby/object:Gem::Version
212
- version: '0'
230
+ version: 2.4.0
213
231
  required_rubygems_version: !ruby/object:Gem::Requirement
214
232
  requirements:
215
233
  - - ">="
216
234
  - !ruby/object:Gem::Version
217
235
  version: '0'
218
236
  requirements: []
219
- rubygems_version: 3.0.3
237
+ rubygems_version: 3.0.6
220
238
  signing_key:
221
239
  specification_version: 4
222
240
  summary: Predicate logic with rule composition
@@ -240,6 +258,7 @@ test_files:
240
258
  - spec/unit/predicates/array_spec.rb
241
259
  - spec/unit/predicates/attr_spec.rb
242
260
  - spec/unit/predicates/bool_spec.rb
261
+ - spec/unit/predicates/bytesize_spec.rb
243
262
  - spec/unit/predicates/case_spec.rb
244
263
  - spec/unit/predicates/date_spec.rb
245
264
  - spec/unit/predicates/date_time_spec.rb
@@ -255,23 +274,28 @@ test_files:
255
274
  - spec/unit/predicates/format_spec.rb
256
275
  - spec/unit/predicates/gt_spec.rb
257
276
  - spec/unit/predicates/gteq_spec.rb
277
+ - spec/unit/predicates/hash_spec.rb
258
278
  - spec/unit/predicates/included_in_spec.rb
259
279
  - spec/unit/predicates/includes_spec.rb
260
280
  - spec/unit/predicates/int_spec.rb
261
281
  - spec/unit/predicates/key_spec.rb
262
282
  - spec/unit/predicates/lt_spec.rb
263
283
  - spec/unit/predicates/lteq_spec.rb
284
+ - spec/unit/predicates/max_bytesize_spec.rb
264
285
  - spec/unit/predicates/max_size_spec.rb
286
+ - spec/unit/predicates/min_bytesize_spec.rb
265
287
  - spec/unit/predicates/min_size_spec.rb
266
288
  - spec/unit/predicates/none_spec.rb
267
289
  - spec/unit/predicates/not_eql_spec.rb
268
290
  - spec/unit/predicates/number_spec.rb
269
291
  - spec/unit/predicates/odd_spec.rb
292
+ - spec/unit/predicates/respond_to_spec.rb
270
293
  - spec/unit/predicates/size_spec.rb
271
294
  - spec/unit/predicates/str_spec.rb
272
295
  - spec/unit/predicates/time_spec.rb
273
296
  - spec/unit/predicates/true_spec.rb
274
297
  - spec/unit/predicates/type_spec.rb
298
+ - spec/unit/predicates/uuid_v4_spec.rb
275
299
  - spec/unit/predicates_spec.rb
276
300
  - spec/unit/rule/predicate_spec.rb
277
301
  - spec/unit/rule_compiler_spec.rb
data/.travis.yml DELETED
@@ -1,31 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- bundler_args: --without benchmarks tools
4
- before_script:
5
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
6
- - chmod +x ./cc-test-reporter
7
- - ./cc-test-reporter before-build
8
- after_script:
9
- - "[ -d coverage ] && ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
10
- script:
11
- - bundle exec rake
12
- rvm:
13
- - 2.6.2
14
- - 2.5.5
15
- - 2.4.6
16
- - jruby-9.2.7.0
17
- - truffleruby
18
- env:
19
- global:
20
- - COVERAGE=true
21
- matrix:
22
- allow_failures:
23
- - rvm: truffleruby
24
- notifications:
25
- email: false
26
- webhooks:
27
- urls:
28
- - https://dry-rb.zulipchat.com/api/v1/external/travis?api_key=SY8LLz6fShd4TJeLDXEdT0eBEgRqT2lv&stream=notifications&topic=ci
29
- on_success: change # options: [always|never|change] default: always
30
- on_failure: always # options: [always|never|change] default: always
31
- on_start: false # default: false