tapenade 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -14
- data/lib/tapenade/delegator.rb +10 -0
- data/lib/tapenade/tap.rb +8 -0
- data/lib/tapenade/version.rb +1 -1
- data/lib/tapenade.rb +3 -2
- metadata +12 -13
- data/lib/tapenade/module.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27a619de5b576a268b65c1abd55af9c9296b2c0b2fa88e2759f0f61b265cabd4
|
4
|
+
data.tar.gz: 524e491e466cdf607abcee4c41f270fa0da7dd2e869bf663b31ebcddad7a69ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3933c8a404c457397648bbdb6ce0574415b6d9ba811011eedcce998b45181f718accc3a08aec714ebdb513dc0b21a3f83f77c348bdcab5e1490fd67029fc2484
|
7
|
+
data.tar.gz: d3fc7f6252a072563ecaf0968661a392958a7d8420e2a99c794c8c99cdbe96467ebf8ab7547e2cd672f9fd176a6df1f51fee98cae3deedf0d600880b2d06b605
|
data/README.md
CHANGED
@@ -1,30 +1,23 @@
|
|
1
1
|
# Tapenade
|
2
2
|
|
3
|
-
|
3
|
+
Tapenade allows to chain method after `tap` instead of using a block.
|
4
4
|
|
5
5
|
## Examples
|
6
6
|
|
7
7
|
```ruby
|
8
|
-
# Without any tap method:
|
9
|
-
def update_user
|
10
|
-
user = User.find(param[:id])
|
11
|
-
user.update!(user_params)
|
12
|
-
return user
|
13
|
-
end
|
14
|
-
|
15
8
|
# With Ruby's tap
|
16
|
-
|
17
|
-
|
18
|
-
end
|
9
|
+
User.find(param[:id]).tap { |user| user.update!(user_params) }
|
10
|
+
# => returns the user
|
19
11
|
|
20
12
|
# With Tapenade:
|
21
|
-
|
22
|
-
|
23
|
-
end
|
13
|
+
User.find(param[:id]).tap.update!(user_params)
|
14
|
+
# => returns the user
|
24
15
|
```
|
25
16
|
|
26
17
|
Examples are using Rails models but it works with any method on any object.
|
27
18
|
|
19
|
+
You can of course still use `tap` with blocks as usual.
|
20
|
+
|
28
21
|
## Installation
|
29
22
|
|
30
23
|
Add this line to your application's Gemfile:
|
@@ -33,6 +26,8 @@ Add this line to your application's Gemfile:
|
|
33
26
|
gem "tapenade"
|
34
27
|
```
|
35
28
|
|
29
|
+
That's all.
|
30
|
+
|
36
31
|
## License
|
37
32
|
|
38
33
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/tapenade/tap.rb
ADDED
data/lib/tapenade/version.rb
CHANGED
data/lib/tapenade.rb
CHANGED
metadata
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tapenade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benoit MARTIN-CHAVE
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
prefix it with tap_ !
|
13
|
+
description: Improved tap method
|
15
14
|
email:
|
16
|
-
- benoit@martin-chave.
|
15
|
+
- benoit@martin-chave.com
|
17
16
|
executables: []
|
18
17
|
extensions: []
|
19
18
|
extra_rdoc_files: []
|
@@ -21,13 +20,14 @@ files:
|
|
21
20
|
- LICENSE.txt
|
22
21
|
- README.md
|
23
22
|
- lib/tapenade.rb
|
24
|
-
- lib/tapenade/
|
23
|
+
- lib/tapenade/delegator.rb
|
24
|
+
- lib/tapenade/tap.rb
|
25
25
|
- lib/tapenade/version.rb
|
26
26
|
homepage: https://github.com/benoitmc/tapenade
|
27
27
|
licenses:
|
28
28
|
- MIT
|
29
29
|
metadata: {}
|
30
|
-
post_install_message:
|
30
|
+
post_install_message:
|
31
31
|
rdoc_options: []
|
32
32
|
require_paths:
|
33
33
|
- lib
|
@@ -35,16 +35,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
35
35
|
requirements:
|
36
36
|
- - ">="
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
version:
|
38
|
+
version: 2.7.0
|
39
39
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '0'
|
44
44
|
requirements: []
|
45
|
-
rubygems_version: 3.
|
46
|
-
signing_key:
|
45
|
+
rubygems_version: 3.3.7
|
46
|
+
signing_key:
|
47
47
|
specification_version: 4
|
48
|
-
summary:
|
49
|
-
it with tap_ !
|
48
|
+
summary: Improved tap method
|
50
49
|
test_files: []
|
data/lib/tapenade/module.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module Tapenade
|
2
|
-
def self.prefix
|
3
|
-
"tap_".freeze
|
4
|
-
end
|
5
|
-
|
6
|
-
private
|
7
|
-
|
8
|
-
def respond_to_missing?(method, include_private = false)
|
9
|
-
respond_to_tapenade?(method) || super
|
10
|
-
end
|
11
|
-
|
12
|
-
def method_missing(method, *args, **kwargs, &block)
|
13
|
-
return super unless respond_to_tapenade?(method)
|
14
|
-
# Ruby 2.6 + 2.7 friendly
|
15
|
-
eval "#{method.to_s[Tapenade.prefix.length..-1]}(*args, **kwargs, &block)"
|
16
|
-
self
|
17
|
-
end
|
18
|
-
|
19
|
-
def respond_to_tapenade?(method)
|
20
|
-
method.to_s.start_with?(Tapenade.prefix) && respond_to?(method.to_s[Tapenade.prefix.length..-1])
|
21
|
-
end
|
22
|
-
end
|