konamio 0.1.1 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/konamio/key_map.rb +15 -12
- data/lib/konamio/sequence/listener.rb +3 -1
- data/lib/konamio/sequence/requisition.rb +1 -0
- data/lib/konamio/version.rb +1 -1
- data/lib/konamio.rb +2 -2
- data/test/konamio/key_map_test.rb +8 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61d4aed1d5bd09a19bb68f6f00d110ced5c6701d
|
4
|
+
data.tar.gz: e9b3517d2be70b3460f48ee619196a82d7932570
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d40dba91a972dae2e26a6d2734dc01139783f434b73544b0b9321bab6c999670520e07f4829ce925e1205bc9ad1006a87a45e06d1dbd04efcba709508e8cf431
|
7
|
+
data.tar.gz: 6e3b7879dd016fb30338399d25b78d0add6ee154affad1e807dddb5e59ed3da4944d63e939b9e9bef481e9b75b40273c4827ec41c9d63ff3add107e76cb7d13a
|
data/lib/konamio/key_map.rb
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
module Konamio
|
2
2
|
module KeyMap
|
3
|
-
def self.
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
3
|
+
def self.included(base)
|
4
|
+
def sequence_for(key)
|
5
|
+
{
|
6
|
+
space: " ",
|
7
|
+
tab: "\t",
|
8
|
+
return: "\r",
|
9
|
+
line_feed: "\n",
|
10
|
+
escape: "\e",
|
11
|
+
up: "\e[A",
|
12
|
+
down: "\e[B",
|
13
|
+
right: "\e[C",
|
14
|
+
left: "\e[D",
|
15
|
+
konami: [:up, :up, :down, :down, :left, :right, :left, :right, "B", "A"]
|
16
|
+
}.fetch(key) { key }
|
17
|
+
end
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Konamio
|
2
2
|
module Sequence
|
3
3
|
class Listener < PayDirt::Base
|
4
|
+
include Konamio::KeyMap
|
5
|
+
|
4
6
|
def initialize(options)
|
5
7
|
options = { input: $stdin, debounce: 0.0001 }.merge(options)
|
6
8
|
load_options(:sequence, options)
|
@@ -34,7 +36,7 @@ module Konamio
|
|
34
36
|
end
|
35
37
|
|
36
38
|
case input
|
37
|
-
when
|
39
|
+
when sequence_for(@sequence[0])
|
38
40
|
true
|
39
41
|
when "\e"
|
40
42
|
:negative
|
data/lib/konamio/version.rb
CHANGED
data/lib/konamio.rb
CHANGED
@@ -2,11 +2,15 @@ require "minitest_helper"
|
|
2
2
|
|
3
3
|
describe Konamio::KeyMap do
|
4
4
|
before do
|
5
|
-
|
5
|
+
class TestCase
|
6
|
+
include Konamio::KeyMap
|
7
|
+
end
|
8
|
+
|
9
|
+
@subject = TestCase.new
|
6
10
|
end
|
7
11
|
|
8
12
|
it "returns the input provided if no matches are found" do
|
9
|
-
assert @subject.sequence(:
|
13
|
+
assert @subject.sequence(:konamio) == :konamio
|
10
14
|
end
|
11
15
|
|
12
16
|
it "recognizes a number of symbols" do
|
@@ -19,7 +23,8 @@ describe Konamio::KeyMap do
|
|
19
23
|
:tab,
|
20
24
|
:return,
|
21
25
|
:line_feed,
|
22
|
-
:escape
|
26
|
+
:escape,
|
27
|
+
:konami
|
23
28
|
].each do |symbol|
|
24
29
|
assert @subject.sequence(symbol) != symbol
|
25
30
|
end
|