synco 1.1.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +3 -0
  3. data/bin/synco +3 -3
  4. data/lib/synco/command/disk.rb +8 -23
  5. data/lib/synco/command/prune.rb +10 -25
  6. data/lib/synco/command/rotate.rb +46 -61
  7. data/lib/synco/command/spawn.rb +10 -25
  8. data/lib/synco/command.rb +23 -35
  9. data/lib/synco/controller.rb +4 -19
  10. data/lib/synco/directory.rb +8 -23
  11. data/lib/synco/disk.rb +4 -19
  12. data/lib/synco/method.rb +11 -26
  13. data/lib/synco/methods/rsync.rb +14 -29
  14. data/lib/synco/methods/scp.rb +8 -23
  15. data/lib/synco/methods/zfs.rb +7 -22
  16. data/lib/synco/scope.rb +33 -68
  17. data/lib/synco/script.rb +15 -32
  18. data/lib/synco/server.rb +9 -24
  19. data/lib/synco/shell.rb +5 -20
  20. data/lib/synco/shells/ssh.rb +10 -25
  21. data/lib/synco/version.rb +5 -20
  22. data/lib/synco.rb +13 -29
  23. data/license.md +21 -0
  24. data/readme.md +248 -0
  25. data.tar.gz.sig +0 -0
  26. metadata +60 -120
  27. metadata.gz.sig +0 -0
  28. data/.gitignore +0 -22
  29. data/.rspec +0 -4
  30. data/.simplecov +0 -9
  31. data/.travis.yml +0 -14
  32. data/Gemfile +0 -11
  33. data/README.md +0 -246
  34. data/Rakefile +0 -8
  35. data/lib/synco/compact_formatter.rb +0 -115
  36. data/media/LSync Logo.artx/Preview/preview.png +0 -0
  37. data/media/LSync Logo.artx/QuickLook/Preview.pdf +0 -0
  38. data/media/LSync Logo.artx/doc.thread +0 -0
  39. data/media/LSync Logo.png +0 -0
  40. data/spec/synco/backup_script.rb +0 -63
  41. data/spec/synco/directory_spec.rb +0 -33
  42. data/spec/synco/local_backup.rb +0 -56
  43. data/spec/synco/local_sync.rb +0 -91
  44. data/spec/synco/method_spec.rb +0 -62
  45. data/spec/synco/rsync_spec.rb +0 -89
  46. data/spec/synco/scp_spec.rb +0 -58
  47. data/spec/synco/script_spec.rb +0 -51
  48. data/spec/synco/shell_spec.rb +0 -42
  49. data/spec/synco/usb_spec.rb +0 -76
  50. data/spec/synco/zfs_spec.rb +0 -50
  51. data/synco.gemspec +0 -35
@@ -1,25 +1,10 @@
1
- # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
20
2
 
21
- require_relative '../method'
22
- require 'shellwords'
3
+ # Released under the MIT License.
4
+ # Copyright, 2011-2024, by Samuel Williams.
5
+
6
+ require_relative "../method"
7
+ require "shellwords"
23
8
 
24
9
  module Synco
25
10
  module Methods
@@ -48,16 +33,16 @@ module Synco
48
33
 
49
34
  class RSync < Method
50
35
  def default_command
51
- ['rsync']
36
+ ["rsync"]
52
37
  end
53
38
 
54
39
  def initialize(*command, arguments: [], archive: false, stats: nil, **options)
55
40
  if archive
56
- arguments << '--archive'
41
+ arguments << "--archive"
57
42
  end
58
43
 
59
44
  if stats
60
- arguments << '--stats'
45
+ arguments << "--stats"
61
46
  end
62
47
 
63
48
  super
@@ -67,7 +52,7 @@ module Synco
67
52
  def escape(command)
68
53
  case command
69
54
  when Array
70
- command.collect{|arg| escape(arg)}.join(' ')
55
+ command.collect{|arg| escape(arg)}.join(" ")
71
56
  when String
72
57
  command =~ /\s|"|'/ ? command.dump : command
73
58
  else
@@ -88,7 +73,7 @@ module Synco
88
73
  command.pop
89
74
  end
90
75
 
91
- return ['-e', escape(command)]
76
+ return ["-e", escape(command)]
92
77
  end
93
78
 
94
79
  def call(scope)
@@ -131,7 +116,7 @@ module Synco
131
116
 
132
117
  latest_path = File.join("../" * depth, latest_name, directory.path)
133
118
 
134
- return ['--link-dest', latest_path]
119
+ return ["--link-dest", latest_path]
135
120
  end
