class Muwu::Project
Attributes
exceptions[RW]
instance_date[RW]
javascript_libraries_requested[RW]
manifest[RW]
metadata[RW]
options[RW]
outline[RW]
slug[RW]
working_directory[RW]
Public Class Methods
new()
click to toggle source
# File lib/muwu/project/project.rb, line 22 def initialize @exceptions = [] @instance_date = Time.now.strftime('%Y-%m-%d') @metadata = {} @outline = [] end
Public Instance Methods
css_basename()
click to toggle source
# File lib/muwu/project/project.rb, line 43 def css_basename if @options.output_file_css_basename.to_s == '' SanitizerHelper::sanitize_destination_file_basename(slug).downcase else SanitizerHelper::sanitize_destination_file_basename(@options.output_file_css_basename).downcase end end
css_manifest_file_does_exist()
click to toggle source
# File lib/muwu/project/project.rb, line 33 def css_manifest_file_does_exist File.exists?(css_manifest_filename) == true end
css_manifest_filename()
click to toggle source
# File lib/muwu/project/project.rb, line 38 def css_manifest_filename File.absolute_path(File.join(path_css, 'index.scss')) end
default_text_block_name()
click to toggle source
# File lib/muwu/project/project.rb, line 52 def default_text_block_name Default::PROJECT_OUTLINE[:default_text_block_name] end
does_not_have_crucial_files()
click to toggle source
# File lib/muwu/project/project.rb, line 57 def does_not_have_crucial_files metadata_file_does_not_exist && options_file_does_not_exist && outline_file_does_not_exist end
exceptions_add(exception)
click to toggle source
# File lib/muwu/project/project.rb, line 64 def exceptions_add(exception) @exceptions << exception end
exceptions_fatal()
click to toggle source
# File lib/muwu/project/project.rb, line 69 def exceptions_fatal @exceptions.select{ |e| e.type == :fatal } end
exceptions_include?(exception)
click to toggle source
# File lib/muwu/project/project.rb, line 74 def exceptions_include?(exception) @exceptions.map{ |e| e.class }.include?(exception) end
has_multiple_html_documents()
click to toggle source
# File lib/muwu/project/project.rb, line 79 def has_multiple_html_documents @manifest.documents_html_count > 1 end
html_basename()
click to toggle source
# File lib/muwu/project/project.rb, line 84 def html_basename if @options.output_file_html_basename.to_s == '' SanitizerHelper::sanitize_destination_file_basename('index').downcase else SanitizerHelper::sanitize_destination_file_basename(@options.output_file_html_basename).downcase end end
inspect()
click to toggle source
# File lib/muwu/project/project.rb, line 93 def inspect ["#{self.to_s}", "{", inspect_instance_variables, "}"].join(' ') end
inspect_instance_variables()
click to toggle source
# File lib/muwu/project/project.rb, line 98 def inspect_instance_variables self.instance_variables.map { |v| "#{v}=#<#{instance_variable_get(v).class}>" }.join(", ") end
js_basename()
click to toggle source
# File lib/muwu/project/project.rb, line 103 def js_basename if @options.output_file_js_basename.to_s == '' SanitizerHelper::sanitize_destination_file_basename(slug).downcase else SanitizerHelper::sanitize_destination_file_basename(@options.output_file_js_basename).downcase end end
metadata_file_does_exist()
click to toggle source
# File lib/muwu/project/project.rb, line 112 def metadata_file_does_exist File.exists?(metadata_filename) == true end
metadata_file_does_not_exist()
click to toggle source
# File lib/muwu/project/project.rb, line 117 def metadata_file_does_not_exist File.exists?(metadata_filename) == false end
metadata_filename()
click to toggle source
# File lib/muwu/project/project.rb, line 122 def metadata_filename determine_project_asset_filepath(:metadata) end
options_file_does_exist()
click to toggle source
# File lib/muwu/project/project.rb, line 127 def options_file_does_exist File.exists?(options_filename) == true end
options_file_does_not_exist()
click to toggle source
# File lib/muwu/project/project.rb, line 132 def options_file_does_not_exist File.exists?(options_filename) == false end
options_filename()
click to toggle source
# File lib/muwu/project/project.rb, line 137 def options_filename determine_project_asset_filepath(:options) end
outline_file_does_exist()
click to toggle source
# File lib/muwu/project/project.rb, line 142 def outline_file_does_exist File.exists?(outline_filename) == true end
outline_file_does_not_exist()
click to toggle source
# File lib/muwu/project/project.rb, line 147 def outline_file_does_not_exist File.exists?(outline_filename) == false end
outline_filename()
click to toggle source
# File lib/muwu/project/project.rb, line 152 def outline_filename determine_project_asset_filepath(:outline) end
outline_has_more_than_one_document()
click to toggle source
# File lib/muwu/project/project.rb, line 157 def outline_has_more_than_one_document outline_length > 1 end
outline_has_only_one_document()
click to toggle source
# File lib/muwu/project/project.rb, line 162 def outline_has_only_one_document outline_length == 1 end
outline_length()
click to toggle source
# File lib/muwu/project/project.rb, line 167 def outline_length outline.length end
outline_text_block_names()
click to toggle source
# File lib/muwu/project/project.rb, line 172 def outline_text_block_names result = [] outline_text_blocks.each do |text_block| text_block_name = determine_text_block_name(text_block) if text_block_name == '' result << 'main' else result << text_block_name end end result.uniq end
outline_text_blocks()
click to toggle source
# File lib/muwu/project/project.rb, line 186 def outline_text_blocks @outline.flatten.select { |outline_step| (Hash === outline_step) && (RegexpLib.outline_text =~ outline_step.flatten[0]) } end
outline_text_blocks_named(text_root_name)
click to toggle source
# File lib/muwu/project/project.rb, line 191 def outline_text_blocks_named(text_root_name) result = [] outline_text_blocks.each do |text_block| text_block_name = determine_text_block_name(text_block) if text_block_name == text_root_name.downcase result.concat(text_block.flatten[1]) end end result end
outline_text_pathnames()
click to toggle source
# File lib/muwu/project/project.rb, line 203 def outline_text_pathnames @options.outline_text_pathnames end
outline_text_pathnames_are_explicit()
click to toggle source
# File lib/muwu/project/project.rb, line 208 def outline_text_pathnames_are_explicit @options.outline_text_pathnames == 'explicit' end
outline_text_pathnames_are_flexible()
click to toggle source
# File lib/muwu/project/project.rb, line 213 def outline_text_pathnames_are_flexible @options.outline_text_pathnames == 'flexible' end
outline_text_pathnames_are_implicit()
click to toggle source
# File lib/muwu/project/project.rb, line 218 def outline_text_pathnames_are_implicit @options.outline_text_pathnames == 'implicit' end
outlined_documents()
click to toggle source
# File lib/muwu/project/project.rb, line 223 def outlined_documents @outline end
outlined_documents_by_index()
click to toggle source
# File lib/muwu/project/project.rb, line 228 def outlined_documents_by_index result = {} @outline.each_index do |index| result[index] = @outline[index] end result end
output_destination()
click to toggle source
# File lib/muwu/project/project.rb, line 237 def output_destination @options.output_destination end
output_destination_requests_stdout()
click to toggle source
# File lib/muwu/project/project.rb, line 242 def output_destination_requests_stdout @options.output_destination == 'stdout' end
output_formats_several()
click to toggle source
# File lib/muwu/project/project.rb, line 247 def output_formats_several @options.output_formats.length > 1 end
path_compiled()
click to toggle source
TODO: Move path definitions into Muwu::Default::FILEPATHS
# File lib/muwu/project/project.rb, line 255 def path_compiled File.absolute_path(File.join(@working_directory, 'compiled')) end
path_compiled_does_exist()
click to toggle source
# File lib/muwu/project/project.rb, line 260 def path_compiled_does_exist Dir.exists?(path_compiled) end
path_config()
click to toggle source
# File lib/muwu/project/project.rb, line 265 def path_config File.absolute_path(File.join(@working_directory, 'config')) end
path_css()
click to toggle source
# File lib/muwu/project/project.rb, line 270 def path_css File.absolute_path(File.join(path_config, 'css')) end
path_css_base()
click to toggle source
# File lib/muwu/project/project.rb, line 275 def path_css_base File.absolute_path(File.join(path_css, 'base')) end
path_css_colors()
click to toggle source
# File lib/muwu/project/project.rb, line 280 def path_css_colors File.absolute_path(File.join(path_css, 'colors')) end
path_css_extensions()
click to toggle source
# File lib/muwu/project/project.rb, line 285 def path_css_extensions File.absolute_path(File.join(path_css, 'extensions')) end
path_outline()
click to toggle source
TODO: Broken due to introduction of the `/compiled` folder Keeping it as a comment in case it becomes useful in the future.
def path_images
File.absolute_path(File.join(@working_directory, 'images'))
end
# File lib/muwu/project/project.rb, line 298 def path_outline @working_directory end
path_text()
click to toggle source
# File lib/muwu/project/project.rb, line 303 def path_text File.absolute_path(File.join(@working_directory, 'text')) end
sort_outline_text_blocks()
click to toggle source
# File lib/muwu/project/project.rb, line 317 def sort_outline_text_blocks result = [] outline_text_blocks.each do |text_block| text_block_name = determine_text_block_name(text_block) text_block_contents = determine_text_block_contents(text_block) existing_block = result.select { |b| b.has_key?(text_block_name) }.flatten if existing_block.empty? result << { text_block_name => text_block_contents } else existing_block[text_block_name].concat(text_block_contents) end end result end
text_block_naming_is_not_simple()
click to toggle source
# File lib/muwu/project/project.rb, line 338 def text_block_naming_is_not_simple text_block_naming_is_simple == false end
text_block_naming_is_simple()
click to toggle source
# File lib/muwu/project/project.rb, line 333 def text_block_naming_is_simple outline_text_block_names == [default_text_block_name] end
title()
click to toggle source
# File lib/muwu/project/project.rb, line 343 def title if @metadata.has_key?('title') @metadata['title'] else working_directory_name end end
will_create_css_file()
click to toggle source
# File lib/muwu/project/project.rb, line 352 def will_create_css_file @options.output_formats.include?('css') end
will_create_html_file_only()
click to toggle source
# File lib/muwu/project/project.rb, line 357 def will_create_html_file_only @options.output_formats == ['html'] end
will_create_javascript_file()
click to toggle source
# File lib/muwu/project/project.rb, line 362 def will_create_javascript_file if will_require_javascript_libraries @options.output_formats.include?('js') end end
will_embed_at_least_one_asset()
click to toggle source
# File lib/muwu/project/project.rb, line 374 def will_embed_at_least_one_asset will_embed_css || will_embed_js end
will_embed_css()
click to toggle source
TODO: What if there's no css to embed? Consider redefining this method.
# File lib/muwu/project/project.rb, line 381 def will_embed_css will_create_css_file == false end
will_embed_js()
click to toggle source
TODO: What if there's no js to embed? Consider redefining this method.
# File lib/muwu/project/project.rb, line 388 def will_embed_js will_create_javascript_file == false end
will_generate_subcontents_automatically()
click to toggle source
# File lib/muwu/project/project.rb, line 398 def will_generate_subcontents_automatically (outline_has_more_than_one_document) && (@options.generate_subcontents_automatically == true) end
will_not_generate_subcontents_automatically()
click to toggle source
# File lib/muwu/project/project.rb, line 413 def will_not_generate_subcontents_automatically not will_generate_subcontents_automatically end
will_render_section_numbers()
click to toggle source
# File lib/muwu/project/project.rb, line 403 def will_render_section_numbers @options.render_section_numbers == true end
will_require_javascript_libraries()
click to toggle source
# File lib/muwu/project/project.rb, line 369 def will_require_javascript_libraries @javascript_libraries_requested.count > 0 end
working_directory_name()
click to toggle source
# File lib/muwu/project/project.rb, line 418 def working_directory_name @working_directory.split(File::SEPARATOR)[-1] end
Private Instance Methods
determine_project_asset_filepath(type)
click to toggle source
# File lib/muwu/project/project.rb, line 427 def determine_project_asset_filepath(type) File.absolute_path(File.join(@working_directory, Default::FILEPATHS[type], Default::FILENAMES[type])) end
determine_text_block_contents(text_block)
click to toggle source
# File lib/muwu/project/project.rb, line 432 def determine_text_block_contents(text_block) text_block.flatten[1] end
determine_text_block_name(text_block)
click to toggle source
# File lib/muwu/project/project.rb, line 437 def determine_text_block_name(text_block) directive = text_block.flatten[0] components = directive.partition(RegexpLib.outline_text_plus_whitespace) text_block_name = components[2].to_s.downcase.strip if text_block_name == '' text_block_name = default_text_block_name end text_block_name end