rbbt-util 5.14.15 → 5.14.16

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4562833949296544e288b767589677cdea4cd54
4
- data.tar.gz: 50c2d8f06c365b3334ab046671031b4dadff448f
3
+ metadata.gz: 70d99fc7279b9731d3f52b47a88b98e754f50376
4
+ data.tar.gz: a44903e02e4cd08f4780b7a64526f14335fcd661
5
5
  SHA512:
6
- metadata.gz: 247c31f35e49849089188684402ae360d88800e4d90cdbe897c36a7d666f00360c10e308a2a5626411f7d917595930efa4213c2af20050e7b8ab235fc4b5f349
7
- data.tar.gz: 31d136e11cc112d958568a7607fc673876822f8c350ffd326c9b66b58ca55dc6e48659ee1f80ff660527188eb30ba63d0ddfa703c3cef285c865ae8fbf5ff824
6
+ metadata.gz: 8f6e582804b9c76c255ef1a7acc1ab8bf261e75a239c6b51f85de1e37baea9e0bd688da035e9999963a8d744e8f327039af4c0fe20e8b57e3f965097be418b7c
7
+ data.tar.gz: e655675f21100fcb903238b74c0e721743d9a78ae2bd7f17e1238ac1de9439b293b712760d781ba05aafd2da601f9b874e64da14848d373c023f0c817ab66025
data/bin/rbbt CHANGED
@@ -206,7 +206,7 @@ rescue ParameterException
206
206
  puts
207
207
  exit -1
208
208
  rescue SystemExit
209
- Log.exception $! unless $?.success?
209
+ Log.error "Command error" unless $?.success?
210
210
  rescue Exception
211
211
  Log.exception $!
212
212
  ensure
@@ -1,14 +1,16 @@
1
+
2
+ #{{{ Require files
1
3
  Rbbt.etc.requires.read.split("\n").each do |file|
2
4
  next if file.empty?
3
5
  Log.debug("requiring #{ file }")
4
6
  require file
5
7
  end if Rbbt.etc.requires.exists?
6
8
 
7
-
8
9
  Entity.entity_list_cache = Rbbt.var.sinatra.find.entity_lists
9
10
  Entity.entity_map_cache = Rbbt.var.sinatra.find.entity_maps
10
11
  Entity.entity_property_cache = Rbbt.var.sinatra.find.entity_properties
11
12
 
13
+ #{{{ Prepare REST entities
12
14
  Rbbt.etc.entities.read.split("\n").each do |name|
13
15
  next if name.empty?
14
16
  mod = Kernel.const_get name
@@ -18,6 +20,7 @@ Rbbt.etc.entities.read.split("\n").each do |name|
18
20
  end
19
21
  end if Rbbt.etc.entities.exists?
20
22
 
23
+ #{{{ Prepare REST entity property persist
21
24
  $annotation_repo = Rbbt.var.sinatra.annotation_repo.find
22
25
  (Rbbt.etc.persist_properties.yaml || {}).each do |name,list|
23
26
  next if name.empty?
@@ -88,6 +88,7 @@ module Association
88
88
  if file.fields == field_headers
89
89
  file
90
90
  else
91
+ iii :reorder
91
92
  file.reorder(source, field_headers)
92
93
  end
93
94
  else
@@ -239,7 +240,7 @@ module Association
239
240
  tsv = load_tsv(file, options)
240
241
 
241
242
  tsv.annotate(data)
242
- data.serializer = tsv.type if data.respond_to? :persistence_path
243
+ data.serializer = tsv.type
243
244
 
244
245
  tsv.with_unnamed do
245
246
  tsv.each do |k,v|
@@ -330,4 +331,3 @@ module Association
330
331
  end
331
332
  end
332
333
  end
333
-
@@ -90,57 +90,61 @@ module Path
90
90
  end
91
91
 
92
92
  def find(where = nil, caller_lib = nil, paths = nil)
