muwu 2.5.1 → 3.0.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dafa3354f3a57677adacf16fe9372167ce2572b68e445fb0f95192142c116633
4
- data.tar.gz: 83130270c6bcfbbb7c3fd46a3cc8825441999eae801dd1ba15368acffc315464
3
+ metadata.gz: b7a3546ed2eb6f4dead8a472ef9460ce5696a5967892151210026e947303766e
4
+ data.tar.gz: f53c66c3a78df5157de9930c78444bc821eaa9de6484b628887b720c6cc4acea
5
5
  SHA512:
6
- metadata.gz: 8a036a78dd8a1ef10f0776a7d014c4e953ababeb0ca154e0718499a8252b06b3b4a708fa9c4542803a986e70f0fdad4bef8e9997b541eabb9f01858f82118722
7
- data.tar.gz: 819c5595a937ff67464e3829b0243d86a2cf3b429bcadf232dfc13eea7995d9c6fe583c48f39555479597a66ebc4cff2dc95eb199693ffd10dcb3d9850a281df
6
+ metadata.gz: 862b1e8424005ce9f952e3609634a986c0c4d31f3697b24502d1175c643cc88caef93113bd4043c9be22c8f220d5a87721923e3b0554c04cad1856fd78f16881
7
+ data.tar.gz: 3e61b41b6dea81978e0226542a1e06ce1caec159bb55f070c2aee54452abd852e190c6328f77b9ee365272ff0dc9c3835dad5e3747eaf3b24196a764121e67fc
@@ -1,7 +1,7 @@
1
1
  module Muwu
2
2
 
3
3
 
4
- VERSION = '2.5.1'
4
+ VERSION = '3.0.0.alpha'
5
5
 
6
6
  GEM_HOME_LIB = File.absolute_path(File.join(File.dirname(__FILE__)))
7
7
  GEM_HOME_LIB_MUWU = File.absolute_path(File.join(GEM_HOME_LIB, 'muwu'))
@@ -38,8 +38,12 @@ module Muwu
38
38
  evaluate_command_inspect
39
39
  when 'new'
40
40
  evaluate_command_new
41
+ when 'publish'
42
+ evaluate_command_publish
41
43
  when 'reset'
42
44
  evaluate_command_reset
45
+ when 'sync'
46
+ evaluate_command_sync
43
47
  when '--version'
44
48
  puts VERSION
45
49
  else
@@ -105,8 +109,12 @@ module Muwu
105
109
  puts CliHelp.new(:inspect).message
106
110
  when 'new'
107
111
  puts CliHelp.new(:new).message
112
+ when 'publish'
113
+ puts CliHelp.new(:publish).message
108
114
  when 'reset'
109
115
  puts CliHelp.new(:reset).message
116
+ when 'sync'
117
+ puts CliHelp.new(:sync).message
110
118
  else
111
119
  puts CliHelp.new(:summary).message
112
120
  end
@@ -124,6 +132,11 @@ module Muwu
124
132
  end
125
133
 
126
134
 
135
+ def evaluate_command_publish
136
+ Controller.new(@current_working_directory).publish
137
+ end
138
+
139
+
127
140
  def evaluate_command_reset
128
141
  if @args[1] == nil
129
142
  puts CliHelp.new(:reset).message
@@ -138,6 +151,23 @@ module Muwu
138
151
  end
139
152
  end
140
153
 
154
+
155
+ def evaluate_command_sync
156
+ if @args[1] == nil
157
+ puts CliHelp.new(:sync).message
158
+
159
+ else
160
+ case @args[1]
161
+ when 'down'
162
+ Controller.new(@current_working_directory).sync_down(@args[2..(@args.length-1)])
163
+ when 'up'
164
+ Controller.new(@current_working_directory).sync_up(@args[2..(@args.length-1)])
165
+ else
166
+ puts CliHelp.new(:sync).message
167
+ end
168
+ end
169
+ end
170
+
141
171
 
142
172
  end
143
173
  end
@@ -0,0 +1,7 @@
1
+ - muwu publish
2
+ - Publishes compiled documents (as indicated by the current outline and
3
+ manifest) to a remote location using scp. Scp must be installed on the
4
+ local system.
5
+
6
+ * Specify the remote host in 'options.yml' using the 'remote_publish' value.
7
+
@@ -1,4 +1,4 @@
1
- - reset css
1
+ - muwu reset css
2
2
  - Reset the `config/css` folder. The following files and folders will
3
3
  revert to their original state:
4
4
 
@@ -6,7 +6,9 @@ Command line:
6
6
  muwu help show this message
7
7
  muwu inspect inspect a project
8
8
  muwu new create a new project directory
9
+ muwu publish publish to a remote server (requires scp)
9
10
  muwu reset css reset the default CSS files
11
+ muwu sync syncronize from/to a remote server (requires rsync)
10
12
 
11
13
  All comands operate within the current working directory.
12
14
 
@@ -0,0 +1,18 @@
1
+ - muwu sync [down | up] [options]
2
+ - Synchronize project from/to a remote location using rsync. Rsync must be
3
+ installed on the local system.
4
+
5
+ - muwu sync down
6
+ - Use rsync to download the project from a remote host.
7
+
8
+ - muwu sync up
9
+ - Use rsync to upload to project to a remote host.
10
+
11
+ - [options]
12
+ - dry-run: invoke the rsync '-n' switch to show which files will be
13
+ transferred, but do not actually transfer files.
14
+
15
+ * Specify the remote host in 'options.yml' using the 'remote_sync' value.
16
+
17
+ * Muwu will invoke the rsync switches '-r' to recurse subdirectories, and
18
+ '-v' to give a verbose description
@@ -92,6 +92,12 @@ module Muwu
92
92
  end
93
93
 
94
94
 
95
+ def publish
96
+ @project = read_project_from_current_working_directory
97
+ Publish.new(@project).up
98
+ end
99
+
100
+
95
101
  def reset_css
96
102
  @project = read_project_from_current_working_directory
97
103
  if @project.does_not_have_crucial_files
@@ -100,6 +106,18 @@ module Muwu
100
106
  ProjectResetCss.new(@project).reset_css
101
107
  end
102
108
  end
109
+
110
+
111
+ def sync_down(args)
112
+ @project = read_project_from_current_working_directory
113
+ Sync.new(@project, args: args).down
114
+ end
115
+
116
+
117
+ def sync_up(args)
118
+ @project = read_project_from_current_working_directory
119
+ Sync.new(@project, args: args).up
120
+ end
103
121
 
104
122
 
105
123
 
@@ -33,6 +33,8 @@ module Muwu
33
33
  output_file_html_basename: 'index',
34
34
  output_file_js_basename: nil,
35
35
  output_formats: ['html','css','js'],
36
+ remote_publish: nil,
37
+ remote_sync: nil,
36
38
  render_punctuation_smart: true,
37
39
  render_section_end_links: ['contents', 'top'],
38
40
  render_section_numbers: true,
@@ -10,6 +10,11 @@ module Muwu
10
10
  )
11
11
 
12
12
 
13
+ def filename
14
+ @destination.output_filename
15
+ end
16
+
17
+
13
18
  def inspect
14
19
  ["#{self.to_s}", "{", inspect_instance_variables, "}"].join(' ')
15
20
  end
@@ -7,7 +7,7 @@ module Muwu
7
7
  :destination,
8
8
  :css_filename,
9
9
  :css_include_method,
10
- :filename,
10
+ # :filename,
11
11
  :index,
12
12
  :js_filename,
13
13
  :js_include_method,
@@ -40,6 +40,11 @@ module Muwu
40
40
  end
41
41
 
42
42
 
43
+ def filename
44
+ @destination.output_filename
45
+ end
46
+
47
+
43
48
  def text_blocks
44
49
  @tasks.select { |task| ManifestTask::Text === task }
45
50
  end
@@ -10,6 +10,11 @@ module Muwu
10
10
  )
11
11
 
12
12
 
13
+ def filename
14
+ @destination.output_filename
15
+ end
16
+
17
+
13
18
  def inspect
14
19
  ["#{self.to_s}", "{", inspect_instance_variables, "}"].join(' ')
15
20
  end
@@ -19,7 +24,7 @@ module Muwu
19
24
  self.instance_variables.map { |v| "#{v}=#<#{instance_variable_get(v).class}>" }.join(", ")
20
25
  end
21
26
 
22
-
27
+
23
28
  end
24
29
  end
25
30
  end
@@ -78,6 +78,8 @@ module Muwu
78
78
 
79
79
  def phase_4_validate
80
80
  @validator.validate_file_css
81
+ @validator.validate_option_remote_publish
82
+ @validator.validate_option_remote_sync
81
83
  @validator.validate_output_destination_and_formats
82
84
  @validator.validate_scenario_if_more_than_one_document
83
85
  end
@@ -52,6 +52,20 @@ module Muwu
52
52
  return false
53
53
  end
54
54
  end
55
+
56
+
57
+ def validate_option_remote_publish
58
+ if @project.options.remote_publish.to_s == ''
59
+ @project.exceptions_add ProjectException::OptionRemotePublishValueNil.new
60
+ end
61
+ end
62
+
63
+
64
+ def validate_option_remote_sync
65
+ if @project.options.remote_sync.to_s == ''
66
+ @project.exceptions_add ProjectException::OptionRemoteSyncValueNil.new
67
+ end
68
+ end
55
69
 
56
70
 
57
71
  def validate_outline_step_navigator(index)
@@ -92,8 +106,8 @@ module Muwu
92
106
  @project.exceptions_add ProjectException::MultipleFormatsRequestedWithStdout.new
93
107
  end
94
108
  end
95
-
96
-
109
+
110
+
97
111
  def validate_scenario_if_more_than_one_document
98
112
  if @project.outline_has_more_than_one_document && @project.output_destination_requests_stdout
99
113
  @project.exceptions_add ProjectException::MultipleDocumentsOutlinedWithStdout.new
@@ -0,0 +1,18 @@
1
+ module Muwu
2
+ module ProjectException
3
+ class OptionRemotePublishValueNil
4
+
5
+
6
+ def report
7
+ "options.yml does not include a value for remote_publish"
8
+ end
9
+
10
+
11
+ def type
12
+ :publish
13
+ end
14
+
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module Muwu
2
+ module ProjectException
3
+ class OptionRemoteSyncValueNil
4
+
5
+
6
+ def report
7
+ "options.yml does not include a value for remote_sync"
8
+ end
9
+
10
+
11
+ def type
12
+ :sync
13
+ end
14
+
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,23 @@
1
+ module Muwu
2
+ module ProjectException
3
+ class RsyncNotAvailable
4
+
5
+
6
+ def initialize
7
+ $stderr.puts "#{self.class}"
8
+ end
9
+
10
+
11
+ def report
12
+ "rsync is not available"
13
+ end
14
+
15
+
16
+ def type
17
+ :sync
18
+ end
19
+
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module Muwu
2
+ module ProjectException
3
+ class ScpNotAvailable
4
+
5
+
6
+ def initialize
7
+ $stderr.puts "#{self.class}"
8
+ end
9
+
10
+
11
+ def report
12
+ "scp is not available"
13
+ end
14
+
15
+
16
+ def type
17
+ :publish
18
+ end
19
+
20
+
21
+ end
22
+ end
23
+ end
@@ -16,6 +16,8 @@ module Muwu
16
16
  :output_file_html_basename,
17
17
  :output_file_js_basename,
18
18
  :output_formats,
19
+ :remote_publish,
20
+ :remote_sync,
19
21
  :render_punctuation_smart,
20
22
  :render_section_end_links,
21
23
  :render_section_numbers,
@@ -76,6 +76,11 @@ module Muwu
76
76
  def value_as_string(value)
77
77
  value.to_s.strip.downcase
78
78
  end
