Class: Muwu::Project
Constant Summary
Constants included
from Muwu
GEM_HOME_LIB, GEM_HOME_LIB_MUWU, VERSION
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Muwu
debug, read
Constructor Details
Returns a new instance of Project.
22
23
24
25
26
27
|
# File 'lib/muwu/project/project.rb', line 22
def initialize
@exceptions = []
@instance_date = Time.now.strftime('%Y-%m-%d')
@metadata = {}
@outline = []
end
|
Instance Attribute Details
#exceptions ⇒ Object
Returns the value of attribute exceptions.
9
10
11
|
# File 'lib/muwu/project/project.rb', line 9
def exceptions
@exceptions
end
|
#instance_date ⇒ Object
Returns the value of attribute instance_date.
9
10
11
|
# File 'lib/muwu/project/project.rb', line 9
def instance_date
@instance_date
end
|
#javascript_libraries_requested ⇒ Object
Returns the value of attribute javascript_libraries_requested.
9
10
11
|
# File 'lib/muwu/project/project.rb', line 9
def javascript_libraries_requested
@javascript_libraries_requested
end
|
#manifest ⇒ Object
Returns the value of attribute manifest.
9
10
11
|
# File 'lib/muwu/project/project.rb', line 9
def manifest
@manifest
end
|
Returns the value of attribute metadata.
9
10
11
|
# File 'lib/muwu/project/project.rb', line 9
def metadata
@metadata
end
|
#options ⇒ Object
Returns the value of attribute options.
9
10
11
|
# File 'lib/muwu/project/project.rb', line 9
def options
@options
end
|
#outline ⇒ Object
Returns the value of attribute outline.
9
10
11
|
# File 'lib/muwu/project/project.rb', line 9
def outline
@outline
end
|
#slug ⇒ Object
Returns the value of attribute slug.
9
10
11
|
# File 'lib/muwu/project/project.rb', line 9
def slug
@slug
end
|
#working_directory ⇒ Object
Returns the value of attribute working_directory.
9
10
11
|
# File 'lib/muwu/project/project.rb', line 9
def working_directory
@working_directory
end
|
Instance Method Details
#css_manifest_file_does_exist ⇒ Object
33
34
35
|
# File 'lib/muwu/project/project.rb', line 33
def css_manifest_file_does_exist
File.exists?(css_manifest_filename) == true
end
|
#css_manifest_filename ⇒ Object
38
39
40
|
# 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 ⇒ Object
52
53
54
|
# 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 ⇒ Object
57
58
59
60
61
|
# 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) ⇒ Object
64
65
66
|
# File 'lib/muwu/project/project.rb', line 64
def exceptions_add(exception)
@exceptions << exception
end
|
#exceptions_fatal ⇒ Object
69
70
71
|
# File 'lib/muwu/project/project.rb', line 69
def exceptions_fatal
@exceptions.select{ |e| e.type == :fatal }
end
|
#exceptions_include?(exception) ⇒ Boolean
74
75
76
|
# File 'lib/muwu/project/project.rb', line 74
def exceptions_include?(exception)
@exceptions.map{ |e| e.class }.include?(exception)
end
|
#has_multiple_html_documents ⇒ Object
79
80
81
|
# File 'lib/muwu/project/project.rb', line 79
def has_multiple_html_documents
@manifest.documents_html_count > 1
end
|
#inspect ⇒ Object
93
94
95
|
# File 'lib/muwu/project/project.rb', line 93
def inspect
["#{self.to_s}", "{", inspect_instance_variables, "}"].join(' ')
end
|
#inspect_instance_variables ⇒ Object
98
99
100
|
# 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
|
112
113
114
|
# File 'lib/muwu/project/project.rb', line 112
def metadata_file_does_exist
File.exists?(metadata_filename) == true
end
|
117
118
119
|
# File 'lib/muwu/project/project.rb', line 117
def metadata_file_does_not_exist
File.exists?(metadata_filename) == false
end
|
122
123
124
|
# File 'lib/muwu/project/project.rb', line 122
def metadata_filename
determine_project_asset_filepath(:metadata)
end
|
#options_file_does_exist ⇒ Object
127
128
129
|
# File 'lib/muwu/project/project.rb', line 127
def options_file_does_exist
File.exists?(options_filename) == true
end
|
#options_file_does_not_exist ⇒ Object
132
133
134
|
# File 'lib/muwu/project/project.rb', line 132
def options_file_does_not_exist
File.exists?(options_filename) == false
end
|
#options_filename ⇒ Object
137
138
139
|
# File 'lib/muwu/project/project.rb', line 137
def options_filename
determine_project_asset_filepath(:options)
end
|
#outline_file_does_exist ⇒ Object
142
143
144
|
# File 'lib/muwu/project/project.rb', line 142
def outline_file_does_exist
File.exists?(outline_filename) == true
end
|
#outline_file_does_not_exist ⇒ Object
147
148
149
|
# File 'lib/muwu/project/project.rb', line 147
def outline_file_does_not_exist
File.exists?(outline_filename) == false
end
|
#outline_filename ⇒ Object
152
153
154
|
# File 'lib/muwu/project/project.rb', line 152
def outline_filename
determine_project_asset_filepath(:outline)
end
|
#outline_has_more_than_one_document ⇒ Object
157
158
159
|
# File 'lib/muwu/project/project.rb', line 157
def outline_has_more_than_one_document
outline_length > 1
end
|
#outline_has_only_one_document ⇒ Object
162
163
164
|
# File 'lib/muwu/project/project.rb', line 162
def outline_has_only_one_document
outline_length == 1
end
|
#outline_length ⇒ Object
167
168
169
|
# File 'lib/muwu/project/project.rb', line 167
def outline_length
outline.length
end
|
#outline_text_block_names ⇒ Object
172
173
174
175
176
177
178
179
180
181
182
183
|
# 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 ⇒ Object
186
187
188
|
# 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) ⇒ Object
191
192
193
194
195
196
197
198
199
200
|
# 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 ⇒ Object
203
204
205
|
# File 'lib/muwu/project/project.rb', line 203
def outline_text_pathnames
@options.outline_text_pathnames
end
|
#outline_text_pathnames_are_explicit ⇒ Object
208
209
210
|
# 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 ⇒ Object
213
214
215
|
# 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 ⇒ Object
218
219
220
|
# File 'lib/muwu/project/project.rb', line 218
def outline_text_pathnames_are_implicit
@options.outline_text_pathnames == 'implicit'
end
|
#outlined_documents ⇒ Object
223
224
225
|
# File 'lib/muwu/project/project.rb', line 223
def outlined_documents
@outline
end
|
#outlined_documents_by_index ⇒ Object
228
229
230
231
232
233
234
|
# 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 ⇒ Object
237
238
239
|
# File 'lib/muwu/project/project.rb', line 237
def output_destination
@options.output_destination
end
|
#output_destination_requests_stdout ⇒ Object
242
243
244
|
# File 'lib/muwu/project/project.rb', line 242
def output_destination_requests_stdout
@options.output_destination == 'stdout'
end
|
247
248
249
|
# File 'lib/muwu/project/project.rb', line 247
def output_formats_several
@options.output_formats.length > 1
end
|
#path_compiled ⇒ Object
TODO: Move path definitions into Muwu::Default::FILEPATHS
255
256
257
|
# File 'lib/muwu/project/project.rb', line 255
def path_compiled
File.absolute_path(File.join(@working_directory, 'compiled'))
end
|
#path_compiled_does_exist ⇒ Object
260
261
262
|
# File 'lib/muwu/project/project.rb', line 260
def path_compiled_does_exist
Dir.exists?(path_compiled)
end
|
#path_config ⇒ Object
265
266
267
|
# File 'lib/muwu/project/project.rb', line 265
def path_config
File.absolute_path(File.join(@working_directory, 'config'))
end
|
#path_css ⇒ Object
270
271
272
|
# File 'lib/muwu/project/project.rb', line 270
def path_css
File.absolute_path(File.join(path_config, 'css'))
end
|
#path_css_base ⇒ Object
275
276
277
|
# File 'lib/muwu/project/project.rb', line 275
def path_css_base
File.absolute_path(File.join(path_css, 'base'))
end
|
#path_css_colors ⇒ Object
280
281
282
|
# File 'lib/muwu/project/project.rb', line 280
def path_css_colors
File.absolute_path(File.join(path_css, 'colors'))
end
|
#path_css_extensions ⇒ Object
285
286
287
|
# File 'lib/muwu/project/project.rb', line 285
def path_css_extensions
File.absolute_path(File.join(path_css, 'extensions'))
end
|
#path_outline ⇒ Object
298
299
300
|
# File 'lib/muwu/project/project.rb', line 298
def path_outline
@working_directory
end
|
#path_text ⇒ Object
303
304
305
|
# File 'lib/muwu/project/project.rb', line 303
def path_text
File.absolute_path(File.join(@working_directory, 'text'))
end
|
#sort_outline_text_blocks ⇒ Object
317
318
319
320
321
322
323
324
325
326
327
328
329
330
|
# 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 ⇒ Object
338
339
340
|
# 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 ⇒ Object
333
334
335
|
# File 'lib/muwu/project/project.rb', line 333
def text_block_naming_is_simple
outline_text_block_names == [default_text_block_name]
end
|
#title ⇒ Object
343
344
345
346
347
348
349
|
# 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 ⇒ Object
352
353
354
|
# File 'lib/muwu/project/project.rb', line 352
def will_create_css_file
@options.output_formats.include?('css')
end
|
#will_create_html_file_only ⇒ Object
357
358
359
|
# File 'lib/muwu/project/project.rb', line 357
def will_create_html_file_only
@options.output_formats == ['html']
end
|
#will_create_javascript_file ⇒ Object
362
363
364
365
366
|
# 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 ⇒ Object
374
375
376
|
# 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 ⇒ Object
TODO: What if there’s no css to embed? Consider redefining this method.
381
382
383
|
# File 'lib/muwu/project/project.rb', line 381
def will_embed_css
will_create_css_file == false
end
|
#will_embed_js ⇒ Object
TODO: What if there’s no js to embed? Consider redefining this method.
388
389
390
|
# File 'lib/muwu/project/project.rb', line 388
def will_embed_js
will_create_javascript_file == false
end
|
#will_generate_navigators_automatically ⇒ Object
393
394
395
|
# File 'lib/muwu/project/project.rb', line 393
def will_generate_navigators_automatically
(outline_has_more_than_one_document) && (@options.generate_navigators_automatically == true) && (@options.output_destination == 'file')
end
|
#will_generate_subcontents_automatically ⇒ Object
398
399
400
|
# 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_navigators_automatically ⇒ Object
408
409
410
|
# File 'lib/muwu/project/project.rb', line 408
def will_not_generate_navigators_automatically
not will_generate_navigators_automatically
end
|
#will_not_generate_subcontents_automatically ⇒ Object
413
414
415
|
# File 'lib/muwu/project/project.rb', line 413
def will_not_generate_subcontents_automatically
not will_generate_subcontents_automatically
end
|
#will_render_section_numbers ⇒ Object
403
404
405
|
# File 'lib/muwu/project/project.rb', line 403
def will_render_section_numbers
@options.render_section_numbers == true
end
|
#will_require_javascript_libraries ⇒ Object
369
370
371
|
# File 'lib/muwu/project/project.rb', line 369
def will_require_javascript_libraries
@javascript_libraries_requested.count > 0
end
|
#working_directory_name ⇒ Object
418
419
420
|
# File 'lib/muwu/project/project.rb', line 418
def working_directory_name
@working_directory.split(File::SEPARATOR)[-1]
end
|