rsb-gol 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rsb/gol/cli.rb +7 -36
- data/lib/rsb/gol/version.rb +1 -1
- data/rsb-gol.gemspec +3 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbbcc6ecbfbcea3087b5a19641a833c67af2ca2e
|
4
|
+
data.tar.gz: cbd7992ceb20e9ac07137110dbeaa5fc9d061623
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ddb001d77f6448a6e4f01b3baae1246ea0288f622093af5a1f3ba318258062c7e852186a6dd4b6f2fffbc84aef21bf7d226b2c561a7bb337ae69a6aca812c06
|
7
|
+
data.tar.gz: 51ac8947c922921d69415f12a4e49852a14f3c58f9d8ef9d58088c715f129ca61cc912cb4287f52dad3b84e463b0cdb3d08f719e1588aa159d9bed7c33aff716
|
data/lib/rsb/gol/cli.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'thor'
|
2
|
+
require 'highline'
|
2
3
|
|
3
4
|
module Rsb
|
4
5
|
module Gol
|
@@ -11,10 +12,12 @@ module Rsb
|
|
11
12
|
|
12
13
|
desc 'start', 'start the game of life'
|
13
14
|
def start
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
columns, rows = HighLine::SystemExtensions.terminal_size
|
16
|
+
rows -= 10
|
17
|
+
columns -= 10
|
18
|
+
iterations = options.iterations
|
19
|
+
alive = options.alive_char
|
20
|
+
dead = options.death_char
|
18
21
|
|
19
22
|
columns = options.columns if options.columns?
|
20
23
|
rows = options.rows if options.rows?
|
@@ -23,38 +26,6 @@ module Rsb
|
|
23
26
|
game = Rsb::Gol::Game.new(cols: columns, rows: rows)
|
24
27
|
game.start(iterations, alive, dead)
|
25
28
|
end
|
26
|
-
|
27
|
-
no_commands do
|
28
|
-
# credit to: https://gist.github.com/nixpulvis/6025433
|
29
|
-
# From the tty_ioctl man page in Linux.
|
30
|
-
#
|
31
|
-
# TIOCGWINSZ struct winsize *argp
|
32
|
-
# Get window size.
|
33
|
-
#
|
34
|
-
# TIOCSWINSZ const struct winsize *argp
|
35
|
-
# Set window size.
|
36
|
-
#
|
37
|
-
# The struct used by these ioctls is defined as
|
38
|
-
#
|
39
|
-
# struct winsize {
|
40
|
-
# unsigned short ws_row;
|
41
|
-
# unsigned short ws_col;
|
42
|
-
# unsigned short ws_xpixel; /* unused */
|
43
|
-
# unsigned short ws_ypixel; /* unused */
|
44
|
-
# };
|
45
|
-
# rows cols width height
|
46
|
-
def screen_size
|
47
|
-
window = [0, 0, 0, 0].pack('SSSS')
|
48
|
-
fd = IO.sysopen('/dev/tty', 'w')
|
49
|
-
terminal = IO.new(fd, "w")
|
50
|
-
|
51
|
-
# The in in this call is === TIOCGWINSZ. No idea where it is defined.
|
52
|
-
# I found it using ruby-termios with `Termios::TIOCGWINSZ`
|
53
|
-
terminal.ioctl(1074295912, window)
|
54
|
-
rows, cols, _, _ = window.unpack('SSSS')
|
55
|
-
[rows - 10, cols - 10]
|
56
|
-
end
|
57
|
-
end
|
58
29
|
end
|
59
30
|
end
|
60
31
|
end
|
data/lib/rsb/gol/version.rb
CHANGED
data/rsb-gol.gemspec
CHANGED
@@ -20,10 +20,12 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.add_dependency "thor",
|
23
|
+
spec.add_dependency "thor", ">= 0.19.1"
|
24
|
+
spec.add_dependency "highline", ">= 1.7.2"
|
24
25
|
|
25
26
|
spec.add_development_dependency "bundler", "~> 1.10"
|
26
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
27
28
|
spec.add_development_dependency "pry", "~> 0.10.1"
|
28
29
|
spec.add_development_dependency "rspec", "~> 3.2.0"
|
30
|
+
spec.required_ruby_version = '>= 2.0'
|
29
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsb-gol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Scott-Buccleuch
|
@@ -14,16 +14,30 @@ dependencies:
|
|
14
14
|
name: thor
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.19.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.19.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: highline
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.7.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.7.2
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
132
|
requirements:
|
119
133
|
- - ">="
|
120
134
|
- !ruby/object:Gem::Version
|
121
|
-
version: '0'
|
135
|
+
version: '2.0'
|
122
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
137
|
requirements:
|
124
138
|
- - ">="
|