dry-logic 0.2.0 → 0.2.1
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/CHANGELOG.md +14 -0
- data/README.md +13 -13
- data/lib/dry/logic/result/each.rb +11 -1
- data/lib/dry/logic/rule/each.rb +1 -1
- data/lib/dry/logic/version.rb +1 -1
- data/spec/unit/rule/each_spec.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 405fbdd05ed04c6abd40e6f4e0bc82798ce17463
|
4
|
+
data.tar.gz: c0d6fb17709b8d8c69594e8fb38caa7161eee873
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5efcddce3c685049908c67e33fdfc3b473ff173c313469c40169ef02332aaa18e1711e40eaf47b683c29dbe2e2d5dd25bd76fa9c8b53b05457661ac98966f52
|
7
|
+
data.tar.gz: 89be8d68859d37e8969ca9ea650bea7ed9225dbc51f0911e5e66dc47df82f6560292879052dcb2906ff7e43d8a3c5f1f2ea2922317fbb82710487fc0cbfc9298
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# v0.2.1 2016-03-20
|
2
|
+
|
3
|
+
### Fixed
|
4
|
+
|
5
|
+
* Result AST for `Rule::Each` correctly maps elements with eql inputs (solnic)
|
6
|
+
|
7
|
+
# v0.2.0 2016-03-11
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
* Entire AST has been redefined (solnic)
|
12
|
+
|
13
|
+
[Compare v0.1.4...v0.2.0](https://github.com/dryrb/dry-logic/compare/v0.1.4...v0.2.0)
|
14
|
+
|
1
15
|
# v0.1.4 2016-01-27
|
2
16
|
|
3
17
|
### Added
|
data/README.md
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
[gem]: https://rubygems.org/gems/dry-logic
|
2
|
-
[travis]: https://travis-ci.org/
|
3
|
-
[gemnasium]: https://gemnasium.com/
|
4
|
-
[codeclimate]: https://codeclimate.com/github/
|
5
|
-
[coveralls]: https://coveralls.io/r/
|
6
|
-
[inchpages]: http://inch-ci.org/github/
|
2
|
+
[travis]: https://travis-ci.org/dry-rb/dry-logic
|
3
|
+
[gemnasium]: https://gemnasium.com/dry-rb/dry-logic
|
4
|
+
[codeclimate]: https://codeclimate.com/github/dry-rb/dry-logic
|
5
|
+
[coveralls]: https://coveralls.io/r/dry-rb/dry-logic
|
6
|
+
[inchpages]: http://inch-ci.org/github/dry-rb/dry-logic
|
7
7
|
|
8
|
-
# dry-logic [](https://gitter.im/dry-rb/chat)
|
9
9
|
|
10
10
|
[][gem]
|
11
|
-
[][travis]
|
12
|
+
[][gemnasium]
|
13
|
+
[][codeclimate]
|
14
|
+
[][codeclimate]
|
15
|
+
[][inchpages]
|
16
16
|
|
17
17
|
Predicate logic and rule composition used by:
|
18
18
|
|
19
|
-
* [dry-
|
20
|
-
* [dry-validation](https://github.com/
|
19
|
+
* [dry-types](https://github.com/dry-rb/dry-types) for constrained types
|
20
|
+
* [dry-validation](https://github.com/dry-rb/dry-validation) for composing validation rules
|
21
21
|
* your project...?
|
22
22
|
|
23
23
|
## Synopsis
|
@@ -2,9 +2,19 @@ module Dry
|
|
2
2
|
module Logic
|
3
3
|
class Result::Each < Result::Multi
|
4
4
|
def to_ast
|
5
|
-
failed_rules = failures.map { |el| [:el, [
|
5
|
+
failed_rules = failures.map { |idx, el| [:el, [idx, el.to_ast]] }
|
6
6
|
[:result, [rule.evaluate(input), [:each, failed_rules]]]
|
7
7
|
end
|
8
|
+
|
9
|
+
def success?
|
10
|
+
response.values.all?(&:success?)
|
11
|
+
end
|
12
|
+
|
13
|
+
def failures
|
14
|
+
response.each_with_object({}) { |(idx, res), hash|
|
15
|
+
hash[idx] = res if res.failure?
|
16
|
+
}
|
17
|
+
end
|
8
18
|
end
|
9
19
|
end
|
10
20
|
end
|
data/lib/dry/logic/rule/each.rb
CHANGED
data/lib/dry/logic/version.rb
CHANGED
data/spec/unit/rule/each_spec.rb
CHANGED
@@ -16,5 +16,16 @@ RSpec.describe Dry::Logic::Rule::Each do
|
|
16
16
|
expect(address_rule.([nil, 'Address'])).to be_failure
|
17
17
|
expect(address_rule.([:Address, 'Address'])).to be_failure
|
18
18
|
end
|
19
|
+
|
20
|
+
it 'returns result ast' do
|
21
|
+
expect(address_rule.([nil, nil]).to_ast).to eql([
|
22
|
+
:result, [[nil, nil], [
|
23
|
+
:each, [
|
24
|
+
[:el, [0, [:result, [nil, [:val, [:predicate, [:str?, []]]]]]]],
|
25
|
+
[:el, [1, [:result, [nil, [:val, [:predicate, [:str?, []]]]]]]]
|
26
|
+
]
|
27
|
+
]]
|
28
|
+
])
|
29
|
+
end
|
19
30
|
end
|
20
31
|
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.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-container
|