qo 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/.pryrc +1 -1
  3. data/README.md +18 -0
  4. data/lib/qo.rb +4 -0
  5. data/lib/qo/version.rb +1 -1
  6. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42970cef4c751efed91fe25ec0aeaaa09e4a60e1
4
- data.tar.gz: fc6439c832bec23e75e0e080686ce2ab5e82ec5e
3
+ metadata.gz: d097b1d36fb935478c96f41a34ac4e7e74ccdcc7
4
+ data.tar.gz: 51ea508193f5156aafc7e86a1a8de2fc0e77c36b
5
5
  SHA512:
6
- metadata.gz: 1fbb43ae9bd6393399fedd716aafb843f666270db54517f40144ce1d74b57b2e799d8e23bf47fc16c2e05e646c5b2db16dfa5bd5e528801049e60c5cd360cf81
7
- data.tar.gz: 92e752aa74d56eabcec5ea245373a647939869a325d582779600e49cef7095e076ccbd839938e9bfaae7978a9909e6490e526fd9e9d0b50cbd9268bb10e944cf
6
+ metadata.gz: 8fc0fa88d3264cd2c8cafefea4be82bdd14bc7eed37d41d0e890d6c55a2352f784327db6d718c24c011b3d39b813501952c4f9859571b5ffaa812d5bf1c1259c
7
+ data.tar.gz: f6d73da83547b82ab3ad62822d1ce3fd7cab7feb396f5542431d015d907d66353bd126bcf3b4baf06a2951622468524420f0cd69a59ac5c56d6cede08dc40582
data/.pryrc CHANGED
@@ -1,5 +1,5 @@
1
1
  class Person
2
- attr_reader :name, :age
2
+ attr_accessor :name, :age
3
3
 
4
4
  def initialize(name, age)
5
5
  @name = name
data/README.md CHANGED
@@ -384,6 +384,24 @@ In this case it's trying to do a few things:
384
384
 
385
385
  If no block function is provided, it assumes an identity function (`-> v { v }`) instead. If no match is found, `nil` will be returned.
386
386
 
387
+ Now you _can_ also use a reversed version, `match_fn` (name pending better ideas), to run with map:
388
+
389
+ ```ruby
390
+ name_longer_than_three = -> person { person.name.size > 3 }
391
+
392
+ people_objects.map(&Qo.match_fn(
393
+ Qo.m(name_longer_than_three) { |person|
394
+ person.name = person.name[0..2]
395
+ person
396
+ },
397
+ Qo.m(:*)
398
+ ))
399
+
400
+ # => [Person(age: 22, name: "Rob"), Person(age: 22, name: "Rob"), Person(age: 42, name: "Foo"), Person(age: 17, name: "Bar")]
401
+ ```
402
+
403
+ So we just truncated everyone's name that was longer than three characters.
404
+
387
405
  ### 5 - Hacky Fun Time
388
406
 
389
407
  These examples will grow over the next few weeks as I think of more fun things to do with Qo. PRs welcome if you find fun uses!
data/lib/qo.rb CHANGED
@@ -20,6 +20,10 @@ module Qo
20
20
  }
21
21
  end
22
22
 
23
+ def match_fn(*qo_matchers)
24
+ -> data { match(data, *qo_matchers) }
25
+ end
26
+
23
27
  def and(*array_matchers, **keyword_matchers)
24
28
  Qo::Matcher.new('and', *array_matchers, **keyword_matchers)
25
29
  end
@@ -1,3 +1,3 @@
1
1
  module Qo
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Weaver