ro_sham_bo 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +24 -0
- data/Gemfile.lock +13 -1
- data/README.md +4 -0
- data/Rakefile +8 -9
- data/lib/ro_sham_bo.rb +10 -2
- data/lib/ro_sham_bo/version.rb +2 -2
- data/ro_sham_bo.gemspec +2 -0
- metadata +36 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce77bcab61a9ae0943e2c524ce9db8549f2f655fe0c94b232459af086332416e
|
4
|
+
data.tar.gz: '0692f563d97e79eedbf2e52d9d06c5b26cafbe7cb4c8f1472b2325ffe2066f69'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d777b31737a483305adc350b97a5fd3983b15f1ba64905c667bbe3862c60ef2f72e458b3cccea258b36e904dccbd956fbecbbe1b3f5720fcdb30e1329a837d7f
|
7
|
+
data.tar.gz: 3598e5ce1fbbbea18391fa235994b7e364eeccdd7780465c0f27386baa60e0953e471b605fe6fa608ccf01477fca70254698fb819e7735584541347e283c29b8
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
- name: Set up Ruby 2.6
|
17
|
+
uses: actions/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: 2.6.x
|
20
|
+
- name: Build and test with Rake
|
21
|
+
run: |
|
22
|
+
gem install bundler
|
23
|
+
bundle install
|
24
|
+
bundle exec rake test
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,22 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ro_sham_bo (0.0
|
4
|
+
ro_sham_bo (0.1.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
docile (1.3.5)
|
10
|
+
power_assert (2.0.0)
|
9
11
|
rake (13.0.3)
|
12
|
+
simplecov (0.21.2)
|
13
|
+
docile (~> 1.1)
|
14
|
+
simplecov-html (~> 0.11)
|
15
|
+
simplecov_json_formatter (~> 0.1)
|
16
|
+
simplecov-html (0.12.3)
|
17
|
+
simplecov_json_formatter (0.1.3)
|
18
|
+
test-unit (3.4.1)
|
19
|
+
power_assert
|
10
20
|
|
11
21
|
PLATFORMS
|
12
22
|
x86_64-darwin-20
|
@@ -14,6 +24,8 @@ PLATFORMS
|
|
14
24
|
DEPENDENCIES
|
15
25
|
rake (~> 13.0, >= 13.0.1)
|
16
26
|
ro_sham_bo!
|
27
|
+
simplecov
|
28
|
+
test-unit (~> 3.3, >= 3.3.5)
|
17
29
|
|
18
30
|
BUNDLED WITH
|
19
31
|
2.2.16
|
data/README.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
# RoShamBo
|
2
|
+
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fevanthegrayt%2Fro_sham_bo%2Fbadge%3Fref%3Dmaster&style=flat)](https://actions-badge.atrox.dev/evanthegrayt/ro_sham_bo/goto?ref=master)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/ro_sham_bo.svg)](https://badge.fury.io/rb/ro_sham_bo)
|
4
|
+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
|
5
|
+
|
2
6
|
Simple Rock, Paper, Scissors game for the command-line, implemented in ruby.
|
3
7
|
|
4
8
|
## Installation
|
data/Rakefile
CHANGED
@@ -2,16 +2,15 @@
|
|
2
2
|
|
3
3
|
require_relative 'lib/ro_sham_bo'
|
4
4
|
require 'bundler/gem_tasks'
|
5
|
+
require 'rake/testtask'
|
5
6
|
# require 'rdoc/task'
|
6
|
-
# require 'rake/testtask'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
# end
|
8
|
+
Rake::TestTask.new do |t|
|
9
|
+
t.libs = ['lib']
|
10
|
+
t.warning = true
|
11
|
+
t.verbose = true
|
12
|
+
t.test_files = FileList['test/**/*_test.rb']
|
13
|
+
end
|
15
14
|
|
16
15
|
# TODO: Add documentation.
|
17
16
|
# RDoc::Task.new do |rdoc|
|
@@ -20,4 +19,4 @@ require 'bundler/gem_tasks'
|
|
20
19
|
# rdoc.rdoc_files.include('README.md', 'lib/**/*.rb')
|
21
20
|
# end
|
22
21
|
|
23
|
-
|
22
|
+
task default: :test
|
data/lib/ro_sham_bo.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative 'ro_sham_bo/version'
|
2
|
+
|
1
3
|
class RoShamBo
|
2
4
|
RULES = {
|
3
5
|
rock: {rock: :draw, paper: :lose, scissors: :win}.freeze,
|
@@ -15,6 +17,12 @@ class RoShamBo
|
|
15
17
|
attr_reader :winner
|
16
18
|
|
17
19
|
def initialize(cheater: nil, rounds: 3)
|
20
|
+
if rounds.even?
|
21
|
+
raise ArgumentError, 'rounds must be odd'
|
22
|
+
elsif ![nil, :user, :computer].include?(cheater)
|
23
|
+
raise ArgumentError, 'cheater must be :computer or :user'
|
24
|
+
end
|
25
|
+
|
18
26
|
@cheater = cheater
|
19
27
|
@rounds = rounds
|
20
28
|
@score = {user: 0, computer: 0}
|
@@ -22,7 +30,7 @@ class RoShamBo
|
|
22
30
|
end
|
23
31
|
|
24
32
|
def play(input)
|
25
|
-
raise 'Game Over!' if over?
|
33
|
+
raise RuntimeError, 'Game Over!' if over?
|
26
34
|
|
27
35
|
@user_choice = sanitized_choice(input)
|
28
36
|
@computer_choice = computer_turn(user_choice)
|
@@ -62,7 +70,7 @@ class RoShamBo
|
|
62
70
|
if cheater == :user && about_to_win?(:computer)
|
63
71
|
cheat(input, :win)
|
64
72
|
elsif cheater == :computer && about_to_win?(:user)
|
65
|
-
cheat(input, :
|
73
|
+
cheat(input, :lose)
|
66
74
|
else
|
67
75
|
RULES.keys.sample
|
68
76
|
end
|
data/lib/ro_sham_bo/version.rb
CHANGED
data/ro_sham_bo.gemspec
CHANGED
@@ -29,4 +29,6 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
30
30
|
spec.require_paths = ['lib']
|
31
31
|
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.1'
|
32
|
+
spec.add_development_dependency 'test-unit', '~> 3.3', '>= 3.3.5'
|
33
|
+
spec.add_development_dependency 'simplecov'
|
32
34
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ro_sham_bo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Gray
|
@@ -30,6 +30,40 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 13.0.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: test-unit
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '3.3'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 3.3.5
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '3.3'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 3.3.5
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: simplecov
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
33
67
|
description: Play rock paper scissors from the command line
|
34
68
|
email: evanthegrayt@vivaldi.net
|
35
69
|
executables:
|
@@ -37,6 +71,7 @@ executables:
|
|
37
71
|
extensions: []
|
38
72
|
extra_rdoc_files: []
|
39
73
|
files:
|
74
|
+
- ".github/workflows/ruby.yml"
|
40
75
|
- ".gitignore"
|
41
76
|
- Gemfile
|
42
77
|
- Gemfile.lock
|