storage_visualizer 0.0.4 → 0.0.5

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/storage_visualizer.rb +51 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e6e3d4c026c39271ced6fc2fc2dec09cff84b79
4
- data.tar.gz: 0c77eae59eb82a981e57d2a62cb3873c4c2fc39d
3
+ metadata.gz: 0f925fed8620fbdf0545c0664db2ce8523850aa4
4
+ data.tar.gz: e66b4883ca7c86c676f1e6c7768038f1b3dfba65
5
5
  SHA512:
6
- metadata.gz: 8a1a7a2d73860503088a95dc92c777b57bec2691e36abc0892a437abc81f4e560f0f93c38ba08df6004949279fe37c062512aa6ce6e9b754a3198f7fd8c1d700
7
- data.tar.gz: a54f7527e27431c0f478d441a4ea8657ddaff5bacb1f090d31fc9842990437918d60ff204a828f06fb67cf6a8cda8a2ab97b55f4016be65bf9a305cd1f3a1502
6
+ metadata.gz: 7fa3d61965e0534e8e12ccfc2badf0d443f485ad0519b3a1d94a533298ef7221d8c45de31c7d5761f7ba5fef273cc69658bc08cb0d18b3fe1913d697fb5f98cf
7
+ data.tar.gz: aefa6235d63f3e94770678527d67a5b43ca1ab78f80319e4dbd95bcd9b427b2932e18e2c8b4dda7cfb35c55f2ca5a6716c439d73ff17cb406aeda2a8a408b510
@@ -26,8 +26,9 @@ class StorageVisualizer
26
26
  # Static
27
27
  def self.print_usage
28
28
  puts "\nThis tool helps visualize which directories are occupying the most storage. Any directory that occupies more than 5% of disk space is added to a visual hierarchichal storage report in the form of a Google Sankey diagram. The storage data is gathered using the linux `du` utility. It has been tested on Mac OSX, should work on linux systems, will not work on Windows. Run as sudo if analyzing otherwise inaccessible directories. May take a while to run\n"
29
- puts "\nCommand line usage: \n\t[sudo] ./visualize_storage.rb [directory to visualize (default ~/) | -h (help) -i | --install (install to /usr/local/bin)]\n\n"
29
+ puts "\nCommand line usage: \n\t[sudo] ./visualize_storage[.rb] [directory to visualize (default ~/) | -h (help) -i | --install (install to /usr/local/bin)]\n\n"
30
30
  puts "API usage: "
31
+ puts "\tgem install storage_visualizer"
31
32
  puts "\t'require storage_visualizer'"
32
33
  puts "\tsv = StorageVisualizer.new('[directory to visualize, ~/ by default]')"
33
34
  puts "\tsv.run()\n\n"
@@ -36,6 +37,53 @@ class StorageVisualizer
36
37
  puts "\n\n"
37
38
  end
38
39
 
40
+
41
+
42
+ def self.install
43
+ # This function installs a copy & symlink into /usr/local/bin, so the utility can simply be run by typing `storage_visualizer`
44
+ # To install for command line use type:
45
+ # git clone https://github.com/teecay/StorageVisualizer.git && ./StorageVisualizer/storage_visualizer.rb --install
46
+ # To install for gem usage type:
47
+ # gem install storage_visualizer
48
+
49
+
50
+ script_src_path = File.expand_path(__FILE__) # File.expand_path('./StorageVisualizer/lib/storage_visualizer.rb')
51
+ script_dest_path = '/usr/local/bin/storage_visualizer.rb'
52
+ symlink_path = '/usr/local/bin/storage_visualizer'
53
+
54
+
55
+ if (!File.exist?(script_src_path))
56
+ raise "Error: file does not exist: #{script_src_path}"
57
+ end
58
+
59
+
60
+ if (File.exist?(script_dest_path))
61
+ puts "Removing old installed script"
62
+ File.delete(script_dest_path)
63
+ end
64
+
65
+
66
+ if (File.exist?(symlink_path))
67
+ puts "Removing old symlink"
68
+ File.delete(symlink_path)
69
+ end
70
+
71
+ cp_cmd = "cp -f #{script_src_path} #{script_dest_path}"
72
+ puts "Copying script into place: #{cp_cmd}"
73
+ `#{cp_cmd}`
74
+
75
+ ln_cmd = "ln -s #{script_path} #{symlink_path}"
76
+ puts "Installing: #{ln_cmd}"
77
+ `#{ln_cmd}`
78
+
79
+ chmod_cmd = "chmod ugo+x #{symlink_path}"
80
+ puts "Setting permissions: #{chmod_cmd}"
81
+ `#{chmod_cmd}`
82
+
83
+ puts "Installation is complete, run `storage_visualizer -h` for help"
84
+ end
85
+
86
+
39
87
  # To do:
40
88
  # x Make it work on linux
41
89
  # x Specify blocksize and do not assume 512 bytes (use the -k flag, which reports blocks as KB)
@@ -381,10 +429,8 @@ def run
381
429
  StorageVisualizer.print_usage()
382
430
  return
383
431
  elsif (ARGV[0] == '-i' || ARGV[0] == '--install')
384
- # install a soft link to /usr/local/bin
385
- cmd = "ln -s #{File.expand_path(__FILE__)} /usr/local/bin/#{File.basename(__FILE__).split('.')[0]}"
386
- puts "Install cmd: #{cmd}"
387
- `#{cmd}`
432
+ StorageVisualizer.install
433
+ StorageVisualizer.print_usage
388
434
  return
389
435
  end
390
436
  vs = StorageVisualizer.new(ARGV[0])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: storage_visualizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Terry Case
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-04 00:00:00.000000000 Z
11
+ date: 2015-07-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This tool helps visualize which directories are occupying the most storage.
14
14
  Any directory that occupies more than 5% of disk space is added to a visual hierarchichal