dirtree 0.5.0 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29ccafc03b49b0f8c15caaf5bd30f4f93be5c02a04bc4ec7e92e9260a4343e12
4
- data.tar.gz: acce9976160e5f322a5cce3a46b96e0af166f3f5f3ef156e4433ab1b498e46b1
3
+ metadata.gz: 488c50a2e59bf6d2c8869e66feefb25d41ae52b00b4bb463cdd0e213f2536536
4
+ data.tar.gz: 25153964406c9b93302bd1f74d833fd44f01124fe211ebbe2e20fb7eb1b0c8b4
5
5
  SHA512:
6
- metadata.gz: 48fcb84d12b4024c99916e8d7970e998914c5294aa396b44747082b028718c304a2305b0904a97b66ddeabf7c005c76e738da89b211467f6ad4e48dc344e8855
7
- data.tar.gz: 5a12ae063ed9e336833cd265c71a4a41480fe8242b61055a340773be454c5a7295e538c98d132c5c5409f4f66df0b5f389734c85bf8f69f165f24bc49a17bbe8
6
+ metadata.gz: ebe9bc99009044b84f6ebd15e8de8bf7001bf0b8beb7df9499bd9613d4ee78681c36d6e2b9a18831570cadaf3ab7efedf00c3611af1ce0b3f67694e3ac94cab7
7
+ data.tar.gz: 1930b9f2e722414acefc07ab3552666617be0c7d35a37d3565be472b58186ffc12091435eb5ea0f26ea48bcc0ec589bcd731cd441f1c7a785549283754412e16
data/README.md CHANGED
@@ -13,8 +13,10 @@ Dirtree visualizes an list of file paths into a tree graph, printed as HTML page
13
13
  ## Circles template
14
14
  ![http://i.imgur.com/WvfOgCp.png](http://i.imgur.com/WvfOgCp.png)
15
15
 
16
- ## Installation
16
+ ## Treemap template
17
+ ![https://i.imgur.com/quO67Ky.png](https://i.imgur.com/quO67Ky.png)
17
18
 
19
+ ## Installation
18
20
 
19
21
  $ gem install dirtree
20
22
 
@@ -24,9 +26,9 @@ Dirtree visualizes an list of file paths into a tree graph, printed as HTML page
24
26
  -v, --version Print version
25
27
  -h, --help Show this help text
26
28
  -l, --local-dependencies Use saved JavaScript libraries instead of downloading them
27
- -o, --output=File.html Specify a path to write output, if not specified output will be printed to STDOUT
28
- -t, --template=TemplateName Specify the template name, available templates ["circles", "tree", "flame"]
29
-
29
+ -s, --screenshot Get an image screenshot of the directory tree
30
+ -o, --output=File.html Specify a path to write HTML output
31
+ -t, --template=TemplateName Specify the template name, available templates ["tree", "circles", "flame", "treemap"]
30
32
 
31
33
  ## Examples
32
34
 
@@ -36,7 +38,7 @@ Dirtree visualizes an list of file paths into a tree graph, printed as HTML page
36
38
  $ dirtree -o output.html **/* *
37
39
  ```
38
40
 
39
- make sure you have `globstar` on
41
+ make sure you have `globstar` on
40
42
  ```
41
43
  $ shopt -s globstar
42
44
  ```
@@ -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'
@@ -4,6 +4,7 @@ require 'optparse'
4
4
  require 'json'
5
5
  require 'erb'
6
6
  require 'open-uri'
7
+ require 'tempfile'
7
8
 
8
9
  templates_dir = File.join(File.dirname(__FILE__), '..', 'templates')
9
10
  templates = Dir.open(templates_dir).map do |file|
@@ -43,12 +44,20 @@ OptionParser.new do |opts|
43
44
  options[:local_dependencies] = true
44
45
  end
45
46
 
47
+ opts.on(
48
+ '-s',
49
+ '--screenshot',
50
+ 'Get an image screenshot of the directory tree'
51
+ ) do
52
+ options[:screenshot] = true
53
+ end
54
+
46
55
  opts.on(
47
56
  '-oFile.html',
48
57
  '--output=File.html',
49
- 'Specify a path to write output, if
50
- not specified output will be printed to STDOUT'
58
+ 'Specify a path to write HTML output'
51
59
  ) do |value|
60
+ raise 'missing filename after ‘-o’' if value.empty?
52
61
  options[:output] = value
53
62
  end
54
63
 
@@ -82,8 +91,25 @@ if options[:local_dependencies]
82
91
  end
83
92
  end
84
93
 
85
- if options.key?(:output)
86
- File.write(options[:output], result)
87
- else
88
- puts result
94
+ File.write(options[:output], result) if options.key?(:output)
95
+
96
+ if options.key?(:screenshot)
97
+ unless options.key?(:output)
98
+ tmp = Tempfile.new
99
+ tmp.write(result)
100
+ tmp.close
101
+ end
102
+ file = options[:output] || tmp.path
103
+ %w[chromium chrome google-chrome google-chrome-stable].each do |chrome|
104
+ system(
105
+ chrome,
106
+ '--disable-gpu',
107
+ '--headless',
108
+ '--screenshot',
109
+ '--window-size=1500,1500',
110
+ "file://" + file
111
+ ) && break
112
+ end
89
113
  end
114
+
115
+ puts result unless options.key?(:output) || options.key?(:screenshot)
@@ -1,3 +1,3 @@
1
1
  module Dirtree
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dirtree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emad Elsaid
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-03 00:00:00.000000000 Z
11
+ date: 2018-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler