fancy-p 0.1.0 → 0.2.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 +45 -2
- data/lib/fancy-p/kernel_ext.rb +17 -1
- 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: 107472a1d3ade61bdb4068582e08aee4b23c002eea353a34767af536cd0f21c1
|
4
|
+
data.tar.gz: f42accf1a9f6cb0aa6f5c3997a9816ce273ee36adfd2dc3f395f7b79155c305f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e60ec3eb24e1ebca75111c239d3dada43eaa0f059118e4821eff34d7487543e083db9bca5be5d12eefda699784e9f2de124a632cf4e1cb6722745efcce2d6e75
|
7
|
+
data.tar.gz: 5f740f42b4dc6e0a948503cd1f47e8e59521995e79d16c28044a0c5e5bcb173004e372652694a8cf9aeed834bf24b40377595b89efc9189faf839549bd2bdaab
|
data/README.md
CHANGED
@@ -2,9 +2,18 @@
|
|
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
|
5
|
-
`p!`, `
|
6
|
-
after printing the provided arguments.
|
5
|
+
`p!`, `p1`, `p2`, etc., which print a specified character 100 times before and after.
|
7
6
|
|
7
|
+
This exists simply because I found myself writing `p '!' * 100` too often. I
|
8
|
+
followed a similar pattern for `p 1 * 100`, `p2 * 100`, etc.
|
9
|
+
|
10
|
+
For unpermitted characters, you can use the `fp` method, which takes a string
|
11
|
+
of any length and prints it with a specified special character or str.
|
12
|
+
|
13
|
+
You can also create your own print methods `pf_factory` method.
|
14
|
+
|
15
|
+
|
16
|
+
```ruby
|
8
17
|
## Installation
|
9
18
|
|
10
19
|
Add this line to your application's Gemfile:
|
@@ -12,3 +21,37 @@ Add this line to your application's Gemfile:
|
|
12
21
|
```ruby
|
13
22
|
gem 'fancy-p'
|
14
23
|
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'fancy-p'
|
29
|
+
|
30
|
+
p! 'Hello, world!'
|
31
|
+
# => "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
32
|
+
# => "Hello, world!"
|
33
|
+
# => "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
34
|
+
|
35
|
+
p1 'Hello, world!'
|
36
|
+
# => "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
|
37
|
+
# => "Hello, world!"
|
38
|
+
# => "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111!!"
|
39
|
+
|
40
|
+
fp "@", "Hello, world!"
|
41
|
+
# => "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
|
42
|
+
# => "Hello, world!"
|
43
|
+
# => "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
|
44
|
+
|
45
|
+
print_wat = pf_factory "WAT ", length: 10
|
46
|
+
|
47
|
+
print_wat['Hello, world!']
|
48
|
+
# => "WAT WAT WAT WAT WAT WAT WAT WAT WAT WAT"
|
49
|
+
# => "Hello, world!"
|
50
|
+
# => "WAT WAT WAT WAT WAT WAT WAT WAT WAT WAT"
|
51
|
+
|
52
|
+
print_wat['Some other string']
|
53
|
+
|
54
|
+
# => "WAT WAT WAT WAT WAT WAT WAT WAT WAT WAT"
|
55
|
+
# => "Some other string"
|
56
|
+
# => "WAT WAT WAT WAT WAT WAT WAT WAT WAT WAT"
|
57
|
+
```
|
data/lib/fancy-p/kernel_ext.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
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, &)
|
5
5
|
super unless method_name.to_s =~ /^p.$/
|
6
6
|
|
7
7
|
char = method_name.to_s[1]
|
@@ -13,4 +13,20 @@ module Kernel
|
|
13
13
|
end
|
14
14
|
send(method_name, *args)
|
15
15
|
end
|
16
|
+
|
17
|
+
def fp(str, *args, length: 100)
|
18
|
+
delimiter = str[0] * length
|
19
|
+
p delimiter
|
20
|
+
p(*args)
|
21
|
+
p delimiter
|
22
|
+
end
|
23
|
+
|
24
|
+
def pf_factory(char, length: 100)
|
25
|
+
lambda { |*args|
|
26
|
+
delimiter = char * length
|
27
|
+
p delimiter
|
28
|
+
p(*args)
|
29
|
+
p delimiter
|
30
|
+
}
|
31
|
+
end
|
16
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fancy-p
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Rhodes
|
@@ -43,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: '0'
|
45
45
|
requirements: []
|
46
|
-
rubygems_version: 3.
|
46
|
+
rubygems_version: 3.5.13
|
47
47
|
signing_key:
|
48
48
|
specification_version: 4
|
49
49
|
summary: A gem that dynamically defines fancy print methods with different characters
|