to_pass 0.7.0 → 0.8.0
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/TODO +24 -14
- data/bin/password_of +4 -3
- data/bin/to_pass +4 -3
- data/doc/CHANGELOG +49 -16
- data/lib/to_pass/cli.rb +7 -2
- data/lib/to_pass/directories.rb +5 -1
- data/lib/to_pass/version.rb +1 -1
- data/test/helper.rb +24 -5
- data/test/test_algorithm_reader.rb +2 -2
- data/test/test_base.rb +15 -6
- data/test/test_cli.rb +38 -10
- data/test/test_converter_reader.rb +2 -2
- metadata +4 -4
data/TODO
CHANGED
@@ -1,26 +1,36 @@
|
|
1
1
|
CURRENT
|
2
2
|
============================================================================
|
3
|
-
|
4
|
-
- have some RELEASE-NOTES or CHANGELOG
|
5
|
-
- GemSpec#post_install_message = filename
|
6
|
-
- maybe http://github.com/proutils/vclog is useful...
|
7
|
-
|
8
|
-
|
9
|
-
UP NEXT
|
10
|
-
============================================================================
|
3
|
+
✔ let tests run separated
|
11
4
|
- Improve CLI-Code
|
12
|
-
|
13
|
-
- add option '-c, --config PATH - Configuration Path (default is ~/.to_pass)'
|
5
|
+
✔ rescue OptionParser::InvalidOption with help screen
|
14
6
|
- add ability to execute commands == handle CLI with Thor ?
|
15
7
|
- add command to generate configuration path
|
16
8
|
- add command to output available converters
|
17
9
|
- add command to output available algorithms
|
10
|
+
- add option '-c, --config PATH - Configuration Path (default is ~/.to_pass)'
|
11
|
+
|
12
|
+
|
13
|
+
UP NEXT
|
14
|
+
============================================================================
|
15
|
+
- make secure algorithm default
|
16
|
+
- make default algorithm configurable in .to_passrc [kronn/to_pass GH-1]
|
18
17
|
- make tests faster
|
18
|
+
- integrate better with YARD
|
19
|
+
- add the TODO file, the doc/ directory
|
20
|
+
- also show protected and private methods because I want to have a complete documentation
|
19
21
|
|
20
22
|
|
21
23
|
SOMEDAY
|
22
24
|
============================================================================
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
test on windows
|
26
|
+
move decision wether a string is a word or a sentence into algorithm definition.
|
27
|
+
add task to validate user supplied algorithms and converters
|
28
|
+
check out and maybe integrate https://github.com/stephencelis/rdoctest
|
29
|
+
?? replace Rake with Thor
|
30
|
+
|
31
|
+
|
32
|
+
LEGEND
|
33
|
+
================================
|
34
|
+
Planned = -
|
35
|
+
Done = ✔
|
36
|
+
Cancelled = ✘
|
data/bin/password_of
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- coding: utf-8 -*-
|
3
|
-
# vim:ft=ruby:
|
3
|
+
# vim:ft=ruby:fileencoding=utf-8
|
4
4
|
|
5
|
-
base_path =
|
5
|
+
base_path = File.expand_path('../../', __FILE__)
|
6
6
|
$LOAD_PATH << base_path unless $LOAD_PATH.include?(base_path)
|
7
|
+
$LOAD_PATH << "#{base_path}/lib" unless $LOAD_PATH.include?("#{base_path}/lib")
|
7
8
|
|
8
|
-
require '
|
9
|
+
require 'to_pass'
|
9
10
|
|
10
11
|
ToPass::Cli.new({
|
11
12
|
:algorithm => 'basic_de',
|
data/bin/to_pass
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- coding: utf-8 -*-
|
3
|
-
# vim:ft=ruby:
|
3
|
+
# vim:ft=ruby:fileencoding=utf-8
|
4
4
|
|
5
|
-
base_path =
|
5
|
+
base_path = File.expand_path('../../', __FILE__)
|
6
6
|
$LOAD_PATH << base_path unless $LOAD_PATH.include?(base_path)
|
7
|
+
$LOAD_PATH << "#{base_path}/lib" unless $LOAD_PATH.include?("#{base_path}/lib")
|
7
8
|
|
8
|
-
require '
|
9
|
+
require 'to_pass'
|
9
10
|
|
10
11
|
ToPass::Cli.new({
|
11
12
|
:algorithm => 'basic_de',
|
data/doc/CHANGELOG
CHANGED
@@ -1,5 +1,43 @@
|
|
1
1
|
RELEASE HISTORY
|
2
2
|
|
3
|
+
v0.7.0 / 2010-10-13
|
4
|
+
|
5
|
+
tag v0.7.0 (Matthias Viehweger <kronn@kronn.de>)
|
6
|
+
|
7
|
+
Changes:
|
8
|
+
|
9
|
+
* 28 General Enhancements
|
10
|
+
|
11
|
+
* setup the $LOAD_PATH better
|
12
|
+
* added ability to include RELEASE_NOTES (which are then also displayed after installing...)
|
13
|
+
* made gem-release an optional development dependency
|
14
|
+
* properly namespace documentation tasks in Rakefile
|
15
|
+
* add the ability to Benchmark tests
|
16
|
+
* added truly optional gems to Gemfile to have some means to install them
|
17
|
+
* fixed typos
|
18
|
+
* moved list of extra_rdoc_files into version.rb
|
19
|
+
* added doc/CHANGELOG
|
20
|
+
* moved LICENSE into doc directory
|
21
|
+
* declare the constants defensively
|
22
|
+
* move meta-information into version.rb-file
|
23
|
+
* updated idea/todo list
|
24
|
+
* include LICENSE again in Documentation
|
25
|
+
* move tests to [test/all, test/helper]-pattern
|
26
|
+
* the gem has all the files which are under version control
|
27
|
+
* ruby 1.9.2 compatibility
|
28
|
+
* don't rely on . being in $LOAD_PATH anymore (1.9.2 compat)
|
29
|
+
* fix vim-modeline (works as ruby 1.9 encoding-hint also)
|
30
|
+
* removed redundant require
|
31
|
+
* fixed manpage locations and links
|
32
|
+
* Version 0.6.0 brings mostly "debian compatiblity" as far as i can test it for now.
|
33
|
+
* added note on redgreen, which is purely optional
|
34
|
+
* documentation update
|
35
|
+
* include all methods in RDoc to make it actually useful
|
36
|
+
* added data-dir to gemspec
|
37
|
+
* extracted ToPass::DIRECTORIES into a real class
|
38
|
+
* assume Debian compatibility for now
|
39
|
+
|
40
|
+
|
3
41
|
v0.6.0 / 2010-08-18
|
4
42
|
|
5
43
|
tag v0.6.0 (Matthias Viehweger <kronn@kronn.de>)
|
@@ -189,14 +227,14 @@ Version bump to 0.2.1 (Matthias Viehweger kronn@kronn.de)
|
|
189
227
|
|
190
228
|
Changes:
|
191
229
|
|
192
|
-
* 1 Cleanup Enhancements
|
193
|
-
|
194
|
-
* redgreen is only needed and wanted for tests
|
195
|
-
|
196
230
|
* 1 General Enhancements
|
197
231
|
|
198
232
|
* Version bump to 0.2.0
|
199
233
|
|
234
|
+
* 1 Cleanup Enhancements
|
235
|
+
|
236
|
+
* redgreen is only needed and wanted for tests
|
237
|
+
|
200
238
|
|
201
239
|
v0.2.0 / 2010-05-30
|
202
240
|
|
@@ -242,20 +280,15 @@ Changes:
|
|
242
280
|
* Initial commit
|
243
281
|
|
244
282
|
|
245
|
-
HEAD / 2010-
|
283
|
+
HEAD / 2010-10-25
|
246
284
|
|
247
|
-
|
285
|
+
Current Development (Matthias Viehweger)
|
248
286
|
|
249
|
-
|
250
|
-
mostly, but has some issues.
|
287
|
+
Changes:
|
251
288
|
|
252
|
-
|
253
|
-
all in the version.rb-file. This way, they can be queried easier.
|
289
|
+
* 3 General Enhancements
|
254
290
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
CHANGELOG.
|
291
|
+
* started development after 0.7.0
|
292
|
+
* version bump to 0.7.0
|
293
|
+
* corrected path to lib-directory
|
259
294
|
|
260
|
-
The gemspec has the filelist now directly from git instead from the
|
261
|
-
filesystem.
|
data/lib/to_pass/cli.rb
CHANGED
@@ -44,7 +44,7 @@ module ToPass
|
|
44
44
|
:pipe_in => false
|
45
45
|
}.merge(options)
|
46
46
|
|
47
|
-
OptionParser.new do |opts|
|
47
|
+
cli_options = OptionParser.new do |opts|
|
48
48
|
opts.banner = "Usage: #{File.basename($0)} [options] passphrase"
|
49
49
|
opts.separator ""
|
50
50
|
|
@@ -62,13 +62,18 @@ module ToPass
|
|
62
62
|
puts opts
|
63
63
|
exit
|
64
64
|
end
|
65
|
-
end
|
65
|
+
end
|
66
|
+
cli_options.parse!
|
66
67
|
|
67
68
|
if ARGV[0].nil?
|
68
69
|
options[:pipe_in] = options[:pipe_out] = true
|
69
70
|
end
|
70
71
|
|
71
72
|
options
|
73
|
+
|
74
|
+
rescue OptionParser::InvalidOption
|
75
|
+
puts cli_options
|
76
|
+
exit 0
|
72
77
|
end
|
73
78
|
|
74
79
|
# get the input string
|
data/lib/to_pass/directories.rb
CHANGED
@@ -25,11 +25,15 @@ module ToPass
|
|
25
25
|
def all
|
26
26
|
{
|
27
27
|
:user => "~/.#{APP_NAME}",
|
28
|
-
:data => "#{
|
28
|
+
:data => "#{ruby_data_dir}/#{APP_NAME}",
|
29
29
|
:base => File.expand_path("#{File.dirname(__FILE__)}/../.."),
|
30
30
|
:source_data => File.expand_path("#{File.dirname(__FILE__)}/../../data/#{APP_NAME}"),
|
31
31
|
}
|
32
32
|
end
|
33
|
+
|
34
|
+
def ruby_data_dir
|
35
|
+
RbConfig::CONFIG['data-dir'] || RbConfig::CONFIG['datadir']
|
36
|
+
end
|
33
37
|
end
|
34
38
|
end
|
35
39
|
end
|
data/lib/to_pass/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'test/unit'
|
4
4
|
require 'mocha'
|
5
5
|
require 'rbconfig'
|
6
|
+
require 'pathname'
|
6
7
|
|
7
8
|
# optional libraries
|
8
9
|
begin
|
@@ -38,12 +39,18 @@ Test::Unit::TestCase.class_eval do
|
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
42
|
+
def assert_include(needle, haystack, msg = nil)
|
43
|
+
msg ||= "#{haystack.inspect} should include #{needle.inspect}"
|
44
|
+
assert haystack.include?(needle), msg
|
45
|
+
end
|
46
|
+
|
41
47
|
def standard_directories
|
42
|
-
[
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
48
|
+
dirs = []
|
49
|
+
dirs << Pathname.new('~/.to_pass').expand_path # user
|
50
|
+
dirs << "#{ruby_data_dir}/#{ToPass::APP_NAME}" # installed
|
51
|
+
dirs << "#{File.dirname(__FILE__)}/../data/#{ToPass::APP_NAME}" if in_to_pass_soure_tree? # source [in github]
|
52
|
+
|
53
|
+
dirs
|
47
54
|
end
|
48
55
|
|
49
56
|
def with_algorithm_in_user_dir
|
@@ -57,6 +64,18 @@ Test::Unit::TestCase.class_eval do
|
|
57
64
|
yield
|
58
65
|
`rm ~/.to_pass/converters/userize.rb`
|
59
66
|
end
|
67
|
+
|
68
|
+
def in_to_pass_soure_tree?
|
69
|
+
Pathname.new("#{File.dirname(__FILE__)}/../to_pass.gemspec").expand_path.exist?
|
70
|
+
end
|
71
|
+
|
72
|
+
def ruby_data_dir
|
73
|
+
RbConfig::CONFIG['data-dir'] || RbConfig::CONFIG['datadir']
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
unless Pathname.new("#{File.dirname(__FILE__)}/../to_pass.gemspec").expand_path.exist?
|
78
|
+
$stderr << "Skipping some assertion as the tests run separated from the source-directory\n"
|
60
79
|
end
|
61
80
|
|
62
81
|
require 'to_pass'
|
@@ -29,11 +29,11 @@ class TestAlgorithmReader < Test::Unit::TestCase
|
|
29
29
|
def test_load_path_contains_standard_dirs
|
30
30
|
dirs = standard_directories.map { |path| "#{path}/algorithms"}
|
31
31
|
|
32
|
-
Pathname.any_instance.expects(:exist?).
|
32
|
+
Pathname.any_instance.expects(:exist?).at_least(dirs.size).returns(true)
|
33
33
|
|
34
34
|
dirs.each do |reldir|
|
35
35
|
dir = Pathname.new(reldir).expand_path
|
36
|
-
|
36
|
+
assert_include dir, reader.load_path
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
data/test/test_base.rb
CHANGED
@@ -17,7 +17,11 @@ class TestBase < Test::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_date
|
20
|
-
|
20
|
+
if in_to_pass_soure_tree?
|
21
|
+
assert_equal Pathname.new("#{File.dirname(__FILE__)}/../lib/to_pass/version.rb").expand_path.mtime, ToPass::DATE
|
22
|
+
else
|
23
|
+
assert_not_nil ToPass::DATE
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
def test_appname
|
@@ -25,8 +29,10 @@ class TestBase < Test::Unit::TestCase
|
|
25
29
|
end
|
26
30
|
|
27
31
|
def test_gemspec_is_valid
|
28
|
-
|
29
|
-
|
32
|
+
if in_to_pass_soure_tree?
|
33
|
+
assert_nothing_raised do
|
34
|
+
assert eval(File.read(File.expand_path('../../to_pass.gemspec', __FILE__))).validate
|
35
|
+
end
|
30
36
|
end
|
31
37
|
end
|
32
38
|
|
@@ -37,9 +43,12 @@ class TestBase < Test::Unit::TestCase
|
|
37
43
|
assert_respond_to dirs, :[]
|
38
44
|
|
39
45
|
assert_equal '~/.to_pass', dirs[:user]
|
40
|
-
assert_equal "#{
|
41
|
-
|
42
|
-
|
46
|
+
assert_equal "#{ruby_data_dir}/#{ToPass::APP_NAME}", dirs[:data]
|
47
|
+
|
48
|
+
if in_to_pass_soure_tree?
|
49
|
+
assert_equal Pathname.new("#{File.dirname(__FILE__)}/../").expand_path.to_s, dirs[:base]
|
50
|
+
assert_equal Pathname.new("#{File.dirname(__FILE__)}/../data/#{ToPass::APP_NAME}").expand_path.to_s, dirs[:source_data]
|
51
|
+
end
|
43
52
|
|
44
53
|
assert_equal [ dirs[:user], dirs[:data], dirs[:source_data] ], dirs[:standard]
|
45
54
|
end
|
data/test/test_cli.rb
CHANGED
@@ -7,52 +7,80 @@ class TestCli < Test::Unit::TestCase
|
|
7
7
|
|
8
8
|
def test_cli_usage_without_algorithm
|
9
9
|
assert_nothing_raised do
|
10
|
-
assert_equal "t35t",
|
10
|
+
assert_equal "t35t", `#{binpath}to_pass test`.chomp
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_cli_usage_with_password_of
|
15
15
|
assert_nothing_raised do
|
16
|
-
assert_equal "t35t",
|
16
|
+
assert_equal "t35t", `#{binpath}password_of test`.chomp
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_cli_usage_with_algorithm
|
21
21
|
assert_nothing_raised do
|
22
|
-
assert_equal "ti1p4u2",
|
22
|
+
assert_equal "ti1p4u2", `#{binpath}to_pass 'there is one problem for us, too' -a basic_en`.chomp
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_cli_usage_with_pipes
|
27
27
|
assert_nothing_raised do
|
28
|
-
assert_equal 't35t', `echo "test" |
|
28
|
+
assert_equal 't35t', `echo "test" | #{binpath}to_pass`
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_cli_usage_with_pipe_input
|
33
33
|
assert_nothing_raised do
|
34
|
-
assert_equal 't35t', `echo "test" |
|
34
|
+
assert_equal 't35t', `echo "test" | #{binpath}to_pass --no-pipe`.chomp
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_cli_usage_with_pipe_output
|
39
39
|
assert_nothing_raised do
|
40
|
-
assert_equal 't35t',
|
40
|
+
assert_equal 't35t', `#{binpath}to_pass test --pipe`
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
|
45
45
|
def test_cli_usage_with_user_algorithm
|
46
46
|
with_algorithm_in_user_dir do
|
47
|
-
assert_equal "le1/2%z",
|
48
|
-
assert_equal "le1/2%z",
|
47
|
+
assert_equal "le1/2%z", `#{binpath}to_pass 'leasbpc' -a user_alg`.chomp
|
48
|
+
assert_equal "le1/2%z", `#{binpath}to_pass 'luke eats all sausagages because peter cries' -a user_alg`.chomp
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_cli_usage_with_pipes_and_user_algorithm
|
53
53
|
with_algorithm_in_user_dir do
|
54
|
-
assert_equal "le1/2%z", `echo 'leasbpc' |
|
55
|
-
assert_equal "le1/2%z", `echo 'luke eats all sausagages because peter cries' |
|
54
|
+
assert_equal "le1/2%z", `echo 'leasbpc' | #{binpath}to_pass -a user_alg`.chomp
|
55
|
+
assert_equal "le1/2%z", `echo 'luke eats all sausagages because peter cries' | #{binpath}to_pass -a user_alg`.chomp
|
56
56
|
end
|
57
57
|
end
|
58
|
+
|
59
|
+
def test_cli_handles_wrong_arguments
|
60
|
+
# i only want to check the return value here
|
61
|
+
system("#{binpath}to_pass 'test' --schnulli >/dev/null 2>/dev/null")
|
62
|
+
to_pass = $?
|
63
|
+
|
64
|
+
assert to_pass.exited?
|
65
|
+
assert_equal 0, to_pass.exitstatus, 'should have exit code 0 (success)'
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_cli_presents_help_on_error
|
69
|
+
# combine everything into result-string
|
70
|
+
result = `#{binpath}to_pass "test" --schnulli 2>&1`
|
71
|
+
|
72
|
+
assert_match /Usage/, result, 'should print usage information'
|
73
|
+
assert_match /Show this message/, result, 'should contain hint for help'
|
74
|
+
end
|
75
|
+
|
76
|
+
protected
|
77
|
+
|
78
|
+
def binpath
|
79
|
+
bin_to_pass = File.expand_path('../../bin/to_pass', __FILE__)
|
80
|
+
if File.exist?(bin_to_pass)
|
81
|
+
File.dirname(bin_to_pass)
|
82
|
+
else
|
83
|
+
File.dirname(`which -a to_pass`.split.uniq.reject { |p| p =~ /gems/ }.first)
|
84
|
+
end + '/'
|
85
|
+
end
|
58
86
|
end
|
@@ -35,11 +35,11 @@ class TestConverterReader < Test::Unit::TestCase
|
|
35
35
|
def test_load_path_contains_standard_dirs
|
36
36
|
dirs = standard_directories.map { |path| "#{path}/converters"}
|
37
37
|
|
38
|
-
Pathname.any_instance.expects(:exist?).
|
38
|
+
Pathname.any_instance.expects(:exist?).at_least(dirs.size).returns(true)
|
39
39
|
|
40
40
|
dirs.each do |reldir|
|
41
41
|
dir = Pathname.new(reldir).expand_path
|
42
|
-
|
42
|
+
assert_include dir, reader.load_path
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
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: 63
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 8
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.8.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-
|
18
|
+
date: 2010-12-15 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|