136
121
 
137
122
  def call(scope)
@@ -143,7 +128,7 @@ module Synco
143
128
  link_arguments = compute_link_arguments(directory, incremental_path)
144
129
 
145
130
  # Create the destination backup directory
146
- target_server.run('mkdir', '-p', target_server.full_path(incremental_path))
131
+ target_server.run("mkdir", "-p", target_server.full_path(incremental_path))
147
132
 
148
133
  master_server.run(
149
134
  *@command,
@@ -159,4 +144,4 @@ module Synco
159
144
  end
160
145
  end
161
146
  end
162
- end
147
+ end
@@ -1,30 +1,15 @@
1
- # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
20
2
 
21
- require_relative '../method'
3
+ # Released under the MIT License.
4
+ # Copyright, 2016-2024, by Samuel Williams.
5
+
6
+ require_relative "../method"
22
7
 
23
8
  module Synco
24
9
  module Methods
25
10
  class SCP < Method
26
11
  def default_command
27
- ['scp', '-pr']
12
+ ["scp", "-pr"]
28
13
  end
29
14
 
30
15
  def call(scope)
@@ -35,10 +20,10 @@ module Synco
35
20
  *@command,
36
21
  *arguments,
37
22
  # If the destination directory already exists, scp will create the source directory inside the destinatio directory. This behaviour means that running scp multiple times gives different results, i.e. the first time it will copy source/* to destination/*, but the second time you will end up with destination/source/*. Putting a dot after the first path alleviates this issue for some reason.
38
- scope.master_server.connection_string(directory, on: server) + '.',
23
+ scope.master_server.connection_string(directory, on: server) + ".",
39
24
  scope.target_server.connection_string(directory, on: server)
40
25
  )
41
26
  end
42
27
  end
43
28
  end
44
- end
29
+ end
@@ -1,30 +1,15 @@
1
- # Copyright, 2016, Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
20
2
 
21
- require_relative '../method'
3
+ # Released under the MIT License.
4
+ # Copyright, 2016-2024, by Samuel Williams.
5
+
6
+ require_relative "../method"
22
7
 
23
8
  module Synco
24
9
  module Methods
25
10
  class ZFS < Method
26
11
  def default_command
27
- ['zfs', '-rnv']
12
+ ["zfs", "-rnv"]
28
13
  end
29
14
 
30
15
  def call(scope, arguments: [])
@@ -57,4 +42,4 @@ module Synco
57
42
  end
58
43
  end
59
44
  end
60
- end
45
+ end
data/lib/synco/scope.rb CHANGED
@@ -1,29 +1,14 @@
1
- # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
20
2
 
21
- require_relative 'script'
3
+ # Released under the MIT License.
4
+ # Copyright, 2016-2024, by Samuel Williams.
22
5
 
23
- require 'process/group'
6
+ require_relative "script"
24
7
 
25
- require 'logger'
26
- require 'delegate'
8
+ require "process/group"
9
+
10
+ require "console"
11
+ require "delegate"
27
12
 
28
13
  module Synco
29
14
  class CommandFailure < RuntimeError
@@ -39,46 +24,33 @@ module Synco
39
24
  end
40
25
 
41
26
  class Runner
42
- def initialize(*scripts, logger: nil, verbose: false)
27
+ def initialize(*scripts)
43
28
  @scripts = scripts
44
-
45
- @logger = logger || Logger.new($stderr).tap do |logger|
46
- logger.formatter = CompactFormatter.new
47
-
48
- if verbose or ENV['SYNCO_VERBOSE']
49
- logger.level = Logger::DEBUG
50
- else
51
- logger.level = Logger::INFO
52
- end
53
- end
54
29
  end
55
30
 
56
31
  attr :scripts
57
- attr :logger
58
32
 
59
33
  def call
60
- start_time = Time.now
61
-
62
- logger.info "===== Starting at #{start_time} ====="
34
+ Console.info(self, "Running scripts...")
63
35
 
64
36
  Process::Group.wait do |group|
65
37
  @scripts.each do |script|
66
38
  Fiber.new do
67
- ScriptScope.new(script, @logger, group).call
39
+ ScriptScope.new(script, group).call
68
40
  end.resume
69
41
  end
70
42
  end
43
+ rescue => error
44
+ Console::Event::Failure.for(error).emit(self)
45
+ raise
71
46
  ensure
72
- end_time = Time.now
73
- logger.info "[Time]: (#{end_time - start_time}s)."
74
- logger.info "===== Finished backup at #{end_time} ====="
47
+ Console.info(self, "Finished running scripts.")
75
48
  end
76
49
  end
77
50
 
78
51
  class ScriptScope
79
- def initialize(script, logger, group)
52
+ def initialize(script, group)
80
53
  @script = script
81
- @logger = logger
82
54
  @group = group
83
55
 
84
56
  @current_server = ServerScope.new(@script.current_server, self)
@@ -86,7 +58,6 @@ module Synco
86
58
  end
87
59
 
88
60
  attr :script
89
- attr :logger
90
61
  attr :group
91
62
  attr :master_server
92
63
  attr :current_server
@@ -97,18 +68,17 @@ module Synco
97
68
 
98
69
  def call
99
70
  if @script.running_on_master?
100
- logger.info "We are the master server..."
71
+ Console.info(self, "We are the master server...")
101
72
  else
102
- logger.info "We are not the master server..."
103
- logger.info "Master server is #{@master}..."
73
+ Console.info(self, "We are not the master server...", master: @master)
104
74
  end
105
-
75
+
106
76
  @script.try(self) do
107
77
  # This allows events to run on the master server if specified, before running any backups.
108
78
 
109
79
  @master_server.try(master_target_server) do
110
80
  method.try(self) do
111
- logger.info "Running backups for server #{@current_server}..."
81
+ Console.info(self, "Running backups...", server: @current_server)
112
82
 
113
83
  run_servers(group)
114
84
  end
@@ -135,16 +105,15 @@ module Synco
135
105
  def run_servers(group)
136
106
  target_servers do |server|
137
107
  sync_scope = TargetScope.new(self, server)
138
-
139
- logger.info "===== Processing ====="
140
- logger.info "[Master]: #{master_server}"
141
- logger.info "[Target]: #{server}"
108
+
109
+ Console.info(self, "Running script...", master: @master_server, target: server)
142
110
 
143
111
  server.try(sync_scope) do
144
112
  @script.directories.each do |directory|
145
113
  directory_scope = DirectoryScope.new(sync_scope, directory)
146
-
147
- logger.info "[Directory]: #{directory}"
114
+
115
+ Console.info(self, "Processing directory...", directory: directory)
116
+
148
117
  directory.try(directory_scope) do
149
118
  method.call(directory_scope)
150
119
  end
@@ -155,9 +124,8 @@ module Synco
155
124
  end
156
125
 
157
126
  class LogPipe < DelegateClass(IO)
158
- def initialize(logger, level = :info)
127
+ def initialize(logger: Console, level: :info)
159
128
  @input, @output = IO.pipe
160
- @logger = logger
161
129
 
162
130
  super(@output)
163
131
 
@@ -186,10 +154,6 @@ module Synco
186
154
  @from = from
187
155
  end
188
156
 
189
- def logger
190
- @logger ||= @script_scope.logger
191
- end
192
-
193
157
  def group
194
158
  @group ||= @script_scope.group
195
159
  end
@@ -204,13 +168,14 @@ module Synco
204
168
  command = self.connection_command + ["--"] + command
205
169
  end
206
170
 
207
- logger.info("shell") {[command, options]}
171
+ Console::Event::Spawn.for(*command, **options).emit(self)
208
172
 
209
- options[:out] ||= LogPipe.new(logger)
210
- options[:err] ||= LogPipe.new(logger, :error)
173
+ options[:out] ||= LogPipe.new
174
+ options[:err] ||= LogPipe.new(level: :error)
211
175
 
212
176
  status = self.group.spawn(*command, **options)
213
- logger.debug{"Process finished: #{status}."}
177
+
178
+ Console.info(self, "Command completed.", status: status)
214
179
 
215
180
  options[:out].close
216
181
  options[:err].close
@@ -228,8 +193,8 @@ module Synco
228
193
  @target_server = ServerScope.new(target, script_scope, script_scope.current_server)
229
194
  end
230
195
 
231
- def run(*arguments)
232
- @target_server.run(*arguments)
196
+ def run(...)
197
+ @target_server.run(...)
233
198
  end
234
199
 
235
200
  attr :target_server
data/lib/synco/script.rb CHANGED
@@ -1,38 +1,21 @@
1
- # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
20
-
21
- require_relative 'method'
22
- require_relative 'server'
23
- require_relative 'directory'
24
- require_relative 'controller'
25
-
26
- require_relative 'compact_formatter'
27
-
28
- require 'socket'
29
-
30
- require 'process/group'
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2008-2024, by Samuel Williams.
5
+
6
+ require_relative "method"
7
+ require_relative "server"
8
+ require_relative "directory"
9
+ require_relative "controller"
10
+
11
+ require "socket"
12
+
13
+ require "process/group"
31
14
 
