Sha256: 0fcefe9f9c5b256c546e23016932821ffc5114d97bf8267c7b8092ffca9a0fb1

Contents?: true

Size: 1020 Bytes

Versions: 6

Compression:

Stored size: 1020 Bytes

Contents

module Swaggard
  class Engine < ::Rails::Engine
    isolate_namespace Swaggard

    def rake?
      File.basename($PROGRAM_NAME) == 'rake'
    end

    initializer 'swaggard.finisher_hook', after: :finisher_hook do |app|
      app.reload_routes!

      if Rails.env.development? && !rake? && !app.methods.include?(:assets_manifest)
        warn <<~END
        [Swaggard] It seems you are using an api only rails setup, but swaggard
        [Swaggard] web app needs sprockets in order to work. Make sure to add
        [Swaggard] require 'sprockets/railtie'.
        [Swaggard] If you plan to use it
        END
      end

      Swaggard.configure do |config|
        unless config.controllers_path
          config.controllers_path = "#{app.root}/app/controllers/**/*.rb"
        end

        unless config.models_paths
          config.models_paths = ["#{app.root}/app/serializers/**/*.rb"]
        end

        config.routes = app.routes.routes
      end

      Swaggard.register_custom_yard_tags!
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
swaggard-1.5.1 lib/swaggard/engine.rb
swaggard-1.5.0 lib/swaggard/engine.rb
swaggard-1.4.0 lib/swaggard/engine.rb
swaggard-1.3.0 lib/swaggard/engine.rb
swaggard-1.2.0 lib/swaggard/engine.rb
swaggard-1.1.1 lib/swaggard/engine.rb