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.
Files changed (36) hide show
  1. data/README.rdoc +50 -5
  2. data/Rakefile +13 -5
  3. data/TODO +3 -19
  4. data/VERSION +1 -1
  5. data/{lib → data}/to_pass/algorithms/basic_de.yml +0 -0
  6. data/{lib → data}/to_pass/algorithms/basic_en.yml +0 -0
  7. data/{lib → data}/to_pass/algorithms/secure.yml +0 -0
  8. data/{lib → data}/to_pass/converters/collapse_chars.rb +0 -0
  9. data/{lib → data}/to_pass/converters/downcase.rb +0 -0
  10. data/{lib → data}/to_pass/converters/expand_below.rb +4 -0
  11. data/{lib → data}/to_pass/converters/first_chars.rb +0 -0
  12. data/{lib → data}/to_pass/converters/remove_repetition.rb +0 -0
  13. data/{lib → data}/to_pass/converters/replace.rb +0 -0
  14. data/{lib → data}/to_pass/converters/reverse.rb +1 -0
  15. data/{lib → data}/to_pass/converters/swapcase.rb +0 -0
  16. data/lib/to_pass/algorithm_reader.rb +44 -44
  17. data/lib/to_pass/base.rb +3 -1
  18. data/lib/to_pass/cli.rb +16 -0
  19. data/lib/to_pass/converter.rb +3 -1
  20. data/lib/to_pass/converter_reader.rb +81 -81
  21. data/lib/to_pass/converters.rb +10 -5
  22. data/lib/to_pass/directories.rb +36 -0
  23. data/lib/to_pass/integration.rb +1 -0
  24. data/lib/to_pass/version.rb +0 -1
  25. data/lib/to_pass.rb +5 -1
  26. data/man/{to_pass.1 → man1/to_pass.1} +1 -1
  27. data/man/{to_pass.1.html → man1/to_pass.1.html} +1 -1
  28. data/man/{to_pass-algorithm.5 → man5/to_pass-algorithm.5} +1 -1
  29. data/man/{to_pass-algorithm.5.html → man5/to_pass-algorithm.5.html} +2 -2
  30. data/man/{to_pass-converter.5 → man5/to_pass-converter.5} +1 -1
  31. data/man/{to_pass-converter.5.html → man5/to_pass-converter.5.html} +1 -1
  32. data/test/helper.rb +11 -1
  33. data/test/test_algorithm_reader.rb +1 -4
  34. data/test/test_base.rb +14 -0
  35. data/test/test_converter_reader.rb +1 -4
  36. 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 'lib/to_pass'
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
- == Note on Patches/Pull Requests
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. Bonus points for topic branches.
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' << 'shtml'
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
- files = Dir['./man/*.ronn'].join(' ')
26
- command = "ronn --html --roff --style=toc #{files}"
27
-
28
- `#{command}`
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
- - make it debian compatible (most of which is common sense anyway)
4
- http://pkg-ruby-extras.alioth.debian.org/upstream-devs.html
5
- Distribute your software as a source code archive
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.5.2
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
@@ -1,5 +1,6 @@
1
1
  module ToPass::Converters
2
2
  class Reverse
3
+ # The given string is reversed
3
4
  def self.reverse(string)
4
5
  string.reverse
5
6
  end
File without changes
@@ -4,58 +4,58 @@
4
4
  require 'pathname'
5
5
  require 'yaml'
6
6
 
7
- # The AlgorithmReader's primary API is to load the rules from a YAML-file
8
- # into a Hash.
9
- #
10
- # Algorithms are searched in the following locations
11
- #
12
- # 1. ~/.to_pass/algorithms
13
- # 2. bundled algorithms of gem
14
- #
15
- class ToPass::AlgorithmReader
16
- attr_reader :load_path
17
-
18
- def initialize(algorithm) # :nodoc:
19
- @algorithm = algorithm
20
- @load_path = []
21
- [
22
- '~/.to_pass/algorithms',
23
- "#{File.dirname(__FILE__)}/algorithms"
24
- ].each do |dir|
25
- dir = Pathname.new(dir).expand_path
26
- @load_path << dir if dir.exist?
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
- class << self
31
- # load an algorithm with a given identifier
32
- def load(algorithm)
33
- new(algorithm).load_from_file
34
- end
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
- # searches for available algorithms
37
- def discover
38
- new(nil).load_path.collect do |dir|
39
- Dir["#{dir}/*.yml"]
40
- end.flatten.compact.map do |fn|
41
- File.basename(fn).gsub('.yml', '')
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
- def load_from_file # :nodoc:
47
- fn = load_path.map do |dir|
48
- file = Pathname.new("#{dir}/#{@algorithm}.yml")
45
+ def load_from_file # :nodoc:
46
+ fn = load_path.map do |dir|
47
+ file = Pathname.new("#{dir}/#{@algorithm}.yml")
49
48
 
50
- if file.exist?
51
- file
52
- else
53
- next
54
- end
55
- end.compact.first
49
+ if file.exist?
50
+ file
51
+ else
52
+ next
53
+ end
54
+ end.compact.first
56
55
 
57
- raise LoadError, "algorithm #{@algorithm} could not be found in #{load_path}" if fn.nil?
56
+ raise LoadError, "algorithm #{@algorithm} could not be found in #{load_path}" if fn.nil?
58
57
 
