Class: Doohickey::Initializer

Inherits:
Object
  • Object
show all
Defined in:
lib/doohickey.rb

Overview

Define the Doohickey initializer

Class Method Summary collapse

Class Method Details

.initializeObject



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
# File 'lib/doohickey.rb', line 31

def self.initialize

  # Global Sass settings
  # -----------------------------------------------------------------------------
  template_locations = {}
  template_locations["#{rails_root}/app/stylesheets"] = Sass::Plugin.options[:css_location]
  template_locations[File.join(File.dirname(__FILE__), *%w[.. app stylesheets])] = Sass::Plugin.options[:css_location]
    
  Sass::Plugin.options[:template_location] = template_locations
  
  # Environment specific configurations
  # -----------------------------------------------------------------------------
  if %w(production staging).include?(rails_env)
  
    # Compress CSS (small files suitable for production)
    Sass::Plugin.options[:style] = :compressed
    
  else
    
    # Expand CSS
    Sass::Plugin.options[:style] = :expanded
    
    # Generate CSS from SASS every time a controller is accessed
    Sass::Plugin.options[:always_update] = true
    
    # Insert comments in the CSS about the line numbers of the Sass source
    Sass::Plugin.options[:line_comments] = true
    
  end

  # Include the Sass functionality extensions
  Sass::Script::Functions.send :include, Doohickey::SassExtensions::Gradients::Functions

  # This has to be re-included to pick up submodules
  Sass::Script::Functions::EvaluationContext.send :include, Sass::Script::Functions

end

.rails_envObject



27
28
29
# File 'lib/doohickey.rb', line 27

def self.rails_env
  defined?(Rails.env) ? Rails.env : RAILS_ENV
end

.rails_rootObject



23
24
25
# File 'lib/doohickey.rb', line 23

def self.rails_root
  defined?(Rails.root) ? Rails.root : RAILS_ROOT
end