Class: Machinery::StaticHtml
- Includes:
- HamlHelpers
- Defined in:
- lib/static_html.rb
Overview
Copyright © 2013-2016 SUSE LLC
This program is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, contact SUSE LLC.
To contact SUSE about this file by physical or electronic mail, you may find current contact information at www.suse.com
Constant Summary collapse
- TEMPLATE_DIR =
File.join(Machinery::ROOT, "html").freeze
- PARTIAL_DIR =
File.join(Machinery::ROOT, "html", "partials").freeze
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
Attributes inherited from Exporter
Instance Method Summary collapse
- #create_directory(force = false) ⇒ Object
- #haml(source, options = {}) ⇒ Object
-
#initialize(description, directory) ⇒ StaticHtml
constructor
A new instance of StaticHtml.
- #write ⇒ Object
Methods included from HamlHelpers
#nav_class, #render_partial, #render_scope, #scope_help, #scope_info, #scope_initials, #scope_meta_info, #scope_title
Methods inherited from Exporter
Constructor Details
#initialize(description, directory) ⇒ StaticHtml
Returns a new instance of StaticHtml.
24 25 26 27 28 |
# File 'lib/static_html.rb', line 24 def initialize(description, directory) @description = description @directory = directory @static_html = true end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
29 30 31 |
# File 'lib/static_html.rb', line 29 def description @description end |
Instance Method Details
#create_directory(force = false) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/static_html.rb', line 41 def create_directory(force = false) if File.exist?(@directory) if force FileUtils.rm_r(@directory) else raise Machinery::Errors::ExportFailed.new( "The output directory '#{@directory}' already exists." \ " You can force overwriting it with the '--force' option." ) end end FileUtils.mkdir_p(@directory) end |
#haml(source, options = {}) ⇒ Object
31 32 33 |
# File 'lib/static_html.rb', line 31 def haml(source, = {}) Haml::Engine.new(source).render(binding, .delete(:locals)) end |
#write ⇒ Object
35 36 37 38 39 |
# File 'lib/static_html.rb', line 35 def write @description.load_existing_diffs render_html copy_assets end |