Class: Droutes::Parser
- Inherits:
-
Object
- Object
- Droutes::Parser
- Defined in:
- lib/droutes/parser.rb
Instance Attribute Summary collapse
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
Instance Method Summary collapse
-
#initialize(routes) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(routes) ⇒ Parser
Returns a new instance of Parser.
40 41 42 43 44 45 46 47 |
# File 'lib/droutes/parser.rb', line 40 def initialize(routes) @routes = ::Hash.new {|h,k| h[k] = {}} routes.each do |route| wrap = ActionDispatch::Routing::RouteWrapper.new(route) next if wrap.internal? @routes[wrap.controller][wrap.action] = wrap end end |
Instance Attribute Details
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
38 39 40 |
# File 'lib/droutes/parser.rb', line 38 def routes @routes end |
Instance Method Details
#parse ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/droutes/parser.rb', line 49 def parse files = Dir["#{Rails.application.root}/app/controllers/**/*.rb"] root = ClassStruct.new(nil) files.each do |file| parser = YARD::Parser::SourceParser.new.parse(file) handle(parser.enumerator, root) end root end |