bankey 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bankey.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Adam Nowak
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Bankey
2
+
3
+ get given characters from your password
4
+
5
+ ## Installation
6
+
7
+ install it yourself as:
8
+
9
+ $ gem install bankey
10
+
11
+ ## Usage
12
+
13
+ just do:
14
+
15
+ $ bankey
16
+
17
+ and you will do something like this (your input won't be echoed):
18
+
19
+ Enter your password/input string:
20
+ Which characters do you need? [space is a separator]:
21
+ 1 3 7 8
22
+ 1 -> 3 -> 7 -> 8
23
+ m -> s -> t -> p
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bankey.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bankey/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "bankey"
8
+ gem.version = Bankey::VERSION
9
+ gem.authors = ["Adam Nowak"]
10
+ gem.email = ["lubieniebieski@gmail.com"]
11
+ gem.description = %q{get given characters from your password}
12
+ gem.summary = %q{I was bored by figuring out 3rd, 4th, 8th and xth character from my password when I was attempting to login to my bank account. so here we are...}
13
+ gem.homepage = "https://github.com/lubieniebieski/bankey"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
data/bin/bankey ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
5
+ require 'bankey'
6
+
7
+ exit Bankey::Cli.new(*ARGV).go!
data/lib/bankey.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'io/console'
2
+ require "bankey/cli"
3
+ require "bankey/presenter"
4
+ require "bankey/version"
data/lib/bankey/cli.rb ADDED
@@ -0,0 +1,38 @@
1
+ module Bankey
2
+ class Cli
3
+
4
+ def initialize *args
5
+ @args = args
6
+ end
7
+
8
+ def go!
9
+ Signal.trap(2) {
10
+ return 0
11
+ }
12
+ begin
13
+ input, characters = prepare_data
14
+ get_result(input, characters)
15
+ return 0
16
+ rescue Exception => e
17
+ puts "[ERROR] #{e}"
18
+ return 1
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def prepare_data
25
+ print "Enter your password/input string: \n"
26
+ input_string = STDIN.noecho(&:gets)
27
+ print "Which characters do you need? [space is a separator]: \n"
28
+ characters = gets.split
29
+ [input_string, characters]
30
+ end
31
+
32
+ def get_result input, characters
33
+ puts
34
+ Bankey::Presenter.new(input, characters).show_chars
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,32 @@
1
+ module Bankey
2
+ class Presenter < Struct.new(:input_string, :char_numbers)
3
+
4
+ def initialize input_string, char_numbers
5
+ self.input_string = input_string
6
+ self.char_numbers = char_numbers.map(&:to_i).delete_if &:zero?
7
+ validate!
8
+ end
9
+
10
+ def show_chars
11
+ output = char_numbers.map { |char_number| input_string[char_number - 1] }
12
+ print "\t #{char_numbers.join(" -> ")}\n"
13
+ print "\t #{output.join(" -> ")}"
14
+ end
15
+
16
+ private
17
+
18
+ def validate!
19
+ raise missing_numbers_error if char_numbers.empty?
20
+ raise input_string_length_error if (char_numbers.max - 1) >= input_string.length
21
+ end
22
+
23
+ def input_string_length_error
24
+ ArgumentError.new("your input is only #{input_string.length} chars long, but you've required chars which are outside the input")
25
+ end
26
+
27
+ def missing_numbers_error
28
+ ArgumentError.new("we need some real numbers here")
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module Bankey
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bankey
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Adam Nowak
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-16 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: get given characters from your password
15
+ email:
16
+ - lubieniebieski@gmail.com
17
+ executables:
18
+ - bankey
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - bankey.gemspec
28
+ - bin/bankey
29
+ - lib/bankey.rb
30
+ - lib/bankey/cli.rb
31
+ - lib/bankey/presenter.rb
32
+ - lib/bankey/version.rb
33
+ homepage: https://github.com/lubieniebieski/bankey
34
+ licenses: []
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ none: false
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ none: false
51
+ requirements: []
52
+ rubyforge_project:
53
+ rubygems_version: 1.8.25
54
+ signing_key:
55
+ specification_version: 3
56
+ summary: I was bored by figuring out 3rd, 4th, 8th and xth character from my password
57
+ when I was attempting to login to my bank account. so here we are...
58
+ test_files: []