muwu 3.0.0.alpha → 3.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,47 +1,83 @@
1
1
  module Muwu
2
2
  class Publish
3
-
4
-
3
+
4
+
5
5
  include Muwu
6
-
7
-
8
- def initialize(project)
9
- @documents_css = project.manifest.documents_css
10
- @documents_html = project.manifest.documents_html
11
- @documents_js = project.manifest.documents_js
12
- @local = project.working_directory
6
+
7
+
8
+ def initialize(project, args: [])
9
+ # @documents_css = project.manifest.documents_css
10
+ # @documents_html = project.manifest.documents_html
11
+ # @documents_js = project.manifest.documents_js
12
+ # @path_local = project.path_compiled
13
+ # @path_remote = project.options.remote_publish
14
+ @path_local = project.path_compiled + File::SEPARATOR
15
+ @path_remote = project.options.remote_publish
13
16
  @project = project
14
- @remote = project.options.remote_publish
15
-
17
+
18
+ switches = ['i','r','v']
19
+ @args = args.map { |a| a.to_s.downcase }
20
+ if @args.include?('dry-run')
21
+ @dry_run = true
22
+ switches << 'n'
23
+ end
24
+ @switches = switches.sort.join
16
25
  end
17
-
18
-
26
+
27
+
28
+ # def up
29
+ # if @project.exceptions_include?(ProjectException::OptionRemotePublishValueNil)
30
+ # raise ProjectExceptionHandler::Fatal.new(ProjectException::OptionRemotePublishValueNil.new)
31
+ # else
32
+ # filenames = []
33
+ # filenames << @documents_css.map { |d| d.destination.filename }
34
+ # filenames << @documents_html.map { |d| d.destination.filename }
35
+ # filenames << @documents_js.map { |d| d.destination.filename }
36
+ # filenames.flatten.each { |f| scp f }
37
+ # end
38
+ # end
39
+
40
+
19
41
  def up
20
42
  if @project.exceptions_include?(ProjectException::OptionRemotePublishValueNil)
21
43
  raise ProjectExceptionHandler::Fatal.new(ProjectException::OptionRemotePublishValueNil.new)
22
- else
23
- filenames = []
24
- filenames << @documents_css.map { |d| d.filename }
25
- filenames << @documents_html.map { |d| d.filename }
26
- filenames << @documents_js.map { |d| d.filename }
27
- filenames.flatten.each { |f| scp f }
44
+ else
45
+ exec_rsync(source: @path_local, target: @path_remote)
28
46
  end
29
47
  end
30
-
31
-
48
+
49
+
50
+
32
51
  private
33
-
34
-
35
- def scp(filename)
36
- filename_local = File.join(@local, filename)
37
- filename_remote = File.join(@remote, filename)
38
- begin
39
- system "scp #{filename_local} #{filename_remote}", exception: true
40
- rescue Errno::ENOENT
41
- raise ProjectExceptionHandler::Fatal.new(ProjectException::ScpNotAvailable.new)
52
+
53
+
54
+ def exec_rsync(source: nil, target: nil)
55
+ if source && target
56
+ puts "source: #{source.inspect}"
57
+ puts "target: #{target.inspect}"
58
+ puts "args: #{@args}"
59
+ puts "switches: -#{@switches}"
60
+ begin
61
+ system "rsync -#{@switches} #{source} #{target}", exception: true
62
+ rescue Errno::ENOENT
63
+ raise ProjectExceptionHandler::Fatal.new(ProjectException::RsyncNotAvailable.new)
64
+ end
42
65
  end
43
- end
44
-
45
-
66
+ end
67
+
68
+
69
+
70
+ # def scp(filename)
71
+ # filename_local = File.join(@path_local, filename)
72
+ # filename_remote = File.join(@path_remote, filename)
73
+ # begin
74
+ # system "scp #{filename_local} #{filename_remote}", exception: true
75
+ # rescue Errno::ENOENT
76
+ # raise ProjectExceptionHandler::Fatal.new(ProjectException::ScpNotAvailable.new)
77
+ # end
78
+ # end
79
+
80
+
81
+
46
82
  end
47
- end
83
+ end
@@ -1,7 +1,10 @@
1
1
  module Muwu
2
2
  class RenderHtml
3
-
4
-
3
+
4
+
5
+ require 'fileutils'
6
+
7
+
5
8
  include Muwu
6
9
 
7
10
 
@@ -10,21 +13,24 @@ module Muwu
10
13
  @project = project
11
14
  halt_if_project_has_fatal_exceptions
12
15
  end
13
-
14
-
15
-
16
+
17
+
18
+
16
19
  public
17
-
18
-
19
- def render
20
+
21
+
22
+ def render_all
23
+ if @project.options.expunge_when_compiling_all == true
24
+ ProjectResetCompiled.new(@project).reset_compiled
25
+ end
20
26
  if @manifest.does_have_documents
21
27
  build_and_render(@manifest.documents)
22
28
  else
23
29
  reply_nothing_to_do
24
30
  end
25
31
  end
26
-
27
-
32
+
33
+
28
34
  def render_css_only
29
35
  if @manifest.does_have_documents_css
30
36
  build_and_render(@manifest.documents_css)
@@ -32,8 +38,8 @@ module Muwu
32
38
  reply_nothing_to_do
33
39
  end
34
40
  end
35
-
36
-
41
+
42
+
37
43
  def render_html_by_index(index)
38
44
  document_html = @manifest.find_document_html_by_index(index)
39
45
  if document_html
@@ -42,8 +48,8 @@ module Muwu
42
48
  reply_nothing_to_do
43
49
  end
44
50
  end
45
-
46
-
51
+
52
+
47
53
  def render_html_only
48
54
  if @manifest.does_have_documents_html
49
55
  build_and_render(@manifest.documents_html)
@@ -60,12 +66,12 @@ module Muwu
60
66
  reply_nothing_to_do
61
67
  end
62
68
  end
63
-
69
+
64
70
 
65
71
 
66
72
  private
67
-
68
-
73
+
74
+
69
75
  def build_and_render(document)
70
76
  case document
71
77
  when Array
@@ -76,13 +82,13 @@ module Muwu
76
82
 
77
83
  when ManifestTask::DocumentHtml
78
84
  RenderHtmlBuilder.new(document).build_and_render
79
-
85
+
80
86
  when ManifestTask::DocumentJs
81
87
  RenderJsBuilder.new(document).build_and_render
82
88
  end
83
89
  end
84
-
85
-
90
+
91
+
86
92
  def halt_if_project_has_fatal_exceptions
87
93
  begin
88
94
  if @project.exceptions_fatal.any?
@@ -90,12 +96,12 @@ module Muwu
90
96
  end
91
97
  end
92
98
  end
93
-
94
-
99
+
100
+
95
101
  def reply_nothing_to_do
96
102
  $stderr.puts '- No documents to compile.'
97
103
  end
98
-
99
-
104
+
105
+
100
106
  end
101
107
  end
@@ -4,13 +4,13 @@ module Muwu
4
4
 
5
5
 
6
6
  include Muwu
7
-
8
-
7
+
8
+
9
9
  require 'commonmarker'
10
-
10
+
11
11
 
