class RailsExportRoutes::CLI
Public Class Methods
exit_on_failure?()
click to toggle source
# File lib/rails_export_routes/cli.rb, line 7 def self.exit_on_failure? true # Thor must exit with status 1 on errors end
Public Instance Methods
export(file)
click to toggle source
# File lib/rails_export_routes/cli.rb, line 15 def export(file) load_rails_app(Dir.pwd) formatter = case options.fetch(:format) when 'csv' then Formatters::CSV when 'json' then Formatters::JSON when 'json-pretty' then Formatters::JSONPretty end formatter.new(wrapped_rails_routes).export_to_file(file) end
load_rails_app(app_path)
click to toggle source
# File lib/rails_export_routes/cli.rb, line 28 def load_rails_app(app_path) require "#{app_path}/config/environment.rb" rescue ::LoadError raise Error, "Rails app not found in #{app_path}" end
wrapped_rails_routes()
click to toggle source
# File lib/rails_export_routes/cli.rb, line 34 def wrapped_rails_routes Rails.application.routes.routes.reject(&:internal).map do |route| RouteWrapper.new(route) end end