Module: MerbDynamicSass

Defined in:
lib/merb_dynamic_sass.rb

Overview

All Slice code is expected to be namespaced inside a module

Defined Under Namespace

Classes: Application, Stylesheets

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#initializedObject (readonly)

Initialization hook - runs before AfterAppLoads BootLoader

  • use @initialized because sometimes self.init is called twice, especially during the spec or rake process.



45
46
47
# File 'lib/merb_dynamic_sass.rb', line 45

def initialized
  @initialized
end

Class Method Details

.action_cache_storeObject



90
91
92
# File 'lib/merb_dynamic_sass.rb', line 90

def self.action_cache_store
  Merb::Cache[action_cache_store_name]
end

.action_cache_store_nameObject



82
83
84
# File 'lib/merb_dynamic_sass.rb', line 82

def self.action_cache_store_name
  :dynamic_sass_action_cache
end

.activateObject

Activation hook - runs after AfterAppLoads BootLoader



61
62
# File 'lib/merb_dynamic_sass.rb', line 61

def self.activate
end

.authorObject



33
34
35
# File 'lib/merb_dynamic_sass.rb', line 33

def self.author
  "Yukiko Kawamoto"
end

.deactivateObject

Deactivation hook - triggered by Merb::Slices.deactivate(MerbDynamicSass)



65
66
# File 'lib/merb_dynamic_sass.rb', line 65

def self.deactivate
end

.descriptionObject

Slice metadata



25
26
27
# File 'lib/merb_dynamic_sass.rb', line 25

def self.description
  "MerbDynamicSass is a slice to provide more handy way to use Sass engine."
end

.initObject



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/merb_dynamic_sass.rb', line 46

def self.init
  unless @initialized
    require "sass"
    # route is automatically prepared.
    Merb::Router.prepare [], Merb::Router.routes do
      slice(:merb_dynamic_sass, :name_prefix => nil)
    end
    Merb.add_mime_type(:css, :to_css, %w[text/css])
    Merb.cache.register(action_cache_store_name, Merb::Cache::FileStore, :dir => Merb.root_path( :tmp / :cache / :stylesheets ))
    Merb.cache.register(page_cache_store_name, Merb::Cache::PageStore[Merb::Cache::FileStore], :dir => Merb.root_path( "public" ))
    @initialized = true
  end
end

.loadedObject

Stub classes loaded hook - runs before LoadClasses BootLoader right after a slice’s classes have been loaded internally.



39
40
# File 'lib/merb_dynamic_sass.rb', line 39

def self.loaded
end

.page_cache_storeObject



94
95
96
# File 'lib/merb_dynamic_sass.rb', line 94

def self.page_cache_store
  Merb::Cache[page_cache_store_name]
end

.page_cache_store_nameObject



86
87
88
# File 'lib/merb_dynamic_sass.rb', line 86

def self.page_cache_store_name
  :dynamic_sass_page_cache
end

.setup_router(scope) ⇒ Object

Note:

prefix your named routes with :merb_dynamic_sass_ to avoid potential conflicts with global named routes.

Setup routes inside the host application

Parameters:

  • scope (Merb::Router::Behaviour)

    Routes will be added within this scope (namespace). In fact, any router behaviour is a valid namespace, so you can attach routes at any level of your router setup.



77
78
79
80
# File 'lib/merb_dynamic_sass.rb', line 77

def self.setup_router(scope)
  # example of a named route
  scope.match(%r{^/stylesheets/(.*)\.css$}).to(:controller => "stylesheets", :action => "index", :path => "[1]").name :css
end

.versionObject



29
30
31
# File 'lib/merb_dynamic_sass.rb', line 29

def self.version
  "0.0.1"
end