diru 0.0.8 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.rdoc +3 -0
- data/README.rdoc +16 -12
- data/bin/diru +80 -27
- data/lib/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fa98c65075bc77ba9cc6236b44d746307be8093f4209fca37012fd5838039182
|
4
|
+
data.tar.gz: c6a1bb20486d300b6cb8f1f02ca392ccf8d29b69ef7ecce7178e509296012306
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a6380ad8a79db5adce05913b296bebb0e69b578f979ecb745cbc2d1f4a51ad252e163390f358062e37ff1f024dd84ba37a227cf11bad36a43dda0376dee8051
|
7
|
+
data.tar.gz: fe44d2598ed43e88774fff50ce480b21b8d79dfe773db27e260f2224d468260536f1a1a6a8c9b8609eef5735abedcfcfb21ac9bf1657390dd9630f1ff283010a
|
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -73,10 +73,12 @@ Hub.
|
|
73
73
|
When Server starts, it will detect the Project root. It can be a file
|
74
74
|
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
|
-
".diru.yml" file is found from current dir or some dir above,
|
77
|
-
containing either of the files will become the Project
|
78
|
-
|
79
|
-
|
76
|
+
".diru.[json|yml]" file is found from current dir or some dir above,
|
77
|
+
the dir containing either of the files will become the Project
|
78
|
+
root. Json format is selected by defining the DIRU_OPTS_FORMAT
|
79
|
+
environment variable as "json". The default is "yml". If no files are
|
80
|
+
found and DIRU_ROOT environment variable is not used, an error is
|
81
|
+
issued.
|
80
82
|
|
81
83
|
Client communicates with the Server in order to get and save directory
|
82
84
|
info. As mentioned above, Diru is more or less useless unless user has
|
@@ -225,9 +227,10 @@ provides thereby backup values for non-specified command line info.
|
|
225
227
|
* DIRU_HUB_PORT - Hub Port, if nothing, 41114 is used.
|
226
228
|
* DIRU_PORT - Server Port, if nothing, ~/.diru.prt is used
|
227
229
|
(Port File).
|
228
|
-
* DIRU_OPTS -
|
230
|
+
* DIRU_OPTS - Options file, if nothing, ~/.diru.[json|yml] is used.
|
229
231
|
* DIRU_ROOT - Project root, used if ".diru_root_dir" and
|
230
|
-
".diru.yml" are missing.
|
232
|
+
".diru.[json|yml]" are missing.
|
233
|
+
* DIRU_OPTS_FORMAT - Options file format: yml or json. Default is yml.
|
231
234
|
|
232
235
|
If Hub is started without "--hport" option, Diru checks if
|
233
236
|
DIRU_HUB_PORT is defined. If not, port 41114 is used.
|
@@ -239,13 +242,14 @@ not work if no port info is given.
|
|
239
242
|
If Server is started in a directory where (or above) a file called
|
240
243
|
".diru_root_dir" is found, then Project root is the directory
|
241
244
|
containing ".diru_root_dir". If ".diru_root_dir" is not found, but
|
242
|
-
".diru.yml" is found, then Project root is the directory
|
243
|
-
".diru.yml", and Options for Project are taken from
|
244
|
-
resort for defining Project root, is DIRU_ROOT
|
245
|
+
".diru.[json|yml]" is found, then Project root is the directory
|
246
|
+
containing ".diru.[json|yml]", and Options for Project are taken from
|
247
|
+
that file. Last resort for defining Project root, is DIRU_ROOT
|
248
|
+
definition.
|
245
249
|
|
246
250
|
If ".diru_root_dir" or DIRU_ROOT is used to define Project root, then
|
247
251
|
DIRU_OPTS is used to define Options File. However, if not defined,
|
248
|
-
then "~/.diru.yml" is used for options.
|
252
|
+
then "~/.diru.[json|yml]" is used for options.
|
249
253
|
|
250
254
|
An example Options file can be displayed with:
|
251
255
|
|
@@ -280,8 +284,8 @@ Project. Depending on the usage pattern, user might as well want to
|
|
280
284
|
use the Port File.
|
281
285
|
|
282
286
|
Each Project could benefit from specific Options File, and hence user
|
283
|
-
can mark the Project Root with ".diru.yml" and specify the
|
284
|
-
setup there.
|
287
|
+
can mark the Project Root with ".diru.[json|yml]" and specify the
|
288
|
+
Project setup there.
|
285
289
|
|
286
290
|
Server caches all Project directory entries from disk to memory. This
|
287
291
|
means that Client can quickly jump to any directory, even deep in the
|
data/bin/diru
CHANGED
@@ -29,8 +29,6 @@
|
|
29
29
|
# updated.
|
30
30
|
#
|
31
31
|
# Perform:
|
32
|
-
# shell> dr @ doc
|
33
|
-
# or
|
34
32
|
# shell> dr i
|
35
33
|
#
|
36
34
|
# for some documentation.
|
@@ -62,6 +60,7 @@
|
|
62
60
|
require 'como'
|
63
61
|
include Como
|
64
62
|
require 'drb'
|
63
|
+
require 'json'
|
65
64
|
require 'yaml'
|
66
65
|
require 'fileutils'
|
67
66
|
|
@@ -98,23 +97,10 @@ module Diru
|
|
98
97
|
# Default port.
|
99
98
|
DIRU_HUB_PORT = ENV['DIRU_HUB_PORT'] || 41114
|
100
99
|
|
101
|
-
# Load yaml configuration file (if exists).
|
102
|
-
def Diru.load_conf( conf_file )
|
103
|
-
conf = nil
|
104
|
-
if File.exist?( conf_file )
|
105
|
-
begin
|
106
|
-
conf = YAML.load( File.read( conf_file ) )
|
107
|
-
rescue
|
108
|
-
STDERR.puts "Diru Error: Broken YAML, please fix: \"#{conf_file}\"..."
|
109
|
-
end
|
110
|
-
end
|
111
|
-
conf
|
112
|
-
end
|
113
|
-
|
114
100
|
|
115
101
|
# See: Diru.load_conf
|
116
102
|
def load_conf( conf_file )
|
117
|
-
@conf =
|
103
|
+
@conf = conf_file.load
|
118
104
|
end
|
119
105
|
|
120
106
|
|
@@ -169,24 +155,87 @@ module Diru
|
|
169
155
|
end
|
170
156
|
end
|
171
157
|
|
172
|
-
|
158
|
+
|
159
|
+
def Diru.opts_filename
|
160
|
+
if ENV['DIRU_OPTS_FORMAT']
|
161
|
+
".diru.#{ENV['DIRU_OPTS_FORMAT']}"
|
162
|
+
else
|
163
|
+
".diru.yml"
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
|
170
|
+
# Diru configuration file.
|
171
|
+
class DiruConf
|
172
|
+
|
173
|
+
def DiruConf.deploy( filename = nil )
|
174
|
+
dc_file = DiruConf.find( filename )
|
175
|
+
DiruConf.use( dc_file )
|
176
|
+
end
|
177
|
+
|
178
|
+
def DiruConf.find( filename = nil )
|
173
179
|
opts_file = nil
|
174
180
|
if Opt['options'].given
|
175
181
|
opts_file = Opt['options'].value
|
176
|
-
elsif
|
177
|
-
opts_file =
|
182
|
+
elsif filename
|
183
|
+
opts_file = filename
|
178
184
|
elsif ENV['DIRU_OPTS']
|
179
185
|
opts_file = ENV['DIRU_OPTS']
|
180
186
|
else
|
181
|
-
opts_file = "#{ENV['HOME']}
|
187
|
+
opts_file = "#{ENV['HOME']}/#{Diru.opts_filename}"
|
182
188
|
end
|
183
189
|
|
184
190
|
opts_file
|
185
191
|
end
|
186
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)!"
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def initialize( filename )
|
202
|
+
@filename = filename
|
203
|
+
end
|
204
|
+
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
# Diru configuration file in JSON.
|
209
|
+
class DiruConfJson < DiruConf
|
210
|
+
|
211
|
+
def load
|
212
|
+
if File.exist?( @filename )
|
213
|
+
JSON.parse( File.read( @filename ), :symbolize_names => true )
|
214
|
+
else
|
215
|
+
STDERR.puts "Diru Error: Broken JSON, please fix: \"#{@filename}\"..."
|
216
|
+
nil
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
187
220
|
end
|
188
221
|
|
189
222
|
|
223
|
+
# Diru configuration file in YAML.
|
224
|
+
class DiruConfYaml < DiruConf
|
225
|
+
|
226
|
+
def load
|
227
|
+
if File.exist?( @filename )
|
228
|
+
YAML.load( File.read( @filename ) )
|
229
|
+
else
|
230
|
+
STDERR.puts "Diru Error: Broken YAML, please fix: \"#{@filename}\"..."
|
231
|
+
nil
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
end
|
236
|
+
|
237
|
+
|
238
|
+
|
190
239
|
# Diru Server State.
|
191
240
|
class Search
|
192
241
|
|
@@ -592,10 +641,11 @@ class Search
|
|
592
641
|
def start_th_data
|
593
642
|
unless @dsync == 0
|
594
643
|
@th_data = Thread.new do
|
644
|
+
sleep 1
|
595
645
|
loop do
|
596
646
|
# puts "data update..."
|
597
|
-
sleep @dsync
|
598
647
|
update_data_sync
|
648
|
+
sleep @dsync
|
599
649
|
end
|
600
650
|
end
|
601
651
|
end
|
@@ -612,9 +662,10 @@ class Search
|
|
612
662
|
# Start opts thread.
|
613
663
|
def start_th_opts
|
614
664
|
@th_opts = Thread.new do
|
665
|
+
sleep 1
|
615
666
|
loop do
|
616
|
-
sleep @sync
|
617
667
|
update_opts_sync
|
668
|
+
sleep @sync
|
618
669
|
end
|
619
670
|
end
|
620
671
|
end
|
@@ -931,18 +982,20 @@ if Opt['server'].given
|
|
931
982
|
end
|
932
983
|
|
933
984
|
unless root
|
934
|
-
|
985
|
+
|
986
|
+
# Next search for .diru.[json|yml] file.
|
935
987
|
begin
|
936
|
-
|
937
|
-
root = File.dirname(
|
938
|
-
opts_file =
|
988
|
+
file = Diru.find_upper_file( Diru.opts_filename )
|
989
|
+
root = File.dirname( file )
|
990
|
+
opts_file = file
|
939
991
|
rescue
|
940
992
|
Diru.error "Could not find user directory root!"
|
941
993
|
end
|
942
994
|
end
|
943
995
|
end
|
944
996
|
|
945
|
-
opts_file = Diru.get_opts_file( opts_file )
|
997
|
+
# opts_file = Diru.get_opts_file( opts_file )
|
998
|
+
opts_file = DiruConf.deploy( opts_file )
|
946
999
|
|
947
1000
|
if Opt['server'].value.any?
|
948
1001
|
user = Opt['server'].value[0]
|
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.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tero Isannainen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: como
|
@@ -105,9 +105,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.7.6.2
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: Diru is a Change Directory (cd) utility.
|
112
112
|
test_files: []
|
113
|
-
has_rdoc:
|