Module: I18n::JS::Dependencies

Defined in:
lib/i18n/js/dependencies.rb

Overview

When using ‘safe_gem_check` to check for a pre-release version of gem, we need to specify pre-release version suffix in version constraint

Class Method Summary collapse

Class Method Details

.rails?Boolean



7
8
9
# File 'lib/i18n/js/dependencies.rb', line 7

def rails?
  defined?(Rails) && Rails.respond_to?(:version)
end

.sprockets_rails_v2_plus?Boolean



11
12
13
# File 'lib/i18n/js/dependencies.rb', line 11

def sprockets_rails_v2_plus?
  safe_gem_check("sprockets-rails", ">= 2")
end

.using_asset_pipeline?Boolean

This cannot be called at class definition time Since not all libraries are loaded

Call this in an initializer



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/i18n/js/dependencies.rb', line 19

def using_asset_pipeline?
  assets_pipeline_available =
    (rails3? || rails4? || rails5?) &&
    Rails.respond_to?(:application) &&
    Rails.application.config.respond_to?(:assets)
  rails3_assets_enabled =
    rails3? &&
    assets_pipeline_available &&
    Rails.application.config.assets.enabled != false

  assets_pipeline_available && (rails4? || rails5? || rails3_assets_enabled)
end