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,160 @@
1
+ module Muwu
2
+ module Helper
3
+ class OutlineHelper
4
+
5
+
6
+ include Muwu::Helper
7
+
8
+
9
+ def initialize(outline_fragment)
10
+ @outline_fragment = outline_fragment
11
+ end
12
+
13
+
14
+
15
+ public
16
+
17
+
18
+ def includes_navigator
19
+ indicates_navigator || includes_navigator_in_array
20
+ end
21
+
22
+
23
+ def includes_navigator_in_array
24
+ (is_array) && (@outline_fragment.select{ |step| OutlineHelper.type_of(step) == :navigator }.any?)
25
+ end
26
+
27
+
28
+ def indicates_contents
29
+ indicates_contents_hash || indicates_contents_string
30
+ end
31
+
32
+
33
+ def indicates_contents_hash
34
+ (is_hash) && (RegexpLib.outline_contents =~ @outline_fragment.flatten[0])
35
+ end
36
+
37
+
38
+ def indicates_contents_string
39
+ (is_string) && (RegexpLib.outline_contents =~ @outline_fragment)
40
+ end
41
+
42
+
43
+ def indicates_metadata
44
+ indicates_metadata_hash || indicates_metadata_string
45
+ end
46
+
47
+
48
+ def indicates_metadata_hash
49
+ (is_hash) && (RegexpLib.outline_metadata =~ @outline_fragment.flatten[0])
50
+ end
51
+
52
+
53
+ def indicates_metadata_string
54
+ (is_string) && (RegexpLib.outline_metadata =~ @outline_fragment)
55
+ end
56
+
57
+
58
+ def indicates_navigator
59
+ (is_string) && (RegexpLib.outline_navigator =~ @outline_fragment)
60
+ end
61
+
62
+
63
+ def indicates_outline_fragment
64
+ is_array
65
+ end
66
+
67
+
68
+ def indicates_subcontents
69
+ indicates_subcontents_hash || indicates_subcontents_string
70
+ end
71
+
72
+
73
+ def indicates_subcontents_hash
74
+ (is_hash) && (RegexpLib.outline_subcontents =~ @outline_fragment.flatten[0])
75
+ end
76
+
77
+
78
+ def indicates_subcontents_string
79
+ (is_string) && (RegexpLib.outline_subcontents =~ @outline_fragment)
80
+ end
81
+
82
+
83
+ def indicates_text
84
+ (is_hash) && (RegexpLib.outline_text =~ @outline_fragment.flatten[0])
85
+ end
86
+
87
+
88
+ def indicates_title
89
+ indicates_title_hash || indicates_title_string
90
+ end
91
+
92
+
93
+ def indicates_title_hash
94
+ (is_hash) && (RegexpLib.outline_title =~ @outline_fragment.flatten[0])
95
+ end
96
+
97
+
98
+ def indicates_title_string
99
+ (is_string) && (RegexpLib.outline_title =~ @outline_fragment)
100
+ end
101
+
102
+
103
+ def is_array
104
+ Array === @outline_fragment
105
+ end
106
+
107
+
108
+ def is_hash
109
+ Hash === @outline_fragment
110
+ end
111
+
112
+
113
+ def is_integer
114
+ Integer === @outline_fragment
115
+ end
116
+
117
+
118
+ def is_string
119
+ String === @outline_fragment
120
+ end
121
+
122
+
123
+ def text_step_flexible_suggests_file
124
+ if @outline_fragment.to_s =~ RegexpLib.file_ext_md
125
+ true
126
+ elsif @outline_fragment.to_s =~ RegexpLib.file_ext_haml
127
+ true
128
+ else
129
+ false
130
+ end
131
+ end
132
+
133
+
134
+
135
+ protected
136
+
137
+
138
+ def self.type_of(step)
139
+ s = new(step)
140
+ if s.indicates_contents
141
+ :contents
142
+ elsif s.indicates_metadata
143
+ :metadata
144
+ elsif s.indicates_navigator
145
+ :navigator
146
+ elsif s.indicates_outline_fragment
147
+ :outline_fragment
148
+ elsif s.indicates_subcontents
149
+ :subcontents
150
+ elsif s.indicates_text
151
+ :text
152
+ elsif s.indicates_title
153
+ :title
154
+ end
155
+ end
156
+
157
+
158
+ end
159
+ end
160
+ end
@@ -0,0 +1,101 @@
1
+ module Muwu
2
+ module Helper
3
+ module RegexpLib
4
+
5
+
6
+ module_function
7
+
8
+
9
+ # def regexp_path_relative_current
10
+ # /\A.\//
11
+ # end
12
+ #
13
+ #
14
+ # def regexp_path_segmenter_fw_slash
15
+ # /[\/\\]/
16
+ # end
17
+
18
+
19
+ def file_ext_haml
20
+ /.haml\z/i
21
+ end
22
+
23
+
24
+ def file_ext_md
25
+ /.md\z/i
26
+ end
27
+
28
+
29
+ def haml_heading
30
+ /\A%h\d*/i
31
+ end
32
+
33
+
34
+ def haml_heading_plus_whitespace
35
+ /\A%h\d*\s*/i
36
+ end
37
+
38
+
39
+ def markdown_heading
40
+ /\A#+/
41
+ end
42
+
43
+
44
+ def markdown_heading_plus_whitespace
45
+ /\A#+\s*/
46
+ end
47
+
48
+
49
+ def metadata_key_date_of_this_edition
50
+ /\Adate\s*of\s*this\s*edition/i
51
+ end
52
+
53
+
54
+ def not_alphanumeric_underscore_or_single_dot
55
+ /[^a-zA-Z0-9_\.]/
56
+ end
57
+
58
+
59
+ def outline_metadata
60
+ /\Ametadata/i
61
+ end
62
+
63
+
64
+ def outline_navigator
65
+ /\Anavigator/i
66
+ end
67
+
68
+
69
+ def outline_contents
70
+ /\Acontents/i
71
+ end
72
+
73
+
74
+ def outline_subcontents
75
+ /\Asubcontents/i
76
+ end
77
+
78
+
79
+ def outline_text
80
+ /\Atext/i
81
+ end
82
+
83
+
84
+ def outline_text_plus_whitespace
85
+ /\Atext\s+/i
86
+ end
87
+
88
+
89
+ def outline_title
90
+ /\Atitle/i
91
+ end
92
+
93
+
94
+ def path_two_or_more_dots
95
+ /\.{2,}/
96
+ end
97
+
98
+
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,50 @@
1
+ module Muwu
2
+ module Helper
3
+ module SanitizerHelper
4
+
5
+
6
+ require 'cgi'
7
+
8
+
9
+ module_function
10
+
11
+
12
+ def sanitize_destination_file_basename(basename)
13
+ File.basename(basename.to_s).gsub(/\W/,'_').gsub(/_{2,}/,'_')
14
+ end
15
+
16
+
17
+ def sanitize_text_item_basename(basename)
18
+ basename.to_s.gsub(RegexpLib.path_two_or_more_dots,'_')
19
+ end
20
+
21
+
22
+ def sanitize_text_item_path(path)
23
+ case path
24
+ when Array
25
+ return path.map { |p| sanitize_text_item_path_segment(p) }
26
+ when Integer, String
27
+ return sanitize_text_item_path_segment(path)
28
+ end
29
+ end
30
+
31
+
32
+ def sanitize_text_item_path_segment(path)
33
+ path.to_s.downcase.gsub(/\s/,'_').gsub(/\W/,'').gsub(/_{2,}/,'_')
34
+ end
35
+
36
+
37
+ def sanitize_metadata(metadata)
38
+ sanitized_metadata = {}
39
+ metadata.each_pair do |k,v|
40
+ key_safe = CGI::escape_html(k.to_s)
41
+ value_safe = CGI::escape_html(v.to_s)
42
+ sanitized_metadata[key_safe] = value_safe
43
+ end
44
+ sanitized_metadata
45
+ end
46
+
47
+
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,158 @@
1
+ module Muwu
2
+ class Manifest
3
+
4
+
5
+ include Muwu
6
+
7
+
8
+ attr_accessor(
9
+ :documents,
10
+ :options,
11
+ :project
12
+ )
13
+
14
+
15
+ def initialize
16
+ @documents = []
17
+ end
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
+
31
+ public
32
+
33
+
34
+ def contents_block_by_name(text_root_name)
35
+ matching_contents = []
36
+ documents_html.each do |document_html|
37
+ matching_contents << document_html.contents_blocks_by_name(text_root_name)
38
+ end
39
+ matching_contents.flatten[0]
40
+ end
41
+
42
+
43
+ def documents_count
44
+ @documents.length
45
+ end
46
+
47
+
48
+ def documents_css
49
+ @documents.select { |d| ManifestTask::DocumentCss === d }
50
+ end
51
+
52
+
53
+ def documents_css_count
54
+ documents_css.length
55
+ end
56
+
57
+
58
+ def documents_html
59
+ @documents.select { |d| ManifestTask::DocumentHtml === d }
60
+ end
61
+
62
+
63
+ def documents_html_count
64
+ documents_html.length
65
+ end
66
+
67
+
68
+ def documents_js
69
+ @documents.select { |d| ManifestTask::DocumentJs === d }
70
+ end
71
+
72
+
73
+ def documents_js_count
74
+ documents_js.length
75
+ end
76
+
77
+
78
+ def does_have_documents
79
+ documents_count > 0
80
+ end
81
+
82
+
83
+ def does_have_documents_css
84
+ documents_css_count > 0
85
+ end
86
+
87
+
88
+ def does_have_documents_html
89
+ documents_html_count > 0
90
+ end
91
+
92
+
93
+ def does_have_documents_js
94
+ documents_js_count > 0
95
+ end
96
+
97
+
98
+ def does_not_have_documents
99
+ documents_count == 0
100
+ end
101
+
102
+
103
+ def find_document_html_by_index(index)
104
+ documents_html.select { |document_html| document_html.index == index }[0]
105
+ end
106
+
107
+
108
+ # def outline_has_more_than_one_text_block
109
+ # outline_text_blocks_count > 1
110
+ # end
111
+ #
112
+ #
113
+ # def outline_has_only_one_text_block
114
+ # outline_text_blocks_count = 1
115
+ # end
116
+ #
117
+ #
118
+ # def outline_text_blocks
119
+ # text_sections = []
120
+ # project_outline.flatten.select{ |step| Hash === step }.each do |step|
121
+ # if step.flatten[0] =~ REGEXP.outline_text
122
+ # text_sections << step
123
+ # end
124
+ # end
125
+ # text_sections
126
+ # end
127
+ #
128
+ #
129
+ # def outline_text_blocks_count
130
+ # outline_text_blocks.count
131
+ # end
132
+ #
133
+ #
134
+ # def project_outline
135
+ # @project.outline
136
+ # end
137
+
138
+
139
+ def text_blocks
140
+ text_blocks = []
141
+ documents_html.each do |document_html|
142
+ text_blocks.concat(document_html.text_blocks)
143
+ end
144
+ text_blocks.flatten
145
+ end
146
+
147
+
148
+ def text_blocks_by_name(text_root_name)
149
+ matching_text_blocks = []
150
+ documents_html.each do |document_html|
151
+ matching_text_blocks.concat(document_html.text_blocks_by_name(text_root_name))
152
+ end
153
+ matching_text_blocks.flatten
154
+ end
155
+
156
+
157
+ end
158
+ end