Class: Requirejs::Config
- Inherits:
-
ActiveSupport::OrderedOptions
- Object
- ActiveSupport::OrderedOptions
- Requirejs::Config
- Defined in:
- lib/requirejs/config.rb
Instance Method Summary collapse
- #almond? ⇒ Boolean
- #cache_assets_location ⇒ Object
- #cache_build_scripts_location ⇒ Object
- #cache_builds_location ⇒ Object
- #check_cache_location ⇒ Object
- #cleanup_cache_dir ⇒ Object
- #digest? ⇒ Boolean
- #ensure_cache_location_exists ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #optimize? ⇒ Boolean
- #setup_directories ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
3 4 5 6 7 8 9 10 11 12 13 14 |
# 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 |
Instance Method Details
#almond? ⇒ Boolean
50 51 52 |
# File 'lib/requirejs/config.rb', line 50 def almond? self.loader == :almond end |
#cache_assets_location ⇒ Object
16 17 18 19 |
# 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 ⇒ Object
21 22 23 24 |
# 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 ⇒ Object
26 27 28 29 |
# 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 ⇒ Object
31 32 33 |
# 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 ⇒ Object
46 47 48 |
# File 'lib/requirejs/config.rb', line 46 def cleanup_cache_dir FileUtils.remove_entry_secure(self.cache_location) rescue nil end |
#digest? ⇒ Boolean
58 59 60 |
# File 'lib/requirejs/config.rb', line 58 def digest? self.digest end |
#ensure_cache_location_exists ⇒ Object
40 41 42 43 44 |
# 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? ⇒ Boolean
54 55 56 |
# File 'lib/requirejs/config.rb', line 54 def optimize? almond? || self.optimize end |
#setup_directories ⇒ Object
35 36 37 38 |
# File 'lib/requirejs/config.rb', line 35 def setup_directories cleanup_cache_dir ensure_cache_location_exists end |