dirtree 0.3.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +17 -7
- data/dirtree.gemspec +9 -5
- data/exe/dirtree +46 -7
- data/exe/dirtree-completion.bash +31 -0
- data/lib/dirtree/version.rb +1 -1
- data/templates/flame.html.erb +61 -0
- data/templates/treemap.html.erb +127 -0
- metadata +22 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 155b20b468f5b18c1c7e217399622d88f9a518c71de7d4ac9a037c43b40bf5af
|
4
|
+
data.tar.gz: 803c02eca516c98bde2e2b0d87dd6234051760e837f3a505275cca7b0e1ebf2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ae0616386b2d83dc7522b50bda09f334cc40a916a82745c55988af95b4f7b562f32eb2d970f64a1bd9cbe62bcd0fc03d85cfb17c1a9e121823afb7eae9ffdb8
|
7
|
+
data.tar.gz: 2e2890a550907ff651aaf62d3ed4c81564b31637284e4c34c343444ad2b3ce55487ea25dbe6460283055ca0fa3fd9400c3d16d37034b78d1732b3a4aa00f8fe8
|
data/README.md
CHANGED
@@ -7,23 +7,33 @@ Dirtree visualizes an list of file paths into a tree graph, printed as HTML page
|
|
7
7
|
## Tree template
|
8
8
|
![http://i.imgur.com/cGhx0lG.png](http://i.imgur.com/cGhx0lG.png)
|
9
9
|
|
10
|
+
## Flame Graph template
|
11
|
+
![https://i.imgur.com/eSTlQNE.png](https://i.imgur.com/eSTlQNE.png)
|
12
|
+
|
10
13
|
## Circles template
|
11
14
|
![http://i.imgur.com/WvfOgCp.png](http://i.imgur.com/WvfOgCp.png)
|
12
15
|
|
13
|
-
##
|
16
|
+
## Treemap template
|
17
|
+
![https://i.imgur.com/quO67Ky.png](https://i.imgur.com/quO67Ky.png)
|
14
18
|
|
19
|
+
## Installation
|
15
20
|
|
16
21
|
$ gem install dirtree
|
17
22
|
|
18
23
|
## Usage
|
19
24
|
|
20
25
|
Usage: dirtree [options]... [file]...
|
26
|
+
|
27
|
+
To get autocompletion functionality
|
28
|
+
run: dirtree completion >> ~/.bashrc
|
29
|
+
Or, dirtree completion > /usr/local/etc/bash_completion.d/dirtree
|
30
|
+
|
21
31
|
-v, --version Print version
|
22
32
|
-h, --help Show this help text
|
23
33
|
-l, --local-dependencies Use saved JavaScript libraries instead of downloading them
|
24
|
-
-
|
25
|
-
-
|
26
|
-
|
34
|
+
-s, --screenshot Get an image screenshot of the directory tree
|
35
|
+
-o, --output=File.html Specify a path to write HTML output
|
36
|
+
-t, --template=TemplateName Specify the template name, available templates ["tree", "circles", "flame", "treemap"]
|
27
37
|
|
28
38
|
## Examples
|
29
39
|
|
@@ -33,7 +43,7 @@ Dirtree visualizes an list of file paths into a tree graph, printed as HTML page
|
|
33
43
|
$ dirtree -o output.html **/* *
|
34
44
|
```
|
35
45
|
|
36
|
-
|
46
|
+
make sure you have `globstar` on
|
37
47
|
```
|
38
48
|
$ shopt -s globstar
|
39
49
|
```
|
@@ -72,11 +82,11 @@ $ ag -l | dirtree -o output.html
|
|
72
82
|
|
73
83
|
## Conjunctions
|
74
84
|
|
75
|
-
* [lsgh](https://www.github.com/
|
85
|
+
* [lsgh](https://www.github.com/emad-elsaid/lsgh) Draw a tree for a github user/org and open pull requests.
|
76
86
|
|
77
87
|
## Contributing
|
78
88
|
|
79
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
89
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/emad-elsaid/dirtree.
|
80
90
|
|
81
91
|
## License
|
82
92
|
|
data/dirtree.gemspec
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
1
|
lib = File.expand_path('../lib', __FILE__)
|
4
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
3
|
require 'dirtree/version'
|
@@ -8,7 +6,7 @@ Gem::Specification.new do |spec|
|
|
8
6
|
spec.name = 'dirtree'
|
9
7
|
spec.version = Dirtree::VERSION
|
10
8
|
spec.authors = ['Emad Elsaid']
|
11
|
-
spec.email = ['
|
9
|
+
spec.email = ['emad.elsaid.hamed@gmail.com']
|
12
10
|
|
13
11
|
spec.summary = 'display list of file paths as an interactive tree'
|
14
12
|
spec.description = 'display list of file paths as an interactive tree'
|
@@ -23,6 +21,12 @@ Gem::Specification.new do |spec|
|
|
23
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
22
|
spec.require_paths = ['lib']
|
25
23
|
|
26
|
-
spec.add_development_dependency 'bundler'
|
27
|
-
spec.add_development_dependency 'rake'
|
24
|
+
spec.add_development_dependency 'bundler'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
|
27
|
+
spec.post_install_message = <<-GUIDE
|
28
|
+
To get autocompletion functionality
|
29
|
+
run: dirtree completion >> ~/.bashrc
|
30
|
+
Or, dirtree completion > /usr/local/etc/bash_completion.d/dirtree
|
31
|
+
GUIDE
|
28
32
|
end
|
data/exe/dirtree
CHANGED
@@ -4,6 +4,13 @@ require 'optparse'
|
|
4
4
|
require 'json'
|
5
5
|
require 'erb'
|
6
6
|
require 'open-uri'
|
7
|
+
require 'tempfile'
|
8
|
+
|
9
|
+
if ARGV.first == 'completion'
|
10
|
+
bash_file = File.join(File.dirname(__FILE__), 'dirtree-completion.bash')
|
11
|
+
puts File.read(bash_file)
|
12
|
+
exit 0
|
13
|
+
end
|
7
14
|
|
8
15
|
templates_dir = File.join(File.dirname(__FILE__), '..', 'templates')
|
9
16
|
templates = Dir.open(templates_dir).map do |file|
|
@@ -15,7 +22,14 @@ options = {
|
|
15
22
|
}
|
16
23
|
|
17
24
|
OptionParser.new do |opts|
|
18
|
-
opts.banner =
|
25
|
+
opts.banner = <<-BANNER
|
26
|
+
Usage: dirtree [options]... [file]...
|
27
|
+
|
28
|
+
To get autocompletion functionality
|
29
|
+
run: dirtree completion >> ~/.bashrc
|
30
|
+
Or, dirtree completion > /usr/local/etc/bash_completion.d/dirtree
|
31
|
+
|
32
|
+
BANNER
|
19
33
|
|
20
34
|
opts.on(
|
21
35
|
'-v',
|
@@ -43,12 +57,20 @@ OptionParser.new do |opts|
|
|
43
57
|
options[:local_dependencies] = true
|
44
58
|
end
|
45
59
|
|
60
|
+
opts.on(
|
61
|
+
'-s',
|
62
|
+
'--screenshot',
|
63
|
+
'Get an image screenshot of the directory tree'
|
64
|
+
) do
|
65
|
+
options[:screenshot] = true
|
66
|
+
end
|
67
|
+
|
46
68
|
opts.on(
|
47
69
|
'-oFile.html',
|
48
70
|
'--output=File.html',
|
49
|
-
'Specify a path to write output
|
50
|
-
not specified output will be printed to STDOUT'
|
71
|
+
'Specify a path to write HTML output'
|
51
72
|
) do |value|
|
73
|
+
raise 'missing filename after ‘-o’' if value.empty?
|
52
74
|
options[:output] = value
|
53
75
|
end
|
54
76
|
|
@@ -82,8 +104,25 @@ if options[:local_dependencies]
|
|
82
104
|
end
|
83
105
|
end
|
84
106
|
|
85
|
-
if options.key?(:output)
|
86
|
-
|
87
|
-
|
88
|
-
|
107
|
+
File.write(options[:output], result) if options.key?(:output)
|
108
|
+
|
109
|
+
if options.key?(:screenshot)
|
110
|
+
unless options.key?(:output)
|
111
|
+
tmp = Tempfile.new
|
112
|
+
tmp.write(result)
|
113
|
+
tmp.close
|
114
|
+
end
|
115
|
+
file = options[:output] || tmp.path
|
116
|
+
%w[chromium chrome google-chrome google-chrome-stable].each do |chrome|
|
117
|
+
system(
|
118
|
+
chrome,
|
119
|
+
'--disable-gpu',
|
120
|
+
'--headless',
|
121
|
+
'--screenshot',
|
122
|
+
'--window-size=1500,1500',
|
123
|
+
'file://' + file
|
124
|
+
) && break
|
125
|
+
end
|
89
126
|
end
|
127
|
+
|
128
|
+
puts result unless options.key?(:output) || options.key?(:screenshot)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# To get autocompletion functionality
|
2
|
+
# run: dirtree completion >> ~/.bashrc
|
3
|
+
# Or, dirtree completion > /usr/local/etc/bash_completion.d/dirtree
|
4
|
+
#!/usr/bin/env bash
|
5
|
+
|
6
|
+
_dirtree_completions()
|
7
|
+
{
|
8
|
+
local cur prev
|
9
|
+
|
10
|
+
cur=${COMP_WORDS[COMP_CWORD]}
|
11
|
+
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
12
|
+
COMPREPLY=()
|
13
|
+
if [ "${#COMP_WORDS[@]}" != "2" ]; then
|
14
|
+
return
|
15
|
+
fi
|
16
|
+
case "$cur" in
|
17
|
+
-*)
|
18
|
+
COMPREPLY=( $( compgen -W '-v -h -l -s -o -t \
|
19
|
+
--version --help --local \
|
20
|
+
--screenshot --output --template' -- $cur ) )
|
21
|
+
;;
|
22
|
+
esac
|
23
|
+
|
24
|
+
if [[ ${prev} == -t ]] || [[ ${prev} == --template ]]; then
|
25
|
+
COMPREPLY=( $( compgen -W 'circles flame tree treemap' -- $cur ) )
|
26
|
+
fi
|
27
|
+
|
28
|
+
return 0
|
29
|
+
}
|
30
|
+
|
31
|
+
complete -F _dirtree_completions dirtree
|
data/lib/dirtree/version.rb
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
|
5
|
+
<meta charset="utf-8">
|
6
|
+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/spiermar/d3-flame-graph@1.0.4/dist/d3.flameGraph.min.css">
|
7
|
+
<style>
|
8
|
+
html, body{
|
9
|
+
height: 100%;
|
10
|
+
margin: 0;
|
11
|
+
padding: 0;
|
12
|
+
font-size: 14px;
|
13
|
+
}
|
14
|
+
</style>
|
15
|
+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.10.0/d3.min.js"></script>
|
16
|
+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3-tip/0.7.1/d3-tip.min.js"></script>
|
17
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/spiermar/d3-flame-graph@1.0.4/dist/d3.flameGraph.min.js"></script>
|
18
|
+
|
19
|
+
</head>
|
20
|
+
<body>
|
21
|
+
|
22
|
+
<div class="container">
|
23
|
+
<div id="chart">
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
<script>
|
27
|
+
// Uses D3js flamegraph: https://github.com/spiermar/d3-flame-graph
|
28
|
+
var flameGraph = d3.flameGraph()
|
29
|
+
.width(window.innerWidth)
|
30
|
+
.cellHeight(18)
|
31
|
+
.transitionDuration(750)
|
32
|
+
.transitionEase(d3.easeCubic)
|
33
|
+
.sort(true)
|
34
|
+
.title("");
|
35
|
+
|
36
|
+
var tip = d3.tip()
|
37
|
+
.direction("s")
|
38
|
+
.offset([8, 0])
|
39
|
+
.attr('class', 'd3-flame-graph-tip')
|
40
|
+
.html(function(d) { return "name: " + d.data.name + ", value: " + d.data.value; });
|
41
|
+
|
42
|
+
flameGraph.tooltip(tip);
|
43
|
+
|
44
|
+
function setValue(d) {
|
45
|
+
var val = 0;
|
46
|
+
for( var i=0; i<d.children.length; i++){
|
47
|
+
setValue(d.children[i]);
|
48
|
+
val += d.children[i].value;
|
49
|
+
}
|
50
|
+
d.value = val == 0 ? 1 : val;
|
51
|
+
}
|
52
|
+
|
53
|
+
root = <%= tree.to_json %>;
|
54
|
+
setValue(root)
|
55
|
+
d3.select("#chart")
|
56
|
+
.datum(root)
|
57
|
+
.call(flameGraph);
|
58
|
+
</script>
|
59
|
+
|
60
|
+
</body>
|
61
|
+
</html>
|
@@ -0,0 +1,127 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<head>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<style>
|
6
|
+
html, body {
|
7
|
+
padding: 0;
|
8
|
+
margin: 0;
|
9
|
+
width: 100%;
|
10
|
+
height: 100%;
|
11
|
+
overflow: hidden;
|
12
|
+
}
|
13
|
+
|
14
|
+
text {
|
15
|
+
font: 12px sans-serif;
|
16
|
+
}
|
17
|
+
|
18
|
+
tspan:last-child {
|
19
|
+
font-size: 12px;
|
20
|
+
fill-opacity: 0.8;
|
21
|
+
}
|
22
|
+
|
23
|
+
.node rect {
|
24
|
+
shape-rendering: crispEdges;
|
25
|
+
}
|
26
|
+
|
27
|
+
.node--hover rect {
|
28
|
+
stroke: #000;
|
29
|
+
}
|
30
|
+
|
31
|
+
</style>
|
32
|
+
<svg width="100%" height="100%"></svg>
|
33
|
+
<script src="http://d3js.org/d3.v4.0.0-alpha.35.min.js"></script>
|
34
|
+
<script>
|
35
|
+
|
36
|
+
var svg = d3.select("svg"),
|
37
|
+
width = window.innerWidth,
|
38
|
+
height = window.innerHeight;
|
39
|
+
|
40
|
+
svg.attr("width", width + "px");
|
41
|
+
svg.attr("height", height + "px");
|
42
|
+
|
43
|
+
var format = d3.format(",d");
|
44
|
+
|
45
|
+
var color = d3.scaleMagma()
|
46
|
+
.domain([-4, 4]);
|
47
|
+
|
48
|
+
var treemap = d3.treemap()
|
49
|
+
.size([width, height])
|
50
|
+
.paddingOuter(3)
|
51
|
+
.paddingTop(19)
|
52
|
+
.paddingInner(1)
|
53
|
+
.round(true);
|
54
|
+
|
55
|
+
|
56
|
+
var data = <%= tree.to_json %>
|
57
|
+
var root = d3.hierarchy(data)
|
58
|
+
.sum(function(d) {
|
59
|
+
var value = 1;
|
60
|
+
d.children.forEach(function(i){ value += i.value; })
|
61
|
+
return value;
|
62
|
+
})
|
63
|
+
.sort(function(a, b) { return b.height - a.height || b.value - a.value; })
|
64
|
+
|
65
|
+
var counter = 0;
|
66
|
+
root.each(function(d){ d.id = counter++; })
|
67
|
+
treemap(root)
|
68
|
+
|
69
|
+
var cell = svg
|
70
|
+
.selectAll(".node")
|
71
|
+
.data(root.descendants())
|
72
|
+
.enter().append("g")
|
73
|
+
.attr("transform", function(d) { return "translate(" + d.x0 + "," + d.y0 + ")"; })
|
74
|
+
.attr("class", "node")
|
75
|
+
.each(function(d) { d.node = this; })
|
76
|
+
.on("mouseover", hovered(true))
|
77
|
+
.on("mouseout", hovered(false));
|
78
|
+
|
79
|
+
cell.append("rect")
|
80
|
+
.attr("id", function(d) { return "rect-" + d.id; })
|
81
|
+
.attr("width", function(d) { return d.x1 - d.x0; })
|
82
|
+
.attr("height", function(d) { return d.y1 - d.y0; })
|
83
|
+
.style("fill", function(d) { return color(d.depth); });
|
84
|
+
|
85
|
+
cell.append("clipPath")
|
86
|
+
.attr("id", function(d) { return "clip-" + d.id; })
|
87
|
+
.append("use")
|
88
|
+
.attr("xlink:href", function(d) { return "#rect-" + d.id + ""; });
|
89
|
+
|
90
|
+
var label = cell.append("text")
|
91
|
+
.attr("clip-path", function(d) { return "url(#clip-" + d.id + ")"; });
|
92
|
+
|
93
|
+
label
|
94
|
+
.filter(function(d) { return d.children; })
|
95
|
+
.selectAll("tspan")
|
96
|
+
.data(function(d) { return [d.data.name]; })
|
97
|
+
.enter().append("tspan")
|
98
|
+
.attr("x", function(d, i) { return i ? null : 4; })
|
99
|
+
.attr("y", 13)
|
100
|
+
.text(function(d) { return d; });
|
101
|
+
|
102
|
+
label
|
103
|
+
.filter(function(d) { return !d.children; })
|
104
|
+
.selectAll("tspan")
|
105
|
+
.data(function(d) { return [d.data.name]; })
|
106
|
+
.enter().append("tspan")
|
107
|
+
.attr("x", 4)
|
108
|
+
.attr("y", function(d, i) { return 13 + i * 10; })
|
109
|
+
.text(function(d) { return d; });
|
110
|
+
|
111
|
+
cell.append("title")
|
112
|
+
.text(function(d) { return d.data.name; });
|
113
|
+
|
114
|
+
function hovered(hover) {
|
115
|
+
return function(d) {
|
116
|
+
d3.selectAll(d.ancestors().map(function(d) { return d.node; }))
|
117
|
+
.classed("node--hover", hover)
|
118
|
+
.select("rect")
|
119
|
+
.attr("width", function(d) { return d.x1 - d.x0 - hover; })
|
120
|
+
.attr("height", function(d) { return d.y1 - d.y0 - hover; });
|
121
|
+
};
|
122
|
+
}
|
123
|
+
|
124
|
+
</script>
|
125
|
+
</head>
|
126
|
+
<body></body>
|
127
|
+
</head>
|
metadata
CHANGED
@@ -1,48 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dirtree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emad Elsaid
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
description: display list of file paths as an interactive tree
|
42
42
|
email:
|
43
|
-
-
|
43
|
+
- emad.elsaid.hamed@gmail.com
|
44
44
|
executables:
|
45
45
|
- dirtree
|
46
|
+
- dirtree-completion.bash
|
46
47
|
extensions: []
|
47
48
|
extra_rdoc_files: []
|
48
49
|
files:
|
@@ -53,16 +54,22 @@ files:
|
|
53
54
|
- Rakefile
|
54
55
|
- dirtree.gemspec
|
55
56
|
- exe/dirtree
|
57
|
+
- exe/dirtree-completion.bash
|
56
58
|
- lib/dirtree.rb
|
57
59
|
- lib/dirtree/node.rb
|
58
60
|
- lib/dirtree/version.rb
|
59
61
|
- templates/circles.html.erb
|
62
|
+
- templates/flame.html.erb
|
60
63
|
- templates/tree.html.erb
|
64
|
+
- templates/treemap.html.erb
|
61
65
|
homepage: https://www.github.com/blazeeboy/dirtree
|
62
66
|
licenses:
|
63
67
|
- MIT
|
64
68
|
metadata: {}
|
65
|
-
post_install_message:
|
69
|
+
post_install_message: |2
|
70
|
+
To get autocompletion functionality
|
71
|
+
run: dirtree completion >> ~/.bashrc
|
72
|
+
Or, dirtree completion > /usr/local/etc/bash_completion.d/dirtree
|
66
73
|
rdoc_options: []
|
67
74
|
require_paths:
|
68
75
|
- lib
|
@@ -77,9 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
84
|
- !ruby/object:Gem::Version
|
78
85
|
version: '0'
|
79
86
|
requirements: []
|
80
|
-
|
81
|
-
|
82
|
-
signing_key:
|
87
|
+
rubygems_version: 3.1.2
|
88
|
+
signing_key:
|
83
89
|
specification_version: 4
|
84
90
|
summary: display list of file paths as an interactive tree
|
85
91
|
test_files: []
|