tms 1.5.0 → 1.6.0

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.
@@ -1,6 +1,6 @@
1
1
  #include "ruby.h"
2
2
  #include <CoreServices/CoreServices.h>
3
- #include <SystemConfiguration/SystemConfiguration.h>>
3
+ #include <SystemConfiguration/SystemConfiguration.h>
4
4
 
5
5
  static VALUE backup_volume(VALUE self){
6
6
  OSStatus status = pathTooLongErr;
@@ -21,7 +21,7 @@ module Tms
21
21
  def backups_dir
22
22
  unless @backups_dir
23
23
  if system('which -s tmutil')
24
- $stderr.puts "Using tmutil to detect and mount Time Machine volume"
24
+ $stderr.print "Using tmutil to detect and mount Time Machine volume\r"
25
25
  self.backups_dir = `tmutil machinedirectory`.strip
26
26
  else
27
27
  self.backups_dir = Path.new(backup_volume) / 'Backups.backupdb' / computer_name
@@ -35,6 +35,25 @@ module Tms
35
35
  @backups_dir = backups_dir
36
36
  end
37
37
 
38
+ VOLUMES_PATH = '/Volumes/'
39
+ def tm_path(path)
40
+ unless path[0, VOLUMES_PATH.length].downcase == VOLUMES_PATH.downcase
41
+ path = File.join(root_volume_path, path)
42
+ end
43
+ path[VOLUMES_PATH.length - 1..-1]
44
+ end
45
+
46
+ def real_path(path)
47
+ path = File.join(VOLUMES_PATH, path)
48
+ path == root_volume_path ? '/' : path
49
+ end
50
+
51
+ def root_volume_path
52
+ @root_volume_path ||= Dir["#{VOLUMES_PATH}*"].find do |volume_path|
53
+ File.symlink?(volume_path) && File.readlink(volume_path) == '/'
54
+ end or abort('can\'t find /Volumes path for root')
55
+ end
56
+
38
57
  def filter_dirs
39
58
  @filter_dirs ||= []
40
59
  end
@@ -12,12 +12,18 @@ module Tms
12
12
  def run
13
13
  @a_total, @b_total = 0, 0
14
14
  begin
15
- root_dirs = (backup_a.path.children(false) | backup_b.path.children(false)).sort
16
- root_dirs.reject!{ |root_dir| root_dir.path[0, 1] == '.' }
17
- root_dirs.each do |root_dir|
18
- dirs = Backup.filter_dirs? ? Backup.filter_dirs.map{ |filter_dir| root_dir / filter_dir } : [root_dir]
19
- dirs.each do |dir|
20
- compare(backup_a.path / dir, backup_b.path / dir, Path.new('/', dir))
15
+ if Backup.filter_dirs?
16
+ Backup.filter_dirs.each do |real_dir|
17
+ real_dir = File.expand_path(real_dir)
18
+ dir = Tms::Backup.tm_path(real_dir)
19
+ compare(backup_a.path / dir, backup_b.path / dir, Path.new(real_dir))
20
+ end
21
+ else
22
+ root_dirs = (backup_a.path.children(false) | backup_b.path.children(false)).sort
23
+ root_dirs.reject!{ |root_dir| root_dir.path[0, 1] == '.' }
24
+ root_dirs.each do |dir|
25
+ real_dir = Tms::Backup.real_path(dir)
26
+ compare(backup_a.path / dir, backup_b.path / dir, Path.new('/', real_dir))
21
27
  end
22
28
  end
23
29
  rescue Interrupt
@@ -34,11 +40,14 @@ module Tms
34
40
  private
35
41
 
36
42
  def compare(a, b, path)
43
+ a_exist, b_exist = a.exist?, b.exist?
37
44
  case
38
- when !a.exist?
39
- diff_line nil, b, path, colorize('', :right), "#{path}#{b.postfix}", true
40
- when !b.exist?
45
+ when !a_exist && !b_exist
46
+ diff_line nil, nil, path, colorize('×××', :unreadable), "#{path}#{b.postfix}", true
47
+ when !b_exist
41
48
  diff_line a, nil, path, colorize('█ ', :left), "#{path}#{a.postfix}", true
49
+ when !a_exist
50
+ diff_line nil, b, path, colorize(' █', :right), "#{path}#{b.postfix}", true
42
51
  when a.ftype != b.ftype
43
52
  diff_line a, b, path, colorize('█≠█', :diff_type), "#{path}#{b.postfix} (#{a.ftype}=>#{b.ftype})", true
44
53
  when a.lstat.ino != b.lstat.ino
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'tms'
5
- s.version = '1.5.0'
5
+ s.version = '1.6.0'
6
6
  s.summary = %q{Time Machine Status}
7
7
  s.description = %Q{View avaliable Time Machine backups and show their diff}
8
8
  s.homepage = "http://github.com/toy/#{s.name}"
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: 3
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 5
8
+ - 6
9
9
  - 0
10
- version: 1.5.0
10
+ version: 1.6.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: 2012-10-17 00:00:00 Z
18
+ date: 2012-12-03 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: colored