32
15
  module Synco
33
16
  # The main backup/synchronisation mechanism is the backup script. It specifies all servers and directories, and these are then combined specifically to produce the desired data replication behaviour.
34
17
  class Script < Controller
35
- def initialize(method: nil, servers: {}, directories: [], master: :master, logger: nil)
18
+ def initialize(method: nil, servers: {}, directories: [], master: :master)
36
19
  super()
37
20
 
38
21
  @method = method
@@ -89,7 +72,7 @@ module Synco
89
72
  else
90
73
  # Find a server config that specifies the local host
91
74
  @servers.values.find{|server| localhost?(server.host)}
92
- end || Server.new('localhost')
75
+ end || Server.new("localhost")
93
76
  end
94
77
 
95
78
  def current_server
data/lib/synco/server.rb CHANGED
@@ -1,32 +1,17 @@
1
- # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
20
2
 
21
- require_relative 'controller'
22
- require_relative 'directory'
23
- require_relative 'shells/ssh'
3
+ # Released under the MIT License.
4
+ # Copyright, 2009-2024, by Samuel Williams.
24
5
 
25
- require 'shellwords'
6
+ require_relative "controller"
7
+ require_relative "directory"
8
+ require_relative "shells/ssh"
9
+
10
+ require "shellwords"
26
11
 
27
12
  module Synco
28
13
  class Server < Controller
29
- def initialize(name, root: '/', shell: nil, **options)
14
+ def initialize(name, root: "/", shell: nil, **options)
30
15
  super()
31
16
 
32
17
  @name = name
data/lib/synco/shell.rb CHANGED
@@ -1,24 +1,9 @@
1
- # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
20
2
 
21
- require 'pathname'
3
+ # Released under the MIT License.
4
+ # Copyright, 2009-2024, by Samuel Williams.
5
+
6
+ require "pathname"
22
7
 
23
8
  module Synco
24
9
  # A shell provides access to a server, typically to run commands.
@@ -1,48 +1,33 @@
1
- # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
20
2
 
21
- require_relative '../shell'
3
+ # Released under the MIT License.
4
+ # Copyright, 2011-2024, by Samuel Williams.
5
+
6
+ require_relative "../shell"
22
7
 
23
8
  module Synco
24
9
  module Shells
25
10
  # SSH shell provides access to a remote server using SSH.
26
11
  class SSH < Shell
27
12
  def default_command
28
- ['ssh']
13
+ ["ssh"]
29
14
  end
30
15
 
31
16
  def initialize(*command, arguments: [], port: nil, key: nil, user: nil, batch_mode: nil, **options)
32
17
  if port
33
- arguments << '-p' << port
18
+ arguments << "-p" << port
34
19
  end
35
20
 
36
21
  if key
37
- arguments << '-i' << key
22
+ arguments << "-i" << key
38
23
  end
39
24
 
40
25
  if user
41
- arguments << '-l' << user
26
+ arguments << "-l" << user
42
27
  end
43
28
 
44
29
  unless batch_mode.nil?
45
- arguments << '-o' << "BatchMode=#{batch_mode ? 'yes' : 'no'}"
30
+ arguments << "-o" << "BatchMode=#{batch_mode ? 'yes' : 'no'}"
46
31
  end
47
32
 
48
33
  super
data/lib/synco/version.rb CHANGED
@@ -1,23 +1,8 @@
1
- # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2008-2024, by Samuel Williams.
20
5
 
21
6
  module Synco
22
- VERSION = "1.1.0"
7
+ VERSION = "1.3.0"
23
8
  end
data/lib/synco.rb CHANGED
@@ -1,36 +1,20 @@
1
- # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
20
2
 
21
- require 'yaml'
22
- require 'socket'
23
- require 'set'
24
- require 'logger'
3
+ # Released under the MIT License.
4
+ # Copyright, 2008-2024, by Samuel Williams.
25
5
 
26
- require_relative 'synco/version'
27
- require_relative 'synco/script'
28
- require_relative 'synco/scope'
6
+ require "yaml"
7
+ require "socket"
8
+ require "set"
29
9
 
30
- require 'fileutils'
31
- require 'optparse'
10
+ require_relative "synco/version"
11
+ require_relative "synco/script"
12
+ require_relative "synco/scope"
32
13
 
33
- require 'lockfile'
14
+ require "fileutils"
15
+ require "optparse"
16
+
17
+ require "lockfile"
34
18
 
35
19
  module Synco
36
20
  # Run a prepared backup script using a lockfile.