diru 0.0.1 → 0.0.2
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 +34 -11
- data/bin/diru +100 -20
- data/lib/version.rb +1 -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: 661a13ca67725be1a3bfd0346e7cf0181c143c45
|
4
|
+
data.tar.gz: 8e2275fadcb18e0c545e58456f2370a354bb1af2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e16248f4b28add940c1085a51f379a416923236d96b71bddb6b111307fb76bc52efb140aca5a0287abf0a65d17ae719778619aa9654188cd48593dbe71409c3
|
7
|
+
data.tar.gz: ac8d58f8815ea2b9697a6446c1d8688a7b1a60f59f74b2e8ad687f81da291c750aa244e571b4a770a4795f18aa33e1fee64cf102c6efce85a764647223fbbc92
|
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -28,8 +28,10 @@ Diru features:
|
|
28
28
|
* Support for multiple concurrent Projects.
|
29
29
|
* User and Project specific options (configuration).
|
30
30
|
* Jump to Project root.
|
31
|
-
* Find and jump to dir under Project root (regexp
|
32
|
-
* Find and jump to dir under current dir (regexp
|
31
|
+
* Find and jump to dir under Project root (regexp search).
|
32
|
+
* Find and jump to dir under current dir (regexp search).
|
33
|
+
* Fast directory search since Server maintains a memory image of
|
34
|
+
directories.
|
33
35
|
* Favorite directories in options (configuration), for permanent
|
34
36
|
favorites.
|
35
37
|
* Bookmark saving and referencing, for current favorites.
|
@@ -87,7 +89,10 @@ Here is an example of such function for Bourne Shell based shells:
|
|
87
89
|
Diru Client command is called now "dr". We specify with "-p" that port
|
88
90
|
"42324" is used towards the Server and with "-c" that we want to issue
|
89
91
|
directory "change" commands. In practice only part of the commands
|
90
|
-
will change directory, since some commands are only for
|
92
|
+
will change directory, since some commands are only for
|
93
|
+
queries. Directory is (and should be) changed if Diru returns
|
94
|
+
0. Otherwise Diru is performing a non-cd command, and Shell should
|
95
|
+
just ignore the current Diru execution.
|
91
96
|
|
92
97
|
If you want to see all Diru options, perform:
|
93
98
|
|
@@ -181,6 +186,8 @@ RPC (Remote Procedure Call) commands:
|
|
181
186
|
* "lbook" - List Bookmarks.
|
182
187
|
* "rbook" - Reset Bookmarks.
|
183
188
|
* "doc" - Show command documentation.
|
189
|
+
* "dsync" - Synchronize Projecr dir content data with Server cache.
|
190
|
+
* "sync" - Synchronize Options File content to Server.
|
184
191
|
|
185
192
|
|
186
193
|
= Configuration
|
@@ -190,7 +197,7 @@ provides thereby backup values for non-specified command line info.
|
|
190
197
|
|
191
198
|
* DIRU_HUB_PORT - Hub Port, if nothing, 41114 is used.
|
192
199
|
* DIRU_PORT - Server Port, if nothing, ~/.diru.prt is used (Port File).
|
193
|
-
* DIRU_OPTS - options file, if nothing, ~/.diru.yml is used.
|
200
|
+
* DIRU_OPTS - options file, if nothing, ~/.diru.yml is used.
|
194
201
|
* DIRU_ROOT - Project root, used if ".diru_root_dir" and ".diru.yml"
|
195
202
|
are missing.
|
196
203
|
|
@@ -219,8 +226,13 @@ An example Options file can be displayed with:
|
|
219
226
|
|
220
227
|
Available options in Options File:
|
221
228
|
|
222
|
-
* :sync - Options File and Project directory hierarchy
|
223
|
-
(for Server).
|
229
|
+
* :sync - Options File and Project directory hierarchy refresh period
|
230
|
+
in seconds (for Server).
|
231
|
+
* :dsync - Project directory hierarchy refresh period. This overrides
|
232
|
+
":sync" for Project updates (only). If value is 0, then no updates
|
233
|
+
are done after initial update when Server starts. User might want to
|
234
|
+
use 0, if the directory hierarhcy is big and/or does not change
|
235
|
+
(often).
|
224
236
|
* :hist - number of entries in history (max).
|
225
237
|
* :favs - tagged favorite dirs.
|
226
238
|
* :peers - <regexp>,<str> pairs for peer matching (String#sub method).
|
@@ -232,13 +244,22 @@ After Hub has been started, user can start Server for each
|
|
232
244
|
Project. Each Server runs on its own Port, and user can either define
|
233
245
|
a Shell function for each Server with specific name, or define
|
234
246
|
environment variable (DIRU_PORT) and change it according to
|
235
|
-
Project. Depending on the usage pattern, user might
|
236
|
-
the Port File.
|
247
|
+
Project. Depending on the usage pattern, user might as well want to
|
248
|
+
use the Port File.
|
237
249
|
|
238
|
-
Each Project
|
250
|
+
Each Project could benefit from specific Options File, and thus user
|
239
251
|
could mark the Project Root with ".diru.yml" and specify the Project
|
240
252
|
setup there.
|
241
253
|
|
254
|
+
Server caches all Project directory entries from disk to memory. This
|
255
|
+
means that Client can quickly jump to any directory, even deep in the
|
256
|
+
hierarchy. The target dir should be fairly accurately identified,
|
257
|
+
otherwise the search results in too many Left-overs, which is
|
258
|
+
impractical. Server updates the cache either peridically or only at
|
259
|
+
start-up. User might prefer no automatic update, if the hierarchy is
|
260
|
+
very large and extra load on disk is to be avoided. Cache update can
|
261
|
+
be performed at will with an RPC call, "dsync".
|
262
|
+
|
242
263
|
If user is working with a programming project, it is fairly common to
|
243
264
|
have separate sub-directories for source code and build targets. Let's
|
244
265
|
assume user starts with editing source code and has a terminal for
|
@@ -252,9 +273,11 @@ current dir, i.e. where program running and debugging takes place.
|
|
252
273
|
|
253
274
|
If programming project is big enough, there might be several sub-dirs
|
254
275
|
where source files reside. User might setup favorites to Options File,
|
255
|
-
in order to easily reference the popular source code directories.
|
276
|
+
in order to easily reference the popular source code directories. For
|
277
|
+
less permanent favorites, user can use Bookmarks.
|
256
278
|
|
257
279
|
Options File can be edited while Server is running. Server reads the
|
258
280
|
Options File every 5 seconds (configurable with ":sync") and refreshes
|
259
281
|
its internal state. Server also updates its internal cache of Project
|
260
|
-
directory content at each refresh cycle.
|
282
|
+
directory content at each refresh cycle (by default). If ":dsync"
|
283
|
+
Option is specified, it defines the "dsync" rate.
|
data/bin/diru
CHANGED
@@ -201,8 +201,11 @@ class Search
|
|
201
201
|
# History limit.
|
202
202
|
@histlimit = 20
|
203
203
|
|
204
|
-
# Sync period.
|
205
|
-
@sync =
|
204
|
+
# Sync period for options (and data if no @dsync).
|
205
|
+
@sync = 10
|
206
|
+
|
207
|
+
# Sync period for data.
|
208
|
+
@dsync = nil
|
206
209
|
|
207
210
|
# Options File.
|
208
211
|
@opts_file = opts_file
|
@@ -218,15 +221,22 @@ class Search
|
|
218
221
|
# @logging = true
|
219
222
|
# end
|
220
223
|
|
221
|
-
#
|
222
|
-
|
223
|
-
|
224
|
+
# Data update thread.
|
225
|
+
@th_data = nil
|
226
|
+
|
227
|
+
# Options update thread.
|
228
|
+
@th_opts = nil
|
224
229
|
|
225
230
|
# Lock for DB access.
|
226
231
|
@datalock = Mutex.new
|
232
|
+
@optslock = Mutex.new
|
233
|
+
|
234
|
+
# Initial data update.
|
235
|
+
update_conf
|
236
|
+
update_data
|
227
237
|
|
228
|
-
|
229
|
-
|
238
|
+
start_th_data
|
239
|
+
start_th_opts
|
230
240
|
end
|
231
241
|
|
232
242
|
|
@@ -333,8 +343,21 @@ class Search
|
|
333
343
|
|
334
344
|
load_conf( @opts_file )
|
335
345
|
|
346
|
+
if @conf[:dsync] && @conf[:dsync] >= 0
|
347
|
+
@dsync = @conf[:dsync]
|
348
|
+
end
|
349
|
+
|
336
350
|
if @conf[:sync] && @conf[:sync] >= 1
|
337
351
|
@sync = @conf[:sync]
|
352
|
+
@dsync = @sync unless @dsync
|
353
|
+
end
|
354
|
+
|
355
|
+
if @dsync == 0
|
356
|
+
kill_th_data
|
357
|
+
else
|
358
|
+
unless @th_data
|
359
|
+
start_th_data
|
360
|
+
end
|
338
361
|
end
|
339
362
|
|
340
363
|
if @conf[:hist] && ( @conf[:hist] >= 2 )
|
@@ -413,11 +436,25 @@ class Search
|
|
413
436
|
def update_data_sync
|
414
437
|
@datalock.synchronize do
|
415
438
|
update_data
|
439
|
+
end
|
440
|
+
end
|
441
|
+
|
442
|
+
|
443
|
+
# Update DB with MT sync.
|
444
|
+
def update_opts_sync
|
445
|
+
@optslock.synchronize do
|
416
446
|
update_conf
|
417
447
|
end
|
418
448
|
end
|
419
449
|
|
420
450
|
|
451
|
+
# Kill search and cleanup resources.
|
452
|
+
def kill
|
453
|
+
kill_th_data
|
454
|
+
kill_th_opts
|
455
|
+
end
|
456
|
+
|
457
|
+
|
421
458
|
# Reset dynamic state.
|
422
459
|
def reset
|
423
460
|
log "reset"
|
@@ -427,20 +464,45 @@ class Search
|
|
427
464
|
update_data_sync
|
428
465
|
end
|
429
466
|
|
467
|
+
# Start data thread.
|
468
|
+
def start_th_data
|
469
|
+
unless @dsync == 0
|
470
|
+
@th_data = Thread.new do
|
471
|
+
loop do
|
472
|
+
# puts "data update..."
|
473
|
+
sleep @dsync
|
474
|
+
update_data_sync
|
475
|
+
end
|
476
|
+
end
|
477
|
+
end
|
478
|
+
end
|
430
479
|
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
@
|
480
|
+
|
481
|
+
# Kill data thread.
|
482
|
+
def kill_th_data
|
483
|
+
Thread.kill( @th_data ) if @th_data
|
484
|
+
@th_data = nil
|
485
|
+
end
|
486
|
+
|
487
|
+
|
488
|
+
# Start opts thread.
|
489
|
+
def start_th_opts
|
490
|
+
@th_opts = Thread.new do
|
435
491
|
loop do
|
436
|
-
# puts "data update..."
|
437
492
|
sleep @sync
|
438
|
-
|
493
|
+
update_opts_sync
|
439
494
|
end
|
440
495
|
end
|
441
496
|
end
|
442
497
|
|
443
498
|
|
499
|
+
# Kill opts thread.
|
500
|
+
def kill_th_opts
|
501
|
+
Thread.kill( @th_opts ) if @th_opts
|
502
|
+
@th_opts = nil
|
503
|
+
end
|
504
|
+
|
505
|
+
|
444
506
|
# Enable logging.
|
445
507
|
def logon
|
446
508
|
@logging = true
|
@@ -475,11 +537,21 @@ class Hub
|
|
475
537
|
def Hub.start( port, daemon = true )
|
476
538
|
if daemon
|
477
539
|
p = fork do
|
478
|
-
|
540
|
+
begin
|
541
|
+
Hub.new( port )
|
542
|
+
rescue
|
543
|
+
Diru.error "Could not start Hub!"
|
544
|
+
exit( false )
|
545
|
+
end
|
479
546
|
end
|
480
547
|
Process.detach( p )
|
481
548
|
else
|
482
|
-
|
549
|
+
begin
|
550
|
+
Hub.new( port )
|
551
|
+
rescue
|
552
|
+
Diru.error "Could not start Hub!"
|
553
|
+
exit( false )
|
554
|
+
end
|
483
555
|
end
|
484
556
|
end
|
485
557
|
|
@@ -574,8 +646,9 @@ class Service
|
|
574
646
|
|
575
647
|
# Kill service.
|
576
648
|
def kill
|
577
|
-
@
|
649
|
+
@search.kill
|
578
650
|
Thread.kill( @th )
|
651
|
+
@drb.stop_service
|
579
652
|
end
|
580
653
|
|
581
654
|
# Start service.
|
@@ -596,8 +669,9 @@ end
|
|
596
669
|
|
597
670
|
if Opt['template'].given
|
598
671
|
puts %q{---
|
599
|
-
:hist:
|
600
|
-
:sync:
|
672
|
+
:hist: 20
|
673
|
+
:sync: 10
|
674
|
+
:dsync: 0
|
601
675
|
:favs:
|
602
676
|
f: dir_0/dir_0_4/dir_0_4_0
|
603
677
|
g: dir_1/dir_1_2
|
@@ -644,8 +718,12 @@ end
|
|
644
718
|
|
645
719
|
|
646
720
|
if Opt['hkill'].given
|
647
|
-
|
648
|
-
|
721
|
+
begin
|
722
|
+
hub = DRbObject.new( nil, "druby://localhost:#{hport}" )
|
723
|
+
hub.kill
|
724
|
+
rescue
|
725
|
+
Diru.error "Could not kill Hub!"
|
726
|
+
end
|
649
727
|
exit( true )
|
650
728
|
end
|
651
729
|
|
@@ -958,6 +1036,8 @@ class Client
|
|
958
1036
|
when 'lbook'; lbook( @search.book )
|
959
1037
|
when 'rbook'; @search.rbook
|
960
1038
|
when 'doc'; doc
|
1039
|
+
when 'sync'; @search.update_opts_sync
|
1040
|
+
when 'dsync'; @search.update_data_sync
|
961
1041
|
else return no_cd
|
962
1042
|
end
|
963
1043
|
no_cd
|
data/lib/version.rb
CHANGED
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.2
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: como
|