PlayRockPaperScissorsGame 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: abbf3d10c358d17bbd21f61eecac04d362b952e1
4
- data.tar.gz: 3a8f37726bec097c10b07925f88a121f13601900
3
+ metadata.gz: d0fef3455fa5e3e5d2b7a783a3d6a3b83b262b82
4
+ data.tar.gz: 6bf49a0aec2d7800ff643d47564da2f73702a85c
5
5
  SHA512:
6
- metadata.gz: 032e9f5098e53617b6a494a6d472e94843e2f12640e5d8885251995e5fc9449acbe3306b74dde03fe011e1e81eb6c4f1cd5ee27e5e6de77d38df7a02308591e8
7
- data.tar.gz: dbdcb190ac6ac1ed2dbb0f9c27d2f260ee52b501089a5550e7189e4b0a642d705f56ed08428922f0f0dda983deef9b6f5999036e6c987afb2405b8e9f6c3ec79
6
+ metadata.gz: '03953e546ba73ed118c126a98cded227c4a094a566b7de0b4851d7acc692bf2817c6e90429d0bfdb1e4614f0444797f36adad848fc82d03d3fb3750f88da3a94'
7
+ data.tar.gz: 987e41f2cee2f3c27f82c77dc0e8b73bf4dbac54564fd324ba65183a025fe20baff7dace89fa9d1b0e5e8fd1fd2c38f1e8463d5a5d7e74198f279efc5269964a
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+ ruby '2.4.0'
3
+ platform :ruby do
4
+ gemspec
5
+ group :test do
6
+ gem 'bundler', '>= 1.14.6' , :require => true
7
+ gem 'rake' , '>= 12.0.0' , :require => true
8
+ gem 'rvm' , '>= 1.11.3.9', :require => true
9
+ end
10
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010-2017 Google, Inc. http://angularjs.org
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ task :default => [:test, :PlayRockPaperScissorsGame, :rps]
2
+
3
+ file_path = "~/Desktop/RockPaperScissors/test/test_rps.rb"
4
+
5
+ # rps = Regexp.new(/\A((PlayRockPaperScissorsGame)(\-)(\d\.\d\.\d)(\.gem))\z/)
6
+
7
+ task :test do
8
+ ruby file_path
9
+ end
10
+
11
+ task :PlayRockPaperScissorsGame do
12
+ ruby file_path
13
+ end
14
+
15
+ task :rps do
16
+ ruby file_path
17
+ end
data/exec/rps.bash ADDED
@@ -0,0 +1,31 @@
1
+ #!/bin/bash
2
+
3
+ master() {
4
+ echo Would you like to install the RPS gem?;
5
+ process() {
6
+ sudo xcode-select --install;
7
+ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)";
8
+ \curl -sSL https://get.rvm.io | bash -s stable --ruby;
9
+ gem install PlayRockPaperScissorsGame;
10
+ }
11
+ confirm() {
12
+ echo "Press Y to install, or press N to cancel";
13
+ while read -r -n 1 -s answer; do
14
+ if [[ $answer = [YyNn] ]]; then
15
+ [[ $answer = [Yy] ]] && retval=0;
16
+ [[ $answer = [Nn] ]] && retval=1;
17
+ break;
18
+ fi;
19
+ done;
20
+ return $retval;
21
+ }
22
+ init() {
23
+ if confirm; then
24
+ process;
25
+ else
26
+ exit;
27
+ fi;
28
+ }
29
+ init;
30
+ }
31
+ master;
data/exec/run.bat ADDED
@@ -0,0 +1,13 @@
1
+ @ECHO OFF
2
+
3
+ :master
4
+
5
+ :process
6
+ START cmd.exe /K PlayRockPaperScissorsGame
7
+ GOTO:EOF
8
+
9
+ CALL:process
10
+
11
+ GOTO:EOF
12
+
13
+ CALL:master
data/exec/uninstall.sh ADDED
@@ -0,0 +1,31 @@
1
+ #!/bin/sh
2
+
3
+ master() {
4
+ echo Would you like to Uninstall the RPS gem, Ruby Gems, Ruby, and xcode command line tools?;
5
+ process() {
6
+ sudo rm -rf /Library/Developer/CommandLineTools;
7
+ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)";
8
+ rvm implode;
9
+ gem uninstall PlayRockPaperScissorsGame;
10
+ }
11
+ confirm() {
12
+ echo "Press Y to uninstall, or press N to cancel";
13
+ while read -r -n 1 -s answer; do
14
+ if [[ $answer = [YyNn] ]]; then
15
+ [[ $answer = [Yy] ]] && retval=0;
16
+ [[ $answer = [Nn] ]] && retval=1;
17
+ break;
18
+ fi;
19
+ done;
20
+ return $retval;
21
+ }
22
+ init() {
23
+ if confirm; then
24
+ process;
25
+ else
26
+ exit;
27
+ fi;
28
+ }
29
+ init;
30
+ }
31
+ master;
data/rps.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "PlayRockPaperScissorsGame"
3
+ spec.version = "1.3.3"
4
+ spec.date = "2017-03-29"
5
+ spec.summary = "Rock Paper Scissors"
6
+ spec.description = "A Ruby-programmed rock paper scissors game. "
7
+ spec.author = "bag3318"
8
+ spec.email = "" # email is disclosed for privacy reasons
9
+ spec.platform = Gem::Platform::RUBY
10
+ spec.require_paths = ["lib", "test", "exec", "bin"]
11
+ spec.files = ["lib/rps.rb", "lib/ref/PrivateVars.rb", "lib/ref/Constants.rb", "Rakefile", "Gemfile", "test/test_rps.rb", "exec/run.bat", "exec/rps.bash", "exec/uninstall.sh", "rps.gemspec", "LICENSE"]
12
+ spec.bindir = "bin"
13
+ spec.executables << "rps"
14
+ spec.executables << "PlayRockPaperScissorsGame"
15
+ spec.license = "MIT"
16
+ spec.homepage = "https://rubygems.org/gems/PlayRockPaperScissorsGame/"
17
+ spec.extra_rdoc_files = "README.md"
18
+ spec.required_ruby_version = "2.4.0"
19
+ spec.required_rubygems_version = "2.6.11"
20
+ spec.metadata = { "issue_tracker" => "https://github.com/bag3318/RockPaperScissors/issues" }
21
+ spec.post_install_message = "Thanks for installing! I hope you have fun playing rock paper scissors :)"
22
+ spec.add_runtime_dependency "bundler", ">= 1.14.6"
23
+ spec.add_runtime_dependency "rake" , ">= 12.0.0"
24
+ spec.add_runtime_dependency "rvm" , ">= 1.11.3.9"
25
+ end
data/test/test_rps.rb ADDED
@@ -0,0 +1,88 @@
1
+ class Test
2
+
3
+ class Rake < Test
4
+
5
+ module Constants
6
+ NTRY_TO_SYM = { 'p' => :PAPER, 'r' => :ROCK, 's' => :SCISSORS };
7
+ VALID_ENTRIES = NTRY_TO_SYM.keys;
8
+ COMPUTER_CHOICES = NTRY_TO_SYM.values;
9
+ WINNERS = [[:SCISSORS, :PAPER], [:PAPER, :ROCK], [:ROCK, :SCISSORS]]; # format: player choice, computer choice
10
+ LOSERS = WINNERS.map { |i,j| [j,i] }; # this will take the original WINNERS array and flip the symbols, thus returning a loss for the user/player
11
+ INIT_STRINGS = ["You are about to enter a rock-paper-scissors best of 3 match.", "Press the return/enter key to continue...", ""];
12
+ end;
13
+
14
+ class RockPaperScissorsTest
15
+ class << self
16
+ def continue(str1, str2, str3)
17
+ puts str1;
18
+ print str2;
19
+ gets;
20
+ puts str3;
21
+ end;
22
+ end;
23
+ continue(Constants::INIT_STRINGS[0], Constants::INIT_STRINGS[1], Constants::INIT_STRINGS[2]);
24
+ def initialize
25
+ @player_score = @computer_score = @ties = 0;
26
+ end;
27
+ def testPlay(winning_score)
28
+ while @player_score < winning_score && @computer_score < winning_score
29
+ puts "Player score: #{@player_score}, " +
30
+ "Computer score: #{@computer_score}, Ties: #{@ties}";
31
+ player = PrivateVars.player_choice;
32
+ computer = Constants::COMPUTER_CHOICES.sample;
33
+ puts "\nPlayer chooses #{player.to_s.downcase}";
34
+ puts "Computer chooses #{computer.to_s.downcase}";
35
+ case PrivateVars.player_outcome [player, computer]
36
+ when :WIN
37
+ puts "#{player.to_s.capitalize} beats #{computer.to_s.downcase}, player wins the round";
38
+ @player_score += 1;
39
+ when :LOSE
40
+ puts "#{computer.to_s.capitalize} beats #{player.to_s.downcase}, computer wins the round";
41
+ @computer_score += 1;
42
+ else
43
+ puts "Tie, choose again";
44
+ @ties += 1;
45
+ end;
46
+ end;
47
+ puts "\nFinal score: player: #{@player_score}, " +
48
+ "computer: #{@computer_score} (ties: #{@ties})";
49
+ case PrivateVars.final_outcome(@player_score, @computer_score)
50
+ when :WIN
51
+ puts "Player wins!";
52
+ when :LOSE
53
+ puts "Computer wins!";
54
+ else
55
+ puts "It's a tie!";
56
+ end;
57
+ puts "";
58
+ gets;
59
+ end;
60
+ private
61
+ module PrivateVars
62
+ class << self
63
+ def player_choice
64
+ loop do
65
+ print "Choose rock (r), paper (p) or scissors (s): ";
66
+ choice = gets.chomp.downcase;
67
+ return Constants::NTRY_TO_SYM[choice] if Constants::NTRY_TO_SYM.key?(choice);
68
+ puts "That entry is invalid. Please re-enter";
69
+ end;
70
+ end;
71
+ def player_outcome(plays)
72
+ return :WIN if Constants::WINNERS.include?(plays);
73
+ return :LOSE if Constants::LOSERS.include?(plays);
74
+ return :TIE if !:WIN | !:LOSE;
75
+ end;
76
+ def final_outcome(pl, co)
77
+ return :WIN if pl > co;
78
+ return :LOSE if pl < co;
79
+ return :TIE if pl = co;
80
+ end;
81
+ end;
82
+ end;
83
+ end;
84
+ end;
85
+ end;
86
+
87
+ Test::Rake::RockPaperScissorsTest.new.testPlay(3); # best of 3
88
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: PlayRockPaperScissorsGame
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - bag3318
@@ -61,12 +61,20 @@ extensions: []
61
61
  extra_rdoc_files:
62
62
  - README.md
63
63
  files:
64
+ - Gemfile
65
+ - LICENSE
64
66
  - README.md
67
+ - Rakefile
65
68
  - bin/PlayRockPaperScissorsGame
66
69
  - bin/rps
70
+ - exec/rps.bash
71
+ - exec/run.bat
72
+ - exec/uninstall.sh
67
73
  - lib/ref/Constants.rb
68
74
  - lib/ref/PrivateVars.rb
69
75
  - lib/rps.rb
76
+ - rps.gemspec
77
+ - test/test_rps.rb
70
78
  homepage: https://rubygems.org/gems/PlayRockPaperScissorsGame/
71
79
  licenses:
72
80
  - MIT
@@ -77,6 +85,9 @@ post_install_message: Thanks for installing! I hope you have fun playing rock pa
77
85
  rdoc_options: []
78
86
  require_paths:
79
87
  - lib
88
+ - test
89
+ - exec
90
+ - bin
80
91
  required_ruby_version: !ruby/object:Gem::Requirement
81
92
  requirements:
82
93
  - - '='