to_pass 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -24,7 +24,7 @@ rescue LoadError
24
24
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
25
25
  end
26
26
 
27
- # documentation task
27
+ # documentation tasks
28
28
  begin
29
29
  %w[ rake/rdoctask sdoc ].each { |lib| require lib }
30
30
  Rake::RDocTask.new do |rdoc|
@@ -39,6 +39,15 @@ begin
39
39
  end
40
40
  rescue LoadError
41
41
  end
42
+ begin
43
+ desc 'generate manpages for project'
44
+ task :man do
45
+ files = Dir['./man/*.ronn'].join(' ')
46
+ command = "ronn --html --roff --style=toc #{files}"
47
+
48
+ `#{command}`
49
+ end
50
+ end
42
51
 
43
52
  desc "run tests"
44
53
  task :test do
data/TODO CHANGED
@@ -26,3 +26,9 @@ SOMEDAY
26
26
  ============================================================================
27
27
  - move decision wether a string is a word or not into algorithm definition.
28
28
  - test on windows
29
+ - rescue OptionParser::InvalidOption with help screen
30
+ - add option '-c, --config PATH - Configuration Path (default is ~/.to_pass)'
31
+ - add ability to execute commands
32
+ - add command to generate configuration path
33
+ - add command to output available converters
34
+ - add command to output available algorithms
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
data/bin/password_of ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ # vim:ft=ruby:enc=utf-8
4
+
5
+ base_path = ( File.expand_path(File.dirname(__FILE__)+'/..') )
6
+ $LOAD_PATH << base_path unless $LOAD_PATH.include?(base_path)
7
+
8
+ require 'lib/to_pass'
9
+
10
+ ToPass::Cli.new({
11
+ :algorithm => 'basic_de',
12
+ :pipe_out => false,
13
+ :pipe_in => false
14
+ }).output
data/bin/to_pass CHANGED
@@ -7,4 +7,8 @@ $LOAD_PATH << base_path unless $LOAD_PATH.include?(base_path)
7
7
 
8
8
  require 'lib/to_pass'
9
9
 
10
- ToPass::Cli.new.output
10
+ ToPass::Cli.new({
11
+ :algorithm => 'basic_de',
12
+ :pipe_out => false,
13
+ :pipe_in => false
14
+ }).output
@@ -0,0 +1,33 @@
1
+ desc: "A basic, but secure password generator"
2
+ name: secure
3
+ sentence:
4
+ - first_chars
5
+ - collapse_chars
6
+ - expand_below: 8
7
+ - downcase
8
+ - replace: symbols
9
+ - replace: numbers
10
+ - remove_repetition
11
+ - expand_below: 8
12
+ - swapcase
13
+ - reverse
14
+ word:
15
+ - expand_below: 8
16
+ - downcase
17
+ - replace: symbols
18
+ - replace: numbers
19
+ - remove_repetition
20
+ - expand_below: 8
21
+ - swapcase
22
+ - reverse
23
+ replacements:
24
+ symbols:
25
+ x: %
26
+ d: $
27
+ i: !
28
+ a: @
29
+ numbers:
30
+ z: 2
31
+ s: 5
32
+ g: 9
33
+ o: 0
data/lib/to_pass/cli.rb CHANGED
@@ -5,8 +5,8 @@ require 'optparse'
5
5
 
6
6
  module ToPass
7
7
  class Cli
8
- def initialize
9
- @options = parse_options
8
+ def initialize(options = {})
9
+ @options = parse_options(options)
10
10
  @string = get_input_string
11
11
  @password = transform
12
12
  end
@@ -22,15 +22,15 @@ module ToPass
22
22
  protected
23
23
 
24
24
  # parse the options
25
- def parse_options
25
+ def parse_options(options = {})
26
26
  options = {
27
27
  :algorithm => 'basic_de',
28
28
  :pipe_out => false,
29
29
  :pipe_in => false
30
- }
30
+ }.merge(options)
31
31
 
32
32
  OptionParser.new do |opts|
33
- opts.banner = "Usage: #{__FILE__} [options] passphrase"
33
+ opts.banner = "Usage: #{$0} [options] passphrase"
34
34
  opts.separator ""
35
35
 
36
36
  opts.on('-a', '--algorithm ALGORITM', "use specified algorithm for transformation") do |value|
@@ -77,7 +77,7 @@ class ToPass::ConverterReader
77
77
  end
78
78
  end.compact.first
79
79
 
80
- raise LoadError, "converter '#{converter}' could not be found in #{load_path}" if fn.nil?
80
+ raise LoadError, "converter '#{converter}' could not be found in #{load_path.join(' ')}" if fn.nil?
81
81
 
82
82
  if require fn
83
83
  classname converter
@@ -0,0 +1,10 @@
1
+ module ToPass::Converters
2
+ class Downcase
3
+ class << self
4
+ # the string is lowercased
5
+ def downcase(string)
6
+ string.downcase
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,21 @@
1
+ require 'md5'
2
+
3
+ module ToPass::Converters
4
+ class ExpandBelow
5
+ class << self
6
+ def expand_below(string, rules, threshold)
7
+ if string.length < threshold.to_i
8
+ digest = "#{MD5.hexdigest(string)}#{MD5.hexdigest(string).reverse}"
9
+ extension = 1.upto(digest.length / 2).map do |nr|
10
+ char = digest[(nr*2-2),2].to_i(16).chr
11
+ char if char =~ /\w/i
12
+ end.compact.join
13
+
14
+ string + extension
15
+ else
16
+ string
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ module ToPass::Converters
2
+ class RemoveRepetition
3
+ class << self
4
+ # remove duplicate characters by replacing them with the character and the count
5
+ def remove_repetition(string)
6
+ string.split('').inject('') do |memo, char|
7
+ if memo.size <= 1
8
+ memo << char
9
+ else
10
+ last = memo[memo.size-1].chr
11
+ if last == char
12
+ memo << '2'
13
+ elsif last =~ /\d/ and memo[memo.size-2].chr == char
14
+ memo.succ
15
+ else
16
+ memo << char
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ module ToPass::Converters
2
+ class Reverse
3
+ def self.reverse(string)
4
+ string.reverse
5
+ end
6
+ end
7
+ end
data/man/index.txt ADDED
@@ -0,0 +1,8 @@
1
+ # manuals included in this project
2
+ to_pass(1) to_pass.1.ronn
3
+ to_pass-converter(5) to_pass-converter.5.ronn
4
+ to_pass-algorithm(5) to_pass-algorithm.5.ronn
5
+
6
+ # external documentation
7
+ yaml(3pm) http://man.cx/yaml(3pm)
8
+ ruby(1) http://man.cx/ruby(1)
@@ -0,0 +1,93 @@
1
+ .\" generated with Ronn/v0.7.3
2
+ .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
+ .
4
+ .TH "TO_PASS\-ALGORITHM" "5" "July 2010" "" ""
5
+ .
6
+ .SH "NAME"
7
+ \fBto_pass\-algorithm\fR \- algorithm\-description for to_pass(1)
8
+ .
9
+ .SH "DESCRIPTION"
10
+ An algorithms is a simple list of conversions which are applied to the input string\. The algorithm file is a yaml(3pm) file\. \fByaml\fR looks like a list of key\-value pairs\. Nesting is done by indentation (2 spaces)\. Consecutive lines which begin with a \fB\-\fR are considered an array\.
11
+ .
12
+ .P
13
+ The following keys should be supported:
14
+ .
15
+ .SS "META"
16
+ .
17
+ .IP "\(bu" 4
18
+ \fBdesc\fR short description of the algorithm
19
+ .
20
+ .IP "\(bu" 4
21
+ \fBname\fR name of the algorithm (think: title)
22
+ .
23
+ .IP "" 0
24
+ .
25
+ .SS "COMMON"
26
+ .
27
+ .IP "\(bu" 4
28
+ \fBsentence\fR list of rules which are applied to a string which contains whitespace\.
29
+ .
30
+ .IP "\(bu" 4
31
+ \fBword\fR list of rules which are applied to everything which is not a sentence\.
32
+ .
33
+ .IP "" 0
34
+ .
35
+ .SS "SUPPORT AND ARGUMENTS"
36
+ These keys are highly dependent on the use conversions\. In the bundled algorithms, \fBreplace\fR needs a replacement table\. Inside the converter code of \fBreplace\fR, the replacements\-key is required\.
37
+ .
38
+ .P
39
+ It is up to the developer/distributor of the converter to document this\.
40
+ .
41
+ .P
42
+ If a conversion step needs arguments, the argument list is expected to follow the converter name, separated by colon\. So far, only simple text arguments are supported\. In theory, anything which is valid yaml could follow the name and would be passed into the converter method\.
43
+ .
44
+ .SH "EXAMPLE"
45
+ .
46
+ .nf
47
+
48
+ desc: Basic Algorithm with a english usage in mind
49
+ name: Basic (english)
50
+ sentence:
51
+ \- replace: words
52
+ \- first_chars
53
+ \- replace: symbols
54
+ \- collapse_chars
55
+ word:
56
+ \- replace: chars
57
+ \- replace: symbols
58
+ replacements:
59
+ words:
60
+ one: 1
61
+ single: 1
62
+ two: 2
63
+ too: 2
64
+ three: 3
65
+ four: 4
66
+ for: 4
67
+ five: 5
68
+ six: 6
69
+ seven: 7
70
+ eight: 8
71
+ nine: 9
72
+ symbols:
73
+ a: \'@\'
74
+ chars:
75
+ a: 4
76
+ e: 3
77
+ i: 1
78
+ o: 0
79
+ s: 5
80
+ .
81
+ .fi
82
+ .
83
+ .SH "CAVEATS"
84
+ The decision wether a string is a word or a sentence is built directly into the gem and not configurable\.
85
+ .
86
+ .P
87
+ The algorithm is not turing\-complete\. It\'s not even intended to be\. Some more capabilty (like conditions and restart) may be added at some point\. The overall design however is intentionally simple and constrained\.
88
+ .
89
+ .SH "AUTHOR"
90
+ Matthias Viehweger
91
+ .
92
+ .SH "SEE ALSO"
93
+ to_pass(1), to_pass\-converter(5), yaml(3pm)
@@ -0,0 +1,185 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv='content-type' value='text/html;charset=utf8'>
5
+ <meta name='generator' value='Ronn/v0.7.3 (http://github.com/rtomayko/ronn/tree/0.7.3)'>
6
+ <title>to_pass-algorithm(5) - algorithm-description for to_pass(1)</title>
7
+ <style type='text/css' media='all'>
8
+ /* style: man */
9
+ body#manpage {margin:0}
10
+ .mp {max-width:100ex;padding:0 9ex 1ex 4ex}
11
+ .mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0}
12
+ .mp h2 {margin:10px 0 0 0}
13
+ .mp > p,.mp > pre,.mp > ul,.mp > ol,.mp > dl {margin-left:8ex}
14
+ .mp h3 {margin:0 0 0 4ex}
15
+ .mp dt {margin:0;clear:left}
16
+ .mp dt.flush {float:left;width:8ex}
17
+ .mp dd {margin:0 0 0 9ex}
18
+ .mp h1,.mp h2,.mp h3,.mp h4 {clear:left}
19
+ .mp pre {margin-bottom:20px}
20
+ .mp pre+h2,.mp pre+h3 {margin-top:22px}
21
+ .mp h2+pre,.mp h3+pre {margin-top:5px}
22
+ .mp img {display:block;margin:auto}
23
+ .mp h1.man-title {display:none}
24
+ .mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143}
25
+ .mp h2 {font-size:16px;line-height:1.25}
26
+ .mp h1 {font-size:20px;line-height:2}
27
+ .mp {text-align:justify;background:#fff}
28
+ .mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211}
29
+ .mp h1,.mp h2,.mp h3,.mp h4 {color:#030201}
30
+ .mp u {text-decoration:underline}
31
+ .mp code,.mp strong,.mp b {font-weight:bold;color:#131211}
32
+ .mp em,.mp var {font-style:italic;color:#232221;text-decoration:none}
33
+ .mp a,.mp a:link,.mp a:hover,.mp a code,.mp a pre,.mp a tt,.mp a kbd,.mp a samp {color:#0000ff}
34
+ .mp b.man-ref {font-weight:normal;color:#434241}
35
+ .mp pre {padding:0 4ex}
36
+ .mp pre code {font-weight:normal;color:#434241}
37
+ .mp h2+pre,h3+pre {padding-left:0}
38
+ ol.man-decor,ol.man-decor li {margin:3px 0 10px 0;padding:0;float:left;width:33%;list-style-type:none;text-transform:uppercase;color:#999;letter-spacing:1px}
39
+ ol.man-decor {width:100%}
40
+ ol.man-decor li.tl {text-align:left}
41
+ ol.man-decor li.tc {text-align:center;letter-spacing:4px}
42
+ ol.man-decor li.tr {text-align:right;float:right}
43
+ </style>
44
+ <style type='text/css' media='all'>
45
+ /* style: toc */
46
+ .man-navigation {display:block !important;position:fixed;top:0;left:113ex;height:100%;width:100%;padding:48px 0 0 0;border-left:1px solid #dbdbdb;background:#eee}
47
+ .man-navigation a,.man-navigation a:hover,.man-navigation a:link,.man-navigation a:visited {display:block;margin:0;padding:5px 2px 5px 30px;color:#999;text-decoration:none}
48
+ .man-navigation a:hover {color:#111;text-decoration:underline}
49
+ </style>
50
+ </head>
51
+ <!--
52
+ The following styles are deprecated and will be removed at some point:
53
+ div#man, div#man ol.man, div#man ol.head, div#man ol.man.
54
+
55
+ The .man-page, .man-decor, .man-head, .man-foot, .man-title, and
56
+ .man-navigation should be used instead.
57
+ -->
58
+ <body id='manpage'>
59
+ <div class='mp' id='man'>
60
+
61
+ <div class='man-navigation' style='display:none'>
62
+ <a href="#NAME">NAME</a>
63
+ <a href="#DESCRIPTION">DESCRIPTION</a>
64
+ <a href="#EXAMPLE">EXAMPLE</a>
65
+ <a href="#CAVEATS">CAVEATS</a>
66
+ <a href="#AUTHOR">AUTHOR</a>
67
+ <a href="#SEE-ALSO">SEE ALSO</a>
68
+ </div>
69
+
70
+ <ol class='man-decor man-head man head'>
71
+ <li class='tl'>to_pass-algorithm(5)</li>
72
+ <li class='tc'></li>
73
+ <li class='tr'>to_pass-algorithm(5)</li>
74
+ </ol>
75
+
76
+ <h2 id="NAME">NAME</h2>
77
+ <p class="man-name">
78
+ <code>to_pass-algorithm</code> - <span class="man-whatis">algorithm-description for <a href="to_pass.1.html" class="man-ref">to_pass<span class="s">(1)</span></a></span>
79
+ </p>
80
+
81
+ <h2 id="DESCRIPTION">DESCRIPTION</h2>
82
+
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
85
+ key-value pairs. Nesting is done by indentation (2 spaces). Consecutive lines
86
+ which begin with a <code>-</code> are considered an array.</p>
87
+
88
+ <p>The following keys should be supported:</p>
89
+
90
+ <h3 id="META">META</h3>
91
+
92
+ <ul>
93
+ <li><p><code>desc</code>
94
+ short description of the algorithm</p></li>
95
+ <li><p><code>name</code>
96
+ name of the algorithm (think: title)</p></li>
97
+ </ul>
98
+
99
+
100
+ <h3 id="COMMON">COMMON</h3>
101
+
102
+ <ul>
103
+ <li><p><code>sentence</code>
104
+ list of rules which are applied to a string which contains whitespace.</p></li>
105
+ <li><p><code>word</code>
106
+ list of rules which are applied to everything which is not a sentence.</p></li>
107
+ </ul>
108
+
109
+
110
+ <h3 id="SUPPORT-AND-ARGUMENTS">SUPPORT AND ARGUMENTS</h3>
111
+
112
+ <p>These keys are highly dependent on the use conversions. In the bundled
113
+ algorithms, <code>replace</code> needs a replacement table. Inside the converter code of
114
+ <code>replace</code>, the replacements-key is required.</p>
115
+
116
+ <p>It is up to the developer/distributor of the converter to document this.</p>
117
+
118
+ <p>If a conversion step needs arguments, the argument list is expected to follow
119
+ the converter name, separated by colon. So far, only simple text arguments are
120
+ supported. In theory, anything which is valid yaml could follow the name and
121
+ would be passed into the converter method.</p>
122
+
123
+ <h2 id="EXAMPLE">EXAMPLE</h2>
124
+
125
+ <pre><code>desc: Basic Algorithm with a english usage in mind
126
+ name: Basic (english)
127
+ sentence:
128
+ - replace: words
129
+ - first_chars
130
+ - replace: symbols
131
+ - collapse_chars
132
+ word:
133
+ - replace: chars
134
+ - replace: symbols
135
+ replacements:
136
+ words:
137
+ one: 1
138
+ single: 1
139
+ two: 2
140
+ too: 2
141
+ three: 3
142
+ four: 4
143
+ for: 4
144
+ five: 5
145
+ six: 6
146
+ seven: 7
147
+ eight: 8
148
+ nine: 9
149
+ symbols:
150
+ a: '@'
151
+ chars:
152
+ a: 4
153
+ e: 3
154
+ i: 1
155
+ o: 0
156
+ s: 5
157
+ </code></pre>
158
+
159
+ <h2 id="CAVEATS">CAVEATS</h2>
160
+
161
+ <p>The decision wether a string is a word or a sentence is built directly into the
162
+ gem and not configurable.</p>
163
+
164
+ <p>The algorithm is not turing-complete. It's not even intended to be. Some more
165
+ capabilty (like conditions and restart) may be added at some point. The overall
166
+ design however is intentionally simple and constrained.</p>
167
+
168
+ <h2 id="AUTHOR">AUTHOR</h2>
169
+
170
+ <p>Matthias Viehweger</p>
171
+
172
+ <h2 id="SEE-ALSO">SEE ALSO</h2>
173
+
174
+ <p><a href="to_pass.1.html" class="man-ref">to_pass<span class="s">(1)</span></a>, <a href="to_pass-converter.5.html" class="man-ref">to_pass-converter<span class="s">(5)</span></a>, <a href="http://man.cx/yaml(3pm)" class="man-ref">yaml<span class="s">(3pm)</span></a></p>
175
+
176
+
177
+ <ol class='man-decor man-foot man foot'>
178
+ <li class='tl'></li>
179
+ <li class='tc'>July 2010</li>
180
+ <li class='tr'>to_pass-algorithm(5)</li>
181
+ </ol>
182
+
183
+ </div>
184
+ </body>
185
+ </html>
@@ -0,0 +1,93 @@
1
+ to_pass-algorithm(5) -- algorithm-description for to_pass(1)
2
+ =========================================================
3
+
4
+ ## DESCRIPTION
5
+
6
+ An algorithms is a simple list of conversions which are applied to the input
7
+ string. The algorithm file is a yaml(3pm) file. `yaml` looks like a list of
8
+ key-value pairs. Nesting is done by indentation (2 spaces). Consecutive lines
9
+ which begin with a `-` are considered an array.
10
+
11
+ The following keys should be supported:
12
+
13
+ ### META
14
+
15
+ * `desc`
16
+ short description of the algorithm
17
+
18
+ * `name`
19
+ name of the algorithm (think: title)
20
+
21
+ ### COMMON
22
+
23
+ * `sentence`
24
+ list of rules which are applied to a string which contains whitespace.
25
+
26
+ * `word`
27
+ list of rules which are applied to everything which is not a sentence.
28
+
29
+ ### SUPPORT AND ARGUMENTS
30
+
31
+ These keys are highly dependent on the use conversions. In the bundled
32
+ algorithms, `replace` needs a replacement table. Inside the converter code of
33
+ `replace`, the replacements-key is required.
34
+
35
+ It is up to the developer/distributor of the converter to document this.
36
+
37
+ If a conversion step needs arguments, the argument list is expected to follow
38
+ the converter name, separated by colon. So far, only simple text arguments are
39
+ supported. In theory, anything which is valid yaml could follow the name and
40
+ would be passed into the converter method.
41
+
42
+ ## EXAMPLE
43
+
44
+ desc: Basic Algorithm with a english usage in mind
45
+ name: Basic (english)
46
+ sentence:
47
+ - replace: words
48
+ - first_chars
49
+ - replace: symbols
50
+ - collapse_chars
51
+ word:
52
+ - replace: chars
53
+ - replace: symbols
54
+ replacements:
55
+ words:
56
+ one: 1
57
+ single: 1
58
+ two: 2
59
+ too: 2
60
+ three: 3
61
+ four: 4
62
+ for: 4
63
+ five: 5
64
+ six: 6
65
+ seven: 7
66
+ eight: 8
67
+ nine: 9
68
+ symbols:
69
+ a: '@'
70
+ chars:
71
+ a: 4
72
+ e: 3
73
+ i: 1
74
+ o: 0
75
+ s: 5
76
+
77
+ ## CAVEATS
78
+
79
+ The decision wether a string is a word or a sentence is built directly into the
80
+ gem and not configurable.
81
+
82
+ The algorithm is not turing-complete. It's not even intended to be. Some more
83
+ capabilty (like conditions and restart) may be added at some point. The overall
84
+ design however is intentionally simple and constrained.
85
+
86
+
87
+ ## AUTHOR
88
+
89
+ Matthias Viehweger
90
+
91
+ ## SEE ALSO
92
+
93
+ to_pass(1), to_pass-converter(5), yaml(3pm)
@@ -0,0 +1,92 @@
1
+ .\" generated with Ronn/v0.7.3
2
+ .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
+ .
4
+ .TH "TO_PASS\-CONVERTER" "5" "July 2010" "" ""
5
+ .
6
+ .SH "NAME"
7
+ \fBto_pass\-converter\fR \- converter\-class for to_pass(1)
8
+ .
9
+ .SH "DESCRIPTION"
10
+ Every converter class is a ruby(1) class which converts a string into a more password\-suitable form\.
11
+ .
12
+ .P
13
+ The converter classes should satisfy the following constraints:
14
+ .
15
+ .IP "\(bu" 4
16
+ the class is scoped inside \fBToPass::Converters\fR
17
+ .
18
+ .IP "\(bu" 4
19
+ the class is named like the camelized version of the converter name
20
+ .
21
+ .IP "\(bu" 4
22
+ the class provides a class\-method with the lowercased, underscored version of the converter name
23
+ .
24
+ .IP "" 0
25
+ .
26
+ .P
27
+ All converters are called with the string as the first parameter\. This string is the result of the previous conversion or the input string, if it is the first converter in the list\.
28
+ .
29
+ .P
30
+ If the converter accepts an additional argument (like replace), then the second parameter is the complete rules hash\. The third parameter is the argument from the algorithm file\.
31
+ .
32
+ .P
33
+ The method is expected to return a string which should be the result of the intended conversion\.
34
+ .
35
+ .SH "EXAMPLES"
36
+ simple converter class
37
+ .
38
+ .IP "" 4
39
+ .
40
+ .nf
41
+
42
+ module ToPass::Converters
43
+ class FirstChars
44
+
45
+ # reduces every word to its first character, preserving case
46
+ def self\.first_chars(string)
47
+ string\.split(\' \')\.map do |word|
48
+ word[0]\.chr
49
+ end\.join(\' \')
50
+ end
51
+
52
+ end
53
+ end
54
+ .
55
+ .fi
56
+ .
57
+ .IP "" 0
58
+ .
59
+ .P
60
+ converter which receives additional parameters
61
+ .
62
+ .IP "" 4
63
+ .
64
+ .nf
65
+
66
+ module ToPass::Converters
67
+ class Replace
68
+ class << self
69
+
70
+ # perform replacements on a string, based on a replacment table
71
+ def replace(string, rules, tablename)
72
+ rules[\'replacements\'][tablename]\.inject(string) do |pwd, map|
73
+ pwd = pwd\.gsub(/#{map[0]\.to_s}/, map[1]\.to_s)
74
+ end
75
+ end
76
+
77
+ end
78
+ end
79
+ end
80
+ .
81
+ .fi
82
+ .
83
+ .IP "" 0
84
+ .
85
+ .SH "CAVEATS"
86
+ Naming is probaly most biggest concern\. The name of the converter should be unique to avoid breaking other algorithms\.
87
+ .
88
+ .SH "AUTHOR"
89
+ Matthias Viehweger
90
+ .
91
+ .SH "SEE ALSO"
92
+ to_pass(1), to_pass\-algorithm(5), ruby(1)