fancy-p 0.3.0 → 0.5.0
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 +12 -5
- data/lib/fancy-p/kernel_ext.rb +15 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74e162fbcd8bb11087d9ca029f8e031d0bb7e276b9c1a16930ea7074e099a98c
|
4
|
+
data.tar.gz: 03f5a5b646843af88597621608efaaa211c7f2720bd51853fbbd15d1f9ccc400
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dce6f3696199d32f9af8c9e050bbaa626fbcd9f508eb403f8000cf0eaa53fce4ed342d849b2739d5aea176cf04373cfe5d87ce0beec4266b3906834c8717002
|
7
|
+
data.tar.gz: aac526ca052709f0fb420e1c6f9f1cf237d31b2f144550e9d83ae5f118d652e750d4e6cbc4535cdcd2b3844a06b1853d1b7779b9e8d34496a3281a74a3322636
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# fancy-p
|
2
2
|
|
3
3
|
`fancy-p` is a Ruby gem that extends the Kernel module to dynamically define
|
4
4
|
print methods with different characters. It allows you to create methods like
|
@@ -13,9 +13,7 @@ of any length and prints it with a specified special character or str.
|
|
13
13
|
You can also create your own print methods `pf_factory` method.
|
14
14
|
|
15
15
|
|
16
|
-
```ruby
|
17
16
|
## Installation
|
18
|
-
|
19
17
|
Add this line to your application's Gemfile:
|
20
18
|
|
21
19
|
```ruby
|
@@ -28,14 +26,19 @@ gem 'fancy-p'
|
|
28
26
|
require 'fancy-p'
|
29
27
|
|
30
28
|
p! 'Hello, world!'
|
31
|
-
# => "
|
29
|
+
# => "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
32
30
|
# => "Hello, world!"
|
33
|
-
# => "
|
31
|
+
# => "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
34
32
|
|
35
33
|
p1 'Hello, world!'
|
36
34
|
# => "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
|
37
35
|
# => "Hello, world!"
|
38
36
|
# => "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
|
37
|
+
```
|
38
|
+
|
39
|
+
|
40
|
+
```rb
|
41
|
+
require 'fancy-p'
|
39
42
|
|
40
43
|
fp "@", "Hello, world!"
|
41
44
|
# => "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
|
@@ -46,6 +49,10 @@ fp "@", "Hello, world!", length: 14
|
|
46
49
|
# => "@@@@@@@@@@@@@@"
|
47
50
|
# => "Hello, world!"
|
48
51
|
# => "@@@@@@@@@@@@@@"
|
52
|
+
```
|
53
|
+
|
54
|
+
```rb
|
55
|
+
require 'fancy-p'
|
49
56
|
|
50
57
|
print_wat = fp_factory "WAT ", length: 10
|
51
58
|
|
data/lib/fancy-p/kernel_ext.rb
CHANGED
@@ -1,32 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Kernel
|
4
|
-
def method_missing(method_name, *args, &)
|
4
|
+
def method_missing(method_name, *args, &block)
|
5
5
|
super unless method_name.to_s =~ /^p.$/
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
p delimiter
|
11
|
-
p(*forwarded_args)
|
12
|
-
p delimiter
|
7
|
+
define_singleton_method(method_name) do |*forwarded_args|
|
8
|
+
char = method_name.to_s[1]
|
9
|
+
fp(char, *forwarded_args)
|
13
10
|
end
|
14
11
|
send(method_name, *args)
|
15
12
|
end
|
16
13
|
|
17
14
|
def fp(str, *args, length: 100)
|
18
|
-
delimiter = str
|
19
|
-
|
15
|
+
delimiter = str * length
|
16
|
+
puts delimiter
|
20
17
|
p(*args)
|
21
|
-
|
18
|
+
puts delimiter
|
22
19
|
end
|
23
20
|
|
24
|
-
def fp_factory(
|
21
|
+
def fp_factory(str, length: 100)
|
25
22
|
lambda { |*args|
|
26
|
-
|
27
|
-
p delimiter
|
28
|
-
p(*args)
|
29
|
-
p delimiter
|
23
|
+
fp(str, *args, length:)
|
30
24
|
}
|
31
25
|
end
|
26
|
+
|
27
|
+
def fp_define(str, length: 100, method_name: str.strip)
|
28
|
+
define_singleton_method("fp_#{method_name.strip}") do |*args|
|
29
|
+
fp(str, *args, length:)
|
30
|
+
end
|
31
|
+
end
|
32
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fancy-p
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Rhodes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06
|
11
|
+
date: 2024-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
This gem extends the Kernel module to dynamically define
|