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,127 @@
1
+ module Muwu
2
+ class ProjectWriter
3
+
4
+
5
+ include Muwu
6
+ include Helper
7
+
8
+
9
+ require 'fileutils'
10
+ require 'yaml'
11
+
12
+
13
+ attr_accessor(
14
+ :project
15
+ )
16
+
17
+
18
+ def initialize(project)
19
+ @project = project
20
+ end
21
+
22
+
23
+ public
24
+
25
+
26
+ def write
27
+ if Dir.exist?(@project.working_directory) == false
28
+ puts '# Writing project'
29
+ phase_1_make_project_folder
30
+ phase_2_make_project_subfolders
31
+ phase_2_make_folder_css_and_copy_files
32
+ phase_3_write_file_metadata_yml
33
+ phase_3_write_file_options_yml
34
+ phase_3_write_file_outline_yml
35
+ puts "\n"
36
+ puts '# Project written.'
37
+
38
+ elsif Dir.exist?(@project.working_directory) == true
39
+ raise ProjectExceptionHandler::Fatal.new(ProjectException::TargetProjectFolderAlreadyExists.new(@project))
40
+
41
+ end
42
+ end
43
+
44
+
45
+ def phase_1_make_project_folder
46
+ announce_and_execute_dir_mkdir(@project.working_directory)
47
+ end
48
+
49
+
50
+ def phase_2_make_project_subfolders
51
+ announce_and_execute_dir_mkdir(@project.path_config)
52
+ announce_and_execute_dir_mkdir(@project.path_images)
53
+ announce_and_execute_dir_mkdir(@project.path_text)
54
+ end
55
+
56
+
57
+ def phase_2_make_folder_css_and_copy_files
58
+ folder_source_gem = File.absolute_path(File.join(Muwu::GEM_HOME_LIB, 'muwu','project_builder','assets','config','css'))
59
+ folder_destination_project = @project.path_css
60
+ announce_and_execute_fileutils_cp_r(folder_source_gem, folder_destination_project)
61
+ end
62
+
63
+
64
+ def phase_3_write_file_metadata_yml
65
+ announce_and_execute_yaml_dump(HashHelper.human_readable_hash(@project.metadata), @project.metadata_filename)
66
+ end
67
+
68
+
69
+ def phase_3_write_file_options_yml
70
+ announce_and_execute_yaml_dump(HashHelper.human_readable_hash(@project.options), @project.options_filename)
71
+ end
72
+
73
+
74
+
75
+ def phase_3_write_file_outline_yml
76
+ if @project.outline.any?
77
+ phase_3_write_file_outline_yml_dump
78
+ elsif @project.outline.empty?
79
+ phase_3_write_file_outline_yml_blank
80
+ end
81
+ end
82
+
83
+
84
+ def phase_3_write_file_outline_yml_dump
85
+ announce_and_execute_yaml_dump(@project.outline, @project.outline_filename)
86
+ end
87
+
88
+
89
+ def phase_3_write_file_outline_yml_blank
90
+ announce_and_execute_fileutils_touch(@project.outline_filename)
91
+ end
92
+
93
+
94
+
95
+ private
96
+
97
+
98
+ def announce_and_execute_dir_mkdir(dir)
99
+ print "- Making directory".ljust(18)
100
+ puts " `#{dir}`"
101
+ Dir.mkdir(dir)
102
+ end
103
+
104
+
105
+ def announce_and_execute_fileutils_cp_r(folder_source_gem, folder_destination_project)
106
+ print "- Writing tree".ljust(18)
107
+ puts " `#{folder_destination_project}`"
108
+ FileUtils.cp_r(folder_source_gem, folder_destination_project)
109
+ end
110
+
111
+
112
+ def announce_and_execute_fileutils_touch(filename)
113
+ print "- Writing file".ljust(18)
114
+ puts " `#{filename}`"
115
+ FileUtils.touch(filename)
116
+ end
117
+
118
+
119
+ def announce_and_execute_yaml_dump(obj, filename)
120
+ print "- Writing file".ljust(18)
121
+ puts " `#{filename}`"
122
+ File.open(filename,'w') { |file| YAML.dump(obj, file, canonical: false) }
123
+ end
124
+
125
+
126
+ end
127
+ end
@@ -0,0 +1,23 @@
1
+ module Muwu
2
+ module ProjectException
3
+ class CssManifestFileNotFound
4
+
5
+
6
+ def initialize(css_manifest_filename)
7
+ @css_manifest_filename = css_manifest_filename
8
+ end
9
+
10
+
11
+ def report
12
+ "The css manifest file `#{@css_manifest_filename}` could not be found."
13
+ end
14
+
15
+
16
+ def type
17
+ :warning
18
+ end
19
+
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ module Muwu
2
+ module ProjectException
3
+ class DryOutputRecommendedWithMultipleDocuments
4
+
5
+
6
+ def report
7
+ "Shared assets will be embedded. Including `css` and `js` in `output_formats` is recommended with multiple documents."
8
+ end
9
+
10
+
11
+ def type
12
+ :warning
13
+ end
14
+
15
+
16
+ end
17
+ end
18
+ end
19
+
@@ -0,0 +1,24 @@
1
+ module Muwu
2
+ module ProjectException
3
+ class MetadataFileNotFound
4
+
5
+
6
+
7
+ def initialize(project)
8
+ @filename = project.metadata_filename
9
+ end
10
+
11
+
12
+ def report
13
+ "The metadata file `#{@filename}` could not be found."
14
+ end
15
+
16
+
17
+ def type
18
+ :warning
19
+ end
20
+
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,42 @@
1
+ module Muwu
2
+ module ProjectException
3
+ class MetadataValueNotGiven
4
+
5
+
6
+ include Muwu
7
+
8
+
9
+ def initialize(task, key)
10
+ @task = task
11
+ @index = task.document_index
12
+ @key = key
13
+ end
14
+
15
+
16
+ def report
17
+ "Metadata value for `#{@key}` not found (document #{@index}, block `#{block_type}`)."
18
+ end
19
+
20
+
21
+ def type
22
+ :warning
23
+ end
24
+
25
+
26
+
27
+ private
28
+
29
+
30
+ def block_type
31
+ case @task
32
+ when ManifestTask::Metadata
33
+ 'metadata'
34
+ when ManifestTask::Title
35
+ 'title'
36
+ end
37
+ end
38
+
39
+
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,18 @@
1
+ module Muwu
2
+ module ProjectException
3
+ class MultipleDocumentsOutlinedWithStdout
4
+
5
+
6
+ def report
7
+ 'The output destination `stdout` can only accommodate a single outlined document.'
8
+ end
9
+
10
+
11
+ def type
12
+ :fatal
13
+ end
14
+
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module Muwu
2
+ module ProjectException
3
+ class MultipleFormatsRequestedWithStdout
4
+
5
+
6
+ def report
7
+ 'The output destination `stdout` can only accommodate a single output format.'
8
+ end
9
+
10
+
11
+ def type
12
+ :fatal
13
+ end
14
+
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,23 @@
1
+ module Muwu
2
+ module ProjectException
3
+ class NavigatorNotRecommendedWithSingleDocument
4
+
5
+
6
+ def initialize(index)
7
+ @index = index
8
+ end
9
+
10
+
11
+ def report
12
+ "Navigator not recommended with a single outlined document."
13
+ end
14
+
15
+
16
+ def type
17
+ :warning
18
+ end
19
+
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module Muwu
2
+ module ProjectException
3
+ class NavigatorsWillBeGeneratedAutomatically
4
+
5
+
6
+ def initialize(index)
7
+ @index = index
8
+ end
9
+
10
+
11
+ def report
12
+ "Navigators will be generated automatically. Ignoring outline directive (document #{@index})."
13
+ end
14
+
15
+
16
+ def type
17
+ :warning
18
+ end
19
+
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module Muwu
2
+ module ProjectException
3
+ class OptionKeyNotUnderstood
4
+
5
+
6
+ def initialize(key)
7
+ @key = key
8
+ end
9
+
10
+
11
+ def report
12
+ "The option key `#{@key}` is not understood."
13
+ end
14
+
15
+
16
+ def type
17
+ :warning
18
+ end
19
+
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module Muwu
2
+ module ProjectException
3
+ class OptionNotValidatable
4
+
5
+
6
+ def initialize(key)
7
+ @key = key
8
+ end
9
+
10
+
11
+ def report
12
+ "The option `#{@key}` cannot be validated. (Muwu::ProjectOptionValidatorValue)"
13
+ end
14
+
15
+
16
+ def type
17
+ :internal
18
+ end
19
+
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ module Muwu
2
+ module ProjectException
3
+ class OptionValueNotUnderstood
4
+
5
+
6
+ def initialize(key, value)
7
+ @key = key
8
+ @value = value
9
+ end
10
+
11
+
12
+ def report
13
+ "For option key `#{@key}`, the value `#{@value}` is not understood."
14
+ end
15
+
16
+
17
+ def type
18
+ :warning
19
+ end
20
+
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ module Muwu
2
+ module ProjectException
3
+ class OptionsFileNotFound
4
+
5
+
6
+ def initialize(project)
7
+ @filename = project.options_filename
8
+ end
9
+
10
+
11
+ def report
12
+ "The options file `#{@filename}` could not be found."
13
+ end
14
+
15
+
16
+ def type
17
+ :warning
18
+ end
19
+
20
+
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,24 @@
1
+ module Muwu
2
+ module ProjectException
3
+ class OutlineFileNotFound
4
+
5
+
6
+ def initialize(project)
7
+ @filename = project.outline_filename
8
+ end
9
+
10
+
11
+ def report
12
+ "The outline file `#{@filename}` could not be found."
13
+ end
14
+
15
+
16
+ def type
17
+ :warning
18
+ end
19
+
20
+
21
+ end
22
+ end
23
+ end
24
+