Class: Rails::Railtie::Configuration
- Inherits:
-
Object
- Object
- Rails::Railtie::Configuration
- Defined in:
- lib/compass-rails4/railtie.rb
Instance Method Summary collapse
-
#compass ⇒ Object
Adds compass configuration accessor to the application configuration.
Instance Method Details
#compass ⇒ Object
Adds compass configuration accessor to the application configuration.
If a configuration file for compass exists, it will be read in and the project’s configuration values will already be set on the config object.
For example:
module MyApp
class Application < Rails::Application
config.compass.line_comments = !Rails.env.production?
config.compass.fonts_dir = "app/assets/fonts"
end
end
It is suggested that you create a compass configuration file if you want a quicker boot time when using the compass command line tool.
For more information on available configuration options see: compass-style.org/help/tutorials/configuration-reference/
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/compass-rails4/railtie.rb', line 27 def compass @compass ||= begin data = if (config_file = Compass.detect_configuration_file) && (config_data = Compass.configuration_for(config_file)) config_data else Compass::Configuration::Data.new("rails_config") end data.project_type = :rails # Forcing this makes sure all the rails defaults will be loaded. data.on_sprite_saved do |filename| if CompassRails4.rails_config.assets.digest && # if digesting is enabled caller.grep(%r{/sprockets/rails/task.rb}).any? && #OMG HAX - check if we're being precompiled Compass.configuration.generated_images_path[Compass.configuration.images_path.to_s] # if the generated images path is not in the assets images directory, we don't have to do these backflips # Clear entries in Hike::Index for this sprite's directory. # This makes sure the asset can be found by find_assets CompassRails4.sprockets.send(:trail).index.instance_variable_get(:@entries).delete(File.dirname(filename)) pathname = Pathname.new(filename) logical_path = pathname.relative_path_from(Pathname.new(Compass.configuration.images_path)) asset = CompassRails4.sprockets.find_asset(logical_path) target = File.join(Rails.public_path, CompassRails4.prefix, asset.digest_path) # Adds the asset to the manifest file. manifest = ActionView::Base.assets_manifest manifest.assets[logical_path.to_s] = asset.digest_path # Adds the fingerprinted asset to the public directory FileUtils.mkdir_p File.dirname(target) logger = CompassRails4.sprockets.logger logger.info("Writing #{target}") if logger asset.write_to target end end Compass.add_configuration(:rails) Compass.add_configuration(data) data end @compass end |