dir_friend 0.0.3 → 0.0.4
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/bin/dir_friend +0 -0
- data/lib/dir_friend/command.rb +8 -2
- data/lib/dir_friend/d.rb +1 -1
- data/lib/dir_friend/f.rb +1 -1
- data/lib/dir_friend/version.rb +1 -1
- data/spec/command_spec.rb +73 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c521ee35292eca17bf8f359334ff82317ff9c1c6
|
4
|
+
data.tar.gz: 47802dbb3d9f0bd4196e3548bbc9de2003f4d883
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 271eab6489bfbfc6dc8bd3f01ee10fbcf86d8480c32bd9e0493a8c7d4763ad9ba47968ecd0db64f7a318d6c13ec3c8580bdf5ff9524bca163f47f9deffb6665e
|
7
|
+
data.tar.gz: 82d14d0bef8ca232e4130f50d39831750d96d61e559342b692289c53c87c648bc8a6a927940c13c3fcbc3043d94b38104e7c871c3c1fea6c7ac868370962ba7a
|
data/bin/dir_friend
CHANGED
File without changes
|
data/lib/dir_friend/command.rb
CHANGED
@@ -2,7 +2,8 @@ require 'thor'
|
|
2
2
|
|
3
3
|
module DirFriend
|
4
4
|
class Command < Thor
|
5
|
-
|
5
|
+
include Thor::Actions
|
6
|
+
|
6
7
|
desc "info PATH", "Show PATH info"
|
7
8
|
def info(path)
|
8
9
|
puts Any.new(path).info
|
@@ -25,6 +26,7 @@ ex.
|
|
25
26
|
option :edges, aliases:"-e"
|
26
27
|
option :save, aliases:"-s", default:'a'
|
27
28
|
option :depth, aliases:"-d", default:9
|
29
|
+
option :with_open, aliases:"-o", default: true, type: :boolean
|
28
30
|
def dot(path)
|
29
31
|
opt = options.dup.inject({}) { |h, (k,v)| h[k.intern] = v; h }
|
30
32
|
save_path = opt.delete(:save)
|
@@ -32,6 +34,10 @@ ex.
|
|
32
34
|
dir = D.new(path, depth:options[:depth].to_i)
|
33
35
|
dir.to_dot(opt).save(save_path)
|
34
36
|
puts "Dot file created: `#{save_path}.dot`"
|
37
|
+
|
38
|
+
if options[:with_open] && OS.mac?
|
39
|
+
run(%Q{open "#{save_path}.dot"}, verbose: false)
|
40
|
+
end
|
35
41
|
end
|
36
42
|
|
37
43
|
desc "version", "Show DirFriend version"
|
@@ -65,4 +71,4 @@ DirFriend is a tool for visualizing file directory.
|
|
65
71
|
end
|
66
72
|
end
|
67
73
|
end
|
68
|
-
end
|
74
|
+
end
|
data/lib/dir_friend/d.rb
CHANGED
data/lib/dir_friend/f.rb
CHANGED
data/lib/dir_friend/version.rb
CHANGED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fakefs/spec_helpers'
|
3
|
+
|
4
|
+
describe DirFriend::Command do
|
5
|
+
include FakeFS::SpecHelpers
|
6
|
+
|
7
|
+
def capture(stream)
|
8
|
+
begin
|
9
|
+
stream = stream.to_s
|
10
|
+
eval "$#{stream} = StringIO.new"
|
11
|
+
yield
|
12
|
+
result = eval("$#{stream}").string
|
13
|
+
ensure
|
14
|
+
eval("$#{stream} = #{stream.upcase}")
|
15
|
+
end
|
16
|
+
|
17
|
+
result
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#dot' do
|
21
|
+
before(:each) do
|
22
|
+
%w(A A/D A/D/G).each { |d| Dir.mkdir d }
|
23
|
+
end
|
24
|
+
|
25
|
+
around do |example|
|
26
|
+
described_class.no_commands do
|
27
|
+
example.run
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'with_open option' do
|
32
|
+
context 'on OS X' do
|
33
|
+
it 'should be true on default' do
|
34
|
+
described_class.
|
35
|
+
any_instance.
|
36
|
+
should_receive(:run).
|
37
|
+
with('open "a.dot"', verbose: false)
|
38
|
+
|
39
|
+
stdout = capture(:stdout) { described_class.start(['dot', 'A']) }
|
40
|
+
expect(stdout).to include 'Dot file created:'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should parse option' do
|
44
|
+
described_class.
|
45
|
+
any_instance.
|
46
|
+
should_not_receive(:run)
|
47
|
+
|
48
|
+
stdout = capture(:stdout) {
|
49
|
+
described_class.start(['dot', '--with-open=false', 'A'])
|
50
|
+
}
|
51
|
+
expect(stdout).to include 'Dot file created:'
|
52
|
+
end
|
53
|
+
end if DirFriend::OS.mac?
|
54
|
+
|
55
|
+
context 'on Not OS X' do
|
56
|
+
before do
|
57
|
+
DirFriend::OS.stub(mac?: false)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should not call open command' do
|
61
|
+
described_class.
|
62
|
+
any_instance.
|
63
|
+
should_not_receive(:run)
|
64
|
+
|
65
|
+
stdout = capture(:stdout) {
|
66
|
+
described_class.start(['dot', '--with-open', 'A'])
|
67
|
+
}
|
68
|
+
expect(stdout).to include 'Dot file created:'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dir_friend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kyoendo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gviz
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/dir_friend/f.rb
|
119
119
|
- lib/dir_friend/graph.rb
|
120
120
|
- lib/dir_friend/version.rb
|
121
|
+
- spec/command_spec.rb
|
121
122
|
- spec/dir_friend_spec.rb
|
122
123
|
- spec/graph_spec.rb
|
123
124
|
- spec/spec_helper.rb
|
@@ -146,6 +147,7 @@ signing_key:
|
|
146
147
|
specification_version: 4
|
147
148
|
summary: '`DirFriend` is a tool for visualizing file directory.'
|
148
149
|
test_files:
|
150
|
+
- spec/command_spec.rb
|
149
151
|
- spec/dir_friend_spec.rb
|
150
152
|
- spec/graph_spec.rb
|
151
153
|
- spec/spec_helper.rb
|