shiyo 0.1.0 → 0.1.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 +4 -0
- data/Gemfile +2 -0
- data/README.md +9 -2
- data/lib/shiyo/and.rb +0 -1
- data/lib/shiyo/not.rb +0 -1
- data/lib/shiyo/or.rb +0 -1
- data/lib/shiyo/{syntax_sugger.rb → syntax_sugar.rb} +3 -3
- data/lib/shiyo/version.rb +1 -1
- data/lib/shiyo.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d3cac64b3952eb7ca2cbc28c4c28bc0be7abad2dcab019e880f0dbd995191151
|
|
4
|
+
data.tar.gz: 867b20167b0327492d8011a6e90388683b7c0dae3ae22edba9b2b2e7f81a60c0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 78bdf7228c8377b54675046eaaa650183f147974bd56e429422bf0ddf44c1e3241ed2cc7fb17c1c7944584b3b12673f6a545659d29f88575333311b1fc2bf774
|
|
7
|
+
data.tar.gz: df0044517dd0589b2b476b645d2c3dce47eec94d6239f001a71cfdf0e8362c795ecd6b67d242e8725c6b8a0aa3d7570f6dddceeb6bb9e6469e11e7170cc1a7a5
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# Shiyo
|
|
2
2
|
[](https://github.com/johnny-miyake/shiyo)
|
|
3
3
|
|
|
4
|
-
Shiyo is a minimal framework that supports writing your business rules using the Specification pattern.
|
|
5
|
-
It
|
|
4
|
+
Shiyo is a minimal framework that supports writing your business rules using the [Specification pattern](https://en.wikipedia.org/wiki/Specification_pattern).
|
|
5
|
+
It helps you to build a composite specification by method chaining like;
|
|
6
6
|
```ruby
|
|
7
7
|
spec1.and(spec2.or(spec3)).satisfied_by?(candidate)
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
+
[API documentation](https://www.rubydoc.info/gems/shiyo)
|
|
11
|
+
|
|
10
12
|
## Installation
|
|
11
13
|
|
|
12
14
|
Add this line to your application's Gemfile:
|
|
@@ -24,7 +26,12 @@ Or install it yourself as:
|
|
|
24
26
|
$ gem install shiyo
|
|
25
27
|
|
|
26
28
|
## Usage
|
|
29
|
+
You can create your own Shiyo specification as following steps;
|
|
30
|
+
1. Include `Shiyo::Specification` module into your class.
|
|
31
|
+
2. Implement `#satisfied_by?`.
|
|
32
|
+
3. (optional) Implement `#initialize` if needed.
|
|
27
33
|
|
|
34
|
+
For example;
|
|
28
35
|
```ruby
|
|
29
36
|
# A specification class
|
|
30
37
|
class ContainerFeatureSpec
|
data/lib/shiyo/and.rb
CHANGED
|
@@ -10,7 +10,6 @@ module Shiyo
|
|
|
10
10
|
# @param one [Shiyo::Specification] A specification object.
|
|
11
11
|
# @param other [Shiyo::Specification] The other specification object.
|
|
12
12
|
def initialize(one, other)
|
|
13
|
-
super()
|
|
14
13
|
@one = Shiyo::Specification(one)
|
|
15
14
|
@other = Shiyo::Specification(other)
|
|
16
15
|
end
|
data/lib/shiyo/not.rb
CHANGED
data/lib/shiyo/or.rb
CHANGED
|
@@ -10,7 +10,6 @@ module Shiyo
|
|
|
10
10
|
# @param one [Shiyo::Specification] A specification object.
|
|
11
11
|
# @param other [Shiyo::Specification] The other specification object.
|
|
12
12
|
def initialize(one, other)
|
|
13
|
-
super()
|
|
14
13
|
@one = Shiyo::Specification(one)
|
|
15
14
|
@other = Shiyo::Specification(other)
|
|
16
15
|
end
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Shiyo
|
|
4
|
-
# The module to provide syntax
|
|
5
|
-
module
|
|
4
|
+
# The module to provide syntax sugars.
|
|
5
|
+
module SyntaxSugar
|
|
6
6
|
# rubocop:disable Naming/MethodName
|
|
7
7
|
|
|
8
|
-
# The syntax
|
|
8
|
+
# The syntax sugar for `Shiyo::Not.new`
|
|
9
9
|
# @param object Any object.
|
|
10
10
|
# @return [Shiyo::Not]
|
|
11
11
|
def Not(object)
|
data/lib/shiyo/version.rb
CHANGED
data/lib/shiyo.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require_relative "shiyo/error"
|
|
4
4
|
require_relative "shiyo/version"
|
|
5
5
|
require_relative "shiyo/conversion"
|
|
6
|
-
require_relative "shiyo/
|
|
6
|
+
require_relative "shiyo/syntax_sugar"
|
|
7
7
|
require_relative "shiyo/specification"
|
|
8
8
|
require_relative "shiyo/and"
|
|
9
9
|
require_relative "shiyo/or"
|
|
@@ -12,5 +12,5 @@ require_relative "shiyo/not"
|
|
|
12
12
|
# The top module of Shiyo
|
|
13
13
|
module Shiyo
|
|
14
14
|
extend Shiyo::Conversion
|
|
15
|
-
extend Shiyo::
|
|
15
|
+
extend Shiyo::SyntaxSugar
|
|
16
16
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shiyo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Takuma Miyake
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-03-
|
|
11
|
+
date: 2022-03-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: " Shiyo is a minimal framework that supports writing your business
|
|
14
14
|
rules using the Specification pattern.\n"
|
|
@@ -33,7 +33,7 @@ files:
|
|
|
33
33
|
- lib/shiyo/not.rb
|
|
34
34
|
- lib/shiyo/or.rb
|
|
35
35
|
- lib/shiyo/specification.rb
|
|
36
|
-
- lib/shiyo/
|
|
36
|
+
- lib/shiyo/syntax_sugar.rb
|
|
37
37
|
- lib/shiyo/version.rb
|
|
38
38
|
- sig/shiyo.rbs
|
|
39
39
|
homepage: https://github.com/johnny-miyake/shiyo
|