Sha256: 869e0db0674d2e67414e75b872afc3b81bf719987e2ab5abe5a9b8e09e0fd781

Contents?: true

Size: 783 Bytes

Versions: 1

Compression:

Stored size: 783 Bytes

Contents

class Ld::Routes

  attr_accessor :headings, :rows

  def initialize root
    @root = root
    parse
  end
  
  def parse
    system "rake routes > #{@root.path}/routes.txt"
    rows = @root.find('routes.txt').lines.map{|line|
      arr = line.split(' ')
      arr.unshift(nil) if arr.size == 3
      arr
    }
               .delete_if{|arr| arr.size >= 5 or arr.size <= 2  }
               .map{|row|
      controller, action = row[3].split('#')
      type        = row[1]
      help_method = row[0]
      uri         = row[2]
      #
      [controller, action, type, uri, help_method]
    }
    File.delete("#{@root.path}/routes.txt") if File.exist? "#{@root.path}/routes.txt"
    @headings = ['控制器', 'action', '请求类型','URI','帮助方法']
    @rows = rows
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ld-0.2.6 lib/ld/project/routes.rb