konamio 0.1.0 → 0.1.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: 22b984e3f6c89a0d7cda0f184d2ec96290a77ee3
4
- data.tar.gz: 9eca8ee78b957a7f9dff172b7bd8f3f241040ee8
3
+ metadata.gz: 64567479769f776f55124c2cc781254b13bb00d2
4
+ data.tar.gz: fce728a4fa000545e348f620e55d130acd192944
5
5
  SHA512:
6
- metadata.gz: 29ea0e389242c88c80b08383342ea42fce8d0be740d3185c7c2cf740ee22903c2cd3b8c2afaf08747a33158b743adfc160af2970e5adb04c19b57fd70f9de90d
7
- data.tar.gz: c53abe1659fccb8c2d31f12edb9088177ca294c07206c55cad5f5a83707b6564dd0b15db3847bc1fa6a7325ea44e31fc28758a12d3d3983f6f43e230c6274d2d
6
+ metadata.gz: f19d56779d7d3f2475ed57249b06b23990449325714d5f896fe33b61e00c76807d38cd8ed1c699f271959c25f1544ffc83a46afdb1c55b9fe7f6c1a95e285cc6
7
+ data.tar.gz: cc2ee72ba0372c95271e8fdf3975171fbbf339826491afdeb4f1394c96bbd5027a69173076aa7474efe79e29c49ac6cdb4573cb739de43048f061251890400cb
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  # Ignore bundler config
8
8
  /.bundle
9
+ /Gemfile.lock
9
10
 
10
11
  *.sw?
11
12
  .sw?
@@ -0,0 +1,17 @@
1
+ module Konamio
2
+ module KeyMap
3
+ def self.sequence(key)
4
+ {
5
+ space: " ",
6
+ tab: "\t",
7
+ return: "\r",
8
+ line_feed: "\n",
9
+ escape: "\e",
10
+ up: "\e[A",
11
+ down: "\e[B",
12
+ right: "\e[C",
13
+ left: "\e[D"
14
+ }.fetch(key) { key }
15
+ end
16
+ end
17
+ end
@@ -34,7 +34,7 @@ module Konamio
34
34
  end
35
35
 
36
36
  case input
37
- when @sequence[0]
37
+ when Konamio::KeyMap.sequence(@sequence[0])
38
38
  true
39
39
  when "\e"
40
40
  :negative
@@ -5,7 +5,7 @@ module Konamio
5
5
  options = {
6
6
  speaker: Konamio::Prompt,
7
7
  listener: Konamio::Sequence::Listener,
8
- sequence: ["\e[A","\e[A","\e[B","\e[B","\e[D","\e[C","\e[D","\e[C","B","A"],
8
+ sequence: [:up,:up,:down,:down,:left,:right,:left,:right,"B","A"],
9
9
  prompt: "Enter konami code (or hit escape)",
10
10
  confirmation: "Good job, you."
11
11
  }.merge(options)
@@ -1,3 +1,3 @@
1
1
  module Konamio
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/konamio.rb CHANGED
@@ -3,3 +3,4 @@ require "pay_dirt"
3
3
  require_relative 'konamio/prompt'
4
4
  require_relative 'konamio/sequence/listener'
5
5
  require_relative 'konamio/sequence/requisition'
6
+ require_relative 'konamio/key_map'
@@ -0,0 +1,28 @@
1
+ require "minitest_helper"
2
+
3
+ describe Konamio::KeyMap do
4
+ before do
5
+ @subject = Konamio::KeyMap
6
+ end
7
+
8
+ it "returns the input provided if no matches are found" do
9
+ assert @subject.sequence(:konami) == :konami
10
+ end
11
+
12
+ it "recognizes a number of symbols" do
13
+ [
14
+ :up,
15
+ :down,
16
+ :left,
17
+ :right,
18
+ :space,
19
+ :tab,
20
+ :return,
21
+ :line_feed,
22
+ :escape
23
+ ].each do |symbol|
24
+ assert @subject.sequence(symbol) != symbol
25
+ end
26
+ end
27
+ end
28
+
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: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tad Hosford
@@ -80,10 +80,12 @@ files:
80
80
  - Rakefile
81
81
  - konamio.gemspec
82
82
  - lib/konamio.rb
83
+ - lib/konamio/key_map.rb
83
84
  - lib/konamio/prompt.rb
84
85
  - lib/konamio/sequence/listener.rb
85
86
  - lib/konamio/sequence/requisition.rb
86
87
  - lib/konamio/version.rb
88
+ - test/konamio/key_map_test.rb
87
89
  - test/konamio/prompt_test.rb
88
90
  - test/konamio/sequence/listener_test.rb
89
91
  - test/konamio/sequence/requisition_test.rb