rainbow_printer 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43c9693fd79f975f0c9ac09216c32974e85d23aa5ffc9c6dc2c8326ace40e8f7
4
- data.tar.gz: af8147661784fd8a94735fd6d54d18526d53e12e0fade44551a187699c62293f
3
+ metadata.gz: adfe5310079354a97fa9ee74976c48be00ebbc3ec4d5cecc1c0e2d30338feace
4
+ data.tar.gz: a55f3fd32d94665c3eee9b434861da434faa5909810b9af3d528dbce473e75b7
5
5
  SHA512:
6
- metadata.gz: 5d42bbfd44662d3406b5690f9541cdeb73af37d5247434e5bf0ea011a2e845642f6a2b84261a075c52066197ac46237eeffcf9aaf63d7f66abca26cc84662ed3
7
- data.tar.gz: 75c6e32d28b364ae67b2cbc6367bf21a9d4f62de4c439c4c176fddead17fe57e4749867484ea8bff21560cdbf59fd3c2a18b00e23fc2bb755fd88eda6fe3a0e8
6
+ metadata.gz: 7e4bd5397680b7c61118e0d5012d7103d3ef69ee406c51a4de19b8c2ef55b56a3c6d66b9effba344e7ddffc169c60984131f1c79d21d6d19509dfb7b005672cf
7
+ data.tar.gz: 1c874a0559ebe51912b31209e9782e30fbc883e7c82b7254b1b386be95c3a510f29f7003be806639402fc432435590b8adf1a526c4978690ea3e90f9b10b863e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rainbow_printer (0.1.0)
4
+ rainbow_printer (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
  ![](https://github.com/dereknguyen269/rainbow_printer/blob/master/demos/demo.png)
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
+ ![](https://github.com/dereknguyen269/rainbow_printer/blob/master/demos/sidekiq.png)
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.
Binary file
@@ -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$$ |_|
@@ -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
- output += "\e[38;5;#{rainbow}m#{str}\e[0m"
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
@@ -1,3 +1,3 @@
1
1
  module RainbowPrinter
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  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.0
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: 2020-09-29 00:00:00.000000000 Z
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