terminal_game_of_life 1.0.3 → 1.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63ab48e83b28420afc50509a439c9901cafa84de7acc4d8c53923513b8cc3631
4
- data.tar.gz: 635c4f76918e9a38b9026f53f296302e78798379632e5df54a524efef4122393
3
+ metadata.gz: d4515e9d5d4f268e92f87ce039a3698b4b6dc12fdb2dc50fdfa37fce7360dfc4
4
+ data.tar.gz: d81371d4fff61c515df1a3b1a72154fcdbb2166490bb040d7996ad502da89e3e
5
5
  SHA512:
6
- metadata.gz: 8a3fae98670de950efd9febad455530b4278b98d89155d6157c7c3ceaa99adb01f132b1536cb15ee672b033316601071080d163289dd8e89cc401066fedfedf8
7
- data.tar.gz: 7f0218b35225633c2e73113080abe520bbc3f509b19e6f5f927a42cdcffd95ef9436926d4a0f978c914bb9d091d651bf2974668d406aa070bbb982e3b14b15e8
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
- puts "Game of Life version #{GameOfLife::VERSION}"
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
- "Do nothing when user exits with Interrupt (CMD/Ctrl + C)"
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
- puts e.message
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
- puts "\33c\e[3J" # Clears the screen and scrollback buffer.
110
- puts universe.to_s
111
- puts BANNER
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  module GameOfLife
4
4
  # Game of life version number
5
- VERSION = "1.0.3"
5
+ VERSION = "1.0.4"
6
6
  end
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.3
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-01-30 00:00:00.000000000 Z
11
+ date: 2021-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor