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_basename ⇒ Object
43
44
45
46
47
48
49
|
# 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 ⇒ Object
33
34
35
|
# File 'lib/muwu/project/project.rb', line 33
def css_manifest_file_does_exist
File.exist?(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
|
#html_basename ⇒ Object
84
85
86
87
88
89
90
|
# 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 ⇒ 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
|
#js_basename ⇒ Object
103
104
105
106
107
108
109
|
# 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
|
112
113
114
|
# File 'lib/muwu/project/project.rb', line 112
def metadata_file_does_exist
File.exist?(metadata_filename) == true
end
|
117
118
119
|
# File 'lib/muwu/project/project.rb', line 117
def metadata_file_does_not_exist
File.exist?(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.exist?(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.exist?(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.exist?(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.exist?(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.exist?(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
290
291
292
|
# File 'lib/muwu/project/project.rb', line 290
def path_outline
@working_directory
end
|
#path_text ⇒ Object
295
296
297
|
# File 'lib/muwu/project/project.rb', line 295
def path_text
File.absolute_path(File.join(@working_directory, 'text'))
end
|
#sort_outline_text_blocks ⇒ Object
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
# File 'lib/muwu/project/project.rb', line 309
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
330
331
332
|
# File 'lib/muwu/project/project.rb', line 330
def text_block_naming_is_not_simple
text_block_naming_is_simple == false
end
|
#text_block_naming_is_simple ⇒ Object
325
326
327
|
# File 'lib/muwu/project/project.rb', line 325
def text_block_naming_is_simple
outline_text_block_names == [default_text_block_name]
end
|
#title ⇒ Object
335
336
337
338
339
340
341
|
# File 'lib/muwu/project/project.rb', line 335
def title
if @metadata.has_key?('title')
@metadata['title']
else
working_directory_name
end
end
|
#will_create_css_file ⇒ Object
344
345
346
|
# File 'lib/muwu/project/project.rb', line 344
def will_create_css_file
@options.output_formats.include?('css')
end
|
#will_create_html_file_only ⇒ Object
349
350
351
|
# File 'lib/muwu/project/project.rb', line 349
def will_create_html_file_only
@options.output_formats == ['html']
end
|
#will_create_javascript_file ⇒ Object
354
355
356
357
358
|
# File 'lib/muwu/project/project.rb', line 354
def will_create_javascript_file
if will_require_javascript_libraries
@options.output_formats.include?('js')
end
end
|
#will_embed_at_least_one_asset ⇒ Object
366
367
368
|
# File 'lib/muwu/project/project.rb', line 366
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.
373
374
375
|
# File 'lib/muwu/project/project.rb', line 373
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.
380
381
382
|
# File 'lib/muwu/project/project.rb', line 380
def will_embed_js
will_create_javascript_file == false
end
|
#will_generate_navigators_automatically ⇒ Object
385
386
387
|
# File 'lib/muwu/project/project.rb', line 385
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
390
391
392
|
# File 'lib/muwu/project/project.rb', line 390
def will_generate_subcontents_automatically
(outline_has_more_than_one_document) && (@options.generate_subcontents_automatically == true)
end
|
#will_not_generate_navigators_automatically ⇒ Object
400
401
402
|
# File 'lib/muwu/project/project.rb', line 400
def will_not_generate_navigators_automatically
not will_generate_navigators_automatically
end
|
#will_not_generate_subcontents_automatically ⇒ Object
405
406
407
|
# File 'lib/muwu/project/project.rb', line 405
def will_not_generate_subcontents_automatically
not will_generate_subcontents_automatically
end
|
#will_render_section_numbers ⇒ Object
395
396
397
|
# File 'lib/muwu/project/project.rb', line 395
def will_render_section_numbers
@options.render_section_numbers == true
end
|
#will_require_javascript_libraries ⇒ Object
361
362
363
|
# File 'lib/muwu/project/project.rb', line 361
def will_require_javascript_libraries
@javascript_libraries_requested.count > 0
end
|
#working_directory_name ⇒ Object
410
411
412
|
# File 'lib/muwu/project/project.rb', line 410
def working_directory_name
@working_directory.split(File::SEPARATOR)[-1]
end
|