Sha256: bb36089ab19b2af017877afc86dc709c24d5d1dbc1c65a9e7e0f07af00816421

Contents?: true

Size: 984 Bytes

Versions: 5

Compression:

Stored size: 984 Bytes

Contents

# frozen_string_literal: true
require "rails"
require "rails/railtie"
require "serviceworker"

module ServiceWorker
  class Engine < ::Rails::Engine
    config.serviceworker = ActiveSupport::OrderedOptions.new
    config.serviceworker.headers = {}
    config.serviceworker.routes = ServiceWorker::Router.new
    config.serviceworker.handler = ServiceWorker::Rails::Handler.new
    config.serviceworker.icon_sizes = %w[36 48 60 72 76 96 120 152 180 192 512]

    initializer "serviceworker-rails.configure_rails_initialization", after: :load_config_initializers do
      config.serviceworker.logger ||= ::Rails.logger

      if config.respond_to?(:assets)
        config.assets.precompile += %w[serviceworker-rails/*.png]
      elsif app.config.respond_to?(:assets)
        app.config.assets.precompile += %w[serviceworker-rails/*.png]
      end

      app.middleware.use ServiceWorker::Middleware, config.serviceworker
    end

    def app
      ::Rails.application
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
serviceworker-rails-0.5.5 lib/serviceworker/engine.rb
serviceworker-rails-0.5.4 lib/serviceworker/engine.rb
serviceworker-rails-0.5.3 lib/serviceworker/engine.rb
serviceworker-rails-0.5.2 lib/serviceworker/engine.rb
serviceworker-rails-0.5.1 lib/serviceworker/engine.rb