Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

String#parameterize should accept a custom separator

#1111

This tiny patch allows String#parameterize to receive an argument as ActiveSupport::Inflector.parameterize does.

Also added tests for String#parameterize as they were missing.

Reported by Miha Filej · September 25th, 2008 @ 03:46 PM

State: duplicate
Milestone: 2.x
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Yaroslav Markin
    Yaroslav Markin
    • Assigned user set to Pratik

    I believe this is already done, can we close?

    
    activesupport/lib/active_support/inflector.rb
    259:    def parameterize(string, sep = '-')
    

    December 25th, 2008 @ 09:12 PM

  2. Frederick Cheung
    Frederick Cheung

    I don't think that's the point - The point is that String#parameterize doesn't allow you to specify the separator argument that is passed to Inflector.parameterize

    December 25th, 2008 @ 09:50 PM

  3. Miha Filej
    Miha Filej

    Yaroslav, the code you cited refers to activesupport/lib/active_support/inflector.rb which is not affected by the patch.

    The purpose of this ticket is to allow

    
    some_string.parameterize("_")
    # instead of
    "La, la, la!".parameterize.dasherize
    # or
    ActiveSupport::Inflector.parameterize "La, la, la!", "_"
    

    Would anyone consider applying if I rebase the patch against master?

    December 25th, 2008 @ 09:52 PM

  4. Miha Filej
    Miha Filej

    "dasherize" should be "underscore". And also Frederick was quicker than me :)

    December 25th, 2008 @ 09:55 PM

  5. Pratik
    Pratik

    I don't think the tests for this need to use mocking/stubbing.

    Thanks.

    December 25th, 2008 @ 09:58 PM

  6. Miha Filej
    Miha Filej

    So should I just test for some output? Because this is kinda already done in InflectorTest#test_parameterize.

    December 25th, 2008 @ 10:07 PM

  7. Pratik
    Pratik

    So should I just test for some output

    Yes please :)

    December 25th, 2008 @ 10:08 PM

  8. Miha Filej
  9. Sam Granieri
    Sam Granieri

    I also made a fix for this problem... probably should not have duplicated efforts

    http://rails.lighthouseapp.com/p...

    March 6th, 2009 @ 08:36 PM

  10. Cheah Chu Yeow
    Cheah Chu Yeow
    • Tag changed from activesupport, core_ext, patch, tests, tiny to activesupport, core_ext, duplicate, patch, tests, tiny

    Since Sam's patch from http://rails.lighthouseapp.com/p... has been committed, I guess we should close this ticket.

    May 12th, 2009 @ 06:11 PM

  11. Pratik
    Pratik
    • State changed from new to duplicate

    May 12th, 2009 @ 06:12 PM