active_pattern 1.0.0 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ebf7eaced41aa38e76dabf6aad96f2c8a883030c53e33c156080610acbd50b42
4
- data.tar.gz: e259a332e984d11fcf131d53384c6d243c25efb87414b20a1c511e2dd1b03586
3
+ metadata.gz: 182ab6becbbf099bd4769c091554adedb808f12abf402c73dd91ace4f25f7019
4
+ data.tar.gz: c66fc4e351f1fe89e051fde81d61e82c4b13226195f658b4119c4736a209f659
5
5
  SHA512:
6
- metadata.gz: 5aaa9c2be8fe74e21cf4b6c281af6c68e0daa310de44b618536c6860b386f2ec095b7a24cce273fa81ea0bf7fe37bce7222cd2a408575fcb1ed1d534a163bd99
7
- data.tar.gz: '069f9da66789f47f7b26835108cb12b377f85c4d953f8c3c1dece3247a17e9e543797d68e39a335932240d959f164f7b60c8a2cf4ffb3ea6af52ad773e3eeb42'
6
+ metadata.gz: aa00f8a83d7c3740ef3dcd45927e2970ae20b296ed3bd3e7fc76497cd7b017b3017707f1424ef48dad717cf17708a299be1ac17fa6fed7ea71a7f45d4d25447b
7
+ data.tar.gz: c7da73f1063acb7186d721f38619d211fb37409556e24c5234fa8e068cd253e49fefd91be0b9b88a3acb9609657fceb3892049bbfbed50fdd3116204f462cd5e
@@ -0,0 +1,10 @@
1
+ # ChangeLog
2
+
3
+ ## 1.1.0
4
+ ### Added
5
+ - Pattern Matching in pattern proc
6
+
7
+ ## 1.0.0
8
+ ### Added
9
+ - Released!
10
+ - Ruby 2.7.0 support
data/README.md CHANGED
@@ -47,6 +47,28 @@ fizzbuzz(5) # => :Buzz
47
47
  fizzbuzz(15) # => :FizzBuzz
48
48
  ```
49
49
 
50
+ You can use normal pattern matching in `pattern` method.
51
+
52
+ ```ruby
53
+ module Response
54
+ extend ActivePattern::Context[Hash]
55
+ OK = pattern { self in { status: :ok, body: body }; [body] }
56
+ NG = pattern { self in { status: :ng, message: message }; [message] }
57
+ end
58
+
59
+ def print_response(response)
60
+ case response
61
+ in OK[body]; puts body
62
+ in NG[message]; puts message
63
+ else; puts 'no match'
64
+ end
65
+ end
66
+
67
+ print_response(status: :ok, body: 'Wow!') # => Wow!
68
+ print_response(status: :ng, message: 'Oops!') #=> Oops!
69
+ print_response(status: :unknown) #=> no match
70
+ ```
71
+
50
72
  ## Development
51
73
 
52
74
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -17,6 +17,8 @@ module ActivePattern
17
17
  $_ACTIVE_PATTERN_MATCHES = nil
18
18
  match_result
19
19
  end
20
+ rescue NoMatchingPatternError
21
+ false
20
22
  end
21
23
  end
22
24
  end
@@ -1,3 +1,3 @@
1
1
  module ActivePattern
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_pattern
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kokuyouwind
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-25 00:00:00.000000000 Z
11
+ date: 2020-01-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: F# like ActivePattern in ruby pattern matching
14
14
  email:
@@ -22,6 +22,7 @@ files:
22
22
  - ".rspec"
23
23
  - ".ruby-version"
24
24
  - ".travis.yml"
25
+ - ChangeLog.md
25
26
  - Gemfile
26
27
  - LICENSE.txt
27
28
  - README.md