baptist 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -43,7 +43,7 @@ Options
43
43
 
44
44
  * <code>:space</code> - Space character (default: '-')
45
45
  * <code>:separator</code> - Separator character (default: '/')
46
- * <code>:modifier</code> - Will add a modifier string in paranteses at the end of the generated URI
46
+ * <code>:modifier</code> - Will add a modifier string in parentheses at the end of the generated URI
47
47
  * <code>:multiplier</code> - The object to multiply with to find a unique URI (default: 1)
48
48
  * <code>:encoding</code> - Force this encoding (default: 'UTF-8')
49
49
 
@@ -1,3 +1,3 @@
1
1
  module Baptist
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
data/lib/baptist.rb CHANGED
@@ -40,7 +40,7 @@ module Baptist
40
40
  #
41
41
  # :space - Space character (default: '-')
42
42
  # :separator - Separator character (default: '/')
43
- # :modifier - Will add a modifier string in paranteses at the end of the generated URI
43
+ # :modifier - Will add a modifier string in parentheses at the end of the generated URI
44
44
  # :multiplier - The object to multiply with to find a unique URI (default: 1)
45
45
  # :encoding - Force this encoding (default: 'UTF-8')
46
46
  #
@@ -60,6 +60,7 @@ module Baptist
60
60
  (options[:modifier] ? "#{options[:space]}(#{escape(options[:modifier], options)})" : '')
61
61
 
62
62
  if block_given?
63
+ return uri if yield(uri)
63
64
  (1..100).each do |i|
64
65
  s = uri + options[:space] + (options[:multiplier] * i).to_s
65
66
  if yield(s)
data/test/baptist_test.rb CHANGED
@@ -26,6 +26,7 @@ class BaptistTest < Test::Unit::TestCase
26
26
  end
27
27
 
28
28
  def test_unique
29
+ assert_equal 'John-Doe', Baptist.generate('John Doe') {|uri| true }
29
30
  assert_equal 'John-Doe-3', Baptist.generate('John Doe') {|uri| uri == 'John-Doe-3' }
30
31
  assert_equal 'John-Doe-1000', Baptist.generate('John Doe', :multiplier => 10) {|uri| uri == 'John-Doe-1000' }
31
32
  assert_equal 'John-Doe-***', Baptist.generate('John Doe', :multiplier => '*') {|uri| uri == 'John-Doe-***' }
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: baptist
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.1.0
5
+ version: 1.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Niklas Holmgren
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-12-16 00:00:00 Z
13
+ date: 2012-01-25 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description: Baptist creates well-formed relative URIs from a set of strings.