Class: StaticMatic::Base
- Inherits:
-
Object
- Object
- StaticMatic::Base
- Includes:
- BuildMixin, HelpersMixin, RenderMixin, RescueMixin, ServerMixin, SetupMixin
- Defined in:
- lib/staticmatic/base.rb
Instance Attribute Summary (collapse)
-
- (Object) configuration
Returns the value of attribute configuration.
-
- (Object) current_page
readonly
Returns the value of attribute current_page.
-
- (Object) site_dir
readonly
Returns the value of attribute site_dir.
-
- (Object) src_dir
readonly
Returns the value of attribute src_dir.
Instance Method Summary (collapse)
- - (Object) base_dir
- - (Object) configure_compass
- - (Object) current_file
- - (Object) full_layout_path(name)
-
- (Base) initialize(base_dir, configuration = Configuration.new)
constructor
A new instance of Base.
- - (Boolean) layout_exists?(name)
- - (Object) load_configuration
- - (Object) run(command)
- - (Boolean) template_directory?(path)
-
- (Boolean) template_exists?(name, dir = '')
TODO: DRY this _exists? section up.
Methods included from RescueMixin
Methods included from ServerMixin
Methods included from HelpersMixin
Methods included from SetupMixin
Methods included from BuildMixin
#build, #build_css, #build_html, #copy_file, #generate_site_file, #save_page, #save_stylesheet
Methods included from RenderMixin
#clear_template_variables!, #determine_layout, #generate_css, #generate_html, #generate_html_from_template_source, #generate_html_with_layout, #generate_partial, #source_for_layout, #source_template_from_path
Constructor Details
- (Base) initialize(base_dir, configuration = Configuration.new)
A new instance of Base
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/staticmatic/base.rb', line 18 def initialize(base_dir, configuration = Configuration.new) @configuration = configuration @current_page = nil @current_file_stack = [] @base_dir = base_dir @src_dir = File.join(@base_dir, "src") @site_dir = File.join(@base_dir, "site") if File.exists?(File.join(@src_dir, "layouts", "application.haml")) puts "DEPRECATION: layouts/application.haml will be renamed to layouts/default.haml in 0.12.0" @default_layout = "application" else @default_layout = "default" end @scope = Object.new @scope.instance_variable_set("@staticmatic", self) load_configuration configure_compass load_helpers end |
Instance Attribute Details
- (Object) configuration
Returns the value of attribute configuration
11 12 13 |
# File 'lib/staticmatic/base.rb', line 11 def configuration @configuration end |
- (Object) current_page (readonly)
Returns the value of attribute current_page
12 13 14 |
# File 'lib/staticmatic/base.rb', line 12 def current_page @current_page end |
- (Object) site_dir (readonly)
Returns the value of attribute site_dir
12 13 14 |
# File 'lib/staticmatic/base.rb', line 12 def site_dir @site_dir end |
- (Object) src_dir (readonly)
Returns the value of attribute src_dir
12 13 14 |
# File 'lib/staticmatic/base.rb', line 12 def src_dir @src_dir end |
Instance Method Details
- (Object) base_dir
63 64 65 |
# File 'lib/staticmatic/base.rb', line 63 def base_dir @base_dir end |
- (Object) configure_compass
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/staticmatic/base.rb', line 94 def configure_compass Compass.configuration.project_path = @base_dir compass_config_path = File.join(@base_dir, "config", "compass.rb") if File.exists?(compass_config_path) Compass.add_configuration(compass_config_path) end configuration..merge!(Compass.configuration.) end |
- (Object) current_file
14 15 16 |
# File 'lib/staticmatic/base.rb', line 14 def current_file @current_file_stack[0] || "" end |
- (Object) full_layout_path(name)
90 91 92 |
# File 'lib/staticmatic/base.rb', line 90 def full_layout_path(name) File.join(@src_dir, "layouts", "#{name}.haml") end |
- (Boolean) layout_exists?(name)
82 83 84 |
# File 'lib/staticmatic/base.rb', line 82 def layout_exists?(name) File.exists? full_layout_path(name) end |
- (Object) load_configuration
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/staticmatic/base.rb', line 42 def load_configuration configuration = StaticMatic::Configuration.new config_file = File.join(@base_dir, "config", "site.rb") if !File.exists?(config_file) config_file = File.join(@base_dir, "src", "configuration.rb") if File.exists?(config_file) puts "DEPRECATION: #{@base_dir}/src/configuration.rb will be moved to #{@base_dir}/config/site.rb in 0.12.0" end end if File.exists?(config_file) config = File.read(config_file) eval(config) end # Compass.sass_engine_options.merge!(configuration.sass_options) @configuration = configuration end |
- (Object) run(command)
67 68 69 70 71 72 73 74 75 |
# File 'lib/staticmatic/base.rb', line 67 def run(command) puts "Site root is: #{@base_dir}" if %w(build setup preview).include?(command) send(command) else puts "#{command} is not a valid StaticMatic command" end end |
- (Boolean) template_directory?(path)
86 87 88 |
# File 'lib/staticmatic/base.rb', line 86 def template_directory?(path) File.directory?(File.join(@src_dir, 'pages', path)) end |
- (Boolean) template_exists?(name, dir = '')
TODO: DRY this _exists? section up
78 79 80 |
# File 'lib/staticmatic/base.rb', line 78 def template_exists?(name, dir = '') File.exists?(File.join(@src_dir, 'pages', dir, "#{name}.haml")) || File.exists?(File.join(@src_dir, 'stylesheets', "#{name}.sass")) || File.exists?(File.join(@src_dir, 'stylesheets', "#{name}.scss")) end |