diru 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +2 -0
- data/README.rdoc +7 -3
- data/bin/diru +98 -7
- data/lib/version.rb +1 -1
- data/test/golden.log +14 -0
- data/test/test_diru.rb +3 -3
- data/test/test_diru.sh +10 -1
- 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: a28f4c905f25bd1b2d3bdec8d38caf27d55fbd45
|
4
|
+
data.tar.gz: 8e8a7210c8e50f1537aa314a97a86f91b373e26c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 247e190660aedee8dff49ae2d36fd906aa5c413ece5b13b86fa007adb4be771ad3e97ef8e21494ced2cfb9c4677eaa54c1a87707706adf7ef8be71a551eb6c5f
|
7
|
+
data.tar.gz: 0ef5b4473de0f18d9473413736c4435e5313237f2e6aac4bb4827c41b082f3f5fa7f2b2c4c2ab71155930fe019976e48a95d7a7e9037e700583e49f23a69d94b
|
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -67,10 +67,12 @@ at will. Complete list of running Servers can be seen with:
|
|
67
67
|
shell> diru --hport 42323 -l
|
68
68
|
|
69
69
|
When Server starts, it will detect the Project root. It can be a file
|
70
|
-
or defined as environment variable.
|
70
|
+
or defined as environment variable. Environment variable DIRU_ROOT has
|
71
|
+
higher precedence than the files. If ".diru_root_dir" file or a
|
71
72
|
".diru.yml" file is found from current dir or some dir above, the dir
|
72
|
-
containing either of the files will become the Project root. If no
|
73
|
-
are found
|
73
|
+
containing either of the files will become the Project root. If no
|
74
|
+
files are found and DIRU_ROOT environment variable is not used, an
|
75
|
+
error is issued.
|
74
76
|
|
75
77
|
Client communicates with the Server in order to get and save directory
|
76
78
|
info. As mentioned above, Diru is more or less useless unless user has
|
@@ -175,6 +177,8 @@ Misc commands:
|
|
175
177
|
* "dr c <cmd>" - issue RPC command to server (reset etc., see below).
|
176
178
|
* "dr f" - list favorites dirs (from options).
|
177
179
|
* "dr f <dir>" - change dir to favorite <dir>.
|
180
|
+
* "dr d m <dir>" - make directory.
|
181
|
+
* "dr d r <dir>" - remove directory.
|
178
182
|
* "dr i" - show command info.
|
179
183
|
* "dr <dir>" - change to given dir (must be under current).
|
180
184
|
* "dr" - change to next "Left-over" directory.
|
data/bin/diru
CHANGED
@@ -63,6 +63,7 @@ require 'como'
|
|
63
63
|
include Como
|
64
64
|
require 'drb'
|
65
65
|
require 'yaml'
|
66
|
+
require 'fileutils'
|
66
67
|
|
67
68
|
# require 'byebug'
|
68
69
|
|
@@ -119,6 +120,12 @@ module Diru
|
|
119
120
|
end
|
120
121
|
|
121
122
|
|
123
|
+
# Warning message display.
|
124
|
+
def Diru.warn( msg )
|
125
|
+
STDERR.puts "Diru Warning: #{msg}"
|
126
|
+
end
|
127
|
+
|
128
|
+
|
122
129
|
# List the dir content (default: pwd).
|
123
130
|
def Diru.list( dir = '.', glob = '*' )
|
124
131
|
Dir.glob( "#{dir}/#{glob}" )
|
@@ -386,14 +393,25 @@ class Search
|
|
386
393
|
end
|
387
394
|
|
388
395
|
|
396
|
+
def abs2rel( path )
|
397
|
+
if path == @root
|
398
|
+
''
|
399
|
+
else
|
400
|
+
rem = "#{@root}/"
|
401
|
+
rel = path.dup
|
402
|
+
rel[rem] = ''
|
403
|
+
rel
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
|
389
408
|
# Match dir/pattern from DB.
|
390
409
|
def match( dir, pattern )
|
391
410
|
list = []
|
392
411
|
|
393
412
|
if dir
|
394
|
-
rem = "#{@root}/"
|
395
413
|
begin
|
396
|
-
dir
|
414
|
+
dir = abs2rel( dir )
|
397
415
|
rescue
|
398
416
|
return []
|
399
417
|
end
|
@@ -425,7 +443,48 @@ class Search
|
|
425
443
|
end
|
426
444
|
|
427
445
|
|
446
|
+
# Make directory.
|
447
|
+
def mk_dir( dir )
|
448
|
+
rel = abs2rel( dir )
|
449
|
+
unless @data.index( rel )
|
450
|
+
@data = @data.push( rel ).sort
|
451
|
+
FileUtils.mkdir_p dir
|
452
|
+
end
|
453
|
+
end
|
454
|
+
|
455
|
+
|
456
|
+
# Make directory in sync.
|
457
|
+
def mk_dir_sync( dir )
|
458
|
+
@datalock.synchronize do
|
459
|
+
mk_dir dir
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
|
464
|
+
# Remove directory.
|
465
|
+
def rm_dir( dir )
|
466
|
+
rel = abs2rel( dir )
|
467
|
+
if @data.index( rel )
|
468
|
+
@data.delete( rel )
|
469
|
+
FileUtils.rmdir dir
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
|
474
|
+
# Remove directory in sync.
|
475
|
+
def rm_dir_sync( dir )
|
476
|
+
@datalock.synchronize do
|
477
|
+
rm_dir dir
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
|
428
482
|
# Update directory DB.
|
483
|
+
#
|
484
|
+
# Relative dir data under Project root.
|
485
|
+
# test
|
486
|
+
# test/dir_0
|
487
|
+
# ...
|
429
488
|
def update_data
|
430
489
|
@data = Dir.glob( @glob ).select{|ent| File.directory?( ent )}
|
431
490
|
@data = @data.sort
|
@@ -943,6 +1002,32 @@ class Client
|
|
943
1002
|
fav_map( arg )
|
944
1003
|
end
|
945
1004
|
|
1005
|
+
when 'd';
|
1006
|
+
# Mkdir:
|
1007
|
+
# dr d m <dir>
|
1008
|
+
# Rmdir:
|
1009
|
+
# dr d r <dir>
|
1010
|
+
if arg.length == 2
|
1011
|
+
if arg[0] == 'm'
|
1012
|
+
abs = File.absolute_path( arg[1] )
|
1013
|
+
if abs.match( @search.root )
|
1014
|
+
# New subdir to Project.
|
1015
|
+
@search.mk_dir_sync( abs )
|
1016
|
+
else
|
1017
|
+
FileUtils.mkdir_p dir
|
1018
|
+
end
|
1019
|
+
elsif arg[0] == 'r'
|
1020
|
+
abs = File.absolute_path( arg[1] )
|
1021
|
+
if abs.match( @search.root )
|
1022
|
+
# New subdir to Project.
|
1023
|
+
@search.rm_dir_sync( abs )
|
1024
|
+
else
|
1025
|
+
FileUtils.rmdir dir
|
1026
|
+
end
|
1027
|
+
end
|
1028
|
+
end
|
1029
|
+
no_cd
|
1030
|
+
|
946
1031
|
when 'i';
|
947
1032
|
rpc( [ 'doc' ] )
|
948
1033
|
|
@@ -969,13 +1054,18 @@ class Client
|
|
969
1054
|
if resp == nil
|
970
1055
|
no_cd
|
971
1056
|
elsif resp.kind_of? Array
|
972
|
-
|
973
|
-
|
974
|
-
resp
|
975
|
-
|
1057
|
+
if resp.any?
|
1058
|
+
puts resp[0]
|
1059
|
+
if resp.length > 1
|
1060
|
+
resp[1..-1].each do |i|
|
1061
|
+
STDERR.puts i
|
1062
|
+
end
|
976
1063
|
end
|
1064
|
+
do_cd
|
1065
|
+
else
|
1066
|
+
Diru.warn "Dir not found!"
|
1067
|
+
no_cd
|
977
1068
|
end
|
978
|
-
do_cd
|
979
1069
|
else
|
980
1070
|
puts resp
|
981
1071
|
do_cd
|
@@ -1010,6 +1100,7 @@ class Client
|
|
1010
1100
|
p = - peer of current
|
1011
1101
|
c @ - command (reset, doc etc.)
|
1012
1102
|
f - favorites
|
1103
|
+
d - directory mutation
|
1013
1104
|
i - short info
|
1014
1105
|
"
|
1015
1106
|
end
|
data/lib/version.rb
CHANGED
data/test/golden.log
CHANGED
@@ -180,6 +180,7 @@ g dir_1/dir_1_2
|
|
180
180
|
p = - peer of current
|
181
181
|
c @ - command (reset, doc etc.)
|
182
182
|
f - favorites
|
183
|
+
d - directory mutation
|
183
184
|
i - short info
|
184
185
|
|
185
186
|
/home/tero/prog/gem/diru/test/dir_0/dir_0_4/dir_0_4_0
|
@@ -238,6 +239,19 @@ g dir_1/dir_1_2
|
|
238
239
|
p = - peer of current
|
239
240
|
c @ - command (reset, doc etc.)
|
240
241
|
f - favorites
|
242
|
+
d - directory mutation
|
241
243
|
i - short info
|
242
244
|
|
243
245
|
/home/tero/prog/gem/diru/test
|
246
|
+
/home/tero/prog/gem/diru/test
|
247
|
+
/home/tero/prog/gem/diru/test
|
248
|
+
/home/tero/prog/gem/diru/test/dir_2/foobar
|
249
|
+
/home/tero/prog/gem/diru/test
|
250
|
+
/home/tero/prog/gem/diru/test
|
251
|
+
Diru Warning: Dir not found!
|
252
|
+
/home/tero/prog/gem/diru/test
|
253
|
+
/home/tero/prog/gem/diru/test
|
254
|
+
2: /home/tero/prog/gem/diru/test/dir_0/dir_0_1/dir_0_1_2
|
255
|
+
1: /home/tero/prog/gem/diru/test
|
256
|
+
0: /home/tero/prog/gem/diru/test/dir_2/foobar
|
257
|
+
/home/tero/prog/gem/diru/test
|
data/test/test_diru.rb
CHANGED
@@ -11,8 +11,8 @@ Test::Unit.at_start do
|
|
11
11
|
Dir.chdir( 'test' )
|
12
12
|
|
13
13
|
$diru = "#{Dir.pwd}/../bin/diru"
|
14
|
-
system( "#{$diru} --hport
|
15
|
-
system( "#{$diru} --hport
|
14
|
+
system( "#{$diru} --hport 43114 --hub" )
|
15
|
+
system( "#{$diru} --hport 43114 -s" )
|
16
16
|
end
|
17
17
|
|
18
18
|
Test::Unit.at_exit do
|
@@ -22,7 +22,7 @@ Test::Unit.at_exit do
|
|
22
22
|
FileUtils.rm_f( "test_bookmarks.txt" )
|
23
23
|
FileUtils.rm_f( "test_basic.log" ) unless TRAINING
|
24
24
|
|
25
|
-
system( "#{$diru} --hport
|
25
|
+
system( "#{$diru} --hport 43114 --hkill" )
|
26
26
|
|
27
27
|
Dir.chdir( '..' )
|
28
28
|
end
|
data/test/test_diru.sh
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
dr()
|
2
2
|
{
|
3
|
-
ret=`diru -p
|
3
|
+
ret=`diru -p 43115 -c $*`
|
4
4
|
if test $? -eq 0; then
|
5
5
|
cd $ret
|
6
6
|
fi
|
@@ -82,3 +82,12 @@ dr h
|
|
82
82
|
dr r
|
83
83
|
dr h
|
84
84
|
dr c doc
|
85
|
+
|
86
|
+
dr d m dir_2
|
87
|
+
dr d m dir_2/foobar
|
88
|
+
dr r foobar
|
89
|
+
dr r
|
90
|
+
dr d r dir_2/foobar
|
91
|
+
dr r foobar
|
92
|
+
dr d r dir_2
|
93
|
+
dr h
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tero Isannainen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: como
|