pattern_matchable 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/README.md +48 -9
 - data/lib/pattern_matchable.rb +4 -0
 - data/lib/pattern_matchable/version.rb +1 -1
 - metadata +5 -5
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: d273be1d68edacc564b26f61dca88747cad7610ec4511479bc8b4ddb4a2232c3
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 60780107cb09fdd8455bb916bcd2fb4813614144f2a335a3aa003028edaa28eb
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: eed4b370842bea8aeed8f63cb1208d07f2c06aa11040a14735ebe5887262aa8a9ebf8cdeb292f30604055ded4a0648a82cb8e5ac8d17115bfce9fffc1b169630
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 314a2aed9892d024b9625e671f8a389e010aa5106f6c844de36b22f81b230db59f5eaa446680e91b7efb0ecc1d52259085d62d3d8a8f134b1c27a35ade3af404
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -73,12 +73,17 @@ class Array 
     | 
|
| 
       73 
73 
     | 
    
         
             
              include PatternMatchable
         
     | 
| 
       74 
74 
     | 
    
         
             
            end
         
     | 
| 
       75 
75 
     | 
    
         | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
      
 76 
     | 
    
         
            +
            # OK: assigned `first` `last` variables
         
     | 
| 
      
 77 
     | 
    
         
            +
            case [1, 2, 3, 4, 5]
         
     | 
| 
      
 78 
     | 
    
         
            +
            in { first:, last: }
         
     | 
| 
      
 79 
     | 
    
         
            +
            end
         
     | 
| 
       77 
80 
     | 
    
         
             
            p first  # => 1
         
     | 
| 
       78 
81 
     | 
    
         
             
            p last   # => 5
         
     | 
| 
       79 
82 
     | 
    
         | 
| 
       80 
83 
     | 
    
         
             
            # error: NoMatchingPatternError
         
     | 
| 
       81 
     | 
    
         
            -
            "Homu" 
     | 
| 
      
 84 
     | 
    
         
            +
            case "Homu"
         
     | 
| 
      
 85 
     | 
    
         
            +
            in { downcase:, upcase: }
         
     | 
| 
      
 86 
     | 
    
         
            +
            end
         
     | 
| 
       82 
87 
     | 
    
         
             
            ```
         
     | 
| 
       83 
88 
     | 
    
         | 
| 
       84 
89 
     | 
    
         
             
            ### 2. `using PatternMatchable`
         
     | 
| 
         @@ -91,11 +96,15 @@ require "pattern_matchable" 
     | 
|
| 
       91 
96 
     | 
    
         
             
            # defined Object#deconstruct_keys
         
     | 
| 
       92 
97 
     | 
    
         
             
            using PatternMatchable
         
     | 
| 
       93 
98 
     | 
    
         | 
| 
       94 
     | 
    
         
            -
            [1, 2, 3, 4, 5] 
     | 
| 
      
 99 
     | 
    
         
            +
            case [1, 2, 3, 4, 5]
         
     | 
| 
      
 100 
     | 
    
         
            +
            in { first:, last: }
         
     | 
| 
      
 101 
     | 
    
         
            +
            end
         
     | 
| 
       95 
102 
     | 
    
         
             
            p first  # => 1
         
     | 
| 
       96 
103 
     | 
    
         
             
            p last   # => 5
         
     | 
| 
       97 
104 
     | 
    
         | 
| 
       98 
     | 
    
         
            -
            "Homu" 
     | 
| 
      
 105 
     | 
    
         
            +
            case "Homu"
         
     | 
| 
      
 106 
     | 
    
         
            +
            in { downcase:, upcase: }
         
     | 
| 
      
 107 
     | 
    
         
            +
            end
         
     | 
| 
       99 
108 
     | 
    
         
             
            p downcase   # => "homu"
         
     | 
| 
       100 
109 
     | 
    
         
             
            p upcase     # => "HOMU"
         
     | 
| 
       101 
110 
     | 
    
         
             
            ```
         
     | 
| 
         @@ -110,12 +119,16 @@ require "pattern_matchable" 
     | 
|
| 
       110 
119 
     | 
    
         
             
            # define Array#deconstruct_keys
         
     | 
| 
       111 
120 
     | 
    
         
             
            using PatternMatchable.refining Array
         
     | 
| 
       112 
121 
     | 
    
         | 
| 
       113 
     | 
    
         
            -
            [1, 2, 3, 4, 5] 
     | 
| 
      
 122 
     | 
    
         
            +
            case [1, 2, 3, 4, 5]
         
     | 
| 
      
 123 
     | 
    
         
            +
            in { first:, last: }
         
     | 
| 
      
 124 
     | 
    
         
            +
            end
         
     | 
| 
       114 
125 
     | 
    
         
             
            p first  # => 1
         
     | 
| 
       115 
126 
     | 
    
         
             
            p last   # => 5
         
     | 
| 
       116 
127 
     | 
    
         | 
| 
       117 
128 
     | 
    
         
             
            # error: NoMatchingPatternError
         
     | 
| 
       118 
     | 
    
         
            -
            "Homu" 
     | 
| 
      
 129 
     | 
    
         
            +
            case "Homu"
         
     | 
| 
      
 130 
     | 
    
         
            +
            in { downcase:, upcase: }
         
     | 
| 
      
 131 
     | 
    
         
            +
            end
         
     | 
| 
       119 
132 
     | 
    
         
             
            ```
         
     | 
| 
       120 
133 
     | 
    
         | 
| 
       121 
134 
     | 
    
         
             
            ### 4. `using PatternMatchable::#{class name}`
         
     | 
| 
         @@ -128,7 +141,9 @@ require "pattern_matchable" 
     | 
|
| 
       128 
141 
     | 
    
         
             
            # define Array#deconstruct_keys
         
     | 
| 
       129 
142 
     | 
    
         
             
            using PatternMatchable::Array
         
     | 
| 
       130 
143 
     | 
    
         | 
| 
       131 
     | 
    
         
            -
            [1, 2, 3, 4, 5] 
     | 
| 
      
 144 
     | 
    
         
            +
            case [1, 2, 3, 4, 5]
         
     | 
| 
      
 145 
     | 
    
         
            +
            in { first:, last: }
         
     | 
| 
      
 146 
     | 
    
         
            +
            end
         
     | 
| 
       132 
147 
     | 
    
         
             
            p first  # => 1
         
     | 
| 
       133 
148 
     | 
    
         
             
            p last   # => 5
         
     | 
| 
       134 
149 
     | 
    
         | 
| 
         @@ -136,12 +151,36 @@ p last   # => 5 
     | 
|
| 
       136 
151 
     | 
    
         
             
            # defined Enumerator::Lazy
         
     | 
| 
       137 
152 
     | 
    
         
             
            using PatternMatchable::Enumerator::Lazy
         
     | 
| 
       138 
153 
     | 
    
         | 
| 
       139 
     | 
    
         
            -
            (1..10).lazy.map { _1 * 2 } 
     | 
| 
      
 154 
     | 
    
         
            +
            case (1..10).lazy.map { _1 * 2 }
         
     | 
| 
      
 155 
     | 
    
         
            +
            in { first:, count: }
         
     | 
| 
      
 156 
     | 
    
         
            +
            end
         
     | 
| 
       140 
157 
     | 
    
         
             
            p first  # => 2
         
     | 
| 
       141 
158 
     | 
    
         
             
            p count  # => 10
         
     | 
| 
       142 
159 
     | 
    
         | 
| 
       143 
160 
     | 
    
         
             
            # error: NoMatchingPatternError
         
     | 
| 
       144 
     | 
    
         
            -
            "Homu" 
     | 
| 
      
 161 
     | 
    
         
            +
            case "Homu"
         
     | 
| 
      
 162 
     | 
    
         
            +
            in { downcase:, upcase: }
         
     | 
| 
      
 163 
     | 
    
         
            +
            end
         
     | 
| 
      
 164 
     | 
    
         
            +
            ```
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
            ### 5. `using PatternMatchable {class name}`
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 169 
     | 
    
         
            +
            require "pattern_matchable"
         
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
      
 171 
     | 
    
         
            +
            # define Array#deconstruct_keys
         
     | 
| 
      
 172 
     | 
    
         
            +
            using PatternMatchable Array
         
     | 
| 
      
 173 
     | 
    
         
            +
             
     | 
| 
      
 174 
     | 
    
         
            +
            case [1, 2, 3, 4, 5]
         
     | 
| 
      
 175 
     | 
    
         
            +
            in { first:, last: }
         
     | 
| 
      
 176 
     | 
    
         
            +
            end
         
     | 
| 
      
 177 
     | 
    
         
            +
            p first  # => 1
         
     | 
| 
      
 178 
     | 
    
         
            +
            p last   # => 5
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
            # error: NoMatchingPatternError
         
     | 
| 
      
 181 
     | 
    
         
            +
            case "Homu"
         
     | 
| 
      
 182 
     | 
    
         
            +
            in { downcase:, upcase: }
         
     | 
| 
      
 183 
     | 
    
         
            +
            end
         
     | 
| 
       145 
184 
     | 
    
         
             
            ```
         
     | 
| 
       146 
185 
     | 
    
         | 
| 
       147 
186 
     | 
    
         | 
    
        data/lib/pattern_matchable.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: pattern_matchable
         
     | 
| 
       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 
     | 
    
         
             
            - manga_osyo
         
     | 
| 
       8 
     | 
    
         
            -
            autorequire: 
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2020-04 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2020-11-04 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       13 
13 
     | 
    
         
             
            description: call method with pattern match.
         
     | 
| 
       14 
14 
     | 
    
         
             
            email:
         
     | 
| 
         @@ -31,7 +31,7 @@ files: 
     | 
|
| 
       31 
31 
     | 
    
         
             
            homepage: ''
         
     | 
| 
       32 
32 
     | 
    
         
             
            licenses: []
         
     | 
| 
       33 
33 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       34 
     | 
    
         
            -
            post_install_message: 
     | 
| 
      
 34 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
       35 
35 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       36 
36 
     | 
    
         
             
            require_paths:
         
     | 
| 
       37 
37 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -47,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       47 
47 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       48 
48 
     | 
    
         
             
            requirements: []
         
     | 
| 
       49 
49 
     | 
    
         
             
            rubygems_version: 3.1.2
         
     | 
| 
       50 
     | 
    
         
            -
            signing_key: 
     | 
| 
      
 50 
     | 
    
         
            +
            signing_key:
         
     | 
| 
       51 
51 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       52 
52 
     | 
    
         
             
            summary: call method with pattern match.
         
     | 
| 
       53 
53 
     | 
    
         
             
            test_files: []
         
     |