rainbow_printer 0.1.0 → 0.1.1
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/Gemfile.lock +1 -1
- data/README.md +28 -0
- data/demos/sidekiq.png +0 -0
- data/demos/text.txt +12 -0
- data/lib/rainbow_printer.rb +16 -2
- data/lib/rainbow_printer/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adfe5310079354a97fa9ee74976c48be00ebbc3ec4d5cecc1c0e2d30338feace
|
4
|
+
data.tar.gz: a55f3fd32d94665c3eee9b434861da434faa5909810b9af3d528dbce473e75b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e4bd5397680b7c61118e0d5012d7103d3ef69ee406c51a4de19b8c2ef55b56a3c6d66b9effba344e7ddffc169c60984131f1c79d21d6d19509dfb7b005672cf
|
7
|
+
data.tar.gz: 1c874a0559ebe51912b31209e9782e30fbc883e7c82b7254b1b386be95c3a510f29f7003be806639402fc432435590b8adf1a526c4978690ea3e90f9b10b863e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -35,10 +35,38 @@ Easy to print yout text or array with Rainbow Printer.
|
|
35
35
|
```
|
36
36
|
Btw, you can use alias `rb_puts` instead of `rainbow_printer`.
|
37
37
|
|
38
|
+
- Read from file:
|
39
|
+
|
40
|
+
```
|
41
|
+
rainbow_printer file_path: 'your_file_path'
|
42
|
+
```
|
43
|
+
|
38
44
|
Demo:
|
39
45
|
|
40
46
|

|
41
47
|
|
48
|
+
Read from file:
|
49
|
+
|
50
|
+
File content look like:
|
51
|
+
|
52
|
+
```
|
53
|
+
m,
|
54
|
+
`$b
|
55
|
+
.ss, $$: .,d$
|
56
|
+
`$$P,d$P' .,md$P"'
|
57
|
+
,$$$$$b/md$$$P^'
|
58
|
+
.d$$$$$$/$$$P'
|
59
|
+
$$^' `"/$$$' ____ _ _ _ _
|
60
|
+
$: ,$$: / ___|(_) __| | ___| | _(_) __ _
|
61
|
+
`b :$$ \___ \| |/ _` |/ _ \ |/ / |/ _` |
|
62
|
+
$$: ___) | | (_| | __/ <| | (_| |
|
63
|
+
$$ |____/|_|\__,_|\___|_|\_\_|\__, |
|
64
|
+
.d$$ |_|
|
65
|
+
```
|
66
|
+
Out put
|
67
|
+
|
68
|
+

|
69
|
+
|
42
70
|
## Development
|
43
71
|
|
44
72
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/demos/sidekiq.png
ADDED
Binary file
|
data/demos/text.txt
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
m,
|
2
|
+
`$b
|
3
|
+
.ss, $$: .,d$
|
4
|
+
`$$P,d$P' .,md$P"'
|
5
|
+
,$$$$$b/md$$$P^'
|
6
|
+
.d$$$$$$/$$$P'
|
7
|
+
$$^' `"/$$$' ____ _ _ _ _
|
8
|
+
$: ,$$: / ___|(_) __| | ___| | _(_) __ _
|
9
|
+
`b :$$ \___ \| |/ _` |/ _ \ |/ / |/ _` |
|
10
|
+
$$: ___) | | (_| | __/ <| | (_| |
|
11
|
+
$$ |____/|_|\__,_|\___|_|\_\_|\__, |
|
12
|
+
.d$$ |_|
|
data/lib/rainbow_printer.rb
CHANGED
@@ -23,14 +23,26 @@ module RainbowPrinter
|
|
23
23
|
@colors[@color_index]
|
24
24
|
end
|
25
25
|
|
26
|
-
def puts_with_rainbow(input)
|
26
|
+
def puts_with_rainbow(input, opts = {})
|
27
|
+
from_file = opts[:from_file]
|
27
28
|
output = ''
|
28
29
|
input.to_s.split('').each do |str|
|
29
|
-
|
30
|
+
if from_file
|
31
|
+
output += "\e[38;5;#{rainbow}m#{str}"
|
32
|
+
else
|
33
|
+
output += "\e[38;5;#{rainbow}m#{str}\e[0m"
|
34
|
+
end
|
30
35
|
end
|
31
36
|
puts output
|
32
37
|
end
|
33
38
|
|
39
|
+
def read_from_file(file_path)
|
40
|
+
content = File.open(file_path, "r")
|
41
|
+
content.each_line do |line|
|
42
|
+
puts_with_rainbow line, from_file: true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
34
46
|
def self.puts(input)
|
35
47
|
if input.is_a?(String)
|
36
48
|
RainbowPrinter::Core.new.puts_with_rainbow input
|
@@ -38,6 +50,8 @@ module RainbowPrinter
|
|
38
50
|
input.each do |child|
|
39
51
|
RainbowPrinter::Core.new.puts_with_rainbow child
|
40
52
|
end
|
53
|
+
elsif input.is_a?(Hash)
|
54
|
+
RainbowPrinter::Core.new.read_from_file(input[:file_path])
|
41
55
|
end
|
42
56
|
end
|
43
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rainbow_printer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: "Rainbow Printer, it adds some methods to help your output display look
|
14
14
|
likes 7 colours of the rainbow \U0001F308"
|
@@ -25,6 +25,8 @@ files:
|
|
25
25
|
- bin/console
|
26
26
|
- bin/setup
|
27
27
|
- demos/demo.png
|
28
|
+
- demos/sidekiq.png
|
29
|
+
- demos/text.txt
|
28
30
|
- lib/rainbow_printer.rb
|
29
31
|
- lib/rainbow_printer/version.rb
|
30
32
|
- rainbow_printer.gemspec
|