cinch_hangman 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ module Cinch::Plugins
2
2
  class Hangman
3
3
  include Cinch::Plugin
4
4
  match /hang guess (.*)/i, :method => :guess
5
- match /hang new (#\S*) (.*)/i, :method => :new_game
5
+ match /hang new (#\S*) ([\sa-zA-Z0-9])/i, :method => :new_game
6
6
  def new_game(m, channel, answer)
7
7
  @game = CinchHangman::Game.new(answer)
8
8
  Channel(channel).send(@game.describe)
@@ -7,7 +7,7 @@ module CinchHangman
7
7
  @guesses = ""
8
8
  end
9
9
  def guess(guess)
10
- @guesses << guess.downcase.gsub(/[^a-z]/, "")
10
+ @guesses << guess.downcase.gsub(/[^a-z0-9]/, "")
11
11
  end
12
12
  def describe
13
13
  if @guesses.empty?
@@ -1,3 +1,3 @@
1
1
  module CinchHangman
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/spec/game_spec.rb CHANGED
@@ -14,16 +14,17 @@ describe CinchHangman::Game do
14
14
  end
15
15
  describe 'guesses' do
16
16
  describe 'ignore' do
17
- it 'digits' do
18
- subject.guess("x3")
19
- subject.describe.should include '5 guesses'
20
- end
21
17
  it 'whitespace' do
22
18
  subject.guess("c a t")
23
19
  subject.describe.should include '3 guesses'
24
20
  end
25
21
  end
26
- describe 'correct' do
22
+ describe 'correct' do
23
+ it 'when containing a single digit from the answer' do
24
+ subject = CinchHangman::Game.new("99 luftballons")
25
+ subject.guess("9")
26
+ subject.describe.should include '6 guesses'
27
+ end
27
28
  it 'when containing a single character from the answer' do
28
29
  subject.guess("h")
29
30
  subject.describe.should include '6 guesses'
@@ -34,6 +35,11 @@ describe CinchHangman::Game do
34
35
  end
35
36
  end
36
37
  describe 'incorrect' do
38
+ it 'when containing a single digit not in the answer' do
39
+ subject = CinchHangman::Game.new("99 luftballons")
40
+ subject.guess("6")
41
+ subject.describe.should include '5 guesses'
42
+ end
37
43
  it 'when containing a single character not in the answer' do
38
44
  subject.guess("x")
39
45
  subject.describe.should include '5 guesses'
@@ -44,6 +50,11 @@ describe CinchHangman::Game do
44
50
  end
45
51
  end
46
52
  describe 'strikeouts' do
53
+ it 'already guessed digits' do
54
+ subject.guess("2")
55
+ subject.guess("1")
56
+ subject.describe.should include 'guessed: 12'
57
+ end
47
58
  it 'already guessed letters' do
48
59
  subject.guess("b")
49
60
  subject.guess("a")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch_hangman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-12 00:00:00.000000000Z
12
+ date: 2011-11-06 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cinch
16
- requirement: &2169564320 !ruby/object:Gem::Requirement
16
+ requirement: &2153871700 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2169564320
24
+ version_requirements: *2153871700
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2169563840 !ruby/object:Gem::Requirement
27
+ requirement: &2153871020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2169563840
35
+ version_requirements: *2153871020
36
36
  description:
37
37
  email:
38
38
  - shanonmcquay@gmail.com
@@ -64,7 +64,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
64
64
  version: '0'
65
65
  segments:
66
66
  - 0
67
- hash: 4239588220923122799
67
+ hash: -4010751664144861075
68
68
  required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  none: false
70
70
  requirements:
@@ -73,10 +73,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  version: '0'
74
74
  segments:
75
75
  - 0
76
- hash: 4239588220923122799
76
+ hash: -4010751664144861075
77
77
  requirements: []
78
78
  rubyforge_project: cinch_hangman
79
- rubygems_version: 1.8.6
79
+ rubygems_version: 1.8.10
80
80
  signing_key:
81
81
  specification_version: 3
82
82
  summary: Let your IRC bot conduct a game of hangman.