muwu 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
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,34 @@
1
+ module Muwu
2
+ module ManifestTask
3
+ class Title
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
+ public
25
+
26
+
27
+ def document_index
28
+ @parent_document.index
29
+ end
30
+
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,88 @@
1
+ module Muwu
2
+ module ManifestTaskBuilders
3
+ class ContentsBuilder
4
+
5
+
6
+ include Muwu
7
+ include Helper
8
+
9
+
10
+ attr_accessor(
11
+ :outline_contents,
12
+ :parent_document,
13
+ :task
14
+ )
15
+
16
+
17
+ def self.build
18
+ builder = new
19
+ yield(builder)
20
+ builder.task
21
+ end
22
+
23
+
24
+ def initialize
25
+ @task = ManifestTask::Contents.new
26
+ end
27
+
28
+
29
+ def build_from_outline(outline_step, parent_document)
30
+ @outline_contents = outline_step
31
+ @parent_document = parent_document
32
+ @project = parent_document.project
33
+ phase_1_set_parent
34
+ phase_1_set_project
35
+ phase_2_set_destination
36
+ phase_2_set_text_root_name
37
+ phase_3_set_item_depth_max
38
+ phase_3_set_will_render_section_numbers
39
+ end
40
+
41
+
42
+ def phase_1_set_parent
43
+ @task.parent = @parent_document
44
+ end
45
+
46
+
47
+ def phase_1_set_project
48
+ @task.project = @project
49
+ end
50
+
51
+
52
+ def phase_2_set_destination
53
+ @task.destination = @parent_document.destination
54
+ end
55
+
56
+
57
+ def phase_2_set_text_root_name
58
+ @task.text_root_name = determine_text_root_name
59
+ end
60
+
61
+
62
+ def phase_3_set_item_depth_max
63
+ @task.item_depth_max = @project.options.render_sections_distinctly_depth_max
64
+ end
65
+
66
+
67
+ def phase_3_set_will_render_section_numbers
68
+ @task.will_render_section_numbers = @project.options.render_section_numbers
69
+ end
70
+
71
+
72
+
73
+ private
74
+
75
+
76
+ def determine_text_root_name
77
+ components = @outline_contents.partition(RegexpLib.outline_text_plus_whitespace)
78
+ text_block_name = components[2].to_s.downcase.strip
79
+ if text_block_name == ''
80
+ text_block_name = @project.default_text_block_name
81
+ end
82
+ text_block_name
83
+ end
84
+
85
+
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,63 @@
1
+ module Muwu
2
+ module ManifestTaskBuilders
3
+ class DocumentCssBuilder
4
+
5
+
6
+ include Muwu
7
+
8
+
9
+ attr_accessor(
10
+ :document,
11
+ :outline,
12
+ :project
13
+ )
14
+
15
+
16
+ def self.build
17
+ builder = new
18
+ yield(builder)
19
+ builder.document
20
+ end
21
+
22
+
23
+ def initialize
24
+ @document = ManifestTask::DocumentCss.new
25
+ end
26
+
27
+
28
+ def build_document(project)
29
+ depends_on_project(project)
30
+ set_destination
31
+ set_project
32
+ end
33
+
34
+
35
+ def depends_on_project(project)
36
+ @project = project
37
+ end
38
+
39
+
40
+ def set_destination
41
+ @document.destination = build_destination
42
+ end
43
+
44
+
45
+ def set_project
46
+ @document.project = @project
47
+ end
48
+
49
+
50
+
51
+ private
52
+
53
+
54
+ def build_destination
55
+ DestinationBuilder.build do |b|
56
+ b.build_css(@project)
57
+ end
58
+ end
59
+
60
+
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,210 @@
1
+ module Muwu
2
+ module ManifestTaskBuilders
3
+ class DocumentHtmlBuilder
4
+
5
+
6
+ include Muwu
7
+ include Helper
8
+
9
+
10
+ attr_accessor(
11
+ :document,
12
+ :index,
13
+ :outline,
14
+ :project,
15
+ :validator
16
+ )
17
+
18
+
19
+ def self.build
20
+ builder = new
21
+ yield(builder)
22
+ builder.document
23
+ end
24
+
25
+
26
+ def initialize
27
+ @document = ManifestTask::DocumentHtml.new
28
+ end
29
+
30
+
31
+ def build_document(project, index, outline_fragment_document)
32
+ @index = index
33
+ @outline = outline_fragment_document
34
+ @project = project
35
+ @validator = ProjectValidator.new(@project)
36
+ set_destination
37
+ set_index
38
+ set_css_filename_and_include_method
39
+ set_js_filename_and_include_method
40
+ set_js_libraries
41
+ set_project
42
+ set_tasks
43
+ end
44
+
45
+
46
+ def set_css_filename_and_include_method
47
+ if @project.will_create_css_file
48
+ @document.css_filename = @project.css_basename + '.css'
49
+ @document.css_include_method = :link
50
+ else
51
+ @document.css_include_method = :embed
52
+ end
53
+ end
54
+
55
+
56
+ def set_destination
57
+ @document.destination = build_destination
58
+ end
59
+
60
+
61
+ def set_index
62
+ @document.index = @index
63
+ end
64
+
65
+
66
+ def set_js_filename_and_include_method
67
+ if @project.will_require_javascript_libraries
68
+ if @project.will_create_javascript_file
69
+ @document.js_filename = @project.js_basename + '.js'
70
+ @document.js_include_method = :link
71
+ else
72
+ @document.js_include_method = :embed
73
+ end
74
+ else
75
+ @document.js_include_method = :none
76
+ end
77
+ end
78
+
79
+
80
+ def set_js_libraries
81
+ if @document.js_include_method == :embed
82
+ @document.js_head_libraries = @project.javascript_libraries_requested
83
+ end
84
+ end
85
+
86
+
87
+ def set_project
88
+ @document.project = @project
89
+ end
90
+
91
+
92
+ def set_tasks
93
+ @document.tasks = determine_tasks
94
+ generate_subcontents_per_options
95
+ generate_navigators_per_options
96
+ end
97
+
98
+
99
+
100
+ private
101
+
102
+
103
+ def build_destination
104
+ DestinationBuilder.build do |b|
105
+ b.build_html(@project, @index)
106
+ end
107
+ end
108
+
109
+
110
+ def build_task_contents(outline_step)
111
+ ManifestTaskBuilders::ContentsBuilder.build do |b|
112
+ b.build_from_outline(outline_step, @document)
113
+ end
114
+ end
115
+
116
+
117
+ def build_task_metadata(outline_step)
118
+ ManifestTaskBuilders::MetadataBuilder.build do |b|
119
+ b.build_from_outline(outline_step, @document)
120
+ end
121
+ end
122
+
123
+
124
+ def build_task_navigator
125
+ ManifestTaskBuilders::NavigatorBuilder.build do |b|
126
+ b.build_from_outline(@document)
127
+ end
128
+ end
129
+
130
+
131
+ def build_task_subcontents(outline_step: 'subcontents')
132
+ ManifestTaskBuilders::SubcontentsBuilder.build do |b|
133
+ b.build_from_document(outline_step, @document)
134
+ end
135
+ end
136
+
137
+
138
+ def build_task_text(outline_step)
139
+ ManifestTaskBuilders::TextBuilder.build do |b|
140
+ b.build_from_outline(outline_step, @document)
141
+ end
142
+ end
143
+
144
+
145
+ def build_task_title(outline_step)
146
+ ManifestTaskBuilders::TitleBuilder.build do |b|
147
+ b.build_from_outline(outline_step, @document)
148
+ end
149
+ end
150
+
151
+
152
+ def determine_tasks
153
+ tasks = []
154
+ @outline.each do |step|
155
+
156
+ case OutlineHelper.type_of(step)
157
+ when :contents
158
+ tasks << build_task_contents(step)
159
+
160
+ when :metadata
161
+ tasks << build_task_metadata(step)
162
+
163
+ when :navigator
164
+ if @validator.validate_outline_step_navigator(@index)
165
+ tasks << build_task_navigator
166
+ end
167
+
168
+ when :subcontents
169
+ if @validator.validate_outline_step_subcontents(@index)
170
+ tasks << build_task_subcontents(outline_step: step)
171
+ end
172
+
173
+ when :text
174
+ tasks << build_task_text(step)
175
+
176
+ when :title
177
+ tasks << build_task_title(step)
178
+
179
+ else
180
+ @project.exceptions_add ProjectException::OutlineStepNotUnderstood.new(step)
181
+
182
+ end
183
+ end
184
+ tasks
185
+ end
186
+
187
+
188
+ def generate_navigators_per_options
189
+ if @project.will_generate_navigators_automatically
190
+ @document.tasks.prepend(build_task_navigator)
191
+ @document.tasks.append(build_task_navigator)
192
+ end
193
+ end
194
+
195
+
196
+ def generate_subcontents_per_options
197
+ if @document.will_generate_subcontents_automatically
198
+ @document.tasks.prepend(build_task_subcontents)
199
+ end
200
+ end
201
+
202
+
203
+ def outline_fragment_includes_navigator
204
+ OutlineHelper.new(@outline).includes_navigator
205
+ end
206
+
207
+
208
+ end
209
+ end
210
+ end
@@ -0,0 +1,69 @@
1
+ module Muwu
2
+ module ManifestTaskBuilders
3
+ class DocumentJsBuilder
4
+
5
+
6
+ include Muwu
7
+
8
+
9
+ attr_accessor(
10
+ :document,
11
+ :outline,
12
+ :project
13
+ )
14
+
15
+
16
+ def self.build
17
+ builder = new
18
+ yield(builder)
19
+ builder.document
20
+ end
21
+
22
+
23
+ def initialize
24
+ @document = ManifestTask::DocumentJs.new
25
+ end
26
+
27
+
28
+ def build_document(project)
29
+ depends_on_project(project)
30
+ set_destination
31
+ set_libraries
32
+ set_project
33
+ end
34
+
35
+
36
+ def depends_on_project(project)
37
+ @project = project
38
+ end
39
+
40
+
41
+ def set_destination
42
+ @document.destination = build_destination
43
+ end
44
+
45
+
46
+ def set_libraries
47
+ @document.libraries = @project.javascript_libraries_requested
48
+ end
49
+
50
+
51
+ def set_project
52
+ @document.project = @project
53
+ end
54
+
55
+
56
+
57
+ private
58
+
59
+
60
+ def build_destination
61
+ DestinationBuilder.build do |b|
62
+ b.build_js(@project)
63
+ end
64
+ end
65
+
66
+
67
+ end
68
+ end
69
+ end