Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

new toString methods return the original definitions

  • Loading branch information...
commit 0a138d64b5069bddc4e4afc518cd0dedb4851a80 1 parent 2c0b85d
@kieran authored
Showing with 14 additions and 16 deletions.
  1. +8 −2 lib/key.coffee
  2. +5 −13 lib/route.coffee
  3. +1 −1  lib/text.coffee
View
10 lib/key.coffee
@@ -73,10 +73,10 @@ class Key
# key.toString()
# --------------
- # returns a unique id that can be compared to other parts
+ # returns the original key definition
#
toString: ->
- "key-#{@name}"
+ ":#{@name}"
# new Glob( name, optional )
@@ -96,3 +96,9 @@ class Glob extends Key
if @name == 'controller' || @name == 'action'
@regex = /[a-zA-Z_][\w\-]*/
+ # glob.toString()
+ # ---------------
+ # returns the original glob definition
+ #
+ toString: ->
+ "*#{@name}"
View
18 lib/route.coffee
@@ -408,19 +408,11 @@ class Route
toString: ->
-
- # right-pads strings
- rpad = (str,len)->
- ret = new Array len+1 # +1 for fenceposting
- ret.splice 0, str.length, str
- ret.join ' '
-
- [
- rpad( @method || 'ALL',8 ),
- rpad( @path, 50 ),
- [ @params.controller, @params.action ].join('.')
- ].join ''
-
+ defn = @parts.reduce (m='',part)-> m+part.toString()
+ if @optional
+ "(#{ defn })"
+ else
+ defn
# Helper methods
View
2  lib/text.coffee
@@ -43,7 +43,7 @@ class Text
# returns a unique id that can be compared to other parts
#
toString: ->
- "text-#{@text}"
+ @text
regExpEscape = do ->
specials = [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\' ]
Please sign in to comment.
Something went wrong with that request. Please try again.