tms 1.0.0.1 → 1.0.1
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.
- data/VERSION +1 -1
- data/bin/tms +20 -6
- data/lib/tms.rb +26 -11
- data/lib/tms/backup.rb +17 -2
- data/tms.gemspec +2 -2
- metadata +3 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/bin/tms
CHANGED
@@ -7,14 +7,28 @@ rescue LoadError
|
|
7
7
|
require 'tms'
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
require 'optparse'
|
11
|
+
|
12
|
+
ids, options = ARGV.partition{ |arg| arg =~ /^-?\d+$/ }
|
13
|
+
OptionParser.new do |op|
|
14
|
+
op.banner = <<-BANNER
|
15
|
+
Usege:
|
16
|
+
List: #{op.program_name} [options]
|
17
|
+
Diff: #{op.program_name} [options] id1 id2
|
18
|
+
Diff with previous: #{op.program_name} [options] id
|
19
|
+
BANNER
|
20
|
+
|
21
|
+
op.on('-d', '--directory DIRECTORY', 'Use backup directory') do |dir|
|
22
|
+
Tms::Backup.backups_dir = dir
|
23
|
+
end
|
24
|
+
end.parse!(options)
|
25
|
+
|
26
|
+
ids = ids.map(&:to_i)
|
27
|
+
case ids.length
|
11
28
|
when 0
|
12
29
|
Tms.list
|
13
30
|
when 1
|
14
|
-
|
15
|
-
Tms.diff(id - 1, id)
|
31
|
+
Tms.diff(ids[0] - 1, ids[0])
|
16
32
|
when 2
|
17
|
-
Tms.diff(
|
18
|
-
else
|
19
|
-
abort 'Max two arguments'
|
33
|
+
Tms.diff(ids[0], ids[1])
|
20
34
|
end
|
data/lib/tms.rb
CHANGED
@@ -18,23 +18,38 @@ class Pathname
|
|
18
18
|
''
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
if
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
def count_size(options = {})
|
22
|
+
if defined?(@counted_size)
|
23
|
+
@counted_size
|
24
|
+
else
|
25
|
+
@counted_size = if exist?
|
26
|
+
if directory?
|
27
|
+
if options[:recursive]
|
28
|
+
total = 0
|
29
|
+
find do |path|
|
30
|
+
total += path.size rescue nil
|
31
|
+
end
|
32
|
+
total
|
33
|
+
else
|
34
|
+
0
|
28
35
|
end
|
29
|
-
Tms::Space.space(total, :color => true)
|
30
36
|
else
|
31
|
-
|
37
|
+
size
|
32
38
|
end
|
33
39
|
else
|
34
|
-
|
40
|
+
nil
|
35
41
|
end
|
36
|
-
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def colored_size(options = {})
|
46
|
+
case size = count_size(options)
|
47
|
+
when nil
|
37
48
|
'!!!!!!'
|
49
|
+
when 0
|
50
|
+
' '
|
51
|
+
else
|
52
|
+
Tms::Space.space(size, :color => true)
|
38
53
|
end
|
39
54
|
end
|
40
55
|
end
|
data/lib/tms/backup.rb
CHANGED
@@ -14,6 +14,9 @@ class Tms::Backup
|
|
14
14
|
backups_dir
|
15
15
|
end
|
16
16
|
end
|
17
|
+
def backups_dir=(dir)
|
18
|
+
@backups_dir = Pathname(dir)
|
19
|
+
end
|
17
20
|
|
18
21
|
def list
|
19
22
|
@list ||= begin
|
@@ -24,9 +27,11 @@ class Tms::Backup
|
|
24
27
|
end
|
25
28
|
|
26
29
|
def diff(a, b)
|
30
|
+
total = 0
|
27
31
|
(a.path.children(false) | b.path.children(false)).reject{ |child| child.to_s[0, 1] == '.' }.sort.each do |path|
|
28
|
-
compare(a.path + path, b.path + path, Pathname('/') + path)
|
32
|
+
total += compare(a.path + path, b.path + path, Pathname('/') + path)
|
29
33
|
end
|
34
|
+
puts "#{'Total:'.bold} #{Tms::Space.space(total, :color => true)}"
|
30
35
|
end
|
31
36
|
|
32
37
|
private
|
@@ -35,21 +40,31 @@ class Tms::Backup
|
|
35
40
|
case
|
36
41
|
when !a.exist?
|
37
42
|
puts "#{' █'.green} #{b.colored_size(:recursive => true)} #{path}#{b.postfix}"
|
43
|
+
b.count_size || 0
|
38
44
|
when !b.exist?
|
39
45
|
puts "#{'█ '.blue} #{a.colored_size(:recursive => true)} #{path}#{a.postfix}"
|
46
|
+
0
|
40
47
|
when a.ftype != b.ftype
|
41
48
|
puts "#{'!!!'.red.bold} #{a.colored_size} #{path} (#{a.ftype}=>#{b.ftype})"
|
49
|
+
b.count_size || 0
|
42
50
|
when a.lino != b.lino
|
43
51
|
if a.readable? && b.readable?
|
44
52
|
puts "#{'█≠█'.yellow} #{a.colored_size} #{path}#{a.postfix}" unless a.symlink? && a.readlink == b.readlink
|
45
53
|
if a.real_directory?
|
54
|
+
total = 0
|
46
55
|
(a.children(false) | b.children(false)).sort.each do |child|
|
47
|
-
compare(a + child, b + child, path + child)
|
56
|
+
total += compare(a + child, b + child, path + child)
|
48
57
|
end
|
58
|
+
total
|
59
|
+
else
|
60
|
+
b.size
|
49
61
|
end
|
50
62
|
else
|
51
63
|
puts "??? #{path}#{a.postfix}".red.bold
|
64
|
+
0
|
52
65
|
end
|
66
|
+
else
|
67
|
+
0
|
53
68
|
end
|
54
69
|
end
|
55
70
|
end
|
data/tms.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{tms}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Boba Fat"]
|
12
|
-
s.date = %q{2010-11-
|
12
|
+
s.date = %q{2010-11-11}
|
13
13
|
s.default_executable = %q{tms}
|
14
14
|
s.description = %q{View avaliable Time Machine backups and show diff}
|
15
15
|
s.executables = ["tms"]
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
- 0
|
10
9
|
- 1
|
11
|
-
version: 1.0.
|
10
|
+
version: 1.0.1
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- Boba Fat
|
@@ -16,7 +15,7 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-11 00:00:00 +03:00
|
20
19
|
default_executable: tms
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|