79
+
80
+
81
+ def value_as_string_preserving_case(value)
82
+ value.to_s.strip
83
+ end
79
84
 
80
85
 
81
86
  def value_provided_as_array
@@ -91,6 +96,11 @@ module Muwu
91
96
  def value_provided_as_string
92
97
  value_as_string(@value_provided)
93
98
  end
99
+
100
+
101
+ def value_provided_as_string_preserving_case
102
+ value_as_string_preserving_case(@value_provided)
103
+ end
94
104
 
95
105
 
96
106
 
@@ -231,6 +241,16 @@ module Muwu
231
241
  end
232
242
 
233
243
 
244
+ def validate_option_remote_publish
245
+ return value_provided_as_string_preserving_case
246
+ end
247
+
248
+
249
+ def validate_option_remote_sync
250
+ return value_provided_as_string_preserving_case
251
+ end
252
+
253
+
234
254
  def validate_option_render_punctuation_smart
235
255
  return validate_option_boolean
236
256
  end
@@ -289,8 +309,8 @@ module Muwu
289
309
  def validate_option_render_punctuation_smart
290
310
  return validate_option_boolean
291
311
  end
292
-
293
-
312
+
313
+
294
314
  def validate_option_warning_if_parent_heading_lacks_source
295
315
  return validate_option_boolean
296
316
  end
@@ -0,0 +1,47 @@
1
+ module Muwu
2
+ class Publish
3
+
4
+
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
13
+ @project = project
14
+ @remote = project.options.remote_publish
15
+
16
+ end
17
+
18
+
19
+ def up
20
+ if @project.exceptions_include?(ProjectException::OptionRemotePublishValueNil)
21
+ 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 }
28
+ end
29
+ end
30
+
31
+
32
+ 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)
42
+ end
43
+ end
44
+
45
+
46
+ end
47
+ end
@@ -1,7 +1,10 @@
1
1
  module Muwu
2
2
  module RenderHtmlPartial
3
3
  class Contents
4
-
4
+
5
+
6
+ require 'cgi'
7
+
5
8
 
6
9
  include Muwu
7
10
 
@@ -0,0 +1,69 @@
1
+ module Muwu
2
+ class Sync
3
+
4
+
5
+ include Muwu
6
+
7
+
8
+ def initialize(project, args: [])
9
+ @local = project.working_directory + File::SEPARATOR
10
+ @project = project
11
+ @remote = project.options.remote_sync
12
+
13
+ switches = ['i','r','v']
14
+ @args = args.map { |a| a.to_s.downcase }
15
+ if @args.include?('dry-run')
16
+ @dry_run = true
17
+ switches << 'n'
18
+ end
19
+ @switches = switches.sort.join
20
+ end
21
+
22
+
23
+ public
24
+
25
+
26
+ def down
27
+ if @project.exceptions_include?(ProjectException::OptionRemoteSyncValueNil)
28
+ raise ProjectExceptionHandler::Fatal.new(ProjectException::OptionRemoteSyncValueNil.new)
29
+ else
30
+ source = @remote
31
+ target = @local
32
+ exec_sync(source: @remote, target: @local)
33
+ end
34
+ end
35
+
36
+
37
+ def up
38
+ if @project.exceptions_include?(ProjectException::OptionRemoteSyncValueNil)
39
+ raise ProjectExceptionHandler::Fatal.new(ProjectException::OptionRemoteSyncValueNil.new)
40
+ else
41
+ source = @local
42
+ target = @remote
43
+ exec_sync(source: @local, target: @remote)
44
+ end
45
+ end
46
+
47
+
48
+
49
+ private
50
+
51
+
52
+ def exec_sync(source: nil, target: nil)
53
+ if source && target
54
+ puts "source: #{source.inspect}"
55
+ puts "target: #{target.inspect}"
56
+ puts "args: #{@args}"
57
+ puts "switches: -#{@switches}"
58
+ begin
59
+ system "rsync -#{@switches} #{source} #{target}", exception: true
60
+ rescue Errno::ENOENT
61
+ raise ProjectExceptionHandler::Fatal.new(ProjectException::RsyncNotAvailable.new)
62
+ end
63
+ end
64
+ end
65
+
66
+
67
+
68
+ end
69
+ end
@@ -16,12 +16,14 @@ paths = [
16
16
  'project_exception_handler',
17
17
  'project_options',
18
18
  'project_options_builder',
19
+ 'publish',
19
20
  'render_concat',
20
21
  'render_html',
21
22
  'render_html_builder',
22
23
  'render_html_partial',
23
24
  'render_html_partial_builder',
24
25
  'render_inspector',
26
+ 'sync',
25
27
  'var'
26
28
  ]
27
29
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muwu
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 3.0.0.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eli Harrison
@@ -110,8 +110,10 @@ files:
110
110
  - lib/muwu/cli/help/heading
111
111
  - lib/muwu/cli/help/inspect
112
112
  - lib/muwu/cli/help/new
113
+ - lib/muwu/cli/help/publish
113
114
  - lib/muwu/cli/help/reset
114
115
  - lib/muwu/cli/help/summary
116
+ - lib/muwu/cli/help/sync
115
117
  - lib/muwu/controller/controller.rb
116
118
  - lib/muwu/controller/controller_interaction.rb
117
119
  - lib/muwu/default/default.rb
@@ -175,12 +177,16 @@ files:
175
177
  - lib/muwu/project_exception/navigators_will_be_generated_automatically.rb
176
178
  - lib/muwu/project_exception/option_key_not_understood.rb
177
179
  - lib/muwu/project_exception/option_not_validatable.rb
180
+ - lib/muwu/project_exception/option_remote_publish_value_nil.rb
181
+ - lib/muwu/project_exception/option_remote_sync_value_nil.rb
178
182
  - lib/muwu/project_exception/option_value_not_understood.rb
179
183
  - lib/muwu/project_exception/options_file_not_found.rb
180
184
  - lib/muwu/project_exception/outline_file_not_found.rb
181
185
  - lib/muwu/project_exception/outline_step_not_understood.rb
182
186
  - lib/muwu/project_exception/output_already_open.rb
183
187
  - lib/muwu/project_exception/output_not_open.rb
188
+ - lib/muwu/project_exception/rsync_not_available.rb
189
+ - lib/muwu/project_exception/scp_not_available.rb
184
190
  - lib/muwu/project_exception/subcontents_will_be_generated_automatically copy.rb
185
191
  - lib/muwu/project_exception/target_project_folder_already_exists.rb
186
192
  - lib/muwu/project_exception/text_source_file_not_found.rb
@@ -190,6 +196,7 @@ files:
190
196
  - lib/muwu/project_options_builder/project_option_validator_key.rb
191
197
  - lib/muwu/project_options_builder/project_option_validator_value.rb
192
198
  - lib/muwu/project_options_builder/project_options_reader.rb
199
+ - lib/muwu/publish/publish.rb
193
200
  - lib/muwu/render_concat/render_concat.rb
194
201
  - lib/muwu/render_html/render_html.rb
195
202
  - lib/muwu/render_html/render_markup_to_html.rb
@@ -222,6 +229,7 @@ files:
222
229
  - lib/muwu/render_html_partial_builder/render_text_item_builder.rb
223
230
  - lib/muwu/render_html_partial_builder/render_title_builder.rb
224
231
  - lib/muwu/render_inspector/render_inspector.rb
232
+ - lib/muwu/sync/sync.rb
225
233
  - lib/muwu/var/deflistdiv.rb
226
234
  - lib/muwu_loader.rb
227
235
  - test/what_no_tests.md
@@ -240,9 +248,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
240
248
  version: 2.5.1
241
249
  required_rubygems_version: !ruby/object:Gem::Requirement
242
250
  requirements:
243
- - - ">="
251
+ - - ">"
244
252
  - !ruby/object:Gem::Version
245
- version: '0'
253
+ version: 1.3.1
246
254
  requirements: []
247
255
  rubygems_version: 3.1.2
248
256
  signing_key: