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 CHANGED
@@ -1,26 +1,36 @@
1
1
  CURRENT
2
2
  ============================================================================
3
- - test on multiple rubies (1.8.7, 1.9.2, Rubinius, REE)
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
- - rescue OptionParser::InvalidOption with help screen
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
- - test on windows
24
- - move decision wether a string is a word or a sentence into algorithm definition.
25
- - add task to validate user supplied algorithms and converters
26
- - ?? replace Rake with Thor
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 = ✘
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- coding: utf-8 -*-
3
- # vim:ft=ruby:enc=utf-8
3
+ # vim:ft=ruby:fileencoding=utf-8
4
4
 
5
- base_path = ( File.expand_path(File.dirname(__FILE__)+'/..') )
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 'lib/to_pass'
9
+ require 'to_pass'
9
10
 
10
11
  ToPass::Cli.new({
11
12
  :algorithm => 'basic_de',
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- coding: utf-8 -*-
3
- # vim:ft=ruby:enc=utf-8
3
+ # vim:ft=ruby:fileencoding=utf-8
4
4
 
5
- base_path = ( File.expand_path(File.dirname(__FILE__)+'/..') )
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 'lib/to_pass'
9
+ require 'to_pass'
9
10
 
10
11
  ToPass::Cli.new({
11
12
  :algorithm => 'basic_de',
@@ -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-09-03
283
+ HEAD / 2010-10-25
246
284
 
247
- Version 0.7.0 is mostly a cleanup and compatibility release.
285
+ Current Development (Matthias Viehweger)
248
286
 
249
- ToPass now runs seamlessly with Ruby 1.8.7, 1.9.2, REE 2010-02. Rubinius works
250
- mostly, but has some issues.
287
+ Changes:
251
288
 
252
- The Metainformation like version, summary, description and the likes are now
253
- all in the version.rb-file. This way, they can be queried easier.
289
+ * 3 General Enhancements
254
290
 
255
- The test can now be run through the test/all.rb-script. In fact, this is the
256
- standard way and internally used by `rake test`. The Manpages are now in the
257
- right location for setup.rb and RDocs now include the LICENSE and this
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.
@@ -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.parse!
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
@@ -25,11 +25,15 @@ module ToPass
25
25
  def all
26
26
  {
27
27
  :user => "~/.#{APP_NAME}",
28
- :data => "#{RbConfig::CONFIG['data-dir']}/#{APP_NAME}",
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
@@ -3,7 +3,7 @@
3
3
  unless defined?(ToPass::VERSION)
4
4
  module ToPass
5
5
  # version of gem
6
- VERSION = '0.7.0'
6
+ VERSION = '0.8.0'
7
7
 
8
8
  # name of gem
9
9
  APP_NAME = 'to_pass'
@@ -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
- '~/.to_pass' , # user
44
- "#{RbConfig::CONFIG['data-dir']}/#{ToPass::APP_NAME}", # installed
45
- "#{File.dirname(__FILE__)}/../data/#{ToPass::APP_NAME}", # source [in github]
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?).times(dirs.size).returns(true)
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
- assert( reader.load_path.include?(dir), "#{reader.load_path.inspect} should include #{dir.inspect}" )
36
+ assert_include dir, reader.load_path
37
37
  end
38
38
  end
39
39
 
@@ -17,7 +17,11 @@ class TestBase < Test::Unit::TestCase
17
17
  end
18
18
 
19
19
  def test_date
20
- assert_equal Pathname.new("#{File.dirname(__FILE__)}/../lib/to_pass/version.rb").expand_path.mtime, ToPass::DATE
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
- assert_nothing_raised do
29
- assert eval(Pathname.new("#{File.dirname(__FILE__)}/../to_pass.gemspec").expand_path.read).validate
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 "#{RbConfig::CONFIG['data-dir']}/#{ToPass::APP_NAME}", dirs[:data]
41
- assert_equal Pathname.new("#{File.dirname(__FILE__)}/../").expand_path.to_s, dirs[:base]
42
- assert_equal Pathname.new("#{File.dirname(__FILE__)}/../data/#{ToPass::APP_NAME}").expand_path.to_s, dirs[:source_data]
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
@@ -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", `bin/to_pass test`.chomp
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", `bin/password_of test`.chomp
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", `bin/to_pass 'there is one problem for us, too' -a basic_en`.chomp
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" | bin/to_pass`
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" | bin/to_pass --no-pipe`.chomp
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', `bin/to_pass test --pipe`
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", `bin/to_pass 'leasbpc' -a user_alg`.chomp
48
- assert_equal "le1/2%z", `bin/to_pass 'luke eats all sausagages because peter cries' -a user_alg`.chomp
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' | bin/to_pass -a user_alg`.chomp
55
- assert_equal "le1/2%z", `echo 'luke eats all sausagages because peter cries' | bin/to_pass -a user_alg`.chomp
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?).times(dirs.size).returns(true)
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
- assert( reader.load_path.include?(dir), "#{reader.load_path.inspect} should include #{dir.inspect}" )
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: 3
4
+ hash: 63
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 7
8
+ - 8
9
9
  - 0
10
- version: 0.7.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-10-13 00:00:00 +02:00
18
+ date: 2010-12-15 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency