summaryrefslogtreecommitdiffstats
path: root/CLI/ruby
diff options
context:
space:
mode:
authorAhmed AbdelHalim <[email protected]>2023-06-30 16:00:40 +0200
committerAhmed AbdelHalim <[email protected]>2023-06-30 16:00:40 +0200
commitf64697a5aede493d52724860856bcbf9f5803169 (patch)
treebc804c7bca9997ad8daea75a7843f7ca211981fb /CLI/ruby
parentd124465bc3a83a614eb10eb7c6d6ddff2fc00f35 (diff)
Update and fix rubocop offenses
Diffstat (limited to 'CLI/ruby')
-rw-r--r--CLI/ruby/Gemfile15
-rw-r--r--CLI/ruby/Gemfile.lock33
-rw-r--r--CLI/ruby/game_of_life.gemspec14
-rw-r--r--CLI/ruby/lib/game_of_life.rb6
-rw-r--r--CLI/ruby/lib/game_of_life/generators/seed.rb2
-rw-r--r--CLI/ruby/spec/game_of_life_spec.rb1
6 files changed, 39 insertions, 32 deletions
diff --git a/CLI/ruby/Gemfile b/CLI/ruby/Gemfile
index c0c8dc1..465d188 100644
--- a/CLI/ruby/Gemfile
+++ b/CLI/ruby/Gemfile
@@ -4,3 +4,18 @@ source "https://rubygems.org"
# Specify your gem's dependencies in game_of_life.gemspec
gemspec
+
+group :development, :test do
+ gem "bundler"
+ gem "pry-byebug"
+ gem "rake"
+ gem "rspec"
+ gem "rubocop"
+ gem "rubocop-rspec"
+ # Code Coverage dependencies
+ gem "json"
+ gem "simplecov"
+ # Documentation dependencies
+ gem "redcarpet"
+ gem "yard"
+end
diff --git a/CLI/ruby/Gemfile.lock b/CLI/ruby/Gemfile.lock
index c4b5556..0caff5a 100644
--- a/CLI/ruby/Gemfile.lock
+++ b/CLI/ruby/Gemfile.lock
@@ -13,21 +13,24 @@ GEM
diff-lcs (1.4.4)
docile (1.3.5)
json (2.5.1)
+ language_server-protocol (3.17.0.3)
method_source (1.0.0)
- parallel (1.20.1)
- parser (3.0.0.0)
+ parallel (1.23.0)
+ parser (3.2.2.3)
ast (~> 2.4.1)
+ racc
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.9.0)
byebug (~> 11.0)
pry (~> 0.13.0)
- rainbow (3.0.0)
+ racc (1.7.1)
+ rainbow (3.1.1)
rake (13.0.3)
redcarpet (3.5.1)
- regexp_parser (2.0.3)
- rexml (3.2.4)
+ regexp_parser (2.8.1)
+ rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
@@ -41,21 +44,23 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)
- rubocop (1.10.0)
+ rubocop (1.53.1)
+ json (~> 2.3)
+ language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
- parser (>= 3.0.0.0)
+ parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
- rexml
- rubocop-ast (>= 1.2.0, < 2.0)
+ rexml (>= 3.2.5, < 4.0)
+ rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
- unicode-display_width (>= 1.4.0, < 3.0)
- rubocop-ast (1.4.1)
- parser (>= 2.7.1.5)
+ unicode-display_width (>= 2.4.0, < 3.0)
+ rubocop-ast (1.29.0)
+ parser (>= 3.2.1.0)
rubocop-rspec (2.2.0)
rubocop (~> 1.0)
rubocop-ast (>= 1.1.0)
- ruby-progressbar (1.11.0)
+ ruby-progressbar (1.13.0)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
@@ -63,7 +68,7 @@ GEM
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.2)
thor (1.1.0)
- unicode-display_width (2.0.0)
+ unicode-display_width (2.4.2)
yard (0.9.26)
PLATFORMS
diff --git a/CLI/ruby/game_of_life.gemspec b/CLI/ruby/game_of_life.gemspec
index 3cd6bb3..3c7f86b 100644
--- a/CLI/ruby/game_of_life.gemspec
+++ b/CLI/ruby/game_of_life.gemspec
@@ -19,23 +19,11 @@ Gem::Specification.new do |spec|
spec.metadata["source_code_uri"] = "https://git.sr.ht/~a14m/game-of-life/tree/master/CLI/ruby"
spec.metadata["documentation_uri"] = "https://rubydoc.info/gems/terminal_game_of_life"
spec.metadata["changelog_uri"] = "https://git.sr.ht/~a14m/game-of-life/tree/master/CLI/ruby/CHANGELOG.md"
+ spec.metadata["rubygems_mfa_required"] = "true"
spec.executables = ["game-of-life"]
spec.require_paths = ["lib"]
spec.files = Dir["README.md", "game_of_life.gemspec", "bin/game-of-life", "lib/**/*.rb", ".yardopts"]
spec.add_dependency "thor", "~> 1.0"
-
- spec.add_development_dependency "bundler"
- spec.add_development_dependency "pry-byebug"
- spec.add_development_dependency "rake"
- spec.add_development_dependency "rspec"
- spec.add_development_dependency "rubocop"
- spec.add_development_dependency "rubocop-rspec"
- # Code Coverage dependencies
- spec.add_development_dependency "json"
- spec.add_development_dependency "simplecov"
- # Documentation dependencies
- spec.add_development_dependency "redcarpet"
- spec.add_development_dependency "yard"
end
diff --git a/CLI/ruby/lib/game_of_life.rb b/CLI/ruby/lib/game_of_life.rb
index cb122cb..ca9ce5d 100644
--- a/CLI/ruby/lib/game_of_life.rb
+++ b/CLI/ruby/lib/game_of_life.rb
@@ -36,11 +36,11 @@ module GameOfLife
end
if (options["width"]&.< 1) || (options["width"]&.> max_width)
fail GameOfLife::Error, "Invalid --width value. " \
- "must be between 1 and #{max_width} (current terminal width)"
+ "must be between 1 and #{max_width} (current terminal width)"
end
if (options["height"]&.< 1) || (options["height"]&.> max_height)
fail GameOfLife::Error, "Invalid --height value. " \
- "must be between 1 and #{max_height} (current terminal height)"
+ "must be between 1 and #{max_height} (current terminal height)"
end
fail GameOfLife::Error, "Invalid --live-cell value. must be a single character" if options["live-cell"].length > 1
@@ -111,7 +111,7 @@ module GameOfLife
# Ref: https://stackoverflow.com/questions/11023929/using-the-alternate-screen-in-a-bash-script
# Ref: https://superuser.com/questions/122911/what-commands-can-i-use-to-reset-and-clear-my-terminal
print "\e[?1049h\e[H"
- print universe.to_s
+ print universe
print "\n #{BANNER}"
sleep(DELAY / 1000.0)
end
diff --git a/CLI/ruby/lib/game_of_life/generators/seed.rb b/CLI/ruby/lib/game_of_life/generators/seed.rb
index 6399945..ba7074b 100644
--- a/CLI/ruby/lib/game_of_life/generators/seed.rb
+++ b/CLI/ruby/lib/game_of_life/generators/seed.rb
@@ -32,7 +32,7 @@ module GameOfLife
# Create a pseudo(stable) random generator from the seed
# Generate a sequence of bytes to cover the Game of Life Universe plane
# each byte can be unpacked into binary data string (ex. "01101011")
- raw = Random.new(seed).bytes(width * height).unpack1("B*").split("").each_slice(width)
+ raw = Random.new(seed).bytes(width * height).unpack1("B*").chars.each_slice(width)
raw.map { |row| row.map { |char| char.eql?("1") } }
end
diff --git a/CLI/ruby/spec/game_of_life_spec.rb b/CLI/ruby/spec/game_of_life_spec.rb
index a0013a6..34570d3 100644
--- a/CLI/ruby/spec/game_of_life_spec.rb
+++ b/CLI/ruby/spec/game_of_life_spec.rb
@@ -183,7 +183,6 @@ RSpec.describe GameOfLife do
stub_const("DELAY", 100.0)
expect_any_instance_of(Kernel).to receive(:print).with("\e[?1049h\e[H")
expect_any_instance_of(Kernel).to receive(:print).twice
- expect(universe).to receive(:to_s)
expect_any_instance_of(Kernel).to receive(:sleep)
described_class.render(universe)