fancy-p 0.3.0 → 0.4.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 +31 -5
  3. data/lib/fancy-p/kernel_ext.rb +12 -11
  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: 48d21fa983878e6759eddc0db9fec1e940bcd26eda49d69d800c2a9813e448b5
4
+ data.tar.gz: 14ef6c60f41890099f102476ae46b77d6539b63dc0b32e32aa33f0eb6b9bcf95
5
5
  SHA512:
6
- metadata.gz: b0849a43260bf2f60e9ea20d75386594d6e04490ae67c0b4dd026083e744465ccd267c7dda866cd35d7a49acf52de3187a74f57d4bc5f05ae82a7f8a5b77e7a5
7
- data.tar.gz: ba2cd3fa17aaf94af0e7b415a0500aef0a674d8560c6adaa6021390b75307c7ef2c324fe16b33ab6eb6ab8be6f607ce75016c6364dff8c432db1d435631c9465
6
+ metadata.gz: 8fc64b440dfc9d62bfff84c0bf9608d51911444ac81aa3d1cb1de22d7512d6077e3284eb734937896f88df944738481cf7e1c8a98c6c6958dedfec12ec2055a5
7
+ data.tar.gz: 16e431de47b80efec215e51c3b8104c4818e79539742ba7b037fbb24306b62ee6e4e2e5e30ac374e5acde6e44e34c8b89f2030337a82e35f4d429a2a584f57de
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
 
@@ -59,3 +66,22 @@ print_wat['Some other string']
59
66
  # => "Some other string"
60
67
  # => "WAT WAT WAT WAT WAT WAT WAT WAT WAT WAT "
61
68
  ```
69
+
70
+
71
+ ## In a Rails Project
72
+
73
+ To automatically load and initialize the gem in a Rails project, follow these steps:
74
+
75
+ 1. Add the gem to your Gemfile:
76
+ ```ruby
77
+ gem 'fancy-p'
78
+ ```
79
+
80
+ 2. Run `bundle install`
81
+
82
+ 3. Create an initializer file in `config/initializers/fancy_p.rb` and add the following code:
83
+ ```ruby
84
+ require 'fancy-p'
85
+ ```
86
+
87
+ Now you can use the dynamic print methods anywhere in your Rails application, including controllers, models, views, and the Rails console.
@@ -4,29 +4,30 @@ module Kernel
4
4
  def method_missing(method_name, *args, &)
5
5
  super unless method_name.to_s =~ /^p.$/
6
6
 
7
- char = method_name.to_s[1]
8
7
  self.class.define_method(method_name) do |*forwarded_args|
9
- delimiter = char * 100
10
- p delimiter
11
- p(*forwarded_args)
12
- p delimiter
8
+ char = method_name.to_s[1]
9
+ print_surrounding(char, *forwarded_args)
13
10
  end
14
11
  send(method_name, *args)
15
12
  end
16
13
 
14
+ def print_surrounding(str, *args, length: 100)
15
+ delimiter = str * length
16
+ p delimiter
17
+ p(*args)
18
+ p delimiter
19
+ end
20
+
17
21
  def fp(str, *args, length: 100)
18
- delimiter = str[0] * length
22
+ delimiter = str * length
19
23
  p delimiter
20
24
  p(*args)
21
25
  p delimiter
22
26
  end
23
27
 
24
- def fp_factory(char, length: 100)
28
+ def fp_factory(str, length: 100)
25
29
  lambda { |*args|
26
- delimiter = char * length
27
- p delimiter
28
- p(*args)
29
- p delimiter
30
+ fp(str, *args, length:)
30
31
  }
31
32
  end
32
33
  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.4.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-07-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  This gem extends the Kernel module to dynamically define