Created
March 7, 2011 02:22
-
-
Save agenteo/857975 to your computer and use it in GitHub Desktop.
Collects the first level of routes from a file containing the 'rake routes' output.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
# Deletes standard route, standard route :format, root route | |
def delete_last_three_lines | |
3.times { @lines.delete_at(-1) } # TODO: change to .drop(3) when using Ruby 1.8.7 | |
end | |
@paths = [] | |
@lines = File.readlines('routes.txt') | |
@lines.delete_at(0) | |
delete_last_three_lines | |
@lines.each do |line| | |
line.match(/\s+\w+\s+\/([^\s][^\(](?:\w|-)*(?:\....)?)/) # match any word or - after /, terminates with { | |
@paths << $1 | |
end | |
@paths.uniq! | |
puts @paths |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment