multisync 0.3.6 → 0.3.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0293de3d6bf07fd58fcaf551c5469aad676d1b51682dcf58a59b85024dbe1f5
4
- data.tar.gz: 55170bd7e42c82b2f3e3dcb7c5a9caede2ad53980611f209d7adad2c2a613ffc
3
+ metadata.gz: 0f5ccf30a0608eca5f17002de411dc941cb90d192c5343863a8b7898d2ab3270
4
+ data.tar.gz: 94d44b2c52223526c379112fa756249ebc0da3b1a61f77413c70229b95fe4525
5
5
  SHA512:
6
- metadata.gz: bf970e9e365204d4af64b975ec165ba616f17bcf90fb6e752cf22348dccf8c515d57471ea22b4410bee8a38fa2de08030922835b8d43eac1bcf88c434bd187a5
7
- data.tar.gz: 4ce7a0b3dc4d9317883558e2c137c2da63e2ed4c8a9a103dffa6e4d24a3ae74f15af04ac07036f4868dc9e5425b769503d5be514df213035d1d34a0e5ab8b46c
6
+ metadata.gz: 841ef74fc08150c9c639551a6b7fe84a2f1c941f77cea8cb10dfe56d0447709f8fc5a992afe7b4d217e76d9ab78248ac81f5859b323b1de0c8d25b26cb6c43de
7
+ data.tar.gz: e77a0e739af5df1530487d035c51ad6c8cc853e6d783a17207d63fae20e2253fe6098b54f5f5cf77c025f8fb48868a337d05c5417f3352176367ac90d9ec6e9f
data/CHANGELOG.md ADDED
@@ -0,0 +1,101 @@
1
+ ## Release v0.3.7 (2021-10-28)
2
+
3
+ * Add grand total to summary
4
+
5
+
6
+ ## Release v0.3.6 (2019-08-20)
7
+
8
+ * Tweak output when specifing --print and/or --quiet
9
+
10
+
11
+ ## Release v0.3.5 (2019-08-13)
12
+
13
+ * Fix option quiet
14
+ * Catch SIGINT and print a summary after an interrupt
15
+
16
+
17
+ ## Release v0.3.4 (2019-07-23)
18
+
19
+ * Update help
20
+ * Update readme
21
+ * Update sample file
22
+
23
+
24
+ ## Release v0.3.3 (2019-07-23)
25
+
26
+ * Update gem description
27
+
28
+
29
+ ## Release v0.3.2 (2019-07-23)
30
+
31
+ * First public release
32
+
33
+
34
+ ## Release v0.3.1 (2018-06-01)
35
+
36
+ Changes in DSL
37
+ * removed "desc"
38
+ * "from" accepts a description option
39
+ * "to"" accepts a description option
40
+ * New: "template" and "include"
41
+
42
+ Changes in CLI
43
+ * New: timeout option
44
+ * New: quiet option
45
+ * polished output
46
+
47
+
48
+ ## Release v0.2.4 (2017-09-23)
49
+
50
+ * Fix: check command
51
+
52
+
53
+ ## Release v0.2.3 (2017-09-23)
54
+
55
+ * Fix: check remote path
56
+
57
+
58
+ ## Release v0.2.2 (2017-09-23)
59
+
60
+ * replaced shell_cmd gem with mixlib-shellout
61
+ * Fix: check path for paths containing spaces
62
+
63
+
64
+ ## Release v0.2.1 (2017-09-22)
65
+
66
+ * New: option "check_from" and "check_to" to let check host or path before sync
67
+ * New: "from" and "to" accept an optional check: true|false parameter
68
+ * Change summery output to a more compact tabular form
69
+ * Use rainbow for colorization
70
+ * Move "only_if" checks to runtime
71
+
72
+
73
+ ## Release v0.2.0 (2016-03-22)
74
+
75
+ * New: option only_if for preflight checks, prior to sync
76
+ * Command line option -p/--print changed to --show
77
+
78
+
79
+ ## Release v0.1.2 (2014-08-29)
80
+
81
+ * Mark default sets with an * when listing
82
+
83
+
84
+ ## Release v0.1.1 (2014-08-28)
85
+
86
+ * Add gem dependecy 'text-highlight'
87
+
88
+
89
+ ## Release v0.1.0 (2014-07-18)
90
+
91
+ * New: define one or more groups/syncs as default, to run when no sets have been given as args
92
+
93
+
94
+ ## Release v0.0.2 (2014-07-17)
95
+
96
+ * Fix: do no escape option strings
97
+
98
+
99
+ ## Release v0.0.1 (2014-07-11)
100
+
101
+ * First release
data/Gemfile CHANGED
@@ -1,5 +1,10 @@
1
- source 'https://rubygems.org'
2
- source 'https://gems.patrickmarchi.ch'
1
+ # frozen_string_literal: true
3
2
 
4
- # Specify your gem's dependencies in multisync.gemspec
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in gitoc.gemspec
5
6
  gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019 Patrick Marchi
3
+ Copyright (c) 2021 Patrick Marchi
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
- task :default => :spec
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/console CHANGED
@@ -7,8 +7,8 @@ require "multisync"
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
9
  # (If you use this, don't forget to add pry to your Gemfile!)
10
- require "pry"
11
- Pry.start
10
+ # require "pry"
11
+ # Pry.start
12
12
 
13
- # require "irb"
14
- # IRB.start(__FILE__)
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -1,58 +1,100 @@
1
-
2
- require 'filesize'
1
+ require "filesize"
3
2
 
4
3
  class Multisync::RsyncStat
5
-
4
+
5
+ # Keep track of totals
6
+ def self.total
7
+ @total ||= Hash.new 0
8
+ end
9
+
10
+ # Sample output
11
+ # ...
12
+ # Number of files: 89,633 (reg: 59,322, dir: 30,311)
13
+ # Number of created files: 356 (reg: 281, dir: 75)
14
+ # Number of deleted files: 114 (reg: 101, dir: 13)
15
+ # Number of regular files transferred: 344
16
+ # Total file size: 546,410,522,192 bytes
17
+ # Total transferred file size: 7,991,491,676 bytes
18
+ # Literal data: 7,952,503,842 bytes
19
+ # Matched data: 38,987,834 bytes
20
+ # File list size: 3,063,808
21
+ # File list generation time: 2.414 seconds
22
+ # File list transfer time: 0.000 seconds
23
+ # Total bytes sent: 7,957,645,803
24
+ # Total bytes received: 101,299
25
+ #
26
+ # sent 7,957,645,803 bytes received 101,299 bytes 23,719,067.37 bytes/sec
27
+ # total size is 546,410,522,192 speedup is 68.66
6
28
  def initialize output
7
29
  @output = output
8
30
  end
9
31
 
10
- # Build an internal hash with normalized stats
11
- def parse
12
- @stats = definitions.each_with_object({}) do |definition, stats|
13
- value = scan[definition[:match]]
14
- stats[definition[:key]] = value ? (definition[:coerce] ? definition[:coerce].call(value) : value) : definition[:default]
15
- end
16
- self
17
- end
18
-
19
- # Scan output and return a hash
32
+ # extracted returns a hash with labels as keys and extracted strings as values
20
33
  # {
21
- # "Number of files" => "35,648",
22
- # "Number of created files" => "0",
23
- # "Number of deleted files" => "0",
24
- # "Number of regular files transferred"=>"0",
34
+ # "Number of files" => "35,648",
35
+ # "Number of created files" => "2,120",
25
36
  # ...
26
37
  # }
27
- def scan
28
- @scan ||= @output.scan(/(#{definitions.map{|d| d[:match] }.join('|')}):\s+([,0-9]+)/).each_with_object({}) {|(k,v), o| o[k] = v }
29
- end
30
-
31
- def to_a
32
- [
33
- @stats[:files],
34
- @stats[:created],
35
- @stats[:deleted],
36
- @stats[:transferred],
37
- @stats[:file_size],
38
- @stats[:transferred_size],
39
- ]
40
- end
41
-
42
- def method_missing name
43
- key = name.to_sym
44
- return @stats[key] if @stats.keys.include? key
45
- super
46
- end
47
-
48
- def definitions
49
- [
50
- { key: :files, match: 'Number of files', coerce: ->(x) { x.gsub(',',"'") }, default: '0' },
51
- { key: :created, match: 'Number of created files', coerce: ->(x) { x.gsub(',',"'") }, default: '0' },
52
- { key: :deleted, match: 'Number of deleted files', coerce: ->(x) { x.gsub(',',"'") }, default: '0' },
53
- { key: :transferred, match: 'Number of regular files transferred', coerce: ->(x) { x.gsub(',',"'") }, default: '0' },
54
- { key: :file_size, match: 'Total file size', coerce: ->(x) { Filesize.new(x.gsub(',','').to_i).pretty }, default: '0 B' },
55
- { key: :transferred_size, match: 'Total transferred file size', coerce: ->(x) { Filesize.new(x.gsub(',','').to_i).pretty }, default: '0 B' },
56
- ]
38
+ def extracted
39
+ @extraced ||= @output.scan(/(#{labels.join('|')}):\s+([,0-9]+)/).to_h
40
+ end
41
+
42
+ # stats returns a hash with the follwing keys (and updates class total)
43
+ # {
44
+ # "Number of files" => 35648,
45
+ # "Number of created files" => 2120,
46
+ # "Number of deleted files" => 37,
47
+ # "Number of regular files transferred" => 394,
48
+ # "Total file size" => 204936349,
49
+ # "Total transferred file size" => 49239,
50
+ # }
51
+ def stats
52
+ @stats ||= labels.each_with_object({}) do |label, h|
53
+ value = extracted[label]&.delete(",").to_i
54
+
55
+ self.class.total[label] += value # update total
56
+ h[label] = value
57
+ end
58
+ end
59
+
60
+ def labels
61
+ self.class.format_map.keys
62
+ end
63
+
64
+ def formatted_values
65
+ self.class.format_values do |label|
66
+ stats[label]
67
+ end
68
+ end
69
+
70
+ def self.formatted_totals
71
+ format_values do |label|
72
+ total[label]
73
+ end
74
+ end
75
+
76
+ def self.format_values
77
+ format_map.map do |label, format|
78
+ format.call(yield label)
79
+ end
80
+ end
81
+
82
+ def self.format_map
83
+ {
84
+ 'Number of files' => to_numbers,
85
+ 'Number of created files' => to_numbers,
86
+ 'Number of deleted files' => to_numbers,
87
+ 'Number of regular files transferred' => to_numbers,
88
+ 'Total file size' => to_filesize,
89
+ 'Total transferred file size' => to_filesize,
90
+ }
91
+ end
92
+
93
+ def self.to_numbers
94
+ ->(x) { x.to_s.gsub(/\B(?=(...)*\b)/, "'") }
95
+ end
96
+
97
+ def self.to_filesize
98
+ ->(x) { Filesize.new(x).pretty }
57
99
  end
58
100
  end
@@ -1,4 +1,3 @@
1
-
2
1
  class Multisync::Summary
3
2
 
4
3
  # All tasks to include in the summary
@@ -21,7 +20,6 @@ class Multisync::Summary
21
20
  end
22
21
 
23
22
  def data
24
- # Exclude tasks with an empty result (> not run) first
25
23
  tasks.map do |task|
26
24
  result = task.result
27
25
  desc = [task.source_description, "--> #{task.destination_description}"]
@@ -30,8 +28,8 @@ class Multisync::Summary
30
28
  when :run
31
29
  if result[:status] && result[:status].success?
32
30
  # successfull run
33
- stat = Multisync::RsyncStat.new(result[:stdout]).parse
34
- [*desc, *stat.to_a.map{|e| {value: e.color(:green), alignment: :right} } ]
31
+ stats = Multisync::RsyncStat.new(result[:stdout])
32
+ [*desc, *stats.formatted_values.map{|e| {value: e.color(:green), alignment: :right} } ]
35
33
  else
36
34
  # failed or interrupted run
37
35
  [*desc, { value: (result[:stderr] || 'n/a').strip.color(:red), colspan: 6 } ]
@@ -45,7 +43,7 @@ class Multisync::Summary
45
43
  # not executed
46
44
  [*desc, { value: 'not executed'.faint, colspan: 6 } ]
47
45
  end
48
- end
46
+ end.push ["Total".faint, "", *Multisync::RsyncStat.formatted_totals.map{|e| {value: e.faint, alignment: :right} } ]
49
47
  end
50
48
 
51
49
  def table_style
@@ -1,3 +1,3 @@
1
1
  module Multisync
2
- VERSION = "0.3.6"
2
+ VERSION = "0.3.7"
3
3
  end
data/multisync.gemspec CHANGED
@@ -1,45 +1,41 @@
1
- lib = File.expand_path("../lib", __FILE__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "multisync/version"
1
+
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "lib/multisync/version"
4
5
 
5
6
  Gem::Specification.new do |spec|
6
- spec.name = "multisync"
7
- spec.version = Multisync::VERSION
8
- spec.authors = ["Patrick Marchi"]
9
- spec.email = ["mail@patrickmarchi.ch"]
10
-
11
- spec.summary = %q{DSL for rsync.}
12
- spec.description = %q{Multisync offers a DSL to organize sets of rsync tasks.}
13
- spec.homepage = "https://github.com/pmarchi/multisync"
14
- spec.license = "MIT"
15
-
16
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
- # to allow pushing to a single host or delete this section to allow pushing to any host.
18
- if spec.respond_to?(:metadata)
19
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
20
-
21
- spec.metadata["homepage_uri"] = spec.homepage
22
- spec.metadata["source_code_uri"] = "https://github.com/pmarchi/multisync"
23
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
24
- else
25
- raise "RubyGems 2.0 or newer is required to protect against " \
26
- "public gem pushes."
27
- end
7
+ spec.name = "multisync"
8
+ spec.version = Multisync::VERSION
9
+ spec.authors = ["Patrick Marchi"]
10
+ spec.email = ["mail@patrickmarchi.ch"]
11
+
12
+ spec.summary = [spec.name, spec.version].join("-")
13
+ spec.description = "A DSL to organize sets of rsync tasks."
14
+ spec.homepage = "https://github.com/pmarchi/multisync"
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = ">= 2.4.0"
17
+
18
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
+
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = spec.homepage
22
+ spec.metadata["changelog_uri"] = File.join(spec.homepage, "blob/main/CHANGELOG.md")
28
23
 
29
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
30
- f.match(%r{^(test|spec|features)/})
24
+ # Specify which files should be added to the gem when it is released.
25
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
27
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
31
28
  end
32
- spec.bindir = "exe"
33
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
34
31
  spec.require_paths = ["lib"]
35
32
 
33
+ # Uncomment to register a new dependency of your gem
36
34
  spec.add_dependency "mixlib-shellout"
37
35
  spec.add_dependency "filesize"
38
36
  spec.add_dependency "rainbow"
39
37
  spec.add_dependency "terminal-table"
40
38
 
41
- spec.add_development_dependency "bundler", "~> 1.16"
42
- spec.add_development_dependency "rake", "~> 10.0"
43
- spec.add_development_dependency "rspec"
44
- spec.add_development_dependency "pry"
39
+ # For more information and examples about making a new gem, checkout our
40
+ # guide at: https://bundler.io/guides/creating_gem.html
45
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multisync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Marchi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-20 00:00:00.000000000 Z
11
+ date: 2021-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -66,63 +66,7 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: bundler
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.16'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.16'
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '10.0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '10.0'
97
- - !ruby/object:Gem::Dependency
98
- name: rspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: pry
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- description: Multisync offers a DSL to organize sets of rsync tasks.
69
+ description: A DSL to organize sets of rsync tasks.
126
70
  email:
127
71
  - mail@patrickmarchi.ch
128
72
  executables:
@@ -132,8 +76,8 @@ extra_rdoc_files: []
132
76
  files:
133
77
  - ".gitignore"
134
78
  - ".rspec"
79
+ - CHANGELOG.md
135
80
  - Gemfile
136
- - History.md
137
81
  - LICENSE.txt
138
82
  - README.md
139
83
  - Rakefile
@@ -163,7 +107,8 @@ metadata:
163
107
  allowed_push_host: https://rubygems.org
164
108
  homepage_uri: https://github.com/pmarchi/multisync
165
109
  source_code_uri: https://github.com/pmarchi/multisync
166
- post_install_message:
110
+ changelog_uri: https://github.com/pmarchi/multisync/blob/main/CHANGELOG.md
111
+ post_install_message:
167
112
  rdoc_options: []
168
113
  require_paths:
169
114
  - lib
@@ -171,15 +116,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
116
  requirements:
172
117
  - - ">="
173
118
  - !ruby/object:Gem::Version
174
- version: '0'
119
+ version: 2.4.0
175
120
  required_rubygems_version: !ruby/object:Gem::Requirement
176
121
  requirements:
177
122
  - - ">="
178
123
  - !ruby/object:Gem::Version
179
124
  version: '0'
180
125
  requirements: []
181
- rubygems_version: 3.0.3
182
- signing_key:
126
+ rubygems_version: 3.1.6
127
+ signing_key:
183
128
  specification_version: 4
184
- summary: DSL for rsync.
129
+ summary: multisync-0.3.7
185
130
  test_files: []
data/History.md DELETED
@@ -1,50 +0,0 @@
1
-
2
- # multisync
3
-
4
- ## v0.3.1 (2018-06-01)
5
- Changes in DSL
6
- - removed "desc"
7
- - "from" accepts a description option
8
- - "to"" accepts a description option
9
- - New: "template" and "include"
10
-
11
- Changes in CLI
12
- - New: timeout option
13
- - New: quiet option
14
- - polished output
15
-
16
- ## v0.2.4 (2017-09-23)
17
- - Fix: check command
18
-
19
- ## v0.2.3 (2017-09-23)
20
- - Fix: check remote path
21
-
22
- ## v0.2.2 (2017-09-23)
23
- - replaced shell_cmd gem with mixlib-shellout
24
- - Fix: check path for paths containing spaces
25
-
26
- ## v0.2.1 (2017-09-22)
27
- - New: option "check_from" and "check_to" to let check host or path before sync
28
- - New: "from" and "to" accept an optional check: true|false parameter
29
- - Change summery output to a more compact tabular form
30
- - Use rainbow for colorization
31
- - Move "only_if" checks to runtime
32
-
33
- ## v0.2.0 (2016-03-22)
34
- - New: option only_if for preflight checks, prior to sync
35
- - Command line option -p/--print changed to --show
36
-
37
- ## v0.1.2 (2014-08-29)
38
- - Mark default sets with an * when listing
39
-
40
- ## v0.1.1 (2014-08-28)
41
- - Add gem dependecy 'text-highlight'
42
-
43
- ## v0.1.0 (2014-07-18)
44
- - New: define one or more groups/syncs as default, to run when no sets have been given as args
45
-
46
- ## v0.0.2 (2014-07-17)
47
- - Fix: do no escape option strings
48
-
49
- ## v0.0.1 (2014-07-11)
50
- - First release