93
- paths = (self.search_paths || SEARCH_PATHS).merge(paths || {})
94
- where = paths[:default] if where == :default
95
- return self if located?
96
- if self.match(/(.*?)\/(.*)/)
97
- toplevel, subpath = self.match(/(.*?)\/(.*)/).values_at 1, 2
98
- else
99
- toplevel, subpath = self, ""
100
- end
101
-
102
- path = nil
103
- if where.nil?
104
- STANDARD_SEARCH.each do |w|
105
- w = w.to_sym
106
- next unless paths.include? w
107
- path = find(w, caller_lib, paths)
108
- return path if File.exists? path
109
- end
110
- (SEARCH_PATHS.keys - STANDARD_SEARCH).each do |w|
111
- w = w.to_sym
112
- next unless paths.include? w
113
- path = find(w, caller_lib, paths)
114
- return path if File.exists? path
115
- end
116
- if paths.include? :default
117
- find((paths[:default] || :user), caller_lib, paths)
118
- else
119
- raise "Path '#{ path }' not found, and no default specified in search paths: #{paths.inspect}"
120
- end
121
- else
122
- where = where.to_sym
123
- raise "Did not recognize the 'where' tag: #{where}. Options: #{paths.keys}" unless paths.include? where
124
-
125
- if where == :lib
126
- libdir = Path.caller_lib_dir(caller_lib) || "NOLIBDIR"
127
- else
128
- libdir = "NOLIBDIR"
129
- end
130
- pwd = FileUtils.pwd
131
- path = paths[where].
132
- sub('{PKGDIR}', pkgdir).
133
- sub('{PWD}', pwd).
134
- sub('{TOPLEVEL}', toplevel).
135
- sub('{SUBPATH}', subpath).
136
- sub('{PATH}', self).
137
- sub('{LIBDIR}', libdir) #, @pkgdir, @resource, @search_paths
138
-
139
- path = path + '.gz' if File.exists? path + '.gz'
140
- path = path + '.bgz' if File.exists? path + '.bgz'
141
-
142
- self.annotate path
143
- end
93
+ @path ||= {}
94
+ key = Misc.digest([where, caller_lib, paths].inspect)
95
+ @path[key] ||= begin
96
+ paths = (self.search_paths || SEARCH_PATHS).merge(paths || {})
97
+ where = paths[:default] if where == :default
98
+ return self if located?
99
+ if self.match(/(.*?)\/(.*)/)
100
+ toplevel, subpath = self.match(/(.*?)\/(.*)/).values_at 1, 2
101
+ else
102
+ toplevel, subpath = self, ""
103
+ end
104
+
105
+ path = nil
106
+ if where.nil?
107
+ STANDARD_SEARCH.each do |w|
108
+ w = w.to_sym
109
+ next unless paths.include? w
110
+ path = find(w, caller_lib, paths)
111
+ return path if File.exists? path
112
+ end
113
+ (SEARCH_PATHS.keys - STANDARD_SEARCH).each do |w|
114
+ w = w.to_sym
115
+ next unless paths.include? w
116
+ path = find(w, caller_lib, paths)
117
+ return path if File.exists? path
118
+ end
119
+ if paths.include? :default
120
+ find((paths[:default] || :user), caller_lib, paths)
121
+ else
122
+ raise "Path '#{ path }' not found, and no default specified in search paths: #{paths.inspect}"
123
+ end
124
+ else
125
+ where = where.to_sym
126
+ raise "Did not recognize the 'where' tag: #{where}. Options: #{paths.keys}" unless paths.include? where
127
+
128
+ if where == :lib
129
+ libdir = Path.caller_lib_dir(caller_lib) || "NOLIBDIR"
130
+ else
131
+ libdir = "NOLIBDIR"
132
+ end
133
+ pwd = FileUtils.pwd
134
+ path = paths[where].
135
+ sub('{PKGDIR}', pkgdir).
136
+ sub('{PWD}', pwd).
137
+ sub('{TOPLEVEL}', toplevel).
138
+ sub('{SUBPATH}', subpath).
139
+ sub('{PATH}', self).
140
+ sub('{LIBDIR}', libdir) #, @pkgdir, @resource, @search_paths
141
+
142
+ path = path + '.gz' if File.exists? path + '.gz'
143
+ path = path + '.bgz' if File.exists? path + '.bgz'
144
+
145
+ self.annotate path
146
+ end
147
+ end
144
148
  end
