to_pass 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
data/bin/to_pass CHANGED
@@ -5,43 +5,6 @@
5
5
  base_path = ( File.expand_path(File.dirname(__FILE__)+'/..') )
6
6
  $LOAD_PATH << base_path unless $LOAD_PATH.include?(base_path)
7
7
 
8
- require 'optparse'
9
8
  require 'lib/to_pass'
10
9
 
11
- # parse options
12
- options = {
13
- :pipe_usage => ARGV[0].nil?,
14
- :algorithm => 'basic_de'
15
- }
16
-
17
- OptionParser.new do |opts|
18
- opts.banner = "Usage: #{__FILE__} [options] passphrase"
19
- opts.separator ""
20
-
21
- opts.on('-a', '--algorithm ALGORITM', "use specified algorithm for transformation") do |value|
22
- options[:algorithm] = value
23
- end
24
-
25
- opts.separator ""
26
-
27
- opts.on_tail("-h", "--help", "Show this message") do
28
- puts opts
29
- exit
30
- end
31
- end.parse!
32
-
33
- # get input string
34
- string= unless options[:pipe_usage]
35
- ARGV[0]
36
- else
37
- $stdin.read.chomp
38
- end
39
-
40
- # perform "heavy" work
41
- password = ToPass::Base.new( string, options[:algorithm] ).to_s
42
-
43
- if options[:pipe_usage]
44
- $stdout << password
45
- else
46
- puts password
47
- end
10
+ ToPass::Cli.new.output
@@ -1,3 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ # vim:ft=ruby:enc=utf-8
3
+
1
4
  require 'pathname'
2
5
  require 'yaml'
3
6
 
data/lib/to_pass/base.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ # vim:ft=ruby:enc=utf-8
3
+
1
4
  module ToPass
2
5
  # ToPass::Base is mostly a facade for the library.
3
6
  #
@@ -0,0 +1,65 @@
1
+ # -*- coding: utf-8 -*-
2
+ # vim:ft=ruby:enc=utf-8
3
+
4
+ require 'optparse'
5
+
6
+ module ToPass
7
+ class Cli
8
+ def initialize
9
+ @options = parse_options
10
+ @string = get_input_string
11
+ @password = transform
12
+ end
13
+
14
+ def output
15
+ if @options[:pipe_usage]
16
+ $stdout << @password
17
+ else
18
+ puts @password
19
+ end
20
+ end
21
+
22
+ protected
23
+
24
+ # parse the options
25
+ def parse_options
26
+ options = {
27
+ :algorithm => 'basic_de'
28
+ }
29
+
30
+ OptionParser.new do |opts|
31
+ opts.banner = "Usage: #{__FILE__} [options] passphrase"
32
+ opts.separator ""
33
+
34
+ opts.on('-a', '--algorithm ALGORITM', "use specified algorithm for transformation") do |value|
35
+ options[:algorithm] = value
36
+ end
37
+
38
+ opts.separator ""
39
+
40
+ opts.on_tail("-h", "--help", "Show this message") do
41
+ puts opts
42
+ exit
43
+ end
44
+ end.parse!
45
+
46
+ options[:pipe_usage] = ARGV[0].nil?
47
+
48
+ options
49
+ end
50
+
51
+ # get the input string
52
+ def get_input_string
53
+ unless @options[:pipe_usage]
54
+ ARGV[0]
55
+ else
56
+ $stdin.read.chomp
57
+ end
58
+ end
59
+
60
+ # perform "heavy" work
61
+ def transform
62
+ Base.new( @string, @options[:algorithm] ).to_s
63
+ end
64
+ end
65
+ end
@@ -1,3 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ # vim:ft=ruby:enc=utf-8
3
+
1
4
  module ToPass
2
5
  # converts a given string into a password-like word
3
6
  #
@@ -1,3 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ # vim:ft=ruby:enc=utf-8
3
+
1
4
  # Any Object can be a password, as long as it has a string representation.
2
5
  #
3
6
  # This Module provides a shortcut to the password-conversion.
@@ -1,3 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ # vim:ft=ruby:enc=utf-8
3
+
1
4
  module ToPass
2
5
  # The StringConversions-Module is a collection of available
3
6
  # Transformations. Every method is given a string as single argument
data/lib/to_pass.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ # vim:ft=ruby:enc=utf-8
3
+
1
4
  # Library to convert a String into a Password
2
5
  module ToPass
3
6
  # version of gem, read directly from the VERSION-File
@@ -6,9 +9,10 @@ module ToPass
6
9
  # name of gem
7
10
  APP_NAME = 'to_pass'
8
11
 
9
- autoload :Converter, 'lib/to_pass/converter'
10
- autoload :StringConversions, 'lib/to_pass/string_conversions'
12
+ autoload :AlgorithmReader, 'lib/to_pass/algorithm_reader'
11
13
  autoload :Base, 'lib/to_pass/base'
14
+ autoload :Cli, 'lib/to_pass/cli.rb'
15
+ autoload :Converter, 'lib/to_pass/converter'
12
16
  autoload :Integration, 'lib/to_pass/integration'
13
- autoload :AlgorithmReader, 'lib/to_pass/algorithm_reader'
17
+ autoload :StringConversions, 'lib/to_pass/string_conversions'
14
18
  end
data/test/helper.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ # vim:ft=ruby:enc=utf-8
3
+
1
4
  require 'test/unit/testcase'
2
5
  require 'test/unit' unless defined?(Test::Unit)
3
6
  require 'mocha'
@@ -1,3 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ # vim:ft=ruby:enc=utf-8
3
+
1
4
  require File.dirname(__FILE__)+'/helper'
2
5
 
3
6
  class TestAlgorithmReader < Test::Unit::TestCase
data/test/test_base.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ # vim:ft=ruby:enc=utf-8
3
+
1
4
  require File.dirname(__FILE__)+'/helper'
2
5
 
3
6
  class TestBase < Test::Unit::TestCase
data/test/test_cli.rb ADDED
@@ -0,0 +1,41 @@
1
+ # -*- coding: utf-8 -*-
2
+ # vim:ft=ruby:enc=utf-8
3
+
4
+ require File.dirname(__FILE__)+'/helper'
5
+
6
+ class TestCli < Test::Unit::TestCase
7
+ test_presence ToPass::Cli
8
+
9
+ def test_cli_usage_without_algorithm
10
+ assert_nothing_raised do
11
+ assert_equal "t35t", `bin/to_pass test`.chomp
12
+ end
13
+ end
14
+
15
+ def test_cli_usage_with_algorithm
16
+ assert_nothing_raised do
17
+ assert_equal "ti1p4u2", `bin/to_pass 'there is one problem for us, too' -a basic_en`.chomp
18
+ end
19
+ end
20
+
21
+ def test_cli_usage_with_pipes
22
+ assert_nothing_raised do
23
+ assert_equal 't35t', `echo "test" | bin/to_pass`
24
+ end
25
+ end
26
+
27
+
28
+ def test_cli_usage_with_user_algorithm
29
+ with_algorithm_in_user_dir do
30
+ assert_equal "le1/2%z", `bin/to_pass 'leasbpc' -a user_alg`.chomp
31
+ assert_equal "le1/2%z", `bin/to_pass 'luke eats all sausagages because peter cries' -a user_alg`.chomp
32
+ end
33
+ end
34
+
35
+ def test_cli_usage_with_pipes_and_user_algorithm
36
+ with_algorithm_in_user_dir do
37
+ assert_equal "le1/2%z", `echo 'leasbpc' | bin/to_pass -a user_alg`.chomp
38
+ assert_equal "le1/2%z", `echo 'luke eats all sausagages because peter cries' | bin/to_pass -a user_alg`.chomp
39
+ end
40
+ end
41
+ end
@@ -1,3 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ # vim:ft=ruby:enc=utf-8
3
+
1
4
  require File.dirname(__FILE__)+'/helper'
2
5
 
3
6
  class TestConverter < Test::Unit::TestCase
@@ -1,24 +1,9 @@
1
+ # -*- coding: utf-8 -*-
2
+ # vim:ft=ruby:enc=utf-8
3
+
1
4
  require File.dirname(__FILE__)+'/helper'
2
5
 
3
6
  class TestIntegration < Test::Unit::TestCase
4
- def test_cli_usage_without_algorithm
5
- assert_nothing_raised do
6
- assert_equal "t35t", `bin/to_pass test`.chomp
7
- end
8
- end
9
-
10
- def test_cli_usage_with_algorithm
11
- assert_nothing_raised do
12
- assert_equal "ti1p4u2", `bin/to_pass 'there is one problem for us, too' -a basic_en`.chomp
13
- end
14
- end
15
-
16
- def test_cli_usage_with_pipes
17
- assert_nothing_raised do
18
- assert_equal 't35t', `echo "test" | bin/to_pass`
19
- end
20
- end
21
-
22
7
  def test_module_integration
23
8
  assert_nothing_raised do
24
9
  str = "test"
@@ -27,11 +12,4 @@ class TestIntegration < Test::Unit::TestCase
27
12
  assert_equal 't35t', str.to_pass
28
13
  end
29
14
  end
30
-
31
- def test_cli_usage_with_user_algorithm
32
- with_algorithm_in_user_dir do
33
- assert_equal "le1/2%z", `bin/to_pass 'leasbpc' -a user_alg`.chomp
34
- assert_equal "le1/2%z", `bin/to_pass 'luke eats all sausagages because peter cries' -a user_alg`.chomp
35
- end
36
- end
37
15
  end
@@ -1,3 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ # vim:ft=ruby:enc=utf-8
3
+
1
4
  require File.dirname(__FILE__)+'/helper'
2
5
 
3
6
  class TestStringConversion < Test::Unit::TestCase
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_pass
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matthias Viehweger
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-14 00:00:00 +02:00
18
+ date: 2010-06-24 00:00:00 +02:00
19
19
  default_executable: to_pass
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -71,6 +71,7 @@ files:
71
71
  - lib/to_pass.rb
72
72
  - lib/to_pass/algorithm_reader.rb
73
73
  - lib/to_pass/base.rb
74
+ - lib/to_pass/cli.rb
74
75
  - lib/to_pass/converter.rb
75
76
  - lib/to_pass/integration.rb
76
77
  - lib/to_pass/string_conversions.rb
@@ -78,6 +79,7 @@ files:
78
79
  - test/helper.rb
79
80
  - test/test_algorithm_reader.rb
80
81
  - test/test_base.rb
82
+ - test/test_cli.rb
81
83
  - test/test_converter.rb
82
84
  - test/test_integration.rb
83
85
  - test/test_string_conversions.rb
@@ -119,6 +121,7 @@ test_files:
119
121
  - test/helper.rb
120
122
  - test/test_algorithm_reader.rb
121
123
  - test/test_base.rb
124
+ - test/test_cli.rb
122
125
  - test/test_converter.rb
123
126
  - test/test_integration.rb
124
127
  - test/test_string_conversions.rb