to_pass 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +50 -5
- data/Rakefile +13 -5
- data/TODO +3 -19
- data/VERSION +1 -1
- data/{lib → data}/to_pass/algorithms/basic_de.yml +0 -0
- data/{lib → data}/to_pass/algorithms/basic_en.yml +0 -0
- data/{lib → data}/to_pass/algorithms/secure.yml +0 -0
- data/{lib → data}/to_pass/converters/collapse_chars.rb +0 -0
- data/{lib → data}/to_pass/converters/downcase.rb +0 -0
- data/{lib → data}/to_pass/converters/expand_below.rb +4 -0
- data/{lib → data}/to_pass/converters/first_chars.rb +0 -0
- data/{lib → data}/to_pass/converters/remove_repetition.rb +0 -0
- data/{lib → data}/to_pass/converters/replace.rb +0 -0
- data/{lib → data}/to_pass/converters/reverse.rb +1 -0
- data/{lib → data}/to_pass/converters/swapcase.rb +0 -0
- data/lib/to_pass/algorithm_reader.rb +44 -44
- data/lib/to_pass/base.rb +3 -1
- data/lib/to_pass/cli.rb +16 -0
- data/lib/to_pass/converter.rb +3 -1
- data/lib/to_pass/converter_reader.rb +81 -81
- data/lib/to_pass/converters.rb +10 -5
- data/lib/to_pass/directories.rb +36 -0
- data/lib/to_pass/integration.rb +1 -0
- data/lib/to_pass/version.rb +0 -1
- data/lib/to_pass.rb +5 -1
- data/man/{to_pass.1 → man1/to_pass.1} +1 -1
- data/man/{to_pass.1.html → man1/to_pass.1.html} +1 -1
- data/man/{to_pass-algorithm.5 → man5/to_pass-algorithm.5} +1 -1
- data/man/{to_pass-algorithm.5.html → man5/to_pass-algorithm.5.html} +2 -2
- data/man/{to_pass-converter.5 → man5/to_pass-converter.5} +1 -1
- data/man/{to_pass-converter.5.html → man5/to_pass-converter.5.html} +1 -1
- data/test/helper.rb +11 -1
- data/test/test_algorithm_reader.rb +1 -4
- data/test/test_base.rb +14 -0
- data/test/test_converter_reader.rb +1 -4
- metadata +42 -25
data/README.rdoc
CHANGED
@@ -9,6 +9,30 @@ This library encapsulates that and satisfies different usage scenarios.
|
|
9
9
|
Currently, only two algorithms are provided. But they are YAML-Files, so it's
|
10
10
|
extensible.
|
11
11
|
|
12
|
+
|
13
|
+
== Installation
|
14
|
+
|
15
|
+
to_pass is distributed as rubygem
|
16
|
+
|
17
|
+
$ gem install to_pass
|
18
|
+
|
19
|
+
If you want to install from source, you can download a tarball or zipfile from
|
20
|
+
github.
|
21
|
+
|
22
|
+
$ curl -L http://github.com/kronn/to_pass/tarball/v0.5.2 -o to_pass.tar.gz
|
23
|
+
$ tar -xzf to_pass.tar.gz
|
24
|
+
$ cd kronn-to_pass-HASHVALUE
|
25
|
+
$ ./setup.rb install
|
26
|
+
|
27
|
+
The tarball contains a directory which has a part of the commit hash in its
|
28
|
+
name. I leave it up to the user to change into the right directory. Shouldn't
|
29
|
+
be too hard ;-)
|
30
|
+
|
31
|
+
The same installation procedure works for git-checkouts, of course.
|
32
|
+
|
33
|
+
The setup.rb installation has the additional benefit of installing the manpages
|
34
|
+
for the gem and the file-formats.
|
35
|
+
|
12
36
|
== Usage
|
13
37
|
|
14
38
|
=== IRB
|
@@ -16,11 +40,17 @@ extensible.
|
|
16
40
|
ToPass::Integration provides a to_pass Method which transforms a sentence to a
|
17
41
|
password.
|
18
42
|
|
19
|
-
irb> require '
|
43
|
+
irb> require 'to_pass'
|
20
44
|
irb> String.send(:include, ToPass::Integration)
|
21
45
|
irb> "Da steht ein Pferd auf dem Flur".to_pass
|
22
46
|
# => "Ds1P@dF"
|
23
47
|
|
48
|
+
A more direct approach is the facade provided by ToPass::Base
|
49
|
+
|
50
|
+
irb> require 'to_pass'
|
51
|
+
irb> ToPass::Base.new('test', :basic_de).to_s
|
52
|
+
# => 't35t'
|
53
|
+
|
24
54
|
=== CLI
|
25
55
|
|
26
56
|
$ to_pass "test" # => t35t
|
@@ -28,11 +58,23 @@ password.
|
|
28
58
|
|
29
59
|
=== CLI with Pipes
|
30
60
|
|
31
|
-
This example is Mac OSX-centric, but you should get the point.
|
61
|
+
This example is a bit Mac OSX-centric, but you should get the point.
|
32
62
|
|
33
63
|
$ echo "test" | to_pass | pbcopy
|
34
64
|
|
35
|
-
==
|
65
|
+
== Development
|
66
|
+
|
67
|
+
If you want to develop it further, patch something or are just plain curious:
|
68
|
+
you're welcome. This should get you started:
|
69
|
+
|
70
|
+
$ git clone git://github.com/kronn/to_pass.git
|
71
|
+
$ bundle install
|
72
|
+
$ rake
|
73
|
+
|
74
|
+
Bundler is only used for installing dependencies. ToPass does not have any
|
75
|
+
runtime dependencies, so Bundler does not make sense there.
|
76
|
+
|
77
|
+
The usual pattern for github-projects applies:
|
36
78
|
|
37
79
|
* Fork the project.
|
38
80
|
* Make your feature addition or bug fix.
|
@@ -41,8 +83,11 @@ This example is Mac OSX-centric, but you should get the point.
|
|
41
83
|
* Commit, do not mess with rakefile, version, or history.
|
42
84
|
(if you want to have your own version, that is fine but bump version in a
|
43
85
|
commit by itself I can ignore when I pull)
|
44
|
-
* Send me a pull request.
|
86
|
+
* Send me a pull request.
|
87
|
+
|
88
|
+
I'll take a look at it and try to integrate it. If I cannot apply your changes
|
89
|
+
or don't want to, I'll let you know.
|
45
90
|
|
46
91
|
== Copyright
|
47
92
|
|
48
|
-
Copyright (c) 2010 Matthias Viehweger. See LICENSE for details.
|
93
|
+
Copyright (c) 2009-2010 Matthias Viehweger. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -12,20 +12,28 @@ begin
|
|
12
12
|
|
13
13
|
rdoc.rdoc_dir = 'doc/rdoc'
|
14
14
|
rdoc.title = "to_pass #{version}"
|
15
|
-
rdoc.options << '--fmt
|
15
|
+
rdoc.options << '--fmt=shtml'
|
16
|
+
rdoc.options << '--all'
|
17
|
+
rdoc.options << '--charset=utf-8'
|
16
18
|
rdoc.template = 'direct'
|
17
19
|
rdoc.rdoc_files.include('README*')
|
20
|
+
# rdoc.rdoc_files.include('LICENSE')
|
21
|
+
rdoc.rdoc_files.include('TODO')
|
18
22
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
rdoc.rdoc_files.include('data/**/*.rb')
|
19
24
|
end
|
20
25
|
rescue LoadError
|
21
26
|
end
|
22
27
|
begin
|
23
28
|
desc 'generate manpages for project'
|
24
29
|
task :man do
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
30
|
+
[1,5].each do |section|
|
31
|
+
files = Dir["./man/*#{section}.ronn"]
|
32
|
+
`ronn --html --roff --style=toc #{files.join(' ')}`
|
33
|
+
FileUtils.mkdir "./man/man#{section}/"
|
34
|
+
FileUtils.mv Dir["./man/*.#{section}.html"], "./man/man#{section}/"
|
35
|
+
FileUtils.mv Dir["./man/*.#{section}"], "./man/man#{section}/"
|
36
|
+
end
|
29
37
|
end
|
30
38
|
end
|
31
39
|
|
data/TODO
CHANGED
@@ -1,22 +1,8 @@
|
|
1
1
|
CURRENT
|
2
2
|
============================================================================
|
3
|
-
-
|
4
|
-
|
5
|
-
|
6
|
-
github allows that
|
7
|
-
|
8
|
-
- Use setup.rb
|
9
|
-
http://github.com/proutils/setup
|
10
|
-
|
11
|
-
✓ Remove all references to rubygems in the software you ship
|
12
|
-
✓ Don’t make your Rakefile depend on RubyGems
|
13
|
-
|
14
|
-
- Make your tests and examples usable outside of your directory tree
|
15
|
-
this might be achieved by using setup.rb anyway...
|
16
|
-
|
17
|
-
✓ Use a shebang that works everywhere
|
18
|
-
✓ Provide man pages for your binaries
|
19
|
-
✓ If possible, maintain a backward-compatible API
|
3
|
+
- have some RELEASE-NOTES or CHANGELOG
|
4
|
+
- GemSpec#post_install_message = filename
|
5
|
+
maybe http://github.com/proutils/vclog is useful...
|
20
6
|
|
21
7
|
|
22
8
|
UP NEXT
|
@@ -29,8 +15,6 @@ UP NEXT
|
|
29
15
|
- add command to output available converters
|
30
16
|
- add command to output available algorithms
|
31
17
|
- handle CLI with Thor
|
32
|
-
- have some RELEASE-NOTES or CHANGELOG
|
33
|
-
- GemSpec#post_install_message = filename
|
34
18
|
|
35
19
|
|
36
20
|
SOMEDAY
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -3,6 +3,10 @@ require 'md5'
|
|
3
3
|
module ToPass::Converters
|
4
4
|
class ExpandBelow
|
5
5
|
class << self
|
6
|
+
# Strings below the threshold are expanded with a md5-hash of them.
|
7
|
+
#
|
8
|
+
# The md5 is used to generate extra characters which are then added
|
9
|
+
# before and after the string.
|
6
10
|
def expand_below(string, rules, threshold)
|
7
11
|
if string.length < threshold.to_i
|
8
12
|
digest = "#{MD5.hexdigest(string)}#{MD5.hexdigest(string).reverse}"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -4,58 +4,58 @@
|
|
4
4
|
require 'pathname'
|
5
5
|
require 'yaml'
|
6
6
|
|
7
|
-
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
class
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
7
|
+
module ToPass
|
8
|
+
# The AlgorithmReader's primary API is to load the rules from a YAML-file
|
9
|
+
# into a Hash.
|
10
|
+
#
|
11
|
+
# Algorithms are searched in a list of standard directories. Those are defined
|
12
|
+
# and managed in ToPass::Directories
|
13
|
+
#
|
14
|
+
# see ToPass::Converter for usage of the loaded algorithm
|
15
|
+
class AlgorithmReader
|
16
|
+
attr_reader :load_path
|
17
|
+
|
18
|
+
def initialize(algorithm) # :nodoc:
|
19
|
+
@algorithm = algorithm
|
20
|
+
@load_path = []
|
21
|
+
ToPass::Directories[:standard].map do |dir|
|
22
|
+
dir + '/algorithms'
|
23
|
+
end.each do |dir|
|
24
|
+
dir = Pathname.new(dir).expand_path
|
25
|
+
@load_path << dir if dir.exist?
|
26
|
+
end
|
27
27
|
end
|
28
|
-
end
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
class << self
|
30
|
+
# load an algorithm with a given identifier
|
31
|
+
def load(algorithm)
|
32
|
+
new(algorithm).load_from_file
|
33
|
+
end
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
35
|
+
# searches for available algorithms
|
36
|
+
def discover
|
37
|
+
new(nil).load_path.collect do |dir|
|
38
|
+
Dir["#{dir}/*.yml"]
|
39
|
+
end.flatten.compact.map do |fn|
|
40
|
+
File.basename(fn).gsub('.yml', '')
|
41
|
+
end
|
42
42
|
end
|
43
43
|
end
|
44
|
-
end
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
def load_from_file # :nodoc:
|
46
|
+
fn = load_path.map do |dir|
|
47
|
+
file = Pathname.new("#{dir}/#{@algorithm}.yml")
|
49
48
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
49
|
+
if file.exist?
|
50
|
+
file
|
51
|
+
else
|
52
|
+
next
|
53
|
+
end
|
54
|
+
end.compact.first
|
56
55
|
|
57
|
-
|
56
|
+
raise LoadError, "algorithm #{@algorithm} could not be found in #{load_path}" if fn.nil?
|
58
57
|
|
59
|
-
|
58
|
+
YAML.load_file(fn.expand_path)
|
59
|
+
end
|
60
60
|
end
|
61
61
|
end
|
data/lib/to_pass/base.rb
CHANGED
@@ -6,7 +6,9 @@ module ToPass
|
|
6
6
|
#
|
7
7
|
# Given a string and a algorithm identifier, the right rules
|
8
8
|
# are loaded and applied to the string. With a simple "to_s",
|
9
|
-
# you can get the final password
|
9
|
+
# you can get the final password.
|
10
|
+
#
|
11
|
+
# see ToPass::AlgorithmReader and ToPass::Converter for details
|
10
12
|
class Base
|
11
13
|
# transform a string according to a certain algorithm
|
12
14
|
def initialize( string, algorithm )
|
data/lib/to_pass/cli.rb
CHANGED
@@ -4,13 +4,29 @@
|
|
4
4
|
require 'optparse'
|
5
5
|
|
6
6
|
module ToPass
|
7
|
+
# ToPass::Cli wraps the ugly code needed for option-parsing an such
|
8
|
+
#
|
9
|
+
# The default values for the options can be passed in to make different
|
10
|
+
# executables behave differently.
|
7
11
|
class Cli
|
12
|
+
# creates a new Cli-wrapper for option-parsing and such. Almost everthing
|
13
|
+
# needed is done inside the initalizer.
|
14
|
+
#
|
15
|
+
# The default options can be overriden. Defaults are:
|
16
|
+
#
|
17
|
+
# options = {
|
18
|
+
# :algorithm => 'basic_de',
|
19
|
+
# :pipe_out => false,
|
20
|
+
# :pipe_in => false
|
21
|
+
# }
|
22
|
+
#
|
8
23
|
def initialize(options = {})
|
9
24
|
@options = parse_options(options)
|
10
25
|
@string = get_input_string
|
11
26
|
@password = transform
|
12
27
|
end
|
13
28
|
|
29
|
+
# output the result of the string transformation
|
14
30
|
def output
|
15
31
|
if @options[:pipe_out]
|
16
32
|
$stdout << @password
|
data/lib/to_pass/converter.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# vim:ft=ruby:enc=utf-8
|
3
3
|
|
4
|
-
module ToPass
|
4
|
+
module ToPass # :nodoc:
|
5
5
|
# converts a given string into a password-like word
|
6
6
|
#
|
7
7
|
# the string can be a word or a sentence. everthing which
|
@@ -9,6 +9,8 @@ module ToPass
|
|
9
9
|
#
|
10
10
|
# a more complete description of the algorithm capabilities
|
11
11
|
# is still pending.
|
12
|
+
#
|
13
|
+
# see ToPass::ConverterReader and ToPass::AlgorithmReader
|
12
14
|
class Converter
|
13
15
|
attr_accessor :converters, :rules
|
14
16
|
# create a new converter, based on a set of conversion-rules
|
@@ -3,105 +3,105 @@
|
|
3
3
|
|
4
4
|
require 'pathname'
|
5
5
|
|
6
|
-
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
class
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
6
|
+
module ToPass
|
7
|
+
# The ConverterReader's primary API is to load the converters from right
|
8
|
+
# directories into an Array
|
9
|
+
#
|
10
|
+
# Converters are searched in a list of standard directories. Those are defined
|
11
|
+
# and managed in ToPass::Directories
|
12
|
+
#
|
13
|
+
# The bundled converter are, however, lazily loaded with autoload.
|
14
|
+
# User-provided converters are always required (for now).
|
15
|
+
#
|
16
|
+
# see ToPass::Converter
|
17
|
+
class ConverterReader
|
18
|
+
attr_reader :load_path, :loaded
|
19
|
+
|
20
|
+
def initialize # :nodoc:
|
21
|
+
@load_path = []
|
22
|
+
@loaded = []
|
23
|
+
@discovered = []
|
24
|
+
ToPass::Directories[:standard].map do |dir|
|
25
|
+
dir + '/converters'
|
26
|
+
end.each do |dir|
|
27
|
+
dir = Pathname.new(dir).expand_path
|
28
|
+
@load_path << dir if dir.exist?
|
29
|
+
end
|
30
30
|
end
|
31
|
-
end
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
# loads the converters
|
33
|
+
def load(converter)
|
34
|
+
unless @loaded.include?(converter.to_sym)
|
35
|
+
load_from_file(converter)
|
36
|
+
@loaded << converter
|
37
|
+
end
|
39
38
|
|
40
|
-
|
41
|
-
|
39
|
+
classname(converter)
|
40
|
+
end
|
42
41
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
42
|
+
# discover a list of available converters
|
43
|
+
def discover
|
44
|
+
search_for_converters
|
45
|
+
end
|
47
46
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
47
|
+
private
|
48
|
+
|
49
|
+
def search_for_converters # :nodoc:
|
50
|
+
files = load_path.collect do |directory|
|
51
|
+
dir = Pathname.new(directory)
|
52
|
+
if dir.exist?
|
53
|
+
Dir["#{dir}/*.rb"].collect do |converter|
|
54
|
+
fn_re = %r!/([^/]*)\.rb$!i
|
55
|
+
name = converter.match(fn_re)
|
56
|
+
if name
|
57
|
+
name[1].to_sym
|
58
|
+
end
|
59
59
|
end
|
60
60
|
end
|
61
|
-
end
|
62
|
-
end.flatten.compact
|
61
|
+
end.flatten.compact
|
63
62
|
|
64
|
-
|
63
|
+
raise LoadError, "converters could not be found in #{load_path}" if files.nil?
|
65
64
|
|
66
|
-
|
67
|
-
|
65
|
+
@discovered = files
|
66
|
+
end
|
68
67
|
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
def load_from_file(converter) # :nodoc:
|
69
|
+
fn = load_path.collect do |dir|
|
70
|
+
path = Pathname.new("#{dir}/#{converter}.rb").expand_path
|
72
71
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
72
|
+
if path.exist?
|
73
|
+
path
|
74
|
+
else
|
75
|
+
next
|
76
|
+
end
|
77
|
+
end.compact.first
|
79
78
|
|
80
|
-
|
79
|
+
raise LoadError, "converter '#{converter}' could not be found in #{load_path.join(' ')}" if fn.nil?
|
81
80
|
|
82
|
-
|
83
|
-
|
81
|
+
if require fn
|
82
|
+
classname converter
|
83
|
+
end
|
84
84
|
end
|
85
|
-
end
|
86
85
|
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
def classname(converter) # :nodoc:
|
87
|
+
constantize("ToPass::Converters::#{camel_case(converter)}")
|
88
|
+
end
|
90
89
|
|
91
|
-
|
92
|
-
|
93
|
-
|
90
|
+
def constantize(camel_cased_word) # :nodoc:
|
91
|
+
names = camel_cased_word.split('::')
|
92
|
+
names.shift if names.empty? || names.first.empty?
|
94
93
|
|
95
|
-
|
96
|
-
|
97
|
-
|
94
|
+
constant = Object
|
95
|
+
names.each do |name|
|
96
|
+
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
97
|
+
end
|
98
|
+
constant
|
98
99
|
end
|
99
|
-
constant
|
100
|
-
end
|
101
100
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
101
|
+
def camel_case(underscored_word) # :nodoc:
|
102
|
+
camel_cased_word = underscored_word.to_s.split('_').map do |part|
|
103
|
+
part.capitalize
|
104
|
+
end.join('')
|
105
|
+
end
|
106
106
|
end
|
107
107
|
end
|
data/lib/to_pass/converters.rb
CHANGED
@@ -2,12 +2,17 @@
|
|
2
2
|
# vim:ft=ruby:enc=utf-8
|
3
3
|
|
4
4
|
module ToPass
|
5
|
-
# The Converters-
|
6
|
-
# Transformations.
|
7
|
-
# and is expected to return a transformed string. The only exception
|
8
|
-
# from this is general rule is the replace method which also takes a
|
9
|
-
# replacement table.
|
5
|
+
# The Converters-module is a collection of available
|
6
|
+
# Transformations.
|
10
7
|
#
|
8
|
+
# Each Transformation is wrapped in a class which has one class-method. This
|
9
|
+
# method is given a string as single argument.
|
10
|
+
# If the method can take arguments, then three parameters are passed:
|
11
|
+
# the string, the full rule-set (algorithm definition hash) and the parameter
|
12
|
+
# from the algorithm.
|
13
|
+
# see ToPass::Converter#apply_rule for details
|
14
|
+
#
|
15
|
+
# All transformations are expected to return only the transformed string.
|
11
16
|
# This enables chaining and eases extending the capabilities.
|
12
17
|
module Converters
|
13
18
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# vim:ft=ruby:enc=utf-8
|
3
|
+
|
4
|
+
require 'rbconfig'
|
5
|
+
|
6
|
+
module ToPass
|
7
|
+
# Wrapper for the search directories. Primary purpose is to keep the dirty
|
8
|
+
# part in one place instead of scattered throughout the project.
|
9
|
+
#
|
10
|
+
# Used by ToPass::AlgorithmReader and ToPass::ConverterReader
|
11
|
+
class Directories
|
12
|
+
class << self
|
13
|
+
# get a directory or a list of directories
|
14
|
+
def [](key)
|
15
|
+
case key
|
16
|
+
when :user, :data, :base, :source_data
|
17
|
+
all[key]
|
18
|
+
when :standard
|
19
|
+
[ all[:user], all[:data], all[:source_data] ]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# list of all direcotries used by this project
|
26
|
+
def all
|
27
|
+
{
|
28
|
+
:user => "~/.#{APP_NAME}",
|
29
|
+
:data => "#{RbConfig::CONFIG['data-dir']}/#{APP_NAME}",
|
30
|
+
:base => File.expand_path("#{File.dirname(__FILE__)}/../.."),
|
31
|
+
:source_data => File.expand_path("#{File.dirname(__FILE__)}/../../data/#{APP_NAME}"),
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/to_pass/integration.rb
CHANGED
data/lib/to_pass/version.rb
CHANGED
data/lib/to_pass.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# vim:ft=ruby:enc=utf-8
|
3
2
|
|
4
3
|
# Library to convert a String into a Password
|
4
|
+
#
|
5
|
+
# see README.rdoc for details
|
5
6
|
module ToPass
|
6
7
|
autoload :VERSION, 'lib/to_pass/version'
|
7
8
|
autoload :DATE, 'lib/to_pass/version'
|
@@ -13,5 +14,8 @@ module ToPass
|
|
13
14
|
autoload :Converter, 'lib/to_pass/converter'
|
14
15
|
autoload :ConverterReader, 'lib/to_pass/converter_reader'
|
15
16
|
autoload :Converters, 'lib/to_pass/converters'
|
17
|
+
autoload :Directories, 'lib/to_pass/directories'
|
16
18
|
autoload :Integration, 'lib/to_pass/integration'
|
17
19
|
end
|
20
|
+
|
21
|
+
# vim:ft=ruby:enc=utf-8
|
@@ -1,7 +1,7 @@
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
2
2
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "TO_PASS\-ALGORITHM" "5" "
|
4
|
+
.TH "TO_PASS\-ALGORITHM" "5" "August 2010" "" ""
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBto_pass\-algorithm\fR \- algorithm\-description for to_pass(1)
|
@@ -81,7 +81,7 @@
|
|
81
81
|
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
82
82
|
|
83
83
|
<p>An algorithms is a simple list of conversions which are applied to the input
|
84
|
-
string. The algorithm file is a <a href="http://man.cx/yaml(3pm)" class="man-ref">yaml<span class="s">(3pm)</span></a> file.
|
84
|
+
string. The algorithm file is a <a href="http://man.cx/yaml(3pm)" class="man-ref">yaml<span class="s">(3pm)</span></a> file. <code>yaml</code> looks like a list of
|
85
85
|
key-value pairs. Nesting is done by indentation (2 spaces). Consecutive lines
|
86
86
|
which begin with a <code>-</code> are considered an array.</p>
|
87
87
|
|
@@ -176,7 +176,7 @@ design however is intentionally simple and constrained.</p>
|
|
176
176
|
|
177
177
|
<ol class='man-decor man-foot man foot'>
|
178
178
|
<li class='tl'></li>
|
179
|
-
<li class='tc'>
|
179
|
+
<li class='tc'>August 2010</li>
|
180
180
|
<li class='tr'>to_pass-algorithm(5)</li>
|
181
181
|
</ol>
|
182
182
|
|
data/test/helper.rb
CHANGED
@@ -4,9 +4,12 @@
|
|
4
4
|
require 'test/unit/testcase'
|
5
5
|
require 'test/unit' unless defined?(Test::Unit)
|
6
6
|
require 'mocha'
|
7
|
+
require 'rbconfig'
|
7
8
|
|
8
9
|
base_path = ( File.expand_path(File.dirname(__FILE__)+'/..') )
|
9
|
-
|
10
|
+
if File.exist?(base_path + '/lib/to_pass')
|
11
|
+
$LOAD_PATH << base_path unless $LOAD_PATH.include?(base_path)
|
12
|
+
end
|
10
13
|
|
11
14
|
Test::Unit::TestCase.class_eval do
|
12
15
|
def assert_class_defined(klass)
|
@@ -25,6 +28,13 @@ Test::Unit::TestCase.class_eval do
|
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
31
|
+
def standard_directories
|
32
|
+
[
|
33
|
+
'~/.to_pass' , # user
|
34
|
+
"#{RbConfig::CONFIG['data-dir']}/#{ToPass::APP_NAME}", # installed
|
35
|
+
"#{File.dirname(__FILE__)}/../data/#{ToPass::APP_NAME}", # source [in github]
|
36
|
+
]
|
37
|
+
end
|
28
38
|
|
29
39
|
def with_algorithm_in_user_dir
|
30
40
|
`mkdir -p ~/.to_pass/algorithms; cp -f #{File.dirname(__FILE__)}/fixtures/user_alg.yml ~/.to_pass/algorithms/user_alg.yml`
|
@@ -28,10 +28,7 @@ class TestAlgorithmReader < Test::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_load_path_contains_standard_dirs
|
31
|
-
dirs =
|
32
|
-
'~/.to_pass/algorithms' ,
|
33
|
-
"#{File.dirname(__FILE__)}/../lib/to_pass/algorithms"
|
34
|
-
]
|
31
|
+
dirs = standard_directories.map { |path| "#{path}/algorithms"}
|
35
32
|
|
36
33
|
Pathname.any_instance.expects(:exist?).times(dirs.size).returns(true)
|
37
34
|
|
data/test/test_base.rb
CHANGED
@@ -30,4 +30,18 @@ class TestBase < Test::Unit::TestCase
|
|
30
30
|
assert eval(Pathname.new("#{File.dirname(__FILE__)}/../to_pass.gemspec").expand_path.read).validate
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
def test_directories
|
35
|
+
dirs = ToPass::Directories
|
36
|
+
|
37
|
+
assert defined?(dirs)
|
38
|
+
assert_respond_to dirs, :[]
|
39
|
+
|
40
|
+
assert_equal '~/.to_pass', dirs[:user]
|
41
|
+
assert_equal "#{RbConfig::CONFIG['data-dir']}/#{ToPass::APP_NAME}", dirs[:data]
|
42
|
+
assert_equal Pathname.new("#{File.dirname(__FILE__)}/../").expand_path.to_s, dirs[:base]
|
43
|
+
assert_equal Pathname.new("#{File.dirname(__FILE__)}/../data/#{ToPass::APP_NAME}").expand_path.to_s, dirs[:source_data]
|
44
|
+
|
45
|
+
assert_equal [ dirs[:user], dirs[:data], dirs[:source_data] ], dirs[:standard]
|
46
|
+
end
|
33
47
|
end
|
@@ -34,10 +34,7 @@ class TestConverterReader < Test::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_load_path_contains_standard_dirs
|
37
|
-
dirs =
|
38
|
-
'~/.to_pass/converters',
|
39
|
-
"#{File.dirname(__FILE__)}/../lib/to_pass/converters"
|
40
|
-
]
|
37
|
+
dirs = standard_directories.map { |path| "#{path}/converters"}
|
41
38
|
|
42
39
|
Pathname.any_instance.expects(:exist?).times(dirs.size).returns(true)
|
43
40
|
|
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:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 6
|
9
|
+
- 0
|
10
|
+
version: 0.6.0
|
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-08-
|
18
|
+
date: 2010-08-18 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
type: :development
|
34
34
|
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
36
|
+
name: ronn
|
37
37
|
prerelease: false
|
38
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
@@ -60,6 +60,20 @@ dependencies:
|
|
60
60
|
version: "0"
|
61
61
|
type: :development
|
62
62
|
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: sdoc
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
type: :development
|
76
|
+
version_requirements: *id004
|
63
77
|
description: " Passwords should be easy to remember and hard to guess.\n One technique is to have a sentence which can be easily remembered transformed to a password.\n\n Pluggable algorithms and converters allow customization of the transformation process.\n"
|
64
78
|
email: kronn@kronn.de
|
65
79
|
executables:
|
@@ -68,7 +82,6 @@ executables:
|
|
68
82
|
extensions: []
|
69
83
|
|
70
84
|
extra_rdoc_files:
|
71
|
-
- LICENSE
|
72
85
|
- README.rdoc
|
73
86
|
- TODO
|
74
87
|
files:
|
@@ -81,34 +94,35 @@ files:
|
|
81
94
|
- bin/password_of
|
82
95
|
- bin/to_pass
|
83
96
|
- lib/to_pass/algorithm_reader.rb
|
84
|
-
- lib/to_pass/algorithms/basic_de.yml
|
85
|
-
- lib/to_pass/algorithms/basic_en.yml
|
86
|
-
- lib/to_pass/algorithms/secure.yml
|
87
97
|
- lib/to_pass/base.rb
|
88
98
|
- lib/to_pass/cli.rb
|
89
99
|
- lib/to_pass/converter.rb
|
90
100
|
- lib/to_pass/converter_reader.rb
|
91
|
-
- lib/to_pass/converters/collapse_chars.rb
|
92
|
-
- lib/to_pass/converters/downcase.rb
|
93
|
-
- lib/to_pass/converters/expand_below.rb
|
94
|
-
- lib/to_pass/converters/first_chars.rb
|
95
|
-
- lib/to_pass/converters/remove_repetition.rb
|
96
|
-
- lib/to_pass/converters/replace.rb
|
97
|
-
- lib/to_pass/converters/reverse.rb
|
98
|
-
- lib/to_pass/converters/swapcase.rb
|
99
101
|
- lib/to_pass/converters.rb
|
102
|
+
- lib/to_pass/directories.rb
|
100
103
|
- lib/to_pass/integration.rb
|
101
104
|
- lib/to_pass/version.rb
|
102
105
|
- lib/to_pass.rb
|
106
|
+
- data/to_pass/algorithms/basic_de.yml
|
107
|
+
- data/to_pass/algorithms/basic_en.yml
|
108
|
+
- data/to_pass/algorithms/secure.yml
|
109
|
+
- data/to_pass/converters/collapse_chars.rb
|
110
|
+
- data/to_pass/converters/downcase.rb
|
111
|
+
- data/to_pass/converters/expand_below.rb
|
112
|
+
- data/to_pass/converters/first_chars.rb
|
113
|
+
- data/to_pass/converters/remove_repetition.rb
|
114
|
+
- data/to_pass/converters/replace.rb
|
115
|
+
- data/to_pass/converters/reverse.rb
|
116
|
+
- data/to_pass/converters/swapcase.rb
|
103
117
|
- man/index.txt
|
104
|
-
- man/to_pass
|
105
|
-
- man/to_pass
|
118
|
+
- man/man1/to_pass.1
|
119
|
+
- man/man1/to_pass.1.html
|
120
|
+
- man/man5/to_pass-algorithm.5
|
121
|
+
- man/man5/to_pass-algorithm.5.html
|
122
|
+
- man/man5/to_pass-converter.5
|
123
|
+
- man/man5/to_pass-converter.5.html
|
106
124
|
- man/to_pass-algorithm.5.ronn
|
107
|
-
- man/to_pass-converter.5
|
108
|
-
- man/to_pass-converter.5.html
|
109
125
|
- man/to_pass-converter.5.ronn
|
110
|
-
- man/to_pass.1
|
111
|
-
- man/to_pass.1.html
|
112
126
|
- man/to_pass.1.ronn
|
113
127
|
- test/fixtures/user_alg.yml
|
114
128
|
- test/fixtures/user_converter.rb
|
@@ -127,7 +141,10 @@ licenses: []
|
|
127
141
|
|
128
142
|
post_install_message:
|
129
143
|
rdoc_options:
|
130
|
-
- --charset=
|
144
|
+
- --charset=utf-8
|
145
|
+
- --fmt=shtml
|
146
|
+
- --all
|
147
|
+
- --include=data/to_pass/converters/
|
131
148
|
require_paths:
|
132
149
|
- lib
|
133
150
|
required_ruby_version: !ruby/object:Gem::Requirement
|