Skip to content

Commit

Permalink
Added functions to check if specific routes exist
Browse files Browse the repository at this point in the history
  • Loading branch information
EtoileFilante committed Mar 23, 2016
1 parent 283fcfd commit 3f18b7f
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/Yodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Yodel

using LightXML # LightXML is required to parse the XML file

export YodelEngine,Route,getRoute,getRouteWithController
export YodelEngine,Route,getRoute,getRouteWithController,isRoute,isRouteWithController

type YodelEngine
routes::Array # Routes of Yodel Object
Expand Down Expand Up @@ -42,7 +42,7 @@ end
function separateAttributes(attributesString) # Parses the variable attribute of the Route XML element to an array
attributesString = string(attributesString)
attributes = []

attributesMatches = eachmatch(r",",attributesString)
lastIndex = 0

Expand All @@ -55,29 +55,49 @@ function separateAttributes(attributesString) # Parses the variable attribute of
return attributes
end

# Returns whether a function has a route for a specific URL or not
function isRoute(ydl::YodelEngine,url::ASCIIString)
for route in ydl.routes
if ismatch(Regex(route.url),url)
return true
end
end
return false
end

# Get a route that matches URL
function getRoute(ydl::YodelEngine,url::ASCIIString)
for route in ydl.routes
if ismatch(Regex(route.url),url)
return route
end
end
return ""
return Route("/",[],"Default")
end

# Get a route with a given controller
function isRouteWithController(ydl::YodelEngine,controller::ASCIIString)
for route in ydl.routes
if controller == route.controller
return true
end
end
return false
end
# Get a route with a given controller
function getRouteWithController(ydl::YodelEngine,controller::ASCIIString)
for route in ydl.routes
if controller == route.controller
return route
end
end
return ""
return Route("/",[],"Default")
end

# Extract variable from the url of a given route
function getVariable(url::ASCIIString,route::Route,variable::ASCIIString)
#TODO
end


end # end of Yodel Module

0 comments on commit 3f18b7f

Please sign in to comment.