145
149
 
146
150
  def find_all(caller_lib = nil, search_paths = nil)
@@ -101,7 +101,7 @@ module Resource
101
101
  task = Misc.path_relative_to rake_dir, path
102
102
  rakefile = rakefile.produce if rakefile.respond_to? :produce
103
103
 
104
- rake_dir = rake_dir.find if rake_dir.respond_to? :find
104
+ rake_dir = rake_dir.find(:user) if rake_dir.respond_to? :find
105
105
 
106
106
  begin
107
107
  require 'rbbt/resource/rake'
@@ -244,7 +244,7 @@ module TSV
244
244
  end
245
245
  self[key] == new
246
246
  else
247
- self[key] = values.collect{|v| [v] }
247
+ self[key] = Array === values.first ? values.dup : values.collect{|v| [v] }
248
248
  end
249
249
  when :flat
250
250
  if self.include? key
@@ -143,7 +143,8 @@ module TSV
143
143
  raise $!
144
144
  end
145
145
 
146
- keys = parts[key_position].split(@sep2, -1)
146
+ str = parts[key_position]
147
+ keys = str.split(@sep2, -1)
147
148
 
148
149
  if @take_all
149
150
  values = parts.collect{|e| e.split(@sep2, -1) }.flatten
@@ -545,7 +546,6 @@ module TSV
545
546
  stream.abort if stream.respond_to? :abort
546
547
  raise $!
547
548
  rescue Exception
548
- Log.exception $!
549
549
  Log.error "Exception parsing #{Misc.fingerprint stream}: #{$!.message}"
550
550
  stream.abort $! if stream.respond_to? :abort
551
551
  raise $!
data/lib/rbbt/util/log.rb CHANGED
@@ -226,6 +226,12 @@ module Log
226
226
  end
227
227
  end
228
228
 
229
+ def self.tsv(tsv)
230
+ STDERR.puts Log.color :magenta, "TSV log: " << Log.last_caller(caller)
231
+ iif tsv
232
+ ppp tsv.summary
233
+ end
234
+
229
235
  def self.stack(stack)
230
236
  LOG_MUTEX.synchronize do
231
237
 
@@ -272,9 +272,12 @@ module Misc
272
272
  end
273
273
 
274
274
  def self.bootstrap(elems, num = :current, file = nil, &block)
275
+ num = :current if num.nil?
275
276
  cpus = case num
276
277
  when :current
277
278
  4
279
+ when String
280
+ num.to_i
278
281
  when Integer
279
282
  if num < 100
280
283
  num
@@ -283,6 +286,9 @@ module Misc
283
286
  end
284
287
  end
285
288
  file = caller.first + rand(1000000).to_s if file.nil?
286
- RbbtSemaphore.fork_each_on_semaphore elems, cpus, file, &block
289
+ index = (0..elems.length-1).to_a.collect{|v| v.to_s }
290
+ RbbtSemaphore.fork_each_on_semaphore index, cpus, file do |i|
291
+ yield elems[i.to_i]
292
+ end
287
293
  end
288
294
  end
@@ -30,9 +30,7 @@ file = STDIN if file == '-'
30
30
 
31
31
  raise ParameterException, "Please specify the tsv file as argument" if file.nil?
32
32
 
33
- iii options
34
33
  options[:fields] = options[:fields].split(/[,\|]/) if options[:fields]
35
- iii options
36
34
  options[:header_hash] = options["header_hash"]
37
35
  options[:sep] = options["sep"]
38
36
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.14.15
4
+ version: 5.14.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-13 00:00:00.000000000 Z
11
+ date: 2014-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake