muwu 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. checksums.yaml +7 -0
  2. data/bin/muwu +5 -0
  3. data/lib/muwu.rb +38 -0
  4. data/lib/muwu/cli/cli.rb +143 -0
  5. data/lib/muwu/cli/cli_help.rb +28 -0
  6. data/lib/muwu/cli/help/compile +22 -0
  7. data/lib/muwu/cli/help/concat +8 -0
  8. data/lib/muwu/cli/help/heading +2 -0
  9. data/lib/muwu/cli/help/inspect +7 -0
  10. data/lib/muwu/cli/help/new +8 -0
  11. data/lib/muwu/cli/help/reset +14 -0
  12. data/lib/muwu/cli/help/summary +14 -0
  13. data/lib/muwu/controller/controller.rb +120 -0
  14. data/lib/muwu/controller/controller_interaction.rb +146 -0
  15. data/lib/muwu/default/default.rb +51 -0
  16. data/lib/muwu/destination/destination.rb +212 -0
  17. data/lib/muwu/destination_builder/destination_builder.rb +127 -0
  18. data/lib/muwu/helper/hash_helper.rb +37 -0
  19. data/lib/muwu/helper/html_href_helper.rb +101 -0
  20. data/lib/muwu/helper/outline_helper.rb +160 -0
  21. data/lib/muwu/helper/regexp_lib.rb +101 -0
  22. data/lib/muwu/helper/sanitizer_helper.rb +50 -0
  23. data/lib/muwu/manifest/manifest.rb +158 -0
  24. data/lib/muwu/manifest_builder/manifest_builder.rb +102 -0
  25. data/lib/muwu/manifest_task/contents.rb +42 -0
  26. data/lib/muwu/manifest_task/document_css.rb +25 -0
  27. data/lib/muwu/manifest_task/document_html.rb +69 -0
  28. data/lib/muwu/manifest_task/document_js.rb +25 -0
  29. data/lib/muwu/manifest_task/metadata.rb +35 -0
  30. data/lib/muwu/manifest_task/navigator.rb +29 -0
  31. data/lib/muwu/manifest_task/subcontents.rb +48 -0
  32. data/lib/muwu/manifest_task/text.rb +51 -0
  33. data/lib/muwu/manifest_task/text_item.rb +124 -0
  34. data/lib/muwu/manifest_task/title.rb +34 -0
  35. data/lib/muwu/manifest_task_builder/contents_builder.rb +88 -0
  36. data/lib/muwu/manifest_task_builder/document_css_builder.rb +63 -0
  37. data/lib/muwu/manifest_task_builder/document_html_builder.rb +210 -0
  38. data/lib/muwu/manifest_task_builder/document_js_builder.rb +69 -0
  39. data/lib/muwu/manifest_task_builder/metadata_builder.rb +118 -0
  40. data/lib/muwu/manifest_task_builder/navigator_builder.rb +78 -0
  41. data/lib/muwu/manifest_task_builder/subcontents_builder.rb +90 -0
  42. data/lib/muwu/manifest_task_builder/text_builder.rb +125 -0
  43. data/lib/muwu/manifest_task_builder/text_item_builder.rb +314 -0
  44. data/lib/muwu/manifest_task_builder/title_builder.rb +122 -0
  45. data/lib/muwu/project/project.rb +430 -0
  46. data/lib/muwu/project_builder/assets/config/css/base/html_elements.scss +138 -0
  47. data/lib/muwu/project_builder/assets/config/css/base/index.scss +11 -0
  48. data/lib/muwu/project_builder/assets/config/css/base/mixin_text_section_heading.scss +23 -0
  49. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_contents.scss +58 -0
  50. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_metadata.scss +17 -0
  51. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_navigator.scss +13 -0
  52. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_subcontents.scss +58 -0
  53. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_text.scss +48 -0
  54. data/lib/muwu/project_builder/assets/config/css/base/section_muwu_title.scss +22 -0
  55. data/lib/muwu/project_builder/assets/config/css/colors/dark.scss +32 -0
  56. data/lib/muwu/project_builder/assets/config/css/colors/index.scss +1 -0
  57. data/lib/muwu/project_builder/assets/config/css/colors/light.scss +34 -0
  58. data/lib/muwu/project_builder/assets/config/css/extensions/index.scss +1 -0
  59. data/lib/muwu/project_builder/assets/config/css/index.scss +19 -0
  60. data/lib/muwu/project_builder/assets/config/css_debugger/debug_section_text.scss +27 -0
  61. data/lib/muwu/project_builder/project_reader.rb +144 -0
  62. data/lib/muwu/project_builder/project_reset_css.rb +95 -0
  63. data/lib/muwu/project_builder/project_starter.rb +27 -0
  64. data/lib/muwu/project_builder/project_validator.rb +157 -0
  65. data/lib/muwu/project_builder/project_writer.rb +127 -0
  66. data/lib/muwu/project_exception/css_manifest_file_not_found.rb +23 -0
  67. data/lib/muwu/project_exception/dry_output_recommended_with_multiple_documents.rb +19 -0
  68. data/lib/muwu/project_exception/metadata_file_not_found.rb +24 -0
  69. data/lib/muwu/project_exception/metadata_value_not_given.rb +42 -0
  70. data/lib/muwu/project_exception/multiple_documents_outlined_with_stdout.rb +18 -0
  71. data/lib/muwu/project_exception/multiple_formats_requested_with_stdout.rb +18 -0
  72. data/lib/muwu/project_exception/navigator_not_recommended_with_stdout.rb +23 -0
  73. data/lib/muwu/project_exception/navigators_will_be_generated_automatically.rb +23 -0
  74. data/lib/muwu/project_exception/option_key_not_understood.rb +23 -0
  75. data/lib/muwu/project_exception/option_not_validatable.rb +23 -0
  76. data/lib/muwu/project_exception/option_value_not_understood.rb +24 -0
  77. data/lib/muwu/project_exception/options_file_not_found.rb +24 -0
  78. data/lib/muwu/project_exception/outline_file_not_found.rb +24 -0
  79. data/lib/muwu/project_exception/outline_step_not_understood.rb +23 -0
  80. data/lib/muwu/project_exception/output_already_open.rb +18 -0
  81. data/lib/muwu/project_exception/output_not_open.rb +18 -0
  82. data/lib/muwu/project_exception/subcontents_will_be_generated_automatically copy.rb +23 -0
  83. data/lib/muwu/project_exception/target_project_folder_already_exists.rb +24 -0
  84. data/lib/muwu/project_exception/text_source_file_not_found.rb +26 -0
  85. data/lib/muwu/project_exception_handler/fatal.rb +39 -0
  86. data/lib/muwu/project_options/project_options.rb +54 -0
  87. data/lib/muwu/project_options_builder/project_option_validator.rb +37 -0
  88. data/lib/muwu/project_options_builder/project_option_validator_key.rb +56 -0
  89. data/lib/muwu/project_options_builder/project_option_validator_value.rb +300 -0
  90. data/lib/muwu/project_options_builder/project_options_reader.rb +80 -0
  91. data/lib/muwu/render_concat/render_concat.rb +80 -0
  92. data/lib/muwu/render_html/render_html.rb +101 -0
  93. data/lib/muwu/render_html/render_markup_to_html.rb +87 -0
  94. data/lib/muwu/render_html_builder/render_css_builder.rb +34 -0
  95. data/lib/muwu/render_html_builder/render_html_builder.rb +34 -0
  96. data/lib/muwu/render_html_builder/render_js_builder.rb +34 -0
  97. data/lib/muwu/render_html_partial/js_library/_init_bare.js +7 -0
  98. data/lib/muwu/render_html_partial/js_library/_zepto.min.js +2 -0
  99. data/lib/muwu/render_html_partial/js_library/init.js +10 -0
  100. data/lib/muwu/render_html_partial/js_library/navigation.js +140 -0
  101. data/lib/muwu/render_html_partial/render_contents.rb +369 -0
  102. data/lib/muwu/render_html_partial/render_document_css.rb +45 -0
  103. data/lib/muwu/render_html_partial/render_document_html.rb +397 -0
  104. data/lib/muwu/render_html_partial/render_document_js.rb +37 -0
  105. data/lib/muwu/render_html_partial/render_js_library.rb +54 -0
  106. data/lib/muwu/render_html_partial/render_metadata.rb +120 -0
  107. data/lib/muwu/render_html_partial/render_navigator.rb +136 -0
  108. data/lib/muwu/render_html_partial/render_subcontents.rb +374 -0
  109. data/lib/muwu/render_html_partial/render_text.rb +74 -0
  110. data/lib/muwu/render_html_partial/render_text_item.rb +230 -0
  111. data/lib/muwu/render_html_partial/render_title.rb +71 -0
  112. data/lib/muwu/render_html_partial_builder/render_contents_builder.rb +100 -0
  113. data/lib/muwu/render_html_partial_builder/render_document_css_builder.rb +46 -0
  114. data/lib/muwu/render_html_partial_builder/render_document_html_builder.rb +211 -0
  115. data/lib/muwu/render_html_partial_builder/render_document_js_builder.rb +52 -0
  116. data/lib/muwu/render_html_partial_builder/render_metadata_builder.rb +47 -0
  117. data/lib/muwu/render_html_partial_builder/render_navigator_builder.rb +74 -0
  118. data/lib/muwu/render_html_partial_builder/render_subcontents_builder.rb +85 -0
  119. data/lib/muwu/render_html_partial_builder/render_text_builder.rb +86 -0
  120. data/lib/muwu/render_html_partial_builder/render_text_item_builder.rb +274 -0
  121. data/lib/muwu/render_html_partial_builder/render_title_builder.rb +47 -0
  122. data/lib/muwu/render_inspector/render_inspector.rb +224 -0
  123. data/lib/muwu/var/deflistdiv.rb +239 -0
  124. data/lib/muwu_loader.rb +35 -0
  125. data/test/what_no_tests.md +5 -0
  126. metadata +251 -0
@@ -0,0 +1,102 @@
1
+ module Muwu
2
+ class ManifestBuilder
3
+
4
+
5
+ include Muwu
6
+
7
+
8
+ attr_accessor(
9
+ :manifest,
10
+ :project
11
+ )
12
+
13
+
14
+ def self.build
15
+ builder = new
16
+ yield(builder)
17
+ builder.manifest
18
+ end
19
+
20
+
21
+ def initialize
22
+ @manifest = Manifest.new
23
+ end
24
+
25
+
26
+ def build_from_project(project)
27
+ @project = project
28
+ set_documents
29
+ set_project
30
+ end
31
+
32
+
33
+ def set_documents
34
+ @manifest.documents = determine_documents
35
+ end
36
+
37
+
38
+ def set_project
39
+ @manifest.project = @project
40
+ end
41
+
42
+
43
+
44
+ private
45
+
46
+
47
+ def build_document_css
48
+ ManifestTaskBuilders::DocumentCssBuilder.build do |b|
49
+ b.build_document(@project)
50
+ end
51
+ end
52
+
53
+
54
+ def build_document_html(index, outline_fragment_document)
55
+ ManifestTaskBuilders::DocumentHtmlBuilder.build do |b|
56
+ b.build_document(@project, index, outline_fragment_document)
57
+ end
58
+ end
59
+
60
+
61
+ def build_document_js
62
+ ManifestTaskBuilders::DocumentJsBuilder.build do |b|
63
+ b.build_document(@project)
64
+ end
65
+ end
66
+
67
+
68
+ def determine_documents
69
+ documents = []
70
+ documents << determine_documents_html
71
+ documents << determine_documents_js
72
+ documents << determine_documents_css
73
+ documents.compact!
74
+ documents.flatten
75
+ end
76
+
77
+
78
+ def determine_documents_css
79
+ if @project.will_create_css_file
80
+ build_document_css
81
+ end
82
+ end
83
+
84
+
85
+ def determine_documents_js
86
+ if @project.will_create_javascript_file
87
+ build_document_js
88
+ end
89
+ end
90
+
91
+
92
+ def determine_documents_html
93
+ documents = []
94
+ @project.outlined_documents_by_index.each_pair do |index, contents|
95
+ documents << build_document_html(index, contents)
96
+ end
97
+ documents
98
+ end
99
+
100
+
101
+ end
102
+ end
@@ -0,0 +1,42 @@
1
+ module Muwu
2
+ module ManifestTask
3
+ class Contents
4
+
5
+
6
+ attr_accessor(
7
+ :destination,
8
+ :item_depth_max,
9
+ :parent,
10
+ :project,
11
+ :section_number_max_depth,
12
+ :text_root_name,
13
+ :will_render_section_numbers
14
+ )
15
+
16
+
17
+ def inspect
18
+ ["#{self.to_s}", "{", inspect_instance_variables, "}"].join(' ')
19
+ end
20
+
21
+
22
+ def inspect_instance_variables
23
+ self.instance_variables.map { |v| "#{v}=#<#{instance_variable_get(v).class}>" }.join(", ")
24
+ end
25
+
26
+
27
+ public
28
+
29
+
30
+ def naming
31
+ [@text_root_name]
32
+ end
33
+
34
+
35
+ def text_blocks_by_name(name)
36
+ @project.manifest.text_blocks_by_name(name)
37
+ end
38
+
39
+
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,25 @@
1
+ module Muwu
2
+ module ManifestTask
3
+ class DocumentCss
4
+
5
+
6
+ attr_accessor(
7
+ :destination,
8
+ :libraries,
9
+ :project
10
+ )
11
+
12
+
13
+ def inspect
14
+ ["#{self.to_s}", "{", inspect_instance_variables, "}"].join(' ')
15
+ end
16
+
17
+
18
+ def inspect_instance_variables
19
+ self.instance_variables.map { |v| "#{v}=#<#{instance_variable_get(v).class}>" }.join(", ")
20
+ end
21
+
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,69 @@
1
+ module Muwu
2
+ module ManifestTask
3
+ class DocumentHtml
4
+
5
+
6
+ attr_accessor(
7
+ :destination,
8
+ :css_filename,
9
+ :css_include_method,
10
+ :filename,
11
+ :index,
12
+ :js_filename,
13
+ :js_include_method,
14
+ :js_head_libraries,
15
+ :project,
16
+ :tasks
17
+ )
18
+
19
+
20
+ def inspect
21
+ ["#{self.to_s}", "{", inspect_instance_variables, "}"].join(' ')
22
+ end
23
+
24
+
25
+ def inspect_instance_variables
26
+ self.instance_variables.map { |v| "#{v}=#<#{instance_variable_get(v).class}>" }.join(", ")
27
+ end
28
+
29
+
30
+ public
31
+
32
+
33
+ def contents_blocks
34
+ @tasks.select { |task| ManifestTask::Contents === task }
35
+ end
36
+
37
+
38
+ def contents_blocks_by_name(text_root_name)
39
+ contents_blocks.select { |task| task.text_root_name.downcase == text_root_name.downcase }
40
+ end
41
+
42
+
43
+ def text_blocks
44
+ @tasks.select { |task| ManifestTask::Text === task }
45
+ end
46
+
47
+
48
+ def text_blocks_by_name(text_root_name)
49
+ text_blocks.select { |task| task.text_root_name.strip.downcase == text_root_name.strip.downcase }
50
+ end
51
+
52
+
53
+ def will_generate_subcontents_automatically
54
+ if @project.options.generate_subcontents_automatically
55
+ return text_blocks.any? && contents_blocks.empty?
56
+ else
57
+ return false
58
+ end
59
+ end
60
+
61
+
62
+
63
+ public
64
+
65
+
66
+
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,25 @@
1
+ module Muwu
2
+ module ManifestTask
3
+ class DocumentJs
4
+
5
+
6
+ attr_accessor(
7
+ :destination,
8
+ :libraries,
9
+ :project
10
+ )
11
+
12
+
13
+ def inspect
14
+ ["#{self.to_s}", "{", inspect_instance_variables, "}"].join(' ')
15
+ end
16
+
17
+
18
+ def inspect_instance_variables
19
+ self.instance_variables.map { |v| "#{v}=#<#{instance_variable_get(v).class}>" }.join(", ")
20
+ end
21
+
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,35 @@
1
+ module Muwu
2
+ module ManifestTask
3
+ class Metadata
4
+
5
+
6
+ attr_accessor(
7
+ :destination,
8
+ :metadata,
9
+ :parent_document,
10
+ :project
11
+ )
12
+
13
+
14
+ def inspect
15
+ ["#{self.to_s}", "{", inspect_instance_variables, "}"].join(' ')
16
+ end
17
+
18
+
19
+ def inspect_instance_variables
20
+ self.instance_variables.map { |v| "#{v}=#<#{instance_variable_get(v).class}>" }.join(", ")
21
+ end
22
+
23
+
24
+
25
+ public
26
+
27
+
28
+ def document_index
29
+ @parent_document.index
30
+ end
31
+
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,29 @@
1
+ module Muwu
2
+ module ManifestTask
3
+ class Navigator
4
+
5
+
6
+ attr_accessor(
7
+ :destination,
8
+ :document_home_index,
9
+ :document_next_index,
10
+ :document_prev_index,
11
+ :heading,
12
+ :index,
13
+ :project
14
+ )
15
+
16
+
17
+ def inspect
18
+ ["#{self.to_s}", "{", inspect_instance_variables, "}"].join(' ')
19
+ end
20
+
21
+
22
+ def inspect_instance_variables
23
+ self.instance_variables.map { |v| "#{v}=#<#{instance_variable_get(v).class}>" }.join(", ")
24
+ end
25
+
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,48 @@
1
+ module Muwu
2
+ module ManifestTask
3
+ class Subcontents
4
+
5
+
6
+ attr_accessor(
7
+ :destination,
8
+ :item_depth_max,
9
+ :parent,
10
+ :project,
11
+ :section_number_max_depth,
12
+ :text_root_name,
13
+ :will_render_section_numbers
14
+ )
15
+
16
+
17
+ def inspect
18
+ ["#{self.to_s}", "{", inspect_instance_variables, "}"].join(' ')
19
+ end
20
+
21
+
22
+ def inspect_instance_variables
23
+ self.instance_variables.map { |v| "#{v}=#<#{instance_variable_get(v).class}>" }.join(", ")
24
+ end
25
+
26
+
27
+
28
+ public
29
+
30
+
31
+ def document
32
+ @parent
33
+ end
34
+
35
+
36
+ def naming
37
+ [@text_root_name]
38
+ end
39
+
40
+
41
+ def text_root_blocks
42
+ document.text_blocks_by_name(@text_root_name)
43
+ end
44
+
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,51 @@
1
+ module Muwu
2
+ module ManifestTask
3
+ class Text
4
+
5
+
6
+ attr_accessor(
7
+ :destination,
8
+ :naming,
9
+ :numbering,
10
+ :project,
11
+ :sections
12
+ )
13
+
14
+
15
+ def inspect
16
+ ["#{self.to_s}", "{", inspect_instance_variables, "}"].join(' ')
17
+ end
18
+
19
+
20
+ def inspect_instance_variables
21
+ self.instance_variables.map { |v| "#{v}=#<#{instance_variable_get(v).class}>" }.join(", ")
22
+ end
23
+
24
+
25
+
26
+ public
27
+
28
+
29
+ def naming_downcase
30
+ @naming.map {|n| n.downcase}
31
+ end
32
+
33
+
34
+ def naming_downcase_without_text_root
35
+ naming_without_text_root.map {|n| n.downcase}
36
+ end
37
+
38
+
39
+ def naming_without_text_root
40
+ @naming[1..-1]
41
+ end
42
+
43
+
44
+ def text_root_name
45
+ @naming[0]
46
+ end
47
+
48
+
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,124 @@
1
+ module Muwu
2
+ module ManifestTask
3
+ class TextItem
4
+
5
+
6
+ include Muwu
7
+
8
+
9
+ attr_accessor(
10
+ :destination,
11
+ :heading,
12
+ :heading_origin,
13
+ :naming,
14
+ :numbering,
15
+ :outline,
16
+ :project,
17
+ :sections,
18
+ :source_filename
19
+ )
20
+
21
+
22
+ def inspect
23
+ ["#{self.to_s}", "{", inspect_instance_variables, "}"].join(' ')
24
+ end
25
+
26
+
27
+ def inspect_instance_variables
28
+ self.instance_variables.map { |v| "#{v}=#<#{instance_variable_get(v).class}>" }.join(", ")
29
+ end
30
+
31
+
32
+
33
+ public
34
+
35
+
36
+ def does_have_child_sections
37
+ is_parent_heading && (@sections.length >= 1)
38
+ end
39
+
40
+
41
+ def is_not_parent_heading
42
+ is_parent_heading == false
43
+ end
44
+
45
+
46
+ def is_parent_heading
47
+ Array === @sections
48
+ end
49
+
50
+
51
+ def naming_downcase
52
+ @naming.map {|n| n.downcase}
53
+ end
54
+
55
+
56
+ def naming_downcase_without_text_root
57
+ naming_without_text_root.map {|n| n.downcase}
58
+ end
59
+
60
+
61
+ def naming_without_text_root
62
+ @naming[1..-1]
63
+ end
64
+
65
+
66
+ def numbering_to_depth_max
67
+ # using a truthy conditional because the option could be an integer, nil, or a boolean false
68
+ if @project.options.render_sections_distinctly_depth_max
69
+ index_min = 0
70
+ index_max = @project.options.render_sections_distinctly_depth_max - 1
71
+ if index_max >= index_min
72
+ @numbering[index_min..index_max]
73
+ else # fallback to @numbering so code doesn't break
74
+ @numbering
75
+ end
76
+ else
77
+ @numbering
78
+ end
79
+ end
80
+
81
+
82
+ def project_directory
83
+ @project.working_directory
84
+ end
85
+
86
+
87
+ def section_depth
88
+ @numbering.length
89
+ end
90
+
91
+
92
+ def source
93
+ File.read(source_filename_absolute)
94
+ end
95
+
96
+
97
+ def source_file_does_exist
98
+ File.exist?(source_filename_absolute) == true
99
+ end
100
+
101
+
102
+ def source_file_does_not_exist
103
+ File.exist?(source_filename_absolute) == false
104
+ end
105
+
106
+
107
+ def source_filename_absolute
108
+ File.absolute_path(File.join(project_directory, source_filename))
109
+ end
110
+
111
+
112
+ def source_filename_relative
113
+ source_filename
114
+ end
115
+
116
+
117
+ def text_root_name
118
+ @naming[0]
119
+ end
120
+
121
+
122
+ end
123
+ end
124
+ end