diru 0.0.4 → 0.0.5
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/CHANGELOG.rdoc +3 -0
- data/README.rdoc +8 -5
- data/bin/diru +51 -14
- data/lib/version.rb +1 -1
- data/test/golden.log +4 -0
- 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: 98c77992c8442b0030204aaa25ec19998e00a27b
|
4
|
+
data.tar.gz: 53fcbf64b69f57b62028be1d1c4adc01d8484b4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fec1c06357e15b0128ceb7301ee54825205a36b056af0e5f48881d747b0b1156198e856c7c9ba37dd0ccb9af91775d11f7bdbd3258fc1bf70a99dbd20a5b4cb
|
7
|
+
data.tar.gz: 635d80fe66b08b5bae9697c0616f32719111284363e87400ae6195015a8bb5fa38db56e0a38ab12d0062a201e8444e131a1ac8eb323e39b40c80d68c8994e61b
|
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -66,6 +66,9 @@ at will. Complete list of running Servers can be seen with:
|
|
66
66
|
|
67
67
|
shell> diru --hport 42323 -l
|
68
68
|
|
69
|
+
Servers are identified per user. This facilitates team use of shared
|
70
|
+
Hub.
|
71
|
+
|
69
72
|
When Server starts, it will detect the Project root. It can be a file
|
70
73
|
or defined as environment variable. Environment variable DIRU_ROOT has
|
71
74
|
higher precedence than the files. If ".diru_root_dir" file or a
|
@@ -169,7 +172,7 @@ History commands:
|
|
169
172
|
|
170
173
|
* "dr h" - display history.
|
171
174
|
* "dr h ." - add current dir to history.
|
172
|
-
* "dr h !" - reset (clear)
|
175
|
+
* "dr h !" - reset (clear) history.
|
173
176
|
* "dr h ," - reference last history item.
|
174
177
|
* "dr h <num>" - change dir to history <num>.
|
175
178
|
|
@@ -193,12 +196,12 @@ Misc commands:
|
|
193
196
|
|
194
197
|
RPC (Remote Procedure Call) commands:
|
195
198
|
|
196
|
-
* "reset" - Reset Server state, i.e. History,
|
199
|
+
* "reset" - Reset Server state, i.e. History, Bookmarks, Left-overs.
|
197
200
|
* "abook" - Add current dir to Bookmarks.
|
198
201
|
* "lbook" - List Bookmarks.
|
199
202
|
* "rbook" - Reset Bookmarks.
|
200
203
|
* "doc" - Show command documentation.
|
201
|
-
* "dsync" - Synchronize
|
204
|
+
* "dsync" - Synchronize Project dir content data with Server cache.
|
202
205
|
* "sync" - Synchronize Options File content to Server.
|
203
206
|
|
204
207
|
|
@@ -243,7 +246,7 @@ Available options in Options File:
|
|
243
246
|
* :dsync - Project directory hierarchy refresh period. This overrides
|
244
247
|
":sync" for Project updates (only). If value is 0, then no updates
|
245
248
|
are done after initial update when Server starts. User might want to
|
246
|
-
use 0, if the directory
|
249
|
+
use 0, if the directory hierarchy is big and/or does not change
|
247
250
|
(often).
|
248
251
|
* :hist - number of entries in history (max).
|
249
252
|
* :favs - tagged favorite dirs.
|
@@ -267,7 +270,7 @@ Server caches all Project directory entries from disk to memory. This
|
|
267
270
|
means that Client can quickly jump to any directory, even deep in the
|
268
271
|
hierarchy. The target dir should be fairly accurately identified,
|
269
272
|
otherwise the search results in too many Left-overs, which is
|
270
|
-
impractical. Server updates the cache either
|
273
|
+
impractical. Server updates the cache either periodically or only at
|
271
274
|
start-up. User might prefer no automatic update, if the hierarchy is
|
272
275
|
very large and extra load on disk is to be avoided. Cache update can
|
273
276
|
be performed at will with an RPC call, "dsync".
|
data/bin/diru
CHANGED
@@ -74,8 +74,8 @@ Spec.command( 'diru', 'Tero Isannainen', '2017',
|
|
74
74
|
[ :opt_single, 'hport', nil, "H: Hub port (default: DIRU_HUB_PORT or 41114)." ],
|
75
75
|
[ :switch, 'hkill', nil, "H: Kill hub." ],
|
76
76
|
[ :switch, 'nodaemon', nil, "H: No daemon for server." ],
|
77
|
-
[ :
|
78
|
-
[ :opt_single, 'kill', '-k', "S: Close server
|
77
|
+
[ :opt_any, 'server', '-s', "S: Open server for user (default: $USER)." ],
|
78
|
+
[ :opt_single, 'kill', '-k', "S: Close server." ],
|
79
79
|
[ :switch, 'list', '-l', "S: List servers." ],
|
80
80
|
[ :opt_single, 'options', '-o', "SC: Options File." ],
|
81
81
|
[ :opt_single, 'port', '-p', "SC: Server port for client (default: DIRU_PORT or ~/.diru.prt)." ],
|
@@ -185,7 +185,7 @@ class Search
|
|
185
185
|
|
186
186
|
include Diru
|
187
187
|
|
188
|
-
def initialize( root, opts_file = nil )
|
188
|
+
def initialize( root, user, opts_file = nil )
|
189
189
|
|
190
190
|
# Server root.
|
191
191
|
@root = root
|
@@ -198,6 +198,9 @@ class Search
|
|
198
198
|
# Change directory to DIRU root.
|
199
199
|
Dir.chdir( @root )
|
200
200
|
|
201
|
+
# User of server.
|
202
|
+
@user = user
|
203
|
+
|
201
204
|
# List of old matches.
|
202
205
|
@old = []
|
203
206
|
|
@@ -253,6 +256,7 @@ class Search
|
|
253
256
|
end
|
254
257
|
|
255
258
|
|
259
|
+
# Return opts_file.
|
256
260
|
def opts_file
|
257
261
|
@opts_file
|
258
262
|
end
|
@@ -262,6 +266,11 @@ class Search
|
|
262
266
|
@root
|
263
267
|
end
|
264
268
|
|
269
|
+
# Return user.
|
270
|
+
def user
|
271
|
+
@user
|
272
|
+
end
|
273
|
+
|
265
274
|
|
266
275
|
# Add bookmark (if not already).
|
267
276
|
def abook( dir )
|
@@ -552,7 +561,7 @@ class Search
|
|
552
561
|
|
553
562
|
|
554
563
|
# Reset dynamic state.
|
555
|
-
def reset
|
564
|
+
def reset
|
556
565
|
log "reset"
|
557
566
|
@old = []
|
558
567
|
@book = []
|
@@ -681,12 +690,12 @@ class Hub
|
|
681
690
|
|
682
691
|
|
683
692
|
# Create new server and return port for the server.
|
684
|
-
def get_server( root, opts_file )
|
693
|
+
def get_server( root, user, opts_file )
|
685
694
|
|
686
695
|
50.times do |i|
|
687
696
|
if @@servers[ @port+1+i ] == nil
|
688
697
|
port = @port+1+i
|
689
|
-
s = Service.new( root, port, opts_file )
|
698
|
+
s = Service.new( root, user, port, opts_file )
|
690
699
|
@@servers[ port ] = s
|
691
700
|
return port
|
692
701
|
end
|
@@ -698,7 +707,7 @@ class Hub
|
|
698
707
|
|
699
708
|
# List all server ports.
|
700
709
|
def list_servers
|
701
|
-
@@servers.keys.map{ |i| [ i, @@servers[i].root ] }
|
710
|
+
@@servers.keys.map{ |i| [ i, @@servers[i].root, @@servers[i].user ] }
|
702
711
|
end
|
703
712
|
|
704
713
|
|
@@ -729,10 +738,12 @@ end
|
|
729
738
|
class Service
|
730
739
|
|
731
740
|
attr_reader :root
|
741
|
+
attr_reader :user
|
732
742
|
|
733
743
|
# Initialize and start service.
|
734
|
-
def initialize( root, port, opts_file )
|
744
|
+
def initialize( root, user, port, opts_file )
|
735
745
|
@root = root
|
746
|
+
@user = user
|
736
747
|
@port = port
|
737
748
|
@drb = nil
|
738
749
|
@opts_file = opts_file
|
@@ -752,7 +763,7 @@ class Service
|
|
752
763
|
@th = Thread.new do
|
753
764
|
|
754
765
|
# Create "front" object.
|
755
|
-
@search = Search.new( @root, @opts_file )
|
766
|
+
@search = Search.new( @root, @user, @opts_file )
|
756
767
|
|
757
768
|
# Start the service
|
758
769
|
@drb = DRb::DRbServer.new( "druby://localhost:#{@port}", @search )
|
@@ -831,7 +842,7 @@ if Opt['server'].given
|
|
831
842
|
|
832
843
|
root = nil
|
833
844
|
opts_file = nil
|
834
|
-
|
845
|
+
|
835
846
|
if ENV['DIRU_ROOT']
|
836
847
|
root = ENV['DIRU_ROOT']
|
837
848
|
else
|
@@ -856,8 +867,14 @@ if Opt['server'].given
|
|
856
867
|
|
857
868
|
opts_file = Diru.get_opts_file( opts_file )
|
858
869
|
|
870
|
+
if Opt['server'].value.any?
|
871
|
+
user = Opt['server'].value[0]
|
872
|
+
else
|
873
|
+
user = ENV['USER']
|
874
|
+
end
|
875
|
+
|
859
876
|
begin
|
860
|
-
s_port = hub.get_server( root, opts_file )
|
877
|
+
s_port = hub.get_server( root, user, opts_file )
|
861
878
|
rescue
|
862
879
|
Diru.error "Access to Hub failed!"
|
863
880
|
end
|
@@ -892,7 +909,7 @@ if Opt['list'].given
|
|
892
909
|
hub = DRbObject.new( nil, "druby://localhost:#{hport}" )
|
893
910
|
begin
|
894
911
|
hub.list_servers.each do |i|
|
895
|
-
puts format( "%-12.d %s", i[0], i[1] )
|
912
|
+
puts format( "%-12.d %-12s %s", i[0], i[2], i[1] )
|
896
913
|
end
|
897
914
|
rescue
|
898
915
|
Diru.error "Access to Hub failed!"
|
@@ -973,6 +990,8 @@ class Client
|
|
973
990
|
|
974
991
|
when 'e'; disp @search.rematch( nil, arg.join('.*') )
|
975
992
|
|
993
|
+
when 'q'; disp @search.rematch( nil, arg.join('.*') )
|
994
|
+
|
976
995
|
when '.', 'b';
|
977
996
|
if arg[0] == nil
|
978
997
|
lbook( @search.book )
|
@@ -1112,6 +1131,23 @@ class Client
|
|
1112
1131
|
end
|
1113
1132
|
|
1114
1133
|
|
1134
|
+
# Display directories without CD.
|
1135
|
+
def show( resp )
|
1136
|
+
if resp == nil
|
1137
|
+
# NOP
|
1138
|
+
elsif resp.kind_of? Array
|
1139
|
+
if resp.any?
|
1140
|
+
resp.each do |i|
|
1141
|
+
STDERR.puts i
|
1142
|
+
end
|
1143
|
+
end
|
1144
|
+
else
|
1145
|
+
STDERR.puts resp
|
1146
|
+
end
|
1147
|
+
no_cd
|
1148
|
+
end
|
1149
|
+
|
1150
|
+
|
1115
1151
|
# Get peer directory. Search list of re-pairs. Match either of the
|
1116
1152
|
# pair, and switch to the pair dir.
|
1117
1153
|
#
|
@@ -1134,6 +1170,7 @@ class Client
|
|
1134
1170
|
r / - search from root (or to root)
|
1135
1171
|
t : - search from this (current)
|
1136
1172
|
e - search from root (with regexp)
|
1173
|
+
q - query from root (with regexp)
|
1137
1174
|
b . - bookmark access
|
1138
1175
|
h , - history access
|
1139
1176
|
s _ - scratch pad access
|
@@ -1197,7 +1234,7 @@ elsif File.exist?( "#{ENV['HOME']}/.diru.prt" )
|
|
1197
1234
|
port = File.read( "#{ENV['HOME']}/.diru.prt" ).to_i
|
1198
1235
|
else
|
1199
1236
|
Diru.error "Server port info missing..."
|
1200
|
-
end
|
1237
|
+
end
|
1201
1238
|
|
1202
1239
|
|
1203
1240
|
# User command content.
|
@@ -1208,7 +1245,7 @@ begin
|
|
1208
1245
|
rescue
|
1209
1246
|
Diru.error "Server not available!"
|
1210
1247
|
exit( false )
|
1211
|
-
end
|
1248
|
+
end
|
1212
1249
|
|
1213
1250
|
ret = false
|
1214
1251
|
begin
|
data/lib/version.rb
CHANGED
data/test/golden.log
CHANGED
@@ -188,6 +188,8 @@ g dir_1/dir_1_2
|
|
188
188
|
|
189
189
|
r / - search from root (or to root)
|
190
190
|
t : - search from this (current)
|
191
|
+
e - search from root (with regexp)
|
192
|
+
q - query from root (with regexp)
|
191
193
|
b . - bookmark access
|
192
194
|
h , - history access
|
193
195
|
s _ - scratch pad access
|
@@ -248,6 +250,8 @@ g dir_1/dir_1_2
|
|
248
250
|
|
249
251
|
r / - search from root (or to root)
|
250
252
|
t : - search from this (current)
|
253
|
+
e - search from root (with regexp)
|
254
|
+
q - query from root (with regexp)
|
251
255
|
b . - bookmark access
|
252
256
|
h , - history access
|
253
257
|
s _ - scratch pad access
|
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.5
|
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-
|
11
|
+
date: 2017-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: como
|