delight 0.1.3 → 0.1.5

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: 8b71843e7ea31f5cd0ead34733ab94d3505e09db476072a9e40f189aa969df72
4
- data.tar.gz: 259873047a56a06f96a907c394a1ce6280021ea886831e43283e3cc1886938fe
3
+ metadata.gz: d2cd266511e6dbdfb174a5605837cf75cbebfb108b42ee5eca092c220e1ed112
4
+ data.tar.gz: 41edbb872467c0fe4c83c9a376e446f24bbf9687f0df7ea99958e8d38689e237
5
5
  SHA512:
6
- metadata.gz: 3300b566241e7874db2f180fd6fb5f406cb0a48bbf81955b8fb2d561a5e83f56319144083d9e98cfd74642f4081b6586e92288ffc368a6840bef0e751b8b17e4
7
- data.tar.gz: a44f89bbf3927b3bc4b79fe677912311d16f29d16a414eb5ab4132aa3c939864cc840aad2c820b8433d75f44b749b62b5b79962f25e6db0c14db8149a4d4a781
6
+ metadata.gz: '0124922833bb99d4471f3fa968963cc70076b8529eeac5165a81f299df474b5ed13bc6a37d8e2d251ded434e2e25fb75d5f1db49b84a6882329d94faa1775fc3'
7
+ data.tar.gz: 3fefc8b830592df6eafdf4b0a06af78f7bde1e40a90d60be19bac9bf52338101a651c771871ec6d1cf08ac2accc45d6c9d0fc94b3993942883fe85951e1eca7c
data/README.md CHANGED
@@ -1,43 +1,21 @@
1
1
  # Delight
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ Delight is a Ruby gem offering small yet useful extensions to the core Ruby classes. Those extensions are implemented as Refinements, which means they are only available in the scope where they are explicitly activated. This allows you to use them without worrying about polluting the global namespace or causing conflicts with other gems.
4
4
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/delight`. To experiment with that code, run `bin/console` for an interactive prompt.
6
-
7
- ## Installation
8
-
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
- Install the gem and add to the application's Gemfile by executing:
12
-
13
- ```bash
14
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
15
- ```
16
-
17
- If bundler is not being used to manage dependencies, install the gem by executing:
5
+ ## [Installation](Installation)
18
6
 
19
7
  ```bash
20
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
8
+ bundle add delight
21
9
  ```
22
10
 
23
11
  ## Usage
24
12
 
25
- TODO: Write usage instructions here
13
+ [...]
26
14
 
27
15
  ## Development
28
16
 
29
- 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.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/delight. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/delight/blob/main/CODE_OF_CONDUCT.md).
17
+ [...]
36
18
 
37
19
  ## License
38
20
 
39
21
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
-
41
- ## Code of Conduct
42
-
43
- Everyone interacting in the Delight project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/delight/blob/main/CODE_OF_CONDUCT.md).
@@ -1,10 +1,9 @@
1
1
  module Delight
2
2
  module Enumerator
3
3
  module SelectBy
4
- def select_by(**)
5
- select do |element|
6
- collection_matcher(element, **)
7
- end
4
+ refine Enumerable do
5
+ import_methods CollectionMatcher
6
+ import_methods SelectByMethods
8
7
  end
9
8
  end
10
9
  end
@@ -0,0 +1,34 @@
1
+ module Delight
2
+ module Enumerator
3
+ module SelectByMethods
4
+ # Filter collection elements using method calls and values passed as
5
+ # keyword arguments.
6
+ #
7
+ # @return [Array] containingg elements that match the passed arguments.
8
+ #
9
+ # @example
10
+ # ["String", 1, 3, :symbol, 'string'].select_by(class: String)
11
+ # # => ["String", 'string']
12
+ #
13
+ # Person = Struct.new(:name, :age)
14
+ #
15
+ # people = [
16
+ # Person.new("John", 30),
17
+ # Person.new("Jane", 25),
18
+ # Person.new("Alice", 30),
19
+ # ]
20
+ #
21
+ # people.select_by(age: 30)
22
+ # # => [
23
+ # # Person.new("John", 30),
24
+ # # Person.new("Alice", 30),
25
+ # # ]
26
+ #
27
+ def select_by(**)
28
+ select do |element|
29
+ collection_matcher(element, **)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -4,7 +4,7 @@ module Delight
4
4
  import_methods CollectionMatcher
5
5
  import_methods HashCollectionMatcher
6
6
 
7
- import_methods SelectBy
7
+ import_methods SelectByMethods
8
8
  import_methods SelectByKey
9
9
 
10
10
  import_methods DetectBang
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Delight
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mariusz Droździel
@@ -45,6 +45,7 @@ files:
45
45
  - lib/delight/enumerator/hash_collection_matcher.rb
46
46
  - lib/delight/enumerator/select_by.rb
47
47
  - lib/delight/enumerator/select_by_key.rb
48
+ - lib/delight/enumerator/select_by_methods.rb
48
49
  - lib/delight/enumerator/sole_by.rb
49
50
  - lib/delight/enumerator/sole_by_key.rb
50
51
  - lib/delight/enumerator/try_sole_by.rb