dir_friend 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5b098a2a2b0f172cbf3a22b7ad1da07a12c0d5e
4
- data.tar.gz: 4a944185a4536bf15ffed148a189d71f1b46ba28
3
+ metadata.gz: c521ee35292eca17bf8f359334ff82317ff9c1c6
4
+ data.tar.gz: 47802dbb3d9f0bd4196e3548bbc9de2003f4d883
5
5
  SHA512:
6
- metadata.gz: fe3bb4cc65e78765081e39f0ffedfdeb3cf1d3d1e612954adf1f3b78e64f2ac4ebe305daac61f32e6decf0b8313a72731e2ce9f3eb3df577d511f2a693728cc8
7
- data.tar.gz: c6ba2fe2315c3cf19753691a8dbd9bbee53d0617093e9cf14a98cfe3680f301cb42b10857b5c28ec1d8ce2d4e49aff78b0b38cf42cfcd5906cf7b44c2d891ff7
6
+ metadata.gz: 271eab6489bfbfc6dc8bd3f01ee10fbcf86d8480c32bd9e0493a8c7d4763ad9ba47968ecd0db64f7a318d6c13ec3c8580bdf5ff9524bca163f47f9deffb6665e
7
+ data.tar.gz: 82d14d0bef8ca232e4130f50d39831750d96d61e559342b692289c53c87c648bc8a6a927940c13c3fcbc3043d94b38104e7c871c3c1fea6c7ac868370962ba7a
File without changes
@@ -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
@@ -74,4 +74,4 @@ module DirFriend
74
74
  end
75
75
  end
76
76
  end
77
- end
77
+ end
@@ -5,7 +5,7 @@ module DirFriend
5
5
  def initialize(name, level:0)
6
6
  @path = File.expand_path(name)
7
7
  @name = File.basename(@path)
8
- @stat = File.stat(@path)
8
+ @stat = File.lstat(@path)
9
9
  @level = level
10
10
  end
11
11
 
@@ -1,3 +1,3 @@
1
1
  module DirFriend
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -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.3
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-28 00:00:00.000000000 Z
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