digi_moji 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +75 -0
- data/Rakefile +7 -0
- data/bin/digi_moji +5 -0
- data/digi_moji.gemspec +25 -0
- data/lib/digi_moji.rb +52 -0
- data/lib/digi_moji/char.rb +792 -0
- data/lib/digi_moji/cli.rb +89 -0
- data/lib/digi_moji/version.rb +3 -0
- data/spec/char_spec.rb +123 -0
- data/spec/cli_spec.rb +35 -0
- data/spec/digi_moji_spec.rb +72 -0
- data/spec/spec_helper.rb +3 -0
- metadata +136 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module DigiMoji
|
4
|
+
class CLI < Thor
|
5
|
+
class_option :fg, aliases:'-f', desc:'Foreground color', default:'bg_white'
|
6
|
+
class_option :bg, aliases:'-b', desc:'Background color'
|
7
|
+
class_option :cell, aliases:'-c', desc:'Cell character'
|
8
|
+
class_option :width, aliases:'-w', desc:'Character width', default:2, type: :numeric
|
9
|
+
|
10
|
+
desc "new WORD", "Print a digital word"
|
11
|
+
def new(word)
|
12
|
+
opts = down_symbolize_key(options)
|
13
|
+
str = String.new(word, opts)
|
14
|
+
puts str
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "time", "Print current time"
|
18
|
+
def time
|
19
|
+
opts = down_symbolize_key(options)
|
20
|
+
trap(:INT) { exit 0 }
|
21
|
+
loop do
|
22
|
+
time = time_format(Time.at(Time.now.to_i))
|
23
|
+
str = String.new(time, opts)
|
24
|
+
clear_screen
|
25
|
+
puts str
|
26
|
+
sleep 1.0
|
27
|
+
end
|
28
|
+
ensure
|
29
|
+
reset_screen
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "timer SEC", "Print count down timer"
|
33
|
+
option :message, aliases:'-m', desc:"Message on time's up", default:"TIME'S UP!"
|
34
|
+
option :message_color, aliases:'-k', desc:"Message color", default:'bg_red'
|
35
|
+
option :unit, aliases:'-u', desc:"Argument unit", default:'sec'
|
36
|
+
def timer(sec)
|
37
|
+
opts = down_symbolize_key(options)
|
38
|
+
message, message_color = opts.delete(:message), opts.delete(:message_color)
|
39
|
+
unit = opts.delete(:unit)
|
40
|
+
t = Time.new('00:00:00') + time_in_sec(sec, unit)
|
41
|
+
trap(:INT) { exit 0 }
|
42
|
+
loop do
|
43
|
+
time = time_format(t)
|
44
|
+
str = String.new(time, opts)
|
45
|
+
clear_screen
|
46
|
+
puts str
|
47
|
+
sleep 1.0
|
48
|
+
break if [t.hour, t.min, t.sec].all?(&:zero?)
|
49
|
+
t -= 1
|
50
|
+
end
|
51
|
+
clear_screen
|
52
|
+
puts String.new(message, fg:message_color)
|
53
|
+
sleep 2.0
|
54
|
+
ensure
|
55
|
+
reset_screen
|
56
|
+
end
|
57
|
+
|
58
|
+
no_tasks do
|
59
|
+
def down_symbolize_key(opts)
|
60
|
+
opts.inject({}) do |h, (k, v)|
|
61
|
+
h[k.to_s.downcase.intern] = v; h
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def time_in_sec(time, unit)
|
66
|
+
case unit
|
67
|
+
when 'sec' then time.to_i
|
68
|
+
when 'min' then time.to_i * 60
|
69
|
+
when 'hour' then time.to_i * 60 * 60
|
70
|
+
else time.to_i
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def clear_screen
|
75
|
+
print "\e[?25l" # hide cursor
|
76
|
+
print "\e[2J" # clear screen
|
77
|
+
print "\e[2;0H"
|
78
|
+
end
|
79
|
+
|
80
|
+
def reset_screen
|
81
|
+
print "\e[?25h" # show cursor
|
82
|
+
end
|
83
|
+
|
84
|
+
def time_format(t)
|
85
|
+
"%02d:%02d:%02d" % [t.hour, t.min, t.sec]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/spec/char_spec.rb
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DigiMoji::Char do
|
4
|
+
before do
|
5
|
+
@MAP_A = [[false, true, true, true, false],
|
6
|
+
[true, false, false, false, true],
|
7
|
+
[true, false, false, false, true],
|
8
|
+
[true, true, true, true, true],
|
9
|
+
[true, false, false, false, true],
|
10
|
+
[true, false, false, false, true],
|
11
|
+
[true, false, false, false, true]]
|
12
|
+
|
13
|
+
@MAP_ONE = [[false, false, true, false, false],
|
14
|
+
[false, true, true, false, false],
|
15
|
+
[false, false, true, false, false],
|
16
|
+
[false, false, true, false, false],
|
17
|
+
[false, false, true, false, false],
|
18
|
+
[false, false, true, false, false],
|
19
|
+
[true, true, true, true, true]]
|
20
|
+
|
21
|
+
@MAP_QUESTION = [[false, true, true, true, false],
|
22
|
+
[true, false, false, false, true],
|
23
|
+
[true, false, false, false, true],
|
24
|
+
[false, false, false, true, false],
|
25
|
+
[false, false, true, false, false],
|
26
|
+
[false, false, false, false, false],
|
27
|
+
[false, false, true, false, false]]
|
28
|
+
|
29
|
+
@A = [
|
30
|
+
" \e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m ",
|
31
|
+
"\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m",
|
32
|
+
"\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m",
|
33
|
+
"\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m",
|
34
|
+
"\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m",
|
35
|
+
"\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m",
|
36
|
+
"\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m"
|
37
|
+
]
|
38
|
+
|
39
|
+
@A2 = [
|
40
|
+
"\e[43m \e[0m\e[43m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[43m \e[0m\e[43m \e[0m",
|
41
|
+
"\e[42m \e[0m\e[42m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[42m \e[0m\e[42m \e[0m",
|
42
|
+
"\e[42m \e[0m\e[42m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[42m \e[0m\e[42m \e[0m",
|
43
|
+
"\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m",
|
44
|
+
"\e[42m \e[0m\e[42m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[42m \e[0m\e[42m \e[0m",
|
45
|
+
"\e[42m \e[0m\e[42m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[42m \e[0m\e[42m \e[0m",
|
46
|
+
"\e[42m \e[0m\e[42m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[43m \e[0m\e[42m \e[0m\e[42m \e[0m"
|
47
|
+
]
|
48
|
+
|
49
|
+
@A3 = [
|
50
|
+
"AA\e[31mA\e[0m\e[31mA\e[0m\e[31mA\e[0m\e[31mA\e[0m\e[31mA\e[0m\e[31mA\e[0mAA",
|
51
|
+
"\e[31mA\e[0m\e[31mA\e[0mAAAAAA\e[31mA\e[0m\e[31mA\e[0m",
|
52
|
+
"\e[31mA\e[0m\e[31mA\e[0mAAAAAA\e[31mA\e[0m\e[31mA\e[0m",
|
53
|
+
"\e[31mA\e[0m\e[31mA\e[0m\e[31mA\e[0m\e[31mA\e[0m\e[31mA\e[0m\e[31mA\e[0m\e[31mA\e[0m\e[31mA\e[0m\e[31mA\e[0m\e[31mA\e[0m",
|
54
|
+
"\e[31mA\e[0m\e[31mA\e[0mAAAAAA\e[31mA\e[0m\e[31mA\e[0m",
|
55
|
+
"\e[31mA\e[0m\e[31mA\e[0mAAAAAA\e[31mA\e[0m\e[31mA\e[0m",
|
56
|
+
"\e[31mA\e[0m\e[31mA\e[0mAAAAAA\e[31mA\e[0m\e[31mA\e[0m"
|
57
|
+
]
|
58
|
+
|
59
|
+
@ohm = [" ", " \e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m ", "\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m", "\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m", "\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m", " \e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m ", "\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m"]
|
60
|
+
end
|
61
|
+
|
62
|
+
describe ".build_char_map" do
|
63
|
+
it "returns a boolean map for an alphabet" do
|
64
|
+
expect(DigiMoji::Char.build_char_map(:A)).to eq @MAP_A
|
65
|
+
end
|
66
|
+
|
67
|
+
it "returns a boolean map for a number" do
|
68
|
+
expect(DigiMoji::Char.build_char_map(1)).to eq @MAP_ONE
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns a boolean map for a sign" do
|
72
|
+
expect(DigiMoji::Char.build_char_map('?')).to eq @MAP_QUESTION
|
73
|
+
end
|
74
|
+
|
75
|
+
it "raises an error for unknown charcters" do
|
76
|
+
expect{ DigiMoji::Char.build_char_map('⌘')}.to raise_error(DigiMoji::Char::NotImplementError)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe ".[]" do
|
81
|
+
it "returns a digital character in white" do
|
82
|
+
expect(DigiMoji::Char[:A]).to eq @A
|
83
|
+
end
|
84
|
+
|
85
|
+
context "with options" do
|
86
|
+
it "returns green 'A' with yellow background" do
|
87
|
+
expect(DigiMoji::Char[:A, fg:'bg_green', bg:'bg_yellow']).to eq @A2
|
88
|
+
end
|
89
|
+
|
90
|
+
it "returns red 'A' constructed A cells" do
|
91
|
+
expect(DigiMoji::Char[:A, fg:'red', cell:'A']).to eq @A3
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe ".register" do
|
97
|
+
it "registers new character" do
|
98
|
+
DigiMoji::Char.register("Ω", %w(f f f f f
|
99
|
+
f t t t f
|
100
|
+
t f f f t
|
101
|
+
t f f f t
|
102
|
+
t f f f t
|
103
|
+
f t f t f
|
104
|
+
t t f t t))
|
105
|
+
expect{ DigiMoji::Char["Ω"] }.not_to raise_error
|
106
|
+
expect(DigiMoji::Char["Ω"]).to eq @ohm
|
107
|
+
end
|
108
|
+
|
109
|
+
it "raises InvalidCharForm error" do
|
110
|
+
map = %w(f f f f f
|
111
|
+
f t t t f
|
112
|
+
t f f f t
|
113
|
+
t f f f t
|
114
|
+
t f f f t
|
115
|
+
f t f t f)
|
116
|
+
expect{ DigiMoji::Char.register("ß", map) }.to raise_error(DigiMoji::Char::InvalidCharForm)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "raises InUseCharError" do
|
120
|
+
expect{ DigiMoji::Char.register("å", %(t t t t t)) }.to raise_error(DigiMoji::Char::InUseCharError)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/spec/cli_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DigiMoji::CLI do
|
4
|
+
before do
|
5
|
+
$stdout = StringIO.new
|
6
|
+
@str_A = " \e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m \n\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m\n\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m\n\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\n\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m\n\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m\n\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m\n"
|
7
|
+
|
8
|
+
@str_colored_A = "\e[42m \e[0m\e[42m \e[0m\e[41m \e[0m\e[41m \e[0m\e[41m \e[0m\e[41m \e[0m\e[41m \e[0m\e[41m \e[0m\e[42m \e[0m\e[42m \e[0m\n\e[41m \e[0m\e[41m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[41m \e[0m\e[41m \e[0m\n\e[41m \e[0m\e[41m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[41m \e[0m\e[41m \e[0m\n\e[41m \e[0m\e[41m \e[0m\e[41m \e[0m\e[41m \e[0m\e[41m \e[0m\e[41m \e[0m\e[41m \e[0m\e[41m \e[0m\e[41m \e[0m\e[41m \e[0m\n\e[41m \e[0m\e[41m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[41m \e[0m\e[41m \e[0m\n\e[41m \e[0m\e[41m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[41m \e[0m\e[41m \e[0m\n\e[41m \e[0m\e[41m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[42m \e[0m\e[41m \e[0m\e[41m \e[0m\n"
|
9
|
+
|
10
|
+
@str_slim_A = "A\e[47mA\e[0m\e[47mA\e[0m\e[47mA\e[0mA\n\e[47mA\e[0mAAA\e[47mA\e[0m\n\e[47mA\e[0mAAA\e[47mA\e[0m\n\e[47mA\e[0m\e[47mA\e[0m\e[47mA\e[0m\e[47mA\e[0m\e[47mA\e[0m\n\e[47mA\e[0mAAA\e[47mA\e[0m\n\e[47mA\e[0mAAA\e[47mA\e[0m\n\e[47mA\e[0mAAA\e[47mA\e[0m\n"
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
$stdout = STDOUT
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "new" do
|
18
|
+
it "prints a digital string" do
|
19
|
+
DigiMoji::CLI.start(['new', 'A'])
|
20
|
+
expect($stdout.string).to eq @str_A
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with options" do
|
24
|
+
it "prints a digital string with options" do
|
25
|
+
DigiMoji::CLI.start(['new', 'A', '--fg', 'bg_red', '--bg', 'bg_green'])
|
26
|
+
expect($stdout.string).to eq @str_colored_A
|
27
|
+
end
|
28
|
+
|
29
|
+
it "prints a slim A by A cells" do
|
30
|
+
DigiMoji::CLI.start(['new', 'A', '--cell', 'A', '--width', 1])
|
31
|
+
expect($stdout.string).to eq @str_slim_A
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DigiMoji do
|
4
|
+
it 'has a version number' do
|
5
|
+
expect(DigiMoji::VERSION).not_to be nil
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe DigiMoji::String do
|
10
|
+
before do
|
11
|
+
@str_map_a = [[" ", " ", "\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m ", " \e[47m \e[0m\e[47m \e[0m ", " \e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m ", "\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m ", " \e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m "]]
|
12
|
+
|
13
|
+
@str_a = " \n \n\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m \n \e[47m \e[0m\e[47m \e[0m \n \e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m \n\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m \n \e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m "
|
14
|
+
|
15
|
+
@str_map_Aa = [[" \e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m ", "\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m", "\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m", "\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m", "\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m", "\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m", "\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m"], [" ", " ", "\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m ", " \e[47m \e[0m\e[47m \e[0m ", " \e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m ", "\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m ", " \e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m "]]
|
16
|
+
|
17
|
+
@str_Aa = " \e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m \n\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m \n\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m \n\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m \n\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m \n\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m \n\e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m \e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m\e[47m \e[0m "
|
18
|
+
end
|
19
|
+
|
20
|
+
describe ".new" do
|
21
|
+
it "builds a character sequence for 'a'" do
|
22
|
+
str = DigiMoji::String.new("a")
|
23
|
+
expect(str.string).to eq @str_map_a
|
24
|
+
expect(str.to_s).to eq @str_a
|
25
|
+
end
|
26
|
+
|
27
|
+
it "builds a character sequence for 'Aa" do
|
28
|
+
str = DigiMoji::String.new("Aa")
|
29
|
+
expect(str.string).to eq @str_map_Aa
|
30
|
+
expect(str.to_s).to eq @str_Aa
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#+" do
|
35
|
+
subject { DigiMoji::String.new("A") }
|
36
|
+
context "pass a string" do
|
37
|
+
it "returns a concated digi_moji" do
|
38
|
+
str = subject + 'a'
|
39
|
+
expect(str.string).to eq @str_map_Aa
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "pass a DigiMoji object" do
|
44
|
+
it "returns a concated digi_moji" do
|
45
|
+
str = subject + DigiMoji::String.new('a')
|
46
|
+
expect(str.string).to eq @str_map_Aa
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "#<<" do
|
52
|
+
subject { DigiMoji::String.new("A") }
|
53
|
+
context "pass a string" do
|
54
|
+
it "returns a concated digi_moji" do
|
55
|
+
str = subject << 'a'
|
56
|
+
expect(str.string).to eq @str_map_Aa
|
57
|
+
expect(str.to_s).to eq @str_Aa
|
58
|
+
expect(str.raw_string).to eq 'Aa'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "pass a DigiMoji object" do
|
63
|
+
it "returns a concated digi_moji" do
|
64
|
+
str = subject << DigiMoji::String.new('a')
|
65
|
+
expect(str.string).to eq @str_map_Aa
|
66
|
+
expect(str.to_s).to eq @str_Aa
|
67
|
+
expect(str.raw_string).to eq 'Aa'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: digi_moji
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kyoendo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colcolor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- postagie@gmail.com
|
86
|
+
executables:
|
87
|
+
- digi_moji
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".travis.yml"
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/digi_moji
|
99
|
+
- digi_moji.gemspec
|
100
|
+
- lib/digi_moji.rb
|
101
|
+
- lib/digi_moji/char.rb
|
102
|
+
- lib/digi_moji/cli.rb
|
103
|
+
- lib/digi_moji/version.rb
|
104
|
+
- spec/char_spec.rb
|
105
|
+
- spec/cli_spec.rb
|
106
|
+
- spec/digi_moji_spec.rb
|
107
|
+
- spec/spec_helper.rb
|
108
|
+
homepage: https://github.com/melborne/digi_moji
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.3.0
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: 5x7 digital color words on your terminal.
|
132
|
+
test_files:
|
133
|
+
- spec/char_spec.rb
|
134
|
+
- spec/cli_spec.rb
|
135
|
+
- spec/digi_moji_spec.rb
|
136
|
+
- spec/spec_helper.rb
|