12
12
  attr_accessor(
13
- :destination,
13
+ :destination,
14
14
  :distinct,
15
15
  :does_have_source_text,
16
16
  :end_links,
@@ -45,7 +45,7 @@ module Muwu
45
45
  elsif (@is_parent_heading == true) && (@subsections_are_distinct == false)
46
46
  render_sections
47
47
  render_end_links
48
- elsif (@is_parent_heading == false)
48
+ elsif (@is_parent_heading == false)
49
49
  render_end_links
50
50
  end
51
51
  write_tag_section_close
@@ -81,14 +81,14 @@ module Muwu
81
81
  write_tag_span_section_number
82
82
  end
83
83
  end
84
-
85
-
84
+
85
+
86
86
  def render_sections
87
87
  @destination.padding_vertical(1) do
88
88
  @sections.each do |section|
89
89
  section.render
90
90
  end
91
- end
91
+ end
92
92
  end
93
93
 
94
94
 
@@ -132,7 +132,7 @@ module Muwu
132
132
  def write_tag_span_section_number
133
133
  @destination.write_line tag_span_section_number
134
134
  end
135
-
135
+
136
136
 
137
137
  def write_text_file_missing
138
138
  @destination.write_line tag_div_file_missing
@@ -142,17 +142,17 @@ module Muwu
142
142
  def write_text_source_to_html
143
143
  @destination.write_inline source_to_html
144
144
  end
145
-
146
145
 
147
-
146
+
147
+
148
148
  private
149
149
 
150
150
 
151
151
  def heading_origin_is_basename_or_outline
152
152
  [:basename, :outline].include?(@heading_origin)
153
153
  end
154
-
155
-
154
+
155
+
156
156
  def source_file_exists
157
157
  if @source_filename_absolute
158
158
  File.exists?(@source_filename_absolute)
@@ -174,11 +174,11 @@ module Muwu
174
174
  "</nav>"
175
175
  end
176
176
 
177
-
177
+
178
178
  def tag_nav_open
179
179
  "<nav>"
180
180
  end
181
-
181
+
182
182
 
183
183
  def tag_nav_end_links_open
184
184
  "<nav class='document_links'>"
@@ -221,7 +221,7 @@ module Muwu
221
221
 
222
222
 
223
223
  def tag_span_section_number
224
- "<span class='section_number'>#{@section_number_as_text}</span>"
224
+ "<h1 class='section_number'>#{@section_number_as_text}</h1>"
225
225
  end
226
226
 
227
227
 
@@ -3,13 +3,13 @@ module Muwu
3
3
 
4
4
 
5
5
  include Muwu
6
-
7
-
6
+
7
+
8
8
  def initialize(project, args: [])
9
- @local = project.working_directory + File::SEPARATOR
9
+ @path_local = project.working_directory + File::SEPARATOR
10
+ @path_remote = project.options.remote_sync
10
11
  @project = project
11
- @remote = project.options.remote_sync
12
-
12
+
13
13
  switches = ['i','r','v']
14
14
  @args = args.map { |a| a.to_s.downcase }
15
15
  if @args.include?('dry-run')
@@ -18,37 +18,33 @@ module Muwu
18
18
  end
19
19
  @switches = switches.sort.join
20
20
  end
21
-
22
-
21
+
22
+
23
23
  public
24
-
25
-
24
+
25
+
26
26
  def down
27
27
  if @project.exceptions_include?(ProjectException::OptionRemoteSyncValueNil)
28
28
  raise ProjectExceptionHandler::Fatal.new(ProjectException::OptionRemoteSyncValueNil.new)
29
29
  else
30
- source = @remote
31
- target = @local
32
- exec_sync(source: @remote, target: @local)
30
+ exec_sync(source: @path_remote, target: @path_local)
33
31
  end
34
32
  end
35
-
36
-
33
+
34
+
37
35
  def up
38
36
  if @project.exceptions_include?(ProjectException::OptionRemoteSyncValueNil)
39
37
  raise ProjectExceptionHandler::Fatal.new(ProjectException::OptionRemoteSyncValueNil.new)
40
38
  else
41
- source = @local
42
- target = @remote
43
- exec_sync(source: @local, target: @remote)
39
+ exec_sync(source: @path_local, target: @path_remote)
44
40
  end
45
41
  end
46
42
 
47
43
 
48
44
 
49
45
  private
50
-
51
-
46
+
47
+
52
48
  def exec_sync(source: nil, target: nil)
53
49
  if source && target
54
50
  puts "source: #{source.inspect}"
@@ -62,8 +58,8 @@ module Muwu
62
58
  end
63
59
  end
64
60
  end
65
-
66
-
67
-
61
+
62
+
63
+
68
64
  end
69
- end
65
+ end
File without changes
@@ -0,0 +1,25 @@
1
+ module Muwu
2
+ class Viewer
3
+
4
+
5
+ include Muwu
6
+
7
+
8
+ def initialize(project)
9
+ document_home = project.manifest.find_document_html_by_index(0).filename
10
+ document_home_path = File.join(project.path_compiled, document_home)
11
+ if File.exists?(document_home_path)
12
+ begin
13
+ system "lynx #{document_home_path}", exception: true
14
+ rescue Errno::ENOENT
15
+ raise ProjectExceptionHandler::Fatal.new(ProjectException::LynxNotAvailable.new)
16
+ end
17
+ else
18
+ puts "Compiled document not found: #{document_home_path}"
19
+ end
20
+ end
21
+
22
+
23
+
24
+ end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muwu
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.alpha
4
+ version: 3.0.0.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eli Harrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-15 00:00:00.000000000 Z
11
+ date: 2020-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commonmarker
@@ -102,6 +102,7 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - bin/muwu
105
+ - lib/loader.rb
105
106
  - lib/muwu.rb
106
107
  - lib/muwu/cli/cli.rb
107
108
  - lib/muwu/cli/cli_help.rb
@@ -114,6 +115,7 @@ files:
114
115
  - lib/muwu/cli/help/reset
115
116
  - lib/muwu/cli/help/summary
116
117
  - lib/muwu/cli/help/sync
118
+ - lib/muwu/cli/help/view
117
119
  - lib/muwu/controller/controller.rb
118
120
  - lib/muwu/controller/controller_interaction.rb
119
121
  - lib/muwu/default/default.rb
@@ -163,12 +165,15 @@ files:
163
165
  - lib/muwu/project_builder/assets/config/css/index.scss
164
166
  - lib/muwu/project_builder/assets/config/css_debugger/debug_section_text.scss
165
167
  - lib/muwu/project_builder/project_reader.rb
168
+ - lib/muwu/project_builder/project_reset_compiled.rb
166
169
  - lib/muwu/project_builder/project_reset_css.rb
167
170
  - lib/muwu/project_builder/project_starter.rb
168
171
  - lib/muwu/project_builder/project_validator.rb
169
172
  - lib/muwu/project_builder/project_writer.rb
173
+ - lib/muwu/project_exception/compiled_folder_not_found.rb
170
174
  - lib/muwu/project_exception/css_manifest_file_not_found.rb
171
175
  - lib/muwu/project_exception/dry_output_recommended_with_multiple_documents.rb
176
+ - lib/muwu/project_exception/lynx_not_available.rb
172
177
  - lib/muwu/project_exception/metadata_file_not_found.rb
173
178
  - lib/muwu/project_exception/metadata_value_not_given.rb
174
179
  - lib/muwu/project_exception/multiple_documents_outlined_with_stdout.rb
@@ -231,7 +236,7 @@ files:
231
236
  - lib/muwu/render_inspector/render_inspector.rb
232
237
  - lib/muwu/sync/sync.rb
233
238
  - lib/muwu/var/deflistdiv.rb
234
- - lib/muwu_loader.rb
239
+ - lib/muwu/viewer/viewer.rb
235
240
  - test/what_no_tests.md
236
241
  homepage: https://github.com/ehdocumentdesign/muwu
237
242
  licenses: