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
-
#configuration ⇒ Object
Returns the value of attribute configuration.
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#site_dir ⇒ Object
readonly
Returns the value of attribute site_dir.
-
#src_dir ⇒ Object
readonly
Returns the value of attribute src_dir.
Class Method Summary collapse
Instance Method Summary collapse
- #base_dir ⇒ Object
- #current_file ⇒ Object
- #full_layout_path(name) ⇒ Object
-
#initialize(base_dir, configuration = Configuration.new) ⇒ Base
constructor
A new instance of Base.
- #layout_exists?(name) ⇒ Boolean
- #run(command) ⇒ Object
- #template_directory?(path) ⇒ Boolean
-
#template_exists?(name, dir = '') ⇒ Boolean
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
#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
#initialize(base_dir, configuration = Configuration.new) ⇒ Base
Returns a new instance of Base.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/staticmatic/base.rb', line 38 def initialize(base_dir, configuration = Configuration.new) @configuration = configuration @current_page = nil @current_file_stack = [] @base_dir = base_dir @src_dir = "#{@base_dir}/src" @site_dir = "#{@base_dir}/site" @templates_dir = File.dirname(__FILE__) + '/templates/default/' @layout = "application" @scope = Object.new @scope.instance_variable_set("@staticmatic", self) load_helpers end |
Instance Attribute Details
#configuration ⇒ Object
Returns the value of attribute configuration.
31 32 33 |
# File 'lib/staticmatic/base.rb', line 31 def configuration @configuration end |
#current_page ⇒ Object (readonly)
Returns the value of attribute current_page.
32 33 34 |
# File 'lib/staticmatic/base.rb', line 32 def current_page @current_page end |
#site_dir ⇒ Object (readonly)
Returns the value of attribute site_dir.
32 33 34 |
# File 'lib/staticmatic/base.rb', line 32 def site_dir @site_dir end |
#src_dir ⇒ Object (readonly)
Returns the value of attribute src_dir.
32 33 34 |
# File 'lib/staticmatic/base.rb', line 32 def src_dir @src_dir end |
Class Method Details
.base_dirs ⇒ Object
82 83 84 |
# File 'lib/staticmatic/base.rb', line 82 def base_dirs StaticMatic::BASE_DIRS end |
Instance Method Details
#base_dir ⇒ Object
52 53 54 |
# File 'lib/staticmatic/base.rb', line 52 def base_dir @base_dir end |
#current_file ⇒ Object
34 35 36 |
# File 'lib/staticmatic/base.rb', line 34 def current_file @current_file_stack[0] || "" end |
#full_layout_path(name) ⇒ Object
77 78 79 |
# File 'lib/staticmatic/base.rb', line 77 def full_layout_path(name) "#{@src_dir}/layouts/#{name}.haml" end |
#layout_exists?(name) ⇒ Boolean
69 70 71 |
# File 'lib/staticmatic/base.rb', line 69 def layout_exists?(name) File.exists? full_layout_path(name) end |
#run(command) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/staticmatic/base.rb', line 56 def run(command) if %w(build setup preview).include?(command) send(command) else puts "#{command} is not a valid StaticMatic command" end end |
#template_directory?(path) ⇒ Boolean
73 74 75 |
# File 'lib/staticmatic/base.rb', line 73 def template_directory?(path) File.directory?(File.join(@src_dir, 'pages', path)) end |
#template_exists?(name, dir = '') ⇒ Boolean
TODO: DRY this _exists? section up
65 66 67 |
# File 'lib/staticmatic/base.rb', line 65 def template_exists?(name, dir = '') File.exists?(File.join(@src_dir, 'pages', dir, "#{name}.haml")) || File.exists?(File.join(@src_dir, 'stylesheets', dir, "#{name}.sass")) end |