tms 1.3.5 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/tms +6 -0
- data/lib/tms/backup.rb +1 -0
- data/lib/tms/comparison.rb +35 -17
- data/lib/tms/space.rb +1 -1
- data/tms.gemspec +2 -2
- metadata +5 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.4.0
|
data/bin/tms
CHANGED
@@ -64,6 +64,12 @@ Options for #{type} (-h to view all options):
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
unless type == :list
|
68
|
+
op.on('-b', '--[no-]both-sizes', 'Show sizes for both left and right path') do |show_both_sizes|
|
69
|
+
Tms::Backup.show_both_sizes = show_both_sizes
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
67
73
|
op.on_tail('-h', '--help', 'Show full help') do
|
68
74
|
puts option_parser.help
|
69
75
|
exit
|
data/lib/tms/backup.rb
CHANGED
data/lib/tms/comparison.rb
CHANGED
@@ -4,13 +4,13 @@ require 'tms/space'
|
|
4
4
|
|
5
5
|
module Tms
|
6
6
|
class Comparison
|
7
|
-
attr_reader :backup_a, :backup_b
|
7
|
+
attr_reader :backup_a, :backup_b
|
8
8
|
def initialize(backup_a, backup_b)
|
9
9
|
@backup_a, @backup_b = backup_a, backup_b
|
10
10
|
end
|
11
11
|
|
12
12
|
def run
|
13
|
-
@
|
13
|
+
@a_total, @b_total = 0, 0
|
14
14
|
begin
|
15
15
|
root_dirs = (backup_a.path.children(false) | backup_b.path.children(false)).sort
|
16
16
|
root_dirs.reject!{ |root_dir| root_dir.path[0, 1] == '.' }
|
@@ -24,7 +24,11 @@ module Tms
|
|
24
24
|
puts
|
25
25
|
puts 'Interrupted'
|
26
26
|
end
|
27
|
-
|
27
|
+
if Tms::Backup.show_both_sizes?
|
28
|
+
line [colorize('Total:', :total), space(@a_total), space(@b_total)].join(' ')
|
29
|
+
else
|
30
|
+
line [colorize('Total:', :total), space(@b_total)].join(' ')
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
private
|
@@ -32,21 +36,26 @@ module Tms
|
|
32
36
|
def compare(a, b, path)
|
33
37
|
case
|
34
38
|
when !a.exist?
|
35
|
-
|
39
|
+
diff_line nil, b, path, colorize(' █', :right), "#{path}#{b.postfix}", true
|
36
40
|
when !b.exist?
|
37
|
-
|
41
|
+
diff_line a, nil, path, colorize('█ ', :left), "#{path}#{a.postfix}", true
|
38
42
|
when a.ftype != b.ftype
|
39
|
-
|
43
|
+
diff_line a, b, path, colorize('█≠█', :diff_type), "#{path}#{b.postfix} (#{a.ftype}=>#{b.ftype})", true
|
40
44
|
when a.lstat.ino != b.lstat.ino
|
41
45
|
if a.readable_real? && b.readable_real?
|
42
|
-
|
46
|
+
diff_line a, b, path, colorize('█≠█', :diff), "#{path}#{b.postfix}", false unless b.symlink? && a.readlink == b.readlink
|
43
47
|
if b.directory? && !b.symlink?
|
44
48
|
(a.children(false) | b.children(false)).sort.each do |child|
|
45
49
|
compare(a / child, b / child, path / child)
|
46
50
|
end
|
47
51
|
end
|
48
52
|
else
|
49
|
-
|
53
|
+
parts = if Tms::Backup.show_both_sizes?
|
54
|
+
['???', Space::NOT_COUNTED_SPACE, Space::NOT_COUNTED_SPACE, "#{path}#{a.postfix}"]
|
55
|
+
else
|
56
|
+
['???', Space::NOT_COUNTED_SPACE, "#{path}#{a.postfix}"]
|
57
|
+
end
|
58
|
+
line colorize(parts.join(' '), :unreadable)
|
50
59
|
end
|
51
60
|
else
|
52
61
|
progress do
|
@@ -100,11 +109,11 @@ module Tms
|
|
100
109
|
if Tms::Backup.show_progress?
|
101
110
|
@last_progress ||= Time.now
|
102
111
|
if (now = Time.now) > @last_progress + 0.1
|
103
|
-
|
112
|
+
l = yield.to_s
|
104
113
|
if width = terminal_width
|
105
|
-
|
114
|
+
l = trim_left_colored(l, terminal_width - 1)
|
106
115
|
end
|
107
|
-
$stderr.print "#{
|
116
|
+
$stderr.print "#{l}#{CLEAR_LINE}\r"
|
108
117
|
@last_progress = now
|
109
118
|
end
|
110
119
|
end
|
@@ -122,9 +131,21 @@ module Tms
|
|
122
131
|
end
|
123
132
|
end
|
124
133
|
|
125
|
-
def
|
134
|
+
def diff_line(a_path, b_path, path, prefix, postfix, recursive)
|
135
|
+
a_sub_total = a_path ? count_space(a_path, path, prefix, recursive) : nil
|
136
|
+
b_sub_total = b_path ? count_space(b_path, path, prefix, recursive) : nil
|
137
|
+
if Tms::Backup.show_both_sizes?
|
138
|
+
line [prefix, space(a_sub_total), space(b_sub_total), postfix].join(' ')
|
139
|
+
else
|
140
|
+
line [prefix, b_sub_total ? space(b_sub_total) : space(a_sub_total), postfix].join(' ')
|
141
|
+
end
|
142
|
+
@a_total += a_sub_total if a_sub_total
|
143
|
+
@b_total += b_sub_total if b_sub_total
|
144
|
+
end
|
145
|
+
|
146
|
+
def count_space(backup_path, path, prefix, recursive)
|
126
147
|
sub_total = 0
|
127
|
-
if
|
148
|
+
if recursive
|
128
149
|
backup_path.find do |sub_path|
|
129
150
|
sub_total += sub_path.size_if_real_file
|
130
151
|
progress do
|
@@ -134,10 +155,7 @@ module Tms
|
|
134
155
|
else
|
135
156
|
sub_total = backup_path.size_if_real_file
|
136
157
|
end
|
137
|
-
|
138
|
-
unless options[:no_total]
|
139
|
-
@total += sub_total
|
140
|
-
end
|
158
|
+
sub_total
|
141
159
|
end
|
142
160
|
|
143
161
|
def command_exists?(command)
|
data/lib/tms/space.rb
CHANGED
data/tms.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "tms"
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ivan Kuchin"]
|
12
|
-
s.date = "2011-11-
|
12
|
+
s.date = "2011-11-16"
|
13
13
|
s.description = "View avaliable Time Machine backups and show their diff"
|
14
14
|
s.executables = ["tms"]
|
15
15
|
s.extensions = ["ext/tms/extconf.rb"]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 1.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ivan Kuchin
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-11-
|
18
|
+
date: 2011-11-16 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: colored
|