Sha256: 76afd316132a08c555c02bc5d46da7574510c1cf7ff5a0908c5f546915675eda

Contents?: true

Size: 786 Bytes

Versions: 6

Compression:

Stored size: 786 Bytes

Contents

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

    puts "Routes handled by #{app}:"

    app.opts[:rodauths].each do |configuration_name, auth_class|
      auth_class.configure { enable :path_class_methods }

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

        [
          auth_class.public_send(path_method),
          "rodauth#{configuration_name && "(:#{configuration_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  ")}" unless route_lines.empty?
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rodauth-rails-0.18.1 lib/rodauth/rails/tasks.rake
rodauth-rails-0.18.0 lib/rodauth/rails/tasks.rake
rodauth-rails-0.17.1 lib/rodauth/rails/tasks.rake
rodauth-rails-0.17.0 lib/rodauth/rails/tasks.rake
rodauth-rails-0.16.0 lib/rodauth/rails/tasks.rake
rodauth-rails-0.15.0 lib/rodauth/rails/tasks.rake