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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -5
  3. data/lib/fancy-p/kernel_ext.rb +15 -15
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3adfff73eafe042635fe1633d11256fff1f564bf902e2e13e45b47193e3a8a9e
4
- data.tar.gz: 25922c5f09128eec12a7fb436c5386eb57384ea22e8bef573683bc5e03eaf395
3
+ metadata.gz: 74e162fbcd8bb11087d9ca029f8e031d0bb7e276b9c1a16930ea7074e099a98c
4
+ data.tar.gz: 03f5a5b646843af88597621608efaaa211c7f2720bd51853fbbd15d1f9ccc400
5
5
  SHA512:
6
- metadata.gz: b0849a43260bf2f60e9ea20d75386594d6e04490ae67c0b4dd026083e744465ccd267c7dda866cd35d7a49acf52de3187a74f57d4bc5f05ae82a7f8a5b77e7a5
7
- data.tar.gz: ba2cd3fa17aaf94af0e7b415a0500aef0a674d8560c6adaa6021390b75307c7ef2c324fe16b33ab6eb6ab8be6f607ce75016c6364dff8c432db1d435631c9465
6
+ metadata.gz: 7dce6f3696199d32f9af8c9e050bbaa626fbcd9f508eb403f8000cf0eaa53fce4ed342d849b2739d5aea176cf04373cfe5d87ce0beec4266b3906834c8717002
7
+ data.tar.gz: aac526ca052709f0fb420e1c6f9f1cf237d31b2f144550e9d83ae5f118d652e750d4e6cbc4535cdcd2b3844a06b1853d1b7779b9e8d34496a3281a74a3322636
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Fancy-p
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
- # => "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
29
+ # => "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
32
30
  # => "Hello, world!"
33
- # => "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
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
 
@@ -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
- char = method_name.to_s[1]
8
- self.class.define_method(method_name) do |*forwarded_args|
9
- delimiter = char * 100
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[0] * length
19
- p delimiter
15
+ delimiter = str * length
16
+ puts delimiter
20
17
  p(*args)
21
- p delimiter
18
+ puts delimiter
22
19
  end
23
20
 
24
- def fp_factory(char, length: 100)
21
+ def fp_factory(str, length: 100)
25
22
  lambda { |*args|
26
- delimiter = char * length
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.3.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-16 00:00:00.000000000 Z
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