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 +4 -4
- data/README.md +5 -27
- data/lib/delight/enumerator/select_by.rb +3 -4
- data/lib/delight/enumerator/select_by_methods.rb +34 -0
- data/lib/delight/enumerator.rb +1 -1
- data/lib/delight/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2cd266511e6dbdfb174a5605837cf75cbebfb108b42ee5eca092c220e1ed112
|
4
|
+
data.tar.gz: 41edbb872467c0fe4c83c9a376e446f24bbf9687f0df7ea99958e8d38689e237
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0124922833bb99d4471f3fa968963cc70076b8529eeac5165a81f299df474b5ed13bc6a37d8e2d251ded434e2e25fb75d5f1db49b84a6882329d94faa1775fc3'
|
7
|
+
data.tar.gz: 3fefc8b830592df6eafdf4b0a06af78f7bde1e40a90d60be19bac9bf52338101a651c771871ec6d1cf08ac2accc45d6c9d0fc94b3993942883fe85951e1eca7c
|
data/README.md
CHANGED
@@ -1,43 +1,21 @@
|
|
1
1
|
# Delight
|
2
2
|
|
3
|
-
|
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
|
-
|
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
|
-
|
8
|
+
bundle add delight
|
21
9
|
```
|
22
10
|
|
23
11
|
## Usage
|
24
12
|
|
25
|
-
|
13
|
+
[...]
|
26
14
|
|
27
15
|
## Development
|
28
16
|
|
29
|
-
|
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).
|
@@ -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
|
data/lib/delight/enumerator.rb
CHANGED
data/lib/delight/version.rb
CHANGED
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.
|
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
|