59
- YAML.load_file(fn.expand_path)
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
@@ -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
- # The ConverterReader's primary API is to load the converters from right
7
- # directories into an Array
8
- #
9
- # Converters are searched in the following locations
10
- #
11
- # 1. ~/.to_pass/converters
12
- # 2. bundled converters of gem
13
- #
14
- # The bundled converter are, however, lazily loaded with autoload.
15
- # User-provided converters are always required (for now).
16
- #
17
- class ToPass::ConverterReader
18
- attr_reader :load_path, :loaded
19
-
20
- def initialize # :nodoc:
21
- @load_path = []
22
- @loaded = []
23
- @discovered = []
24
- [
25
- '~/.to_pass/converters',
26
- "#{File.dirname(__FILE__)}/converters"
27
- ].each do |dir|
28
- dir = Pathname.new(dir).expand_path
29
- @load_path << dir if dir.exist?
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
- # loads the converters
34
- def load(converter)
35
- unless @loaded.include?(converter.to_sym)
36
- load_from_file(converter)
37
- @loaded << converter
38
- end
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
- classname(converter)
41
- end
39
+ classname(converter)
40
+ end
42
41
 
43
- # discover a list of available converters
44
- def discover
45
- search_for_converters
46
- end
42
+ # discover a list of available converters
43
+ def discover
44
+ search_for_converters
45
+ end
47
46
 
48
- private
49
-
50
- def search_for_converters # :nodoc:
51
- files = load_path.collect do |directory|
52
- dir = Pathname.new(directory)
53
- if dir.exist?
54
- Dir["#{dir}/*.rb"].collect do |converter|
55
- fn_re = %r!/([^/]*)\.rb$!i
56
- name = converter.match(fn_re)
57
- if name
58
- name[1].to_sym
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
- raise LoadError, "converters could not be found in #{load_path}" if files.nil?
63
+ raise LoadError, "converters could not be found in #{load_path}" if files.nil?
65
64
 
66
- @discovered = files
67
- end
65
+ @discovered = files
66
+ end
68
67
 
69
- def load_from_file(converter) # :nodoc:
70
- fn = load_path.collect do |dir|
71
- path = Pathname.new("#{dir}/#{converter}.rb").expand_path
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
- if path.exist?
74
- path
75
- else
76
- next
77
- end
78
- end.compact.first
72
+ if path.exist?
73
+ path
74
+ else
75
+ next
76
+ end
77
+ end.compact.first
79
78
 
80
- raise LoadError, "converter '#{converter}' could not be found in #{load_path.join(' ')}" if fn.nil?
79
+ raise LoadError, "converter '#{converter}' could not be found in #{load_path.join(' ')}" if fn.nil?
81
80
 
82
- if require fn
83
- classname converter
81
+ if require fn
82
+ classname converter
83
+ end
84
84
  end
85
- end
86
85
 
87
- def classname(converter) # :nodoc:
88
- constantize("ToPass::Converters::#{camel_case(converter)}")
89
- end
86
+ def classname(converter) # :nodoc:
87
+ constantize("ToPass::Converters::#{camel_case(converter)}")
88
+ end
90
89
 
91
- def constantize(camel_cased_word) # :nodoc:
92
- names = camel_cased_word.split('::')
93
- names.shift if names.empty? || names.first.empty?
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
- constant = Object
96
- names.each do |name|
97
- constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
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
- def camel_case(underscored_word) # :nodoc:
103
- camel_cased_word = underscored_word.to_s.split('_').map do |part|
104
- part.capitalize
105
- end.join('')
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
@@ -2,12 +2,17 @@
2
2
  # vim:ft=ruby:enc=utf-8
3
3
 
4
4
  module ToPass
5
- # The Converters-class is a collection of available
6
- # Transformations. Every method is given a string as single argument
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
@@ -8,6 +8,7 @@
8
8
  # String.send(:include, ToPass::Integration)
9
9
  # puts "Da steht ein Pferd auf dem Flur".to_pass => 'Ds1P@dF'
10
10
  #
11
+ # See ToPass::Base for more details
11
12
  module ToPass::Integration
12
13
  # simplified password-creation
13
14
  def to_pass( algorithm = 'basic_de' )
@@ -1,7 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # vim:ft=ruby:enc=utf-8
3
3
 
4
- # Library to convert a String into a Password
5
4
  module ToPass
6
5
  # version of gem, read directly from the VERSION-File
7
6
  VERSION = File.read(File.join(File.dirname(__FILE__), '../../VERSION')).strip
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" "1" "July 2010" "" ""
4
+ .TH "TO_PASS" "1" "August 2010" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBto_pass\fR \- transform a string to a password
@@ -151,7 +151,7 @@ ti1pwtsi2ltti@pf
151
151
 
152
152
  <ol class='man-decor man-foot man foot'>
153
153
  <li class='tl'></li>
154
- <li class='tc'>July 2010</li>
154
+ <li class='tc'>August 2010</li>
155
155
  <li class='tr'>to_pass(1)</li>
156
156
  </ol>
157
157
 
@@ -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" "July 2010" "" ""
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. <code>yaml</code> looks like a list of
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'>July 2010</li>
179
+ <li class='tc'>August 2010</li>
180
180
  <li class='tr'>to_pass-algorithm(5)</li>
181
181
  </ol>
182
182
 
@@ -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\-CONVERTER" "5" "July 2010" "" ""
4
+ .TH "TO_PASS\-CONVERTER" "5" "August 2010" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBto_pass\-converter\fR \- converter\-class for to_pass(1)
@@ -155,7 +155,7 @@ end
155
155
 
156
156
  <ol class='man-decor man-foot man foot'>
157
157
  <li class='tl'></li>
158
- <li class='tc'>July 2010</li>
158
+ <li class='tc'>August 2010</li>
159
159
  <li class='tr'>to_pass-converter(5)</li>
160
160
  </ol>
161
161
 
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
- $LOAD_PATH << base_path unless $LOAD_PATH.include?(base_path)
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: 15
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 5
9
- - 2
10
- version: 0.5.2
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-10 00:00:00 +02:00
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: sdoc
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-algorithm.5
105
- - man/to_pass-algorithm.5.html
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=UTF-8
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