Sha256: 4c7701079d08ab70c1518f1ea9e7860693a74db22d0ec098cfaada24a4b69a5b

Contents?: true

Size: 729 Bytes

Versions: 4

Compression:

Stored size: 729 Bytes

Contents

namespace :rodauth do
  task routes: :environment do
    app = Rodauth::Rails.app

    puts "Routes handled by #{app}:"

    app.opts[:rodauths].each_key do |rodauth_name|
      rodauth = Rodauth::Rails.rodauth(rodauth_name)

      routes = rodauth.class.routes.map do |handle_method|
        path_method = "#{handle_method.to_s.sub(/\Ahandle_/, "")}_path"

        [
          rodauth.public_send(path_method),
          "rodauth#{rodauth_name && "(:#{rodauth_name})"}.#{path_method}",
        ]
      end

      padding = routes.map { |path, _| path.length }.max

      route_lines = routes.map do |path, code|
        "#{path.ljust(padding)}  #{code}"
      end

      puts "\n  #{route_lines.join("\n  ")}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rodauth-rails-0.8.0 lib/rodauth/rails/tasks.rake
rodauth-rails-0.7.0 lib/rodauth/rails/tasks.rake
rodauth-rails-0.6.1 lib/rodauth/rails/tasks.rake
rodauth-rails-0.6.0 lib/rodauth/rails/tasks.rake