Sha256: c4f81e375bdf0f4db10753c4add1841581417dbb35ee3bbb902a83e709eb78cb

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

require 'npmdc/core/string_strip_heredoc'

module Npmdc
  class Railtie < Rails::Railtie # :nodoc:
    using StringStripHeredoc

    # Make config accessible through application config
    config.npmdc = Npmdc.config

    initializer "npmdc.initialize" do
      Npmdc.config.path = Rails.root unless Npmdc.config.path?
    end

    initializer "npmdc.environment_check" do
      unless config.npmdc.environments.include?(Rails.env)
        abort <<-END.strip_heredoc
          Npmdc is trying to be activated in the #{Rails.env} environment.
          Probably, this is a mistake. To ensure it's only activated in development
          mode, move it to the development group of your Gemfile:
              gem 'npmdc', group: :development
          If you still want to run it in the #{Rails.env} environment (and know
          what you are doing), put this in your Rails application
          configuration:
              config.npmdc.environments = ['development', '#{Rails.env}']
        END
      end
    end

    initializer "npmdc.call" do
      Npmdc.call
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
npmdc-0.5.0 lib/npmdc/railtie.rb
npmdc-0.4.1 lib/npmdc/railtie.rb
npmdc-0.4.0 lib/npmdc/railtie.rb
npmdc-0.3.2 lib/npmdc/railtie.rb