konamio 1.0.0 → 1.0.1

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: 37ffc53d7fc6b46bcbb18189e27cc170152dc44c
4
- data.tar.gz: 924d388a7c51e926ffecb6ffbc8058326ac7eca9
3
+ metadata.gz: 9355bbc85a0b405369b30b96176d3275749a69a9
4
+ data.tar.gz: c9610b2b28cc66a1f96bce6e0f470422fc80fbff
5
5
  SHA512:
6
- metadata.gz: 7bb9c6a000e52adea2c05c8f8c75a0e40350e35bce0fb650222260bb7805782337acef371cf2601c902e780ff3f9bae0bc3598c59341ba3da3091dbca549cae5
7
- data.tar.gz: 889017b85fd30f1e188af487f320c4660b8cbcc413bbc8f3c9c8478dccdfb0c3e7b8e8bbf144598f33fa204cd90496de4036cb27ac16958e7077ff6840f645ae
6
+ metadata.gz: dfcb60568f3c7289ae2eec4b0ac44066e7f80216841fe7bfcef3d91f420910907a8f1ac9dc9b1426f0b2857f52be40d6400adc31e1db034b240e17bad5c4e421
7
+ data.tar.gz: d224f73499c5ced6f5e21b6976a667bc09f64792aa619d7fe786906a410ef6242b87f0fc4788220234d69be8c16d1d73d254be64910e04a9e1045c6544ed02c3
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/konamio.png)](http://badge.fury.io/rb/konamio) [![Build Status](https://travis-ci.org/rthbound/konamio.png?branch=master)](https://travis-ci.org/rthbound/konamio) [![Coverage Status](https://coveralls.io/repos/rthbound/konamio/badge.png)](https://coveralls.io/r/rthbound/konamio) [![Code Climate](https://codeclimate.com/github/rthbound/konamio.png)](https://codeclimate.com/github/rthbound/konamio)
4
4
 
5
-
6
5
  ![Konami Code](http://images.nintendolife.com/news/2012/01/the_origins_of_the_konami_code_revealed/attachment/0/small.jpg)
7
6
 
8
7
  gem install konamio
@@ -26,9 +25,12 @@ Good job, you.
26
25
 
27
26
  #### Sequences
28
27
 
29
- You can configure it to listen for any ascii based sequence you want. This can be specified using a string (`"foobar"`) or an array of recognized symbols and one character strings (escaped characters are okay, e.g. `[:up, "1", "2", "3", "\t"]`):
28
+ You can configure it to listen for any ascii based sequence you want
29
+ using the `:sequence` option. This can be specified using a string
30
+ (`"foobar"`) or an array of recognized symbols and one-character strings
31
+ (escaped charactersare okay, e.g. `[:up, "1", "2", "3", "\t"]`):
30
32
 
31
- ```ruby
33
+ ```
32
34
  > Konamio::Sequence::Requisition.new({
33
35
  sequence: "a".upto("z").to_a.reverse,
34
36
  prompt: "Say the alphabet backwards",
@@ -43,7 +45,7 @@ Okay, you can go
43
45
 
44
46
  #### Output
45
47
 
46
- There are three dialogs that Konamio might send to standard out.
48
+ There are three dialogs that Konamio might send to stdout.
47
49
 
48
50
  1. `:prompt` is the dialog displayed initially, and each time the user fails to supply the proper sequence.
49
51
  2. `:confirmation` is displayed when the required sequence is entered properly.
@@ -53,7 +55,11 @@ You can customize any of these dialogs, or disable them individually by passing
53
55
 
54
56
  #### Success!
55
57
 
56
- It would be boring if all Konamio did was return a result object. In fact, `Konamio::Sequence::Requisition#execute!` takes a block, and will execute that block when the sequence has been successfully entered. You're limited only by your imagination and the context of your application.
58
+ It would be boring if all Konamio did was return a result object. That's why
59
+ `Konamio::Sequence::Requisition#execute!` **takes a block**, and will execute
60
+ that block when the sequence has been successfully entered. You're limited only
61
+ by your imagination and the context of your application. Konamio will supply
62
+ the value of the sequence to the block.
57
63
 
58
64
  The following code would prompt the user to enter the konami code twice:
59
65
  ```ruby
@@ -24,13 +24,14 @@ module Konamio
24
24
  end
25
25
 
26
26
  # @api public
27
+ # @yield [sequence] Gives the sequence to the block
27
28
  # @yieldreturn The result of a block, if supplied
28
29
  # @return Konamio::Result
29
30
  def execute! &block
30
31
  prompt
31
32
 
32
33
  result = listen(@sequence)
33
- yield if block_given? && result.successful?
34
+ yield(@sequence) if block_given? && result.successful?
34
35
 
35
36
  result
36
37
  end
@@ -1,3 +1,3 @@
1
1
  module Konamio
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -9,7 +9,7 @@ describe Konamio::Sequence::Requisition do
9
9
  prompt: @prompt = false,
10
10
  listener: @listener = MiniTest::Mock.new,
11
11
  speaker: @speaker = MiniTest::Mock.new,
12
- sequence: @sequence = ["a"],
12
+ sequence: @sequence = "ab",
13
13
  confirmation: @confirmation = false,
14
14
  cancellation: false
15
15
  }
@@ -22,10 +22,6 @@ describe Konamio::Sequence::Requisition do
22
22
  @listener_result = MiniTest::Mock.new
23
23
  @listener_instance.expect(:execute!, @listener_result)
24
24
 
25
- # The @listener_result contains some data
26
- @data_hash = MiniTest::Mock.new
27
- @listener_result.expect(:data, @data_hash)
28
- @data_hash.expect(:[], :negative, [:sequence])
29
25
  end
30
26
 
31
27
  it "can be initialized" do
@@ -37,6 +33,27 @@ describe Konamio::Sequence::Requisition do
37
33
  end
38
34
 
39
35
  it "can be cancelled" do
36
+ # The @listener_result contains some data
37
+ @data_hash = MiniTest::Mock.new
38
+ @listener_result.expect(:data, @data_hash)
39
+ @data_hash.expect(:[], :negative, [:sequence])
40
+
41
+ assert !@subject.new(@options).execute!.successful?
42
+ end
43
+
44
+ it "will listen for the next character" do
45
+ # This will happen a second time
46
+ @listener.expect(:new, @listener_instance, [{ sequence: "b", input: @input }])
47
+ @listener_instance.expect(:execute!, @listener_result)
48
+
49
+ # The @listener_result contains some data
50
+ @data_hash = MiniTest::Mock.new
51
+ @listener_result.expect(:data, @data_hash)
52
+ @data_hash.expect(:[], "b", [:sequence])
53
+
54
+ @listener_result.expect(:data, @data_hash)
55
+ @data_hash.expect(:[], :negative, [:sequence])
56
+
40
57
  assert !@subject.new(@options).execute!.successful?
41
58
  end
42
59
  end
@@ -59,4 +59,13 @@ describe Konamio::Sequence::Requisition do
59
59
  @speaker.expect(:new, @speaker_instance, [{ prompt: "konamio!", output: @output }])
60
60
  assert @subject.new(@options).execute! { @speaker.new(prompt: "konamio!", output: @output) }
61
61
  end
62
+
63
+ it "will pass the sequence to the block" do
64
+ truth = false
65
+ assert @subject.new(@options).execute! { |seq|
66
+ truth = !truth if @sequence == seq
67
+ }
68
+
69
+ assert truth
70
+ end
62
71
  end
@@ -1,6 +1,8 @@
1
1
  # Testing frameworks
2
- require 'coveralls'
3
- Coveralls.wear!
2
+ #require 'coveralls'
3
+ #Coveralls.wear!
4
+ require 'simplecov'
5
+ SimpleCov.start
4
6
 
5
7
  require "minitest/autorun"
6
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: konamio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tad Hosford