terminal_game_of_life 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/game-of-life +5 -3
- data/lib/game_of_life.rb +7 -3
- data/lib/game_of_life/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4515e9d5d4f268e92f87ce039a3698b4b6dc12fdb2dc50fdfa37fce7360dfc4
|
4
|
+
data.tar.gz: d81371d4fff61c515df1a3b1a72154fcdbb2166490bb040d7996ad502da89e3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e59c4ca841c5f3ee3c9e3c70d77b13513df85fc4ef90cf69ef15223121646d0288512a5645e4794d8554bec37b7f0b1becb0b2be778cc15594b2afa1941c7202
|
7
|
+
data.tar.gz: 62271c16e415cf22b99e3785b49921e0939fc7a5d65ca5b4e39ea87cbe5b76990d054e4eb263a00e04429d0b04f1439e48560126078c13d41f240fb96a89b602
|
data/bin/game-of-life
CHANGED
@@ -8,7 +8,7 @@ class CLI < Thor
|
|
8
8
|
map %w[-v --version] => :version
|
9
9
|
desc "--version, -v", "Prints the Game of Life version information"
|
10
10
|
def version
|
11
|
-
|
11
|
+
print "Game of Life version #{GameOfLife::VERSION}"
|
12
12
|
end
|
13
13
|
|
14
14
|
default_task :start
|
@@ -50,8 +50,10 @@ end
|
|
50
50
|
begin
|
51
51
|
CLI.start(ARGV)
|
52
52
|
rescue SystemExit, Interrupt
|
53
|
-
|
53
|
+
# Print Seed/File used in previous run when user exits with Interrupt (CMD/Ctrl + C)
|
54
|
+
print "\e[?1049l"
|
55
|
+
print "#{GameOfLife::BANNER}\n\e[0m"
|
54
56
|
rescue NotImplementedError, GameOfLife::Error => e
|
55
|
-
|
57
|
+
print e.message
|
56
58
|
exit(-1)
|
57
59
|
end
|
data/lib/game_of_life.rb
CHANGED
@@ -106,9 +106,13 @@ module GameOfLife
|
|
106
106
|
# and rendering of the current universe/banner info
|
107
107
|
# based on the delay/cell configured by the user
|
108
108
|
def render(universe)
|
109
|
-
|
110
|
-
|
111
|
-
|
109
|
+
# Use Alternate Screen (\e[?1049h) and move cursor to top left (\e[H)
|
110
|
+
# Ref: https://github.com/ruby/ruby/blob/ruby_2_7/lib/irb/easter-egg.rb#L112-L131
|
111
|
+
# Ref: https://stackoverflow.com/questions/11023929/using-the-alternate-screen-in-a-bash-script
|
112
|
+
# Ref: https://superuser.com/questions/122911/what-commands-can-i-use-to-reset-and-clear-my-terminal
|
113
|
+
print "\e[?1049h\e[H"
|
114
|
+
print universe.to_s
|
115
|
+
print BANNER
|
112
116
|
sleep(DELAY / 1000.0)
|
113
117
|
end
|
114
118
|
end
|
data/lib/game_of_life/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terminal_game_of_life
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- a14m
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|