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.
- checksums.yaml +4 -4
- data/lib/storage_visualizer.rb +51 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f925fed8620fbdf0545c0664db2ce8523850aa4
|
4
|
+
data.tar.gz: e66b4883ca7c86c676f1e6c7768038f1b3dfba65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fa3d61965e0534e8e12ccfc2badf0d443f485ad0519b3a1d94a533298ef7221d8c45de31c7d5761f7ba5fef273cc69658bc08cb0d18b3fe1913d697fb5f98cf
|
7
|
+
data.tar.gz: aefa6235d63f3e94770678527d67a5b43ca1ab78f80319e4dbd95bcd9b427b2932e18e2c8b4dda7cfb35c55f2ca5a6716c439d73ff17cb406aeda2a8a408b510
|
data/lib/storage_visualizer.rb
CHANGED
@@ -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
|
-
|
385
|
-
|
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
|
+
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-
|
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
|