muwu 3.0.0.alpha → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/lib/{muwu_loader.rb → loader.rb} +2 -2
  3. data/lib/muwu.rb +3 -3
  4. data/lib/muwu/cli/cli.rb +33 -22
  5. data/lib/muwu/cli/help/compile +4 -4
  6. data/lib/muwu/cli/help/publish +19 -6
  7. data/lib/muwu/cli/help/reset +5 -2
  8. data/lib/muwu/cli/help/summary +4 -4
  9. data/lib/muwu/cli/help/sync +23 -15
  10. data/lib/muwu/cli/help/view +3 -0
  11. data/lib/muwu/controller/controller.rb +65 -30
  12. data/lib/muwu/controller/controller_interaction.rb +66 -44
  13. data/lib/muwu/default/default.rb +12 -9
  14. data/lib/muwu/destination/destination.rb +61 -57
  15. data/lib/muwu/destination_builder/destination_builder.rb +31 -33
  16. data/lib/muwu/manifest_task_builder/text_item_builder.rb +1 -8
  17. data/lib/muwu/project/project.rb +146 -127
  18. data/lib/muwu/project_builder/assets/config/css/base/html_elements.scss +19 -15
  19. data/lib/muwu/project_builder/assets/config/css/base/mixin_text_section_heading.scss +12 -11
  20. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_contents.scss +5 -5
  21. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_metadata.scss +2 -4
  22. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_navigator.scss +3 -4
  23. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_subcontents.scss +5 -5
  24. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_text.scss +16 -15
  25. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_title.scss +9 -6
  26. data/lib/muwu/project_builder/project_reader.rb +1 -0
  27. data/lib/muwu/project_builder/project_reset_compiled.rb +31 -0
  28. data/lib/muwu/project_builder/project_reset_css.rb +30 -30
  29. data/lib/muwu/project_builder/project_starter.rb +7 -7
  30. data/lib/muwu/project_builder/project_validator.rb +14 -4
  31. data/lib/muwu/project_builder/project_writer.rb +12 -11
  32. data/lib/muwu/project_exception/compiled_folder_not_found.rb +23 -0
  33. data/lib/muwu/project_exception/lynx_not_available.rb +23 -0
  34. data/lib/muwu/project_exception_handler/fatal.rb +10 -9
  35. data/lib/muwu/project_options/project_options.rb +9 -8
  36. data/lib/muwu/project_options_builder/project_option_validator.rb +12 -12
  37. data/lib/muwu/project_options_builder/project_option_validator_value.rb +78 -82
  38. data/lib/muwu/publish/publish.rb +42 -34
  39. data/lib/muwu/render_concat/render_concat.rb +26 -27
  40. data/lib/muwu/render_html/render_html.rb +27 -24
  41. data/lib/muwu/render_html_partial/render_document_html.rb +64 -64
  42. data/lib/muwu/render_html_partial/render_text_item.rb +16 -16
  43. data/lib/muwu/sync/sync.rb +40 -36
  44. data/lib/muwu/var/deflistdiv.rb +0 -0
  45. data/lib/muwu/viewer/viewer.rb +25 -0
  46. data/test/what_no_tests.md +1 -3
  47. metadata +16 -11
@@ -1,16 +1,16 @@
1
1
  module Muwu
2
2
  class DestinationBuilder
3
-
4
-
3
+
4
+
5
5
  include Muwu
6
-
7
-
6
+
7
+
8
8
  attr_accessor(
9
9
  :destination,
10
10
  :project
11
11
  )
12
-
13
-
12
+
13
+
14
14
  def self.build
15
15
  builder = new
16
16
  yield(builder)
@@ -21,24 +21,24 @@ module Muwu
21
21
  def initialize
22
22
  @destination = Destination.new
23
23
  end
24
-
25
-
24
+
25
+
26
26
  def build_css(project)
27
27
  depends_on_project(project)
28
28
  set_output_class
29
29
  set_output_filename_css
30
30
  set_output_working_directory
31
31
  end
32
-
33
-
32
+
33
+
34
34
  def build_html(project, index)
35
35
  depends_on_project(project)
36
36
  set_output_class
37
37
  set_output_filename_html(index)
38
38
  set_output_working_directory
39
39
  end
40
-
41
-
40
+
41
+
42
42
  def build_js(project)
43
43
  depends_on_project(project)
44
44
  set_output_class
@@ -50,13 +50,13 @@ module Muwu
50
50
  def depends_on_project(project)
51
51
  @project = project
52
52
  end
53
-
54
-
53
+
54
+
55
55
  def set_output_class
56
56
  @destination.output_class = @project.output_destination
57
57
  end
58
-
59
-
58
+
59
+
60
60
  def set_output_filename_css
61
61
  if @destination.output_class == 'file'
62
62
  @destination.output_filename = determine_output_filename_css
@@ -69,26 +69,26 @@ module Muwu
69
69
  @destination.output_filename = determine_output_filename_html(index)
70
70
  end
71
71
  end
72
-
73
-
72
+
73
+
74
74
  def set_output_filename_js
75
75
  if @destination.output_class == 'file'
76
76
  @destination.output_filename = determine_output_filename_js
77
77
  end
78
78
  end
79
-
80
-
79
+
80
+
81
81
  def set_output_working_directory
82
82
  if @destination.output_class == 'file'
83
- @destination.output_working_directory = @project.working_directory
83
+ @destination.output_working_directory = @project.path_compiled
84
84
  end
85
85
  end
86
-
87
-
86
+
87
+
88
88
 
89
89
  private
90
-
91
-
90
+
91
+
92
92
  def determine_output_filename_css
93
93
  filename = ''
94
94
  filename.concat @project.css_basename
@@ -106,22 +106,20 @@ module Muwu
106
106
  filename.concat ".html"
107
107
  filename
108
108
  end
109
-
110
-
109
+
110
+
111
111
  def determine_output_filename_js
112
112
  filename = ''
113
113
  filename.concat @project.js_basename
114
114
  filename.concat ".js"
115
115
  filename
116
116
  end
117
-
118
-
117
+
118
+
119
119
  def index_is_integer_greater_than_zero(index)
120
120
  (Integer === index) && (index >= 1)
121
121
  end
122
-
123
-
122
+
123
+
124
124
  end
125
125
  end
126
-
127
-
@@ -153,7 +153,7 @@ module Muwu
153
153
  end
154
154
  end
155
155
 
156
-
156
+ # TODO: This method looks obsolete. Find its references.
157
157
  def determine_source_filename_implicitly
158
158
  # filename = make_filename_implicitly(outline_step)
159
159
  # filepath = make_filepath_implicitly
@@ -259,13 +259,6 @@ module Muwu
259
259
  end
260
260
 
261
261
 
262
- # def make_filename_implicitly(string)
263
- # file_basename = SanitizerHelper.sanitize_text_item_path(string)
264
- # filename = file_basename + '.md'
265
- # filename
266
- # end
267
-
268
-
269
262
  def make_filepath_implicitly
270
263
  path_from_project_home = ['text']
271
264
  if @project.text_block_naming_is_simple
@@ -1,10 +1,10 @@
1
1
  module Muwu
2
2
  class Project
3
-
4
-
3
+
4
+
5
5
  include Muwu
6
6
  include Helper
7
-
7
+
8
8
 
9
9
  attr_accessor(
10
10
  :exceptions,
@@ -17,40 +17,29 @@ module Muwu
17
17
  :slug,
18
18
  :working_directory
19
19
  )
20
-
21
-
20
+
21
+
22
22
  def initialize
23
23
  @exceptions = []
24
24
  @instance_date = Time.now.strftime('%Y-%m-%d')
25
25
  @metadata = {}
26
26
  @outline = []
27
27
  end
28
-
29
-
30
- def inspect
31
- ["#{self.to_s}", "{", inspect_instance_variables, "}"].join(' ')
32
- end
33
-
34
-
35
- def inspect_instance_variables
36
- self.instance_variables.map { |v| "#{v}=#<#{instance_variable_get(v).class}>" }.join(", ")
37
- end
38
-
39
28
 
40
29
 
41
30
  public
42
-
43
-
31
+
32
+
44
33
  def css_manifest_file_does_exist
45
34
  File.exists?(css_manifest_filename) == true
46
35
  end
47
-
48
-
36
+
37
+
49
38
  def css_manifest_filename
50
39
  File.absolute_path(File.join(path_css, 'index.scss'))
51
40
  end
52
-
53
-
41
+
42
+
54
43
  def css_basename
55
44
  if @options.output_file_css_basename.to_s == ''
56
45
  SanitizerHelper::sanitize_destination_file_basename(slug).downcase
@@ -58,40 +47,40 @@ module Muwu
58
47
  SanitizerHelper::sanitize_destination_file_basename(@options.output_file_css_basename).downcase
59
48
  end
60
49
  end
61
-
62
-
50
+
51
+
63
52
  def default_text_block_name
64
53
  Default::PROJECT_OUTLINE[:default_text_block_name]
65
54
  end
66
-
67
-
55
+
56
+
68
57
  def does_not_have_crucial_files
69
- exceptions_include?(ProjectException::MetadataFileNotFound) &&
70
- exceptions_include?(ProjectException::OptionsFileNotFound) &&
71
- exceptions_include?(ProjectException::OutlineFileNotFound)
58
+ metadata_file_does_not_exist &&
59
+ options_file_does_not_exist &&
60
+ outline_file_does_not_exist
72
61
  end
73
62
 
74
63
 
75
64
  def exceptions_add(exception)
76
65
  @exceptions << exception
77
66
  end
78
-
79
-
67
+
68
+
80
69
  def exceptions_fatal
81
70
  @exceptions.select{ |e| e.type == :fatal }
82
71
  end
83
-
84
-
72
+
73
+
85
74
  def exceptions_include?(exception)
86
75
  @exceptions.map{ |e| e.class }.include?(exception)
87
76
  end
88
-
89
-
77
+
78
+
90
79
  def has_multiple_html_documents
91
80
  @manifest.documents_html_count > 1
92
81
  end
93
-
94
-
82
+
83
+
95
84
  def html_basename
96
85
  if @options.output_file_html_basename.to_s == ''
97
86
  SanitizerHelper::sanitize_destination_file_basename('index').downcase
@@ -99,8 +88,18 @@ module Muwu
99
88
  SanitizerHelper::sanitize_destination_file_basename(@options.output_file_html_basename).downcase
100
89
  end
101
90
  end
102
-
103
-
91
+
92
+
93
+ def inspect
94
+ ["#{self.to_s}", "{", inspect_instance_variables, "}"].join(' ')
95
+ end
96
+
97
+
98
+ def inspect_instance_variables
99
+ self.instance_variables.map { |v| "#{v}=#<#{instance_variable_get(v).class}>" }.join(", ")
100
+ end
101
+
102
+
104
103
  def js_basename
105
104
  if @options.output_file_js_basename.to_s == ''
106
105
  SanitizerHelper::sanitize_destination_file_basename(slug).downcase
@@ -108,8 +107,8 @@ module Muwu
108
107
  SanitizerHelper::sanitize_destination_file_basename(@options.output_file_js_basename).downcase
109
108
  end
110
109
  end
111
-
112
-
110
+
111
+
113
112
  def metadata_file_does_exist
114
113
  File.exists?(metadata_filename) == true
115
114
  end
@@ -118,28 +117,28 @@ module Muwu
118
117
  def metadata_file_does_not_exist
119
118
  File.exists?(metadata_filename) == false
120
119
  end
121
-
122
-
120
+
121
+
123
122
  def metadata_filename
124
123
  determine_project_asset_filepath(:metadata)
125
124
  end
126
-
127
-
125
+
126
+
128
127
  def options_file_does_exist
129
128
  File.exists?(options_filename) == true
130
129
  end
131
-
132
-
130
+
131
+
133
132
  def options_file_does_not_exist
134
133
  File.exists?(options_filename) == false
135
134
  end
136
-
137
-
135
+
136
+
138
137
  def options_filename
139
138
  determine_project_asset_filepath(:options)
140
139
  end
141
-
142
-
140
+
141
+
143
142
  def outline_file_does_exist
144
143
  File.exists?(outline_filename) == true
145
144
  end
@@ -148,28 +147,28 @@ module Muwu
148
147
  def outline_file_does_not_exist
149
148
  File.exists?(outline_filename) == false
150
149
  end
151
-
152
-
150
+
151
+
153
152
  def outline_filename
154
153
  determine_project_asset_filepath(:outline)
155
154
  end
156
-
157
-
155
+
156
+
158
157
  def outline_has_more_than_one_document
159
158
  outline_length > 1
160
159
  end
161
-
162
-
160
+
161
+
163
162
  def outline_has_only_one_document
164
163
  outline_length == 1
165
164
  end
166
-
167
-
165
+
166
+
168
167
  def outline_length
169
168
  outline.length
170
169
  end
171
-
172
-
170
+
171
+
173
172
  def outline_text_block_names
174
173
  result = []
175
174
  outline_text_blocks.each do |text_block|
@@ -199,8 +198,8 @@ module Muwu
199
198
  end
200
199
  result
201
200
  end
202
-
203
-
201
+
202
+
204
203
  def outline_text_pathnames
205
204
  @options.outline_text_pathnames
206
205
  end
@@ -209,47 +208,60 @@ module Muwu
209
208
  def outline_text_pathnames_are_explicit
210
209
  @options.outline_text_pathnames == 'explicit'
211
210
  end
212
-
211
+
213
212
 
214
213
  def outline_text_pathnames_are_flexible
215
214
  @options.outline_text_pathnames == 'flexible'
216
215
  end
217
216
 
218
-
217
+
219
218
  def outline_text_pathnames_are_implicit
220
219
  @options.outline_text_pathnames == 'implicit'
221
220
  end
222
-
221
+
223
222
 
224
223
  def outlined_documents
225
224
  @outline
226
225
  end
227
-
228
-
226
+
227
+
229
228
  def outlined_documents_by_index
230
229
  result = {}
231
230
  @outline.each_index do |index|
232
231
  result[index] = @outline[index]
233
- end
232
+ end
234
233
  result
235
234
  end
236
-
237
-
235
+
236
+
238
237
  def output_destination
239
238
  @options.output_destination
240
239
  end
241
-
242
-
240
+
241
+
243
242
  def output_destination_requests_stdout
244
243
  @options.output_destination == 'stdout'
245
244
  end
246
-
247
-
245
+
246
+
248
247
  def output_formats_several
249
248
  @options.output_formats.length > 1
250
249
  end
251
-
252
-
250
+
251
+
252
+
253
+ # TODO: Move path definitions into Muwu::Default::FILEPATHS
254
+
255
+ def path_compiled
256
+ File.absolute_path(File.join(@working_directory, 'compiled'))
257
+ end
258
+
259
+
260
+ def path_compiled_does_exist
261
+ Dir.exists?(path_compiled)
262
+ end
263
+
264
+
253
265
  def path_config
254
266
  File.absolute_path(File.join(@working_directory, 'config'))
255
267
  end
@@ -268,28 +280,31 @@ module Muwu
268
280
  def path_css_colors
269
281
  File.absolute_path(File.join(path_css, 'colors'))
270
282
  end
271
-
272
-
283
+
284
+
273
285
  def path_css_extensions
274
286
  File.absolute_path(File.join(path_css, 'extensions'))
275
287
  end
276
288
 
277
289
 
278
- def path_images
279
- File.absolute_path(File.join(@working_directory, 'images'))
280
- end
281
-
282
-
290
+ # TODO: Broken due to introduction of the `/compiled` folder
291
+ # Keeping it as a comment in case it becomes useful in the future.
292
+ #
293
+ # def path_images
294
+ # File.absolute_path(File.join(@working_directory, 'images'))
295
+ # end
296
+
297
+
283
298
  def path_outline
284
299
  @working_directory
285
300
  end
286
-
287
-
301
+
302
+
288
303
  def path_text
289
304
  File.absolute_path(File.join(@working_directory, 'text'))
290
305
  end
291
-
292
-
306
+
307
+
293
308
  def slug
294
309
  if @metadata.has_key?('slug')
295
310
  @metadata['slug']
@@ -297,8 +312,8 @@ module Muwu
297
312
  working_directory_name
298
313
  end
299
314
  end
300
-
301
-
315
+
316
+
302
317
  def sort_outline_text_blocks
303
318
  result = []
304
319
  outline_text_blocks.each do |text_block|
@@ -306,25 +321,25 @@ module Muwu
306
321
  text_block_contents = determine_text_block_contents(text_block)
307
322
  existing_block = result.select { |b| b.has_key?(text_block_name) }.flatten
308
323
  if existing_block.empty?
309
- result << { text_block_name => text_block_contents }
324
+ result << { text_block_name => text_block_contents }
310
325
  else
311
326
  existing_block[text_block_name].concat(text_block_contents)
312
327
  end
313
328
  end
314
329
  result
315
330
  end
316
-
317
-
331
+
332
+
318
333
  def text_block_naming_is_simple
319
334
  outline_text_block_names == [default_text_block_name]
320
335
  end
321
-
336
+
322
337
 
323
338
  def text_block_naming_is_not_simple
324
339
  text_block_naming_is_simple == false
325
340
  end
326
341
 
327
-
342
+
328
343
  def title
329
344
  if @metadata.has_key?('title')
330
345
  @metadata['title']
@@ -332,55 +347,59 @@ module Muwu
332
347
  working_directory_name
333
348
  end
334
349
  end
335
-
336
-
350
+
351
+
337
352
  def will_create_css_file
338
353
  @options.output_formats.include?('css')
339
354
  end
340
-
341
-
355
+
356
+
342
357
  def will_create_html_file_only
343
358
  @options.output_formats == ['html']
344
359
  end
345
-
346
-
360
+
361
+
347
362
  def will_create_javascript_file
348
363
  if will_require_javascript_libraries
349
364
  @options.output_formats.include?('js')
350
365
  end
351
366
  end
352
-
353
-
367
+
368
+
354
369
  def will_require_javascript_libraries
355
370
  @javascript_libraries_requested.count > 0
356
371
  end
357
-
358
-
372
+
373
+
359
374
  def will_embed_at_least_one_asset
360
375
  will_embed_css || will_embed_js
361
376
  end
362
377
 
363
378
 
379
+ # TODO: What if there's no css to embed?
380
+ # Consider redefining this method.
364
381
  def will_embed_css
365
382
  will_create_css_file == false
366
383
  end
367
-
368
-
384
+
385
+
386
+ # TODO: What if there's no js to embed?
387
+ # Consider redefining this method.
369
388
  def will_embed_js
370
389
  will_create_javascript_file == false
371
390
  end
372
-
373
-
391
+
392
+
374
393
  def will_generate_navigators_automatically
375
394
  (outline_has_more_than_one_document) && (@options.generate_navigators_automatically == true) && (@options.output_destination == 'file')
376
395
  end
377
-
378
-
396
+
397
+
379
398
  def will_generate_subcontents_automatically
380
399
  (outline_has_more_than_one_document) && (@options.generate_subcontents_automatically == true)
381
400
  end
382
-
383
-
401
+
402
+
384
403
  def will_render_section_numbers
385
404
  @options.render_section_numbers == true
386
405
  end
@@ -389,32 +408,32 @@ module Muwu
389
408
  def will_not_generate_navigators_automatically
390
409
  not will_generate_navigators_automatically
391
410
  end
392
-
393
-
411
+
412
+
394
413
  def will_not_generate_subcontents_automatically
395
414
  not will_generate_subcontents_automatically
396
415
  end
397
-
398
-
416
+
417
+
399
418
  def working_directory_name
400
419
  @working_directory.split(File::SEPARATOR)[-1]
401
420
  end
402
-
403
-
421
+
422
+
404
423
 
405
424
  private
406
-
407
-
425
+
426
+
408
427
  def determine_project_asset_filepath(type)
409
428
  File.absolute_path(File.join(@working_directory, Default::FILEPATHS[type], Default::FILENAMES[type]))
410
429
  end
411
430
 
412
-
431
+
413
432
  def determine_text_block_contents(text_block)
414
433
  text_block.flatten[1]
415
434
  end
416
-
417
-
435
+
436
+
418
437
  def determine_text_block_name(text_block)
419
438
  directive = text_block.flatten[0]
420
439
  components = directive.partition(RegexpLib.outline_text_plus_whitespace)
@@ -424,7 +443,7 @@ module Muwu
424
443
  end
425
444
  text_block_name
426
445
  end
427
-
428
-
446
+
447
+
429
448
  end
430
- end
449
+ end