Module: JasmineRails::OfflineAssetPaths
- Defined in:
- lib/jasmine_rails/offline_asset_paths.rb
Instance Method Summary collapse
- #compute_asset_path(source, options = {}) ⇒ Object
-
#compute_public_path(source, dir, options = {}) ⇒ Object
For Rails 3.2 support.
Instance Method Details
#compute_asset_path(source, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/jasmine_rails/offline_asset_paths.rb', line 9 def compute_asset_path(source, ={}) return super if JasmineRails::OfflineAssetPaths.disabled source = source.to_s return source if source.empty? || source.starts_with?('/') content = Rails.application.assets[source].to_s asset_prefix = Rails.configuration.assets.prefix.gsub(/\A\//,'') source_path = JasmineRails.tmp_dir.join(asset_prefix).join(source) FileUtils.mkdir_p File.dirname(source_path) Rails.logger.debug "Compiling #{source} to #{source_path}" File.open(source_path, 'wb') do |f| if Rails::VERSION::MAJOR >= 4 && !Rails.env.test? && source == 'jasmine-specs.js' f << '' else f << content end end "/#{asset_prefix}/#{source}" end |
#compute_public_path(source, dir, options = {}) ⇒ Object
For Rails 3.2 support
30 31 32 |
# File 'lib/jasmine_rails/offline_asset_paths.rb', line 30 def compute_public_path(source, dir, ={}) JasmineRails::OfflineAssetPaths.disabled ? super : compute_asset_path(source, ) end |