diru 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +4 -0
- data/README.rdoc +17 -17
- data/bin/diru +96 -61
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52998510ee6ded3ea6fa81a826e82e648cbffb1abf1174a985ee71627bfc2d75
|
4
|
+
data.tar.gz: ee3d26f1d9d6668e67e9eabe0b34402a5b5c7e477d20a6cb58f1d51da4449ab3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4dbaef3dc53c31010493374b2feefd8c15f01a2e1cbfac777ccee14e7488208b3f27c195abd2ce4d51d5ebfe34493bba734551d4ef6ff9b2cbe4bae8ac6a9ff
|
7
|
+
data.tar.gz: bb18dc7513830cfbbf4b2b33ef07aa084ccb2b44c4f01ba3b722b81c4d4c60f29b4f82a82d181302acd0847401738542436f08f6eebd62da8e9da87dc49bd3b1
|
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -75,10 +75,8 @@ or defined as environment variable. Environment variable DIRU_ROOT has
|
|
75
75
|
higher precedence than the files. If ".diru_root_dir" file or a
|
76
76
|
".diru.[json|yml]" file is found from current dir or some dir above,
|
77
77
|
the dir containing either of the files will become the Project
|
78
|
-
root.
|
79
|
-
|
80
|
-
found and DIRU_ROOT environment variable is not used, an error is
|
81
|
-
issued.
|
78
|
+
root. If no files are found and DIRU_ROOT environment variable is not
|
79
|
+
used, an error is issued.
|
82
80
|
|
83
81
|
Client communicates with the Server in order to get and save directory
|
84
82
|
info. As mentioned above, Diru is more or less useless unless user has
|
@@ -230,7 +228,6 @@ provides thereby backup values for non-specified command line info.
|
|
230
228
|
* DIRU_OPTS - Options file, if nothing, ~/.diru.[json|yml] is used.
|
231
229
|
* DIRU_ROOT - Project root, used if ".diru_root_dir" and
|
232
230
|
".diru.[json|yml]" are missing.
|
233
|
-
* DIRU_OPTS_FORMAT - Options file format: yml or json. Default is yml.
|
234
231
|
|
235
232
|
If Hub is started without "--hport" option, Diru checks if
|
236
233
|
DIRU_HUB_PORT is defined. If not, port 41114 is used.
|
@@ -251,6 +248,9 @@ If ".diru_root_dir" or DIRU_ROOT is used to define Project root, then
|
|
251
248
|
DIRU_OPTS is used to define Options File. However, if not defined,
|
252
249
|
then "~/.diru.[json|yml]" is used for options.
|
253
250
|
|
251
|
+
The "json" format is searched before "yml" format, and hence "json" is
|
252
|
+
selected if both exist.
|
253
|
+
|
254
254
|
An example Options file can be displayed with:
|
255
255
|
|
256
256
|
shell> diru -t
|
@@ -258,20 +258,20 @@ An example Options file can be displayed with:
|
|
258
258
|
|
259
259
|
Available options in Options File:
|
260
260
|
|
261
|
-
*
|
262
|
-
|
261
|
+
* sync - Options File and Project directory hierarchy refresh period
|
262
|
+
in seconds (for Server).
|
263
263
|
|
264
|
-
*
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
264
|
+
* dsync - Project directory hierarchy refresh period. This overrides
|
265
|
+
"sync" for Project updates (only). If value is 0, then no
|
266
|
+
updates are done after initial update when Server
|
267
|
+
starts. User might want to use 0, if the directory
|
268
|
+
hierarchy is big and/or does not change (often).
|
269
269
|
|
270
|
-
*
|
270
|
+
* hist - number of entries in history (max).
|
271
271
|
|
272
|
-
*
|
272
|
+
* favs - tagged favorite dirs.
|
273
273
|
|
274
|
-
*
|
274
|
+
* peers - <regexp>,<str> pairs for peer matching (String#sub method).
|
275
275
|
|
276
276
|
|
277
277
|
= Practical usage tips
|
@@ -313,7 +313,7 @@ in order to easily reference the popular source code directories. For
|
|
313
313
|
less permanent favorites, user can use Bookmarks.
|
314
314
|
|
315
315
|
Options File can be edited while Server is running. Server reads the
|
316
|
-
Options File every 5 seconds (configurable with "
|
316
|
+
Options File every 5 seconds (configurable with "sync") and refreshes
|
317
317
|
its internal state. Server also updates its internal cache of Project
|
318
|
-
directory content at each refresh cycle (by default). If "
|
318
|
+
directory content at each refresh cycle (by default). If "dsync"
|
319
319
|
Option is specified, it defines the "dsync" rate.
|
data/bin/diru
CHANGED
@@ -145,14 +145,40 @@ module Diru
|
|
145
145
|
end
|
146
146
|
|
147
147
|
|
148
|
-
# Find file entry from directory hierarchy upwards
|
149
|
-
def Diru.
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
148
|
+
# Find file entry from directory hierarchy upwards.
|
149
|
+
def Diru.find_an_upper_file( files, dir = Dir.pwd )
|
150
|
+
found = nil
|
151
|
+
|
152
|
+
# Process all directory levels.
|
153
|
+
while true
|
154
|
+
|
155
|
+
# Process directory level.
|
156
|
+
while true
|
157
|
+
# Process all files per directory level.
|
158
|
+
idx = 0
|
159
|
+
files.each do |file|
|
160
|
+
match = Dir.glob( "#{dir}/#{file}" )
|
161
|
+
unless match.empty?
|
162
|
+
found = match[0]
|
163
|
+
break
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
break if found
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
break if found
|
172
|
+
|
173
|
+
if dir == "/"
|
174
|
+
raise RuntimeError, "Could not find file(s): \"#{files.join("\", \"")}\"!"
|
175
|
+
end
|
176
|
+
|
177
|
+
dir = File.dirname( dir )
|
178
|
+
|
155
179
|
end
|
180
|
+
|
181
|
+
found
|
156
182
|
end
|
157
183
|
|
158
184
|
|
@@ -170,32 +196,18 @@ end
|
|
170
196
|
# Diru configuration file.
|
171
197
|
class DiruConf
|
172
198
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
opts_file = filename
|
184
|
-
elsif ENV['DIRU_OPTS']
|
185
|
-
opts_file = ENV['DIRU_OPTS']
|
186
|
-
else
|
187
|
-
opts_file = "#{ENV['HOME']}/#{Diru.opts_filename}"
|
188
|
-
end
|
189
|
-
|
190
|
-
opts_file
|
191
|
-
end
|
192
|
-
|
193
|
-
def DiruConf.use( filename )
|
194
|
-
case File.extname( filename )
|
195
|
-
when ".json"; DiruConfJson.new( filename )
|
196
|
-
when ".yml"; DiruConfYaml.new( filename )
|
197
|
-
else raise RuntimeError, "Wrong Diru configuration file format (i.e. not json or yaml)!"
|
199
|
+
# Convert YAML config to hash with String keys at highest level.
|
200
|
+
def DiruConf.stringify_yaml_keys( entry )
|
201
|
+
ret = {}
|
202
|
+
entry.each do |k,v|
|
203
|
+
if k.is_a? String
|
204
|
+
key = k
|
205
|
+
else
|
206
|
+
key = k.to_s
|
207
|
+
end
|
208
|
+
ret[ key ] = v
|
198
209
|
end
|
210
|
+
ret
|
199
211
|
end
|
200
212
|
|
201
213
|
def initialize( filename )
|
@@ -210,7 +222,7 @@ class DiruConfJson < DiruConf
|
|
210
222
|
|
211
223
|
def load
|
212
224
|
if File.exist?( @filename )
|
213
|
-
JSON.parse( File.read( @filename )
|
225
|
+
JSON.parse( File.read( @filename ) )
|
214
226
|
else
|
215
227
|
STDERR.puts "Diru Error: Broken JSON, please fix: \"#{@filename}\"..."
|
216
228
|
nil
|
@@ -225,7 +237,7 @@ class DiruConfYaml < DiruConf
|
|
225
237
|
|
226
238
|
def load
|
227
239
|
if File.exist?( @filename )
|
228
|
-
YAML.load( File.read( @filename ) )
|
240
|
+
DiruConf.stringify_yaml_keys( YAML.load( File.read( @filename ) ) )
|
229
241
|
else
|
230
242
|
STDERR.puts "Diru Error: Broken YAML, please fix: \"#{@filename}\"..."
|
231
243
|
nil
|
@@ -421,12 +433,12 @@ class Search
|
|
421
433
|
|
422
434
|
return unless load_conf( @opts_file )
|
423
435
|
|
424
|
-
if @conf[
|
425
|
-
@dsync = @conf[
|
436
|
+
if @conf[ "dsync" ] && @conf[ "dsync" ] >= 0
|
437
|
+
@dsync = @conf[ "dsync" ]
|
426
438
|
end
|
427
439
|
|
428
|
-
if @conf[
|
429
|
-
@sync = @conf[
|
440
|
+
if @conf[ "sync" ] && @conf[ "sync" ] >= 1
|
441
|
+
@sync = @conf[ "sync" ]
|
430
442
|
@dsync = @sync unless @dsync
|
431
443
|
end
|
432
444
|
|
@@ -438,14 +450,14 @@ class Search
|
|
438
450
|
end
|
439
451
|
end
|
440
452
|
|
441
|
-
if @conf[
|
442
|
-
@histlimit = @conf[
|
453
|
+
if @conf[ "hist" ] && ( @conf[ "hist" ] >= 2 )
|
454
|
+
@histlimit = @conf[ "hist" ]
|
443
455
|
else
|
444
456
|
@histlimit = 20
|
445
457
|
end
|
446
458
|
|
447
|
-
if @conf[
|
448
|
-
@fav = @conf[
|
459
|
+
if @conf[ "favs" ]
|
460
|
+
@fav = @conf[ "favs" ]
|
449
461
|
end
|
450
462
|
|
451
463
|
end
|
@@ -846,13 +858,13 @@ end
|
|
846
858
|
|
847
859
|
if Opt['template'].given
|
848
860
|
puts %q{---
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
861
|
+
hist: 20
|
862
|
+
sync: 10
|
863
|
+
dsync: 0
|
864
|
+
favs:
|
853
865
|
f: dir_0/dir_0_4/dir_0_4_0
|
854
866
|
g: dir_1/dir_1_2
|
855
|
-
|
867
|
+
peers:
|
856
868
|
- - "(.*/dir_0/.*)/dir_0_2_0"
|
857
869
|
- "\\1"
|
858
870
|
- - "(.*/dir_0/.*)/dir_0_1_0"
|
@@ -969,8 +981,8 @@ if Opt['server'].given
|
|
969
981
|
hub = DRbObject.new( nil, "druby://localhost:#{hport}" )
|
970
982
|
|
971
983
|
root = nil
|
972
|
-
opts_file = nil
|
973
984
|
|
985
|
+
# Define project root, if it is explicitly defined.
|
974
986
|
if ENV['DIRU_ROOT']
|
975
987
|
root = ENV['DIRU_ROOT']
|
976
988
|
else
|
@@ -980,22 +992,46 @@ if Opt['server'].given
|
|
980
992
|
rescue
|
981
993
|
root = nil
|
982
994
|
end
|
995
|
+
end
|
983
996
|
|
984
|
-
|
997
|
+
opts_json = ".diru.json"
|
998
|
+
opts_yaml = ".diru.yml"
|
985
999
|
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
1000
|
+
opts_filename = nil
|
1001
|
+
opts_file = nil
|
1002
|
+
|
1003
|
+
if root
|
1004
|
+
if Opt['options'].given
|
1005
|
+
opts_filename = Opt['options'].value
|
1006
|
+
elsif ENV['DIRU_OPTS']
|
1007
|
+
opts_filename = ENV['DIRU_OPTS']
|
1008
|
+
elsif File.exists? "#{ENV['HOME']}/#{opts_json}"
|
1009
|
+
opts_filename = "#{ENV['HOME']}/#{opts_json}"
|
1010
|
+
elsif File.exists? "#{ENV['HOME']}/#{opts_yaml}"
|
1011
|
+
opts_filename = "#{ENV['HOME']}/#{opts_yaml}"
|
1012
|
+
else
|
1013
|
+
opts_filename = nil
|
1014
|
+
end
|
1015
|
+
else
|
1016
|
+
# No explicit root, hence derive from options file (if any).
|
1017
|
+
begin
|
1018
|
+
file = Diru.find_an_upper_file( [ opts_json, opts_yaml ] )
|
1019
|
+
root = File.dirname( file )
|
1020
|
+
opts_filename = file
|
1021
|
+
rescue
|
1022
|
+
Diru.error "Could not find user directory root!"
|
994
1023
|
end
|
995
1024
|
end
|
996
1025
|
|
997
|
-
|
998
|
-
|
1026
|
+
if opts_filename
|
1027
|
+
case File.extname( opts_filename )
|
1028
|
+
when ".json"; opts_file = DiruConfJson.new( opts_filename )
|
1029
|
+
when ".yml"; opts_file = DiruConfYaml.new( opts_filename )
|
1030
|
+
else raise RuntimeError, "Wrong Diru configuration file format (i.e. not json or yaml)!"
|
1031
|
+
end
|
1032
|
+
else
|
1033
|
+
raise RuntimeError, "Missing configuration file!"
|
1034
|
+
end
|
999
1035
|
|
1000
1036
|
if Opt['server'].value.any?
|
1001
1037
|
user = Opt['server'].value[0]
|
@@ -1012,7 +1048,6 @@ if Opt['server'].given
|
|
1012
1048
|
if s_port == 0
|
1013
1049
|
Diru.error "Could not start server!"
|
1014
1050
|
else
|
1015
|
-
# File.write( port_file, s_port.to_s ) if port_file
|
1016
1051
|
puts "Using server port: #{s_port}..."
|
1017
1052
|
end
|
1018
1053
|
|
@@ -1318,7 +1353,7 @@ class Client
|
|
1318
1353
|
def peer
|
1319
1354
|
# cur = Dir.pwd
|
1320
1355
|
cur = @pwd
|
1321
|
-
peers = @conf[
|
1356
|
+
peers = @conf[ "peers" ]
|
1322
1357
|
peers.each do |pair|
|
1323
1358
|
re = Regexp.new( pair[0] )
|
1324
1359
|
if ( re.match( cur ) )
|
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tero Isannainen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: como
|