baptist 1.1.0 → 1.1.1
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/README.md +1 -1
- data/lib/baptist/version.rb +1 -1
- data/lib/baptist.rb +2 -1
- data/test/baptist_test.rb +1 -0
- metadata +2 -2
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
|
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
|
|
data/lib/baptist/version.rb
CHANGED
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
|
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.
|
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:
|
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.
|