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
15
# File 'lib/themes_for_rails/config.rb', line 10

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

Instance Attribute Details

#asset_digests_enabledObject

Returns the value of attribute asset_digests_enabled.



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

def asset_digests_enabled
  @asset_digests_enabled
end

#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



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

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

#base_dirObject



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

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



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

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.



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

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



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

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

Instance Method Details

#asset_digests_enabled?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/themes_for_rails/config.rb', line 75

def asset_digests_enabled?
  @asset_digests_enabled
end

#clearObject



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

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

#sass_is_available?Boolean

Returns:

  • (Boolean)


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

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

#themes_pathObject

Full path to themes



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

def themes_path
  interpolate(themes_dir)
end

#use_sass?Boolean

Returns:

  • (Boolean)


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

def use_sass?
  @use_sass and sass_is_available?
end