Sha256: 195f2fa37d0a4628b8ca51bc60733a0da15e8a9b53c4c4c1016805b8ae5c6baf

Contents?: true

Size: 771 Bytes

Versions: 4

Compression:

Stored size: 771 Bytes

Contents

# frozen_string_literal: true

require "rails/railtie"

# NOTE: Not strictly required, but it helps to simplify the setup.
class JsFromRoutes::Railtie < Rails::Railtie
  railtie_name :js_from_routes

  if Rails.env.development?
    # Allows to automatically trigger code generation after updating routes.
    initializer "js_from_routes.reloader" do |app|
      app.config.to_prepare do
        JsFromRoutes.generate!(app)
      end
    end
  end

  # Suitable when triggering code generation manually.
  rake_tasks do |app|
    namespace :js_from_routes do
      desc "Generates JavaScript files from Rails routes, one file per controller, and one function per route."
      task generate: :environment do
        JsFromRoutes.generate!(app)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
js_from_routes-2.0.4 lib/js_from_routes/railtie.rb
js_from_routes-2.0.3 lib/js_from_routes/railtie.rb
js_from_routes-2.0.2 lib/js_from_routes/railtie.rb
js_from_routes-2.0.1 lib/js_from_routes/railtie.rb