fancy-p 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +49 -2
  3. data/lib/fancy-p/kernel_ext.rb +17 -1
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c126e5b53e5835c9bcf72410a0ef7cf48665bbd5b849cac018aeb590c3af7303
4
- data.tar.gz: 5875b9ae2d8ada99f4aca2b000920fec11acce6b37c36ab1c27a6f01169dbc81
3
+ metadata.gz: 3adfff73eafe042635fe1633d11256fff1f564bf902e2e13e45b47193e3a8a9e
4
+ data.tar.gz: 25922c5f09128eec12a7fb436c5386eb57384ea22e8bef573683bc5e03eaf395
5
5
  SHA512:
6
- metadata.gz: c4dbf91a334b92b5a1dfc1d6c33467c0ebba0705b942b7e59aa70f7e9501a0537c4a188567c6767100536f071c2d59215cdab517600fb3f826e20309a7af655c
7
- data.tar.gz: 3f123975c87922f614202ac3e749763490997a0ef52864b4bf50e7a95e5afe75cf82c4ad4f2160fa1ae83c2e520aea1ea7b1d367e09d0eb06c5689e9ac924fd1
6
+ metadata.gz: b0849a43260bf2f60e9ea20d75386594d6e04490ae67c0b4dd026083e744465ccd267c7dda866cd35d7a49acf52de3187a74f57d4bc5f05ae82a7f8a5b77e7a5
7
+ data.tar.gz: ba2cd3fa17aaf94af0e7b415a0500aef0a674d8560c6adaa6021390b75307c7ef2c324fe16b33ab6eb6ab8be6f607ce75016c6364dff8c432db1d435631c9465
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!`, `p@`, `p$`, etc., which print a specified character 100 times before and
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,41 @@ 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
+ # => "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
32
+ # => "Hello, world!"
33
+ # => "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
34
+
35
+ p1 'Hello, world!'
36
+ # => "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
37
+ # => "Hello, world!"
38
+ # => "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
39
+
40
+ fp "@", "Hello, world!"
41
+ # => "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
42
+ # => "Hello, world!"
43
+ # => "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
44
+
45
+ fp "@", "Hello, world!", length: 14
46
+ # => "@@@@@@@@@@@@@@"
47
+ # => "Hello, world!"
48
+ # => "@@@@@@@@@@@@@@"
49
+
50
+ print_wat = fp_factory "WAT ", length: 10
51
+
52
+ print_wat['Hello, world!']
53
+ # => "WAT WAT WAT WAT WAT WAT WAT WAT WAT WAT "
54
+ # => "Hello, world!"
55
+ # => "WAT WAT WAT WAT WAT WAT WAT WAT WAT WAT "
56
+
57
+ print_wat['Some other string']
58
+ # => "WAT WAT WAT WAT WAT WAT WAT WAT WAT WAT "
59
+ # => "Some other string"
60
+ # => "WAT WAT WAT WAT WAT WAT WAT WAT WAT WAT "
61
+ ```
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kernel
4
- def method_missing(method_name, *args, &block)
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 fp_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.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Rhodes
@@ -36,14 +36,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 3.1.0
39
+ version: 2.0.0
40
40
  required_rubygems_version: !ruby/object:Gem::Requirement
41
41
  requirements:
42
42
  - - ">="
43
43
  - !ruby/object:Gem::Version
44
44
  version: '0'
45
45
  requirements: []
46
- rubygems_version: 3.4.19
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