konamio 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +26 -0
- data/MIT-LICENSE +20 -0
- data/README.md +1 -0
- data/Rakefile +9 -0
- data/konamio.gemspec +22 -0
- data/lib/konamio.rb +6 -0
- data/lib/konamio/key_map.rb +1 -0
- data/lib/konamio/prompt.rb +13 -0
- data/lib/konamio/sequence.rb +7 -0
- data/lib/konamio/sequence/listener.rb +33 -0
- data/lib/konamio/sequence/requisition.rb +46 -0
- data/lib/konamio/version.rb +3 -0
- data/test/minitest_helper.rb +13 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 07768607588f91ae5e6c3ec94cb699ba11d41013
|
4
|
+
data.tar.gz: 9734e2819d9e9f47766b2540e54e3cb10ccf7002
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dadb81c80c6d589fa9c74d186a23fad5ac15d8879df638205574b5b0beb1a17bc787adf76f02c0731870104cbb232a4eb3ddfd4d3e05f31735e5a52307b484d0
|
7
|
+
data.tar.gz: 6ac723e1f3ff320ac883782e9aac5599b06b707cf7be45a4ffdde96a62ce16b881879df0c23ee8e7ff2878857173e258a96cf844dab20398bb64142c93d4256d
|
data/.gitignore
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
6
|
+
|
7
|
+
# Ignore bundler config
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
*.sw?
|
11
|
+
.sw?
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
konamio (0.0.1)
|
5
|
+
pay_dirt
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
coderay (1.0.9)
|
11
|
+
method_source (0.8.1)
|
12
|
+
minitest (4.7.0)
|
13
|
+
pay_dirt (0.0.5)
|
14
|
+
pry (0.9.12)
|
15
|
+
coderay (~> 1.0.5)
|
16
|
+
method_source (~> 0.8)
|
17
|
+
slop (~> 3.4)
|
18
|
+
slop (3.4.4)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
konamio!
|
25
|
+
minitest
|
26
|
+
pry
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Konamio
|
data/Rakefile
ADDED
data/konamio.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "konamio/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "konamio"
|
7
|
+
s.version = Konamio::VERSION
|
8
|
+
s.authors = ["Tad Hosford"]
|
9
|
+
s.email = ["tad.hosford@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/rthbound/konamio"
|
11
|
+
s.summary = "I'm gonna recognize the konami sequence"
|
12
|
+
s.description = "Recognize sequences in Ruby... just for fun."
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test}/*`.split("\n")
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
|
18
|
+
s.add_runtime_dependency "pay_dirt"
|
19
|
+
s.add_development_dependency "minitest"
|
20
|
+
s.add_development_dependency "pry"
|
21
|
+
s.add_development_dependency "rake"
|
22
|
+
end
|
data/lib/konamio.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
module Konamio
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Konamio
|
2
|
+
module Sequence
|
3
|
+
class Listener < PayDirt::Base
|
4
|
+
def initialize(options)
|
5
|
+
options = { input: $stdin }.merge(options)
|
6
|
+
load_options(:sequence, options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def execute!
|
10
|
+
result = listen(@sequence)
|
11
|
+
|
12
|
+
if result == true
|
13
|
+
return PayDirt::Result.new(success: true, data: { sequence: @sequence[1..-1]})
|
14
|
+
elsif result == false
|
15
|
+
return PayDirt::Result.new(success: false)
|
16
|
+
elsif result.nil?
|
17
|
+
return PayDirt::Result.new(success: false, data: {terminate: true })
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def listen(sequence)
|
22
|
+
case @input.getch
|
23
|
+
when sequence[0]
|
24
|
+
true
|
25
|
+
when "\e"
|
26
|
+
nil
|
27
|
+
else
|
28
|
+
false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Konamio
|
2
|
+
module Sequence
|
3
|
+
class Requisition < PayDirt::Base
|
4
|
+
def initialize(options={})
|
5
|
+
options = {
|
6
|
+
sequence: "\e[A\e[A\e[B\e[B\e[D\e[C\e[D\e[CBA",
|
7
|
+
prompt: "Enter konami code (or hit escape)",
|
8
|
+
confirmation: "Good job, you."
|
9
|
+
}.merge(options)
|
10
|
+
|
11
|
+
load_options(:sequence, options)
|
12
|
+
|
13
|
+
prompt(@prompt)
|
14
|
+
listen(@sequence)
|
15
|
+
finish(false)
|
16
|
+
end
|
17
|
+
|
18
|
+
def prompt(prompt)
|
19
|
+
Konamio::Prompt.new(prompt: prompt)
|
20
|
+
end
|
21
|
+
|
22
|
+
def listen(sequence)
|
23
|
+
listener = Konamio::Sequence::Listener.new(sequence: sequence)
|
24
|
+
received = listener.execute!
|
25
|
+
|
26
|
+
if received.successful?
|
27
|
+
if received.data[:sequence].empty?
|
28
|
+
puts @confirmation and finish
|
29
|
+
else
|
30
|
+
listen(received.data[:sequence])
|
31
|
+
end
|
32
|
+
elsif received.data[:terminate]
|
33
|
+
finish(false)
|
34
|
+
else
|
35
|
+
prompt(@prompt)
|
36
|
+
listen(sequence)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def finish(successful)
|
41
|
+
return PayDirt::Result.new(success: successful)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: konamio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tad Hosford
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-05-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pay_dirt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Recognize sequences in Ruby... just for fun.
|
70
|
+
email:
|
71
|
+
- tad.hosford@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- Gemfile.lock
|
79
|
+
- MIT-LICENSE
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- konamio.gemspec
|
83
|
+
- lib/konamio.rb
|
84
|
+
- lib/konamio/key_map.rb
|
85
|
+
- lib/konamio/prompt.rb
|
86
|
+
- lib/konamio/sequence.rb
|
87
|
+
- lib/konamio/sequence/listener.rb
|
88
|
+
- lib/konamio/sequence/requisition.rb
|
89
|
+
- lib/konamio/version.rb
|
90
|
+
- test/minitest_helper.rb
|
91
|
+
homepage: https://github.com/rthbound/konamio
|
92
|
+
licenses: []
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.0.0.rc.2
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: I'm gonna recognize the konami sequence
|
114
|
+
test_files: []
|