Class: ThemesForRails::Config

Inherits:
Object
  • Object
show all
Includes:
Interpolation
Defined in:
lib/themes_for_rails/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Interpolation

#interpolate

Constructor Details

#initialize(&block) ⇒ Config

Returns a new instance of Config.



10
11
12
13
14
# File 'lib/themes_for_rails/config.rb', line 10

def initialize(&block)
  @use_sass = true
  @default_theme = 'default'
  yield if block_given?
end

Instance Attribute Details

#assets_dirObject

relative assets dir for view overloading support used for theme_view_path_for method to get theme path and add to view paths. Defaults to themes_dir for non asset pipeline users

If you are using the Rails Asset Pipeline, this should be changed to the path of your assets in your app. For example, if you store your themes under /app/assets/themes - Rails.root/app/assets/themes you would need to set this to ‘app/assets/themes’ in your initializer config



28
29
30
# File 'lib/themes_for_rails/config.rb', line 28

def assets_dir
  @assets_dir ||= ":root/themes/:name"
end

#base_dirObject



16
17
18
# File 'lib/themes_for_rails/config.rb', line 16

def base_dir
  @base_dir ||= Rails.root.to_s
end

#default_themeObject

Returns the value of attribute default_theme.



6
7
8
# File 'lib/themes_for_rails/config.rb', line 6

def default_theme
  @default_theme
end

#themes_dirObject



38
39
40
# File 'lib/themes_for_rails/config.rb', line 38

def themes_dir
  @themes_dir ||= ":root/themes"
end

#themes_routes_dirObject

This is the base themes dir that is used for mapping URL paths.

If you are using the Rails Asset Pipeline, this should be changed to the prefix dir of your assets path. For example, if you store your themes under /app/assets/themes - Rails.root/app/assets/themes you would need to set this value to ‘assets’ to match up with the Sprockets path resolution process.



55
56
57
# File 'lib/themes_for_rails/config.rb', line 55

def themes_routes_dir
  @themes_routes_dir ||= "themes"  
end

#use_sassObject

Returns the value of attribute use_sass.



6
7
8
# File 'lib/themes_for_rails/config.rb', line 6

def use_sass
  @use_sass
end

#views_dirObject

relative views directory for theme views to be separated from assets used for Asset Pipeline support. Defaults to match #assets_dir/views



34
35
36
# File 'lib/themes_for_rails/config.rb', line 34

def views_dir
  @views_dir ||= ":root/themes/:name/views"
end

Instance Method Details

#clearObject



59
60
61
62
63
64
# File 'lib/themes_for_rails/config.rb', line 59

def clear
  @base_dir   = nil
  @themes_dir = nil
  @assets_dir = nil
  @views_dir  = nil
end

#sass_is_available?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/themes_for_rails/config.rb', line 70

def sass_is_available?
  !!defined?Sass::Plugin
end

#themes_pathObject

Full path to themes



43
44
45
# File 'lib/themes_for_rails/config.rb', line 43

def themes_path
  interpolate(themes_dir)
end

#use_sass?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/themes_for_rails/config.rb', line 66

def use_sass?
  @use_sass and sass_is_available?
end