public
Fork of caring/acts_as_url_param
Description: Pretty url support for Ruby on Rails applications
Homepage: http://www.caring.com
Clone URL: git://github.com/joshuabates/acts_as_url_param.git
Search Repo:
Changed the default starting point for endings to 2 instead of 1.
This makes more sense because the first one is already taken.
Chris Eppstein (author)
Tue Mar 25 08:02:53 -0700 2008
commit  f57fc17722bbc9a358a710ebde9fcfa1e69119d8
tree    5a959de3329ca712e34e95a0fa399458faf21b8a
parent  d6c53692da2d7aaa70cad14ea23f8e5d5f96ded3
...
54
55
56
57
 
58
59
60
 
61
62
63
...
54
55
56
 
57
58
59
 
60
61
62
63
0
@@ -54,10 +54,10 @@
0
       # Options:
0
       # => :separator => "-", a string that will be injected between the base string and the uniqifier
0
       # => :endings => generator, a Generator that provides endings to be placed at the end of the base.
0
- # defaults to the set of positive integers.
0
+ # defaults to the set of positive integers starting with two.
0
       def uniquify(base, options = {})
0
         sep = options.fetch(:separator, "-")
0
- endings = options[:endings] || int_generator
0
+ endings = options[:endings] || int_generator(:start => 2)
0
         return base if yield base
0
         while endings.next? do
0
           candidate = base+sep+endings.next.to_s
...
15
16
17
18
 
19
20
 
21
22
23
...
15
16
17
 
18
19
 
20
21
22
23
0
@@ -15,9 +15,9 @@
0
   def test_uniquify
0
     assert_equal "asdf", uniquify("asdf") { |candidate| true }
0
     i = 0
0
- assert_equal "asdf-1", uniquify("asdf") { |candidate| (i = i+1) == 2 }
0
+ assert_equal "asdf-2", uniquify("asdf") { |candidate| (i = i+1) == 2 }
0
     i = 0
0
- assert_equal "asdf-2", uniquify("asdf") { |candidate| (i = i+1) == 3 }
0
+ assert_equal "asdf-3", uniquify("asdf") { |candidate| (i = i+1) == 3 }
0
     assert_raises ArgumentError do
0
       uniquify("asdf", :endings => Generator.new(%w(a b c))) {|c| false}
0
     end

Comments

    No one has commented yet.