class Requirejs::Config

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/requirejs/config.rb, line 3
def initialize
  super

  self.gem_root_path = Gem::Specification.find_by_name('ruby-requirejs').gem_dir
  self.runtime_location = File.join(gem_root_path, 'lib', 'requirejs', 'runtime', 'r.js')
  self.cache_location = nil
  self.js_compressor = :none # :uglify

  self.loader = :requirejs # :almond
  self.optimize = false # :almond
  self.digest = false # :almond
end

Public Instance Methods

almond?() click to toggle source
# File lib/requirejs/config.rb, line 50
def almond?
  self.loader == :almond
end
cache_assets_location() click to toggle source
# File lib/requirejs/config.rb, line 16
def cache_assets_location
  check_cache_location
  @cache_assets_location ||= File.join(cache_location, 'assets')
end
cache_build_scripts_location() click to toggle source
# File lib/requirejs/config.rb, line 21
def cache_build_scripts_location
  check_cache_location
  @cache_build_scripts_location ||= File.join(cache_location, 'build_scripts')
end
cache_builds_location() click to toggle source
# File lib/requirejs/config.rb, line 26
def cache_builds_location
  check_cache_location
  @cache_builds_location ||= File.join(cache_location, 'builds')
end
check_cache_location() click to toggle source
# File lib/requirejs/config.rb, line 31
def check_cache_location
  raise 'cache location is not set. Set cache_location. Ex.: Require.config.cache_location  = File.dirname(__FILE__)' if cache_location.blank?
end
cleanup_cache_dir() click to toggle source
# File lib/requirejs/config.rb, line 46
def cleanup_cache_dir
  FileUtils.remove_entry_secure(self.cache_location) rescue nil
end
digest?() click to toggle source
# File lib/requirejs/config.rb, line 58
def digest?
  self.digest
end
ensure_cache_location_exists() click to toggle source
# File lib/requirejs/config.rb, line 40
def ensure_cache_location_exists
  [cache_location, cache_assets_location, cache_build_scripts_location, cache_builds_location].each do |path|
    Pathname.new(path).mkpath
  end
end
optimize?() click to toggle source
# File lib/requirejs/config.rb, line 54
def optimize?
  almond? || self.optimize
end
setup_directories() click to toggle source
# File lib/requirejs/config.rb, line 35
def setup_directories
  cleanup_cache_dir
  ensure_cache_location_exists
end