to_pass 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -19,8 +19,8 @@ class ToPass::AlgorithmReader
19
19
  '~/.to_pass/algorithms',
20
20
  "#{File.dirname(__FILE__)}/../algorithms"
21
21
  ].each do |dir|
22
- dir = Pathname.new(dir)
23
- @load_path << dir.expand_path if dir.exist?
22
+ dir = Pathname.new(dir).expand_path
23
+ @load_path << dir if dir.exist?
24
24
  end
25
25
  end
26
26
 
@@ -38,10 +38,12 @@ class ToPass::AlgorithmReader
38
38
  if file.exist?
39
39
  file
40
40
  else
41
- nil
41
+ next
42
42
  end
43
43
  end.compact.first
44
44
 
45
+ raise LoadError, "algorithm #{@algorithm} could not be found in #{load_path}" if fn.nil?
46
+
45
47
  YAML.load_file(fn.expand_path)
46
48
  end
47
49
  end
@@ -0,0 +1,18 @@
1
+ desc: Test Algorithm
2
+ name: Test
3
+ sentence:
4
+ - first_chars
5
+ - table: chars
6
+ - table: symbols
7
+ - collapse_chars
8
+ word:
9
+ - table: chars
10
+ - table: symbols
11
+ tables:
12
+ symbols:
13
+ p: '%'
14
+ s: '/'
15
+ chars:
16
+ a: 1
17
+ b: 2
18
+ c: z
data/test/helper.rb CHANGED
@@ -21,6 +21,13 @@ Test::Unit::TestCase.class_eval do
21
21
  assert_class_defined klass
22
22
  end
23
23
  end
24
+
25
+
26
+ def with_algorithm_in_user_dir
27
+ `mkdir -p ~/to_pass/algorithms; cp -f #{File.dirname(__FILE__)}/fixtures/user_alg.yml ~/.to_pass/algorithms/user_alg.yml`
28
+ yield
29
+ `rm ~/.to_pass/algorithms/user_alg.yml`
30
+ end
24
31
  end
25
32
 
26
33
  require 'lib/to_pass'
@@ -33,6 +33,12 @@ class TestAlgorithmReader < Test::Unit::TestCase
33
33
  end
34
34
  end
35
35
 
36
+ def test_loads_from_user_dir
37
+ with_algorithm_in_user_dir do
38
+ assert_kind_of Hash, klass.load(:user_alg)
39
+ end
40
+ end
41
+
36
42
  protected
37
43
 
38
44
  def klass
@@ -27,4 +27,11 @@ class TestIntegration < Test::Unit::TestCase
27
27
  assert_equal 't35t', str.to_pass
28
28
  end
29
29
  end
30
+
31
+ def test_cli_usage_with_user_algorithm
32
+ with_algorithm_in_user_dir do
33
+ assert_equal "le1/2%z", `bin/to_pass 'leasbpc' -a user_alg`.chomp
34
+ assert_equal "le1/2%z", `bin/to_pass 'luke eats all sausagages because peter cries' -a user_alg`.chomp
35
+ end
36
+ end
30
37
  end
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: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
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-06-13 00:00:00 +02:00
18
+ date: 2010-06-14 00:00:00 +02:00
19
19
  default_executable: to_pass
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -74,6 +74,7 @@ files:
74
74
  - lib/to_pass/converter.rb
75
75
  - lib/to_pass/integration.rb
76
76
  - lib/to_pass/string_conversions.rb
77
+ - test/fixtures/user_alg.yml
77
78
  - test/helper.rb
78
79
  - test/test_algorithm_reader.rb
79
80
  - test/test_base.rb