fprinter 0.1.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.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NzhjMWU3MzA4NDMzNGZhYTEyYmNkMmIwZDQ1NzNjMGUxYzg5NzM3NQ==
5
+ data.tar.gz: !binary |-
6
+ ZGFiMjU5NDVlNTY1NDkzN2VjOWFmODRhMGNhYzU1OTMwZTZkNmU5YQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZTNhZmIyN2ZiYzVhZmJiYWM0Mjg5MjI3YzFkNGIwZjkzYWU4Mjc1NTdhYmEz
10
+ MTA1NDYzMmVkY2QxMDQ5ZDE2ODgwMmJlZjgyMDRkMzk0YjVkMDVlMDVlOGNl
11
+ ODk5MGRjY2M4YjA5NmU3ZmVhNWVmMTk4YmY2MTY2NWUwNTg1Mjc=
12
+ data.tar.gz: !binary |-
13
+ MDU1OWExOWVjMzAzZThhYzM5YWQ3MGJlYWZkZDVmMmUwZWYxZmM0OWU3Nzgx
14
+ NmViODZjYTY3MThiNDUyNzM1MGQxMTdhNjFjZjNhZWJmNTljZjI3MzBhYjk2
15
+ OWQ4YjU4ODcyYjlhYjMxMGI2Mzk1YWU1OWZjMDRhMzJlOGQ1NzM=
@@ -0,0 +1,3 @@
1
+ require 'fprinter/display_change'
2
+ require 'fprinter/printer_change'
3
+ require 'fprinter/screen'
@@ -0,0 +1,162 @@
1
+ require_relative 'screen.rb'
2
+ module FPrinter
3
+ def self.bold(str)
4
+ print "\e[1m" + str + "\e[0m\n"
5
+ end
6
+
7
+ def self.blink(str, sec = 1)
8
+ print "\e[5m" + str + "\e[0m\n"
9
+ end
10
+
11
+ def self.underline(str)
12
+ print "\e[4m" + str + "\e[0m\n"
13
+ end
14
+
15
+ def self.highlight(str)
16
+ print "\e[7m" + str + "\e[0m\n"
17
+ end
18
+
19
+ def self.black(str)
20
+ print "\e[30m" + str + "\e[0m\n"
21
+ end
22
+
23
+ def self.red(str)
24
+ print "\e[31m" + str + "\e[0m\n"
25
+ end
26
+
27
+ def self.green(str)
28
+ print "\e[32m" + str + "\e[0m\n"
29
+ end
30
+
31
+ def self.yellow(str)
32
+ print "\e[33m" + str + "\e[0m\n"
33
+ end
34
+
35
+ def self.blue(str)
36
+ print "\e[34m" + str + "\e[0m\n"
37
+ end
38
+
39
+ def self.magenta(str)
40
+ print "\e[35m" + str + "\e[0m\n"
41
+ end
42
+
43
+ def self.cyan(str)
44
+ print "\e[36m" + str + "\e[0m\n"
45
+ end
46
+
47
+ def self.white(str)
48
+ print "\e[37m" + str + "\e[0m\n"
49
+ end
50
+
51
+ def self.highlighted_black(str)
52
+ print "\e[40m" + str + "\e[0m\n"
53
+ end
54
+
55
+ def self.highlighted_red(str)
56
+ print "\e[41m" + str + "\e[0m\n"
57
+ end
58
+
59
+ def self.highlighted_green(str)
60
+ print "\e[42m" + str + "\e[0m\n"
61
+ end
62
+
63
+ def self.highlighted_yellow(str)
64
+ print "\e[43m" + str + "\e[0m\n"
65
+ end
66
+
67
+ def self.highlighted_blue(str)
68
+ print "\e[44m" + str + "\e[0m\n"
69
+ end
70
+
71
+ def self.highlighted_magenta(str)
72
+ print "\e[45m" + str + "\e[0m\n"
73
+ end
74
+
75
+ def self.highlighted_cyan(str)
76
+ print "\e[46m" + str + "\e[0m\n"
77
+ end
78
+
79
+ def self.highlighted_white(str)
80
+ print "\e[47m" + str + "\e[0m\n"
81
+ end
82
+
83
+ def self.big(str)
84
+ transform = str.split("")
85
+ line0, line1, line2, line3, line4, line5 = [], [], [], [], [], []
86
+ transform.each do |letter|
87
+ letter.downcase!
88
+ raise "Unknown character #{letter}" if !BIG_LETTERS.has_key?(letter)
89
+ line0 << LINE0[BIG_LETTERS[letter]..(BIG_LETTERS[letter.next] - 1)]
90
+ line1 << LINE1[BIG_LETTERS[letter]..(BIG_LETTERS[letter.next] - 1)]
91
+ line2 << LINE2[BIG_LETTERS[letter]..(BIG_LETTERS[letter.next] - 1)]
92
+ line3 << LINE3[BIG_LETTERS[letter]..(BIG_LETTERS[letter.next] - 1)]
93
+ line4 << LINE4[BIG_LETTERS[letter]..(BIG_LETTERS[letter.next] - 1)]
94
+ line5 << LINE5[BIG_LETTERS[letter]..(BIG_LETTERS[letter.next] - 1)]
95
+ end
96
+ puts line0.join("")
97
+ puts line1.join("")
98
+ puts line2.join("")
99
+ puts line3.join("")
100
+ puts line4.join("")
101
+ puts line5.join("")
102
+ end
103
+
104
+ end
105
+
106
+
107
+
108
+
109
+ LINE0 = " ____ _____ _____ ______ ______ _____ _ _ _____ _ _ __ _ __ __ _ _ ____ _____ ____ _____ _____ _______ _ _ __ ____ ____ ____ __ ______ _ _ _ _ _ ___ ____ "
110
+ LINE1 = " /\\ | _ \\ / ____|| __ \\ | ____|| ____| / ____|| | | ||_ _| | || |/ /| | | \\/ || \\ | | / __ \\ | __ \\ / __ \\ | __ \\ / ____||__ __|| | | |\\ \\ / /\\ \\ / /\\ \\ / /\\ \\ / /|___ / | || | | _| || |_ |__ \\ / __ \\ "
111
+ LINE2 = " / \\ | |_) || | | | | || |__ | |__ | | __ | |__| | | | | || ' / | | | \\ / || \\| || | | || |__) || | | || |__) || (___ | | | | | | \\ \\ / / \\ \\ /\\ / / \\ V / \\ \\_/ / / / | ||/|/ |_ __ _| ) | / / _` |"
112
+ LINE3 = " / /\\ \\ | _ < | | | | | || __| | __| | | |_ || __ | | | _ | || < | | | |\\/| || . ` || | | || ___/ | | | || _ / \\___ \\ | | | | | | \\ \\/ / \\ \\/ \\/ / > < \\ / / / |_| _| || |_ / / | | (_| |"
113
+ LINE4 = " / ____ \\ | |_) || |____ | |__| || |____ | | | |__| || | | | _| |_ | |__| || . \\ | |____ | | | || |\\ || |__| || | | |__| || | \\ \\ ____) | | | | |__| | \\ / \\ /\\ / / . \\ | | / /__ _ |_ __ _| |_| \\ \\__,_|"
114
+ LINE5 = "/_/ \\_\\|____/ \\_____||_____/ |______||_| \\_____||_| |_||_____| \\____/ |_|\\_\\|______||_| |_||_| \\_| \\____/ |_| \\___\\_\\|_| \\_\\|_____/ |_| \\____/ \\/ \\/ \\/ /_/ \\_\\ |_| /_____| |_| |_||_| (_) \\____/ "
115
+
116
+
117
+ BIG_LETTERS = { "a" => 0,
118
+ "b" => 10,
119
+ "c" => 17,
120
+ "d" => 25,
121
+ "e" => 33,
122
+ "f" => 41,
123
+ "g" => 49,
124
+ "h" => 57,
125
+ "i" => 65,
126
+ "j" => 72,
127
+ "k" => 80,
128
+ "l" => 86,
129
+ "m" => 94,
130
+ "n" => 102,
131
+ "o" => 109,
132
+ "p" => 117,
133
+ "q" => 125,
134
+ "r" => 133,
135
+ "s" => 141,
136
+ "t" => 149,
137
+ "u" => 158,
138
+ "v" => 166,
139
+ "w" => 176,
140
+ "x" => 190,
141
+ "y" => 197,
142
+ "z" => 206,
143
+ "aa" => 213,
144
+ " " => 213,
145
+ "!" => 215,
146
+ "\"" => 218,
147
+ "#" => 223,
148
+ "$" => 233,
149
+ "?" => 233,
150
+ "@" => 241,
151
+ "A" => 251
152
+ }
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
@@ -0,0 +1,51 @@
1
+ require_relative 'screen.rb'
2
+ module FPrinter
3
+
4
+ def self.slow(str, sec = 0.05)
5
+ str.split("").each do |l|
6
+ print l
7
+ sleep(sec)
8
+ end
9
+ puts ""
10
+ end
11
+
12
+ def self.slow_unprint(str, sec = 0.05)
13
+ s = str.length
14
+ str.split("").each_with_index do |l, i|
15
+ print "\e[K", str[0..(s-i)]
16
+ sleep(sec)
17
+ print "\e[D" * (s - i + 2)
18
+ end
19
+ print "\e[D" * 2, "\e[K", "\n"
20
+ end
21
+
22
+ def self.appear_from_left(str, sec = 0.05)
23
+ s = str.length
24
+ str.split("").each_with_index do |l, i|
25
+ print "\e[K", str[(s-1-i)..(s-1)], "\e[D" * (i + 1)
26
+ sleep(sec)
27
+ print "\e[D" * (s - i)
28
+ end
29
+ print "\e[D" * 2, "\n"
30
+ end
31
+
32
+ def self.appear_from_right(str, sec = 0.05)
33
+ s = str.length
34
+ str.split("").each_with_index do |l, i|
35
+ print "\e[K", " " * (s - i - 1), str[0..(i)]
36
+ sleep(sec)
37
+ print "\e[D" * (s + i)
38
+ end
39
+ print "\e[D" * 2, "\n"
40
+ end
41
+
42
+ def self.reverse(str, sec = 0.05)
43
+ s = str.length
44
+ str.split("").each_with_index do |l, i|
45
+ print "\e[K", " " * (s - i - 1), str[(s-1-i)..(s-1)], "\e[D" * (i + 1)
46
+ sleep(sec)
47
+ print "\e[D" * (s - i)
48
+ end
49
+ print "\e[D" * 2, "\n"
50
+ end
51
+ end
@@ -0,0 +1,14 @@
1
+ module FPrinter
2
+
3
+ def self.clean!
4
+ print "\e[2J"
5
+ end
6
+
7
+ def self.move_to_home!
8
+ print "\e[H"
9
+ end
10
+
11
+ def self.flush!
12
+ $stdout.flush
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fprinter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stephan Thomas
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-11 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple printer gem, to print your stuff a fancy way
14
+ email: thomas.stephn@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/fprinter.rb
20
+ - lib/fprinter/screen.rb
21
+ - lib/fprinter/display_change.rb
22
+ - lib/fprinter/printer_change.rb
23
+ homepage: https://github.com/thomasstephane/fprinter
24
+ licenses: []
25
+ metadata: {}
26
+ post_install_message: ! "********************************************************************************\n\n
27
+ \ Follow @thomasstephn on Twitter for updates, and news.\n https://twitter.com/thomasstephn\n\n
28
+ \ Thanks for using fprinter !\n\n********************************************************************************\n"
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.0.3
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: Fancy Printer - also known as F*^$:#` Printer
48
+ test_files: []