rbbt-util 5.5.4 → 5.5.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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWIwMmM0MmY4N2RkZWY3MzFkZDNhMGNmNGU2NzBmMWQwMGU5MWNkMw==
4
+ N2QwOWU5NGVjMWZlZjQyMmIxNTk4NWFhOGQxNzMwZGNjOTlmNThmNA==
5
5
  data.tar.gz: !binary |-
6
- MDUzODQ2Njc4NDJlYWI2MmNkNzE0YTM4M2I3OTkyZTdkMjA1Y2JjYw==
6
+ Y2YwMzc0ZDY0YjZlNGU1MjVhYmNkMzVkZjliYmY3N2MyNThiYjg4MQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NjAzMDQ1YTRkZmE5NjM3YzY4NTA5MDU5MDk1YWY4MGZlZGI5ZDVkNzI4NWNm
10
- OTRjNDgwNGQ4MjBmNmE0OThjMWIzMTY2MzFhNDk5NWRhYTg1ODdmOWNhNTIy
11
- ODJmNzkxMGVlZjkwZmQ0MDU2YzllNjIxZWI4ZDA4ZjBmNzZiMTQ=
9
+ MzZkZWNhN2Y0OWQ5Y2YxMGU3Y2U3NDRmYWFlYTkwYjJhOGFlMjZlMzRhYTlk
10
+ MmE2ZjAxOTVkYjk2NWY5MDg0ZWU1ZTE0MWU5YTMyN2NlNTNhNzc3Y2RjNjBi
11
+ YzI0NDQxODExM2RlZDU5MDliYzg0OTM1NjI4ZjI2ODhjOWI3Y2M=
12
12
  data.tar.gz: !binary |-
13
- ZTI0ODM1MThjZmU4NzJiMzIyMmZjOTM4Y2Y3N2JiNTM0MDUwOWI1OTU4Mzlm
14
- MjFkN2MzZTBjMTZjNGQ0NWY5N2UzZTk5YjBmMTFiODZiYjk3MDIyMTg3ZDYy
15
- NDdlMjc0MWRlZjhhM2E1NTA0NWNkNjI5MjNmODM1MzViODkwY2E=
13
+ ZGEyZDk5YmNhM2E4OWYwZjNmNWU1Y2Y4OGEzNWY3YjYxMjdkMWZhYjZmNWIx
14
+ N2I0N2ExY2QzNTMwZTZhMTFmMGRlNDRhMjRlZTNkMjdiZGQxMmQ3NGNmNjA0
15
+ ZWY0YTI2ZTAyMDcyYzMxOWIyZjU5MTRhZTYwOGQyYmZmMzQwMGI=
data/etc/app.d/base.rb CHANGED
@@ -14,7 +14,7 @@ use Rack::Session::Cookie, :key => 'rack.session',
14
14
 
15
15
 
16
16
  #{{{ DIRECTORIES
17
- local_var = Rbbt.var.find
17
+ local_var = Rbbt.var.find(:current)
18
18
  set :cache_dir , local_var.sinatra.cache.find
19
19
  set :file_dir , local_var.sinatra.files.find
20
20
  set :permalink_dir , local_var.sinatra.permalink.find
@@ -18,7 +18,7 @@ Rbbt.etc.entities.read.split("\n").each do |name|
18
18
  end
19
19
  end if Rbbt.etc.entities.exists?
20
20
 
21
- $annotation_repo = Rbbt.var.find(:lib).sinatra.annotation_repo.find
21
+ $annotation_repo = Rbbt.var.find.sinatra.annotation_repo.find
22
22
  Rbbt.etc.persit_properties.yaml.each do |name,list|
23
23
  next if name.empty?
24
24
  mod = Kernel.const_get name
@@ -4,8 +4,13 @@ module Annotated
4
4
 
5
5
  def self.flatten(array)
6
6
  return array if array.nil? or array.empty?
7
+ array.extend AnnotatedArray if Annotated === array
7
8
  return array.flatten if AnnotatedArray === array
8
- return array if array.compact.collect{|e| e.info }.uniq.length > 1
9
+ begin
10
+ return array if array.compact.collect{|e| e.info }.uniq.length > 1
11
+ rescue
12
+ return array
13
+ end
9
14
  array.compact.first.annotate(array.flatten).tap{|a| a.extend AnnotatedArray }
10
15
  end
11
16
 
@@ -37,8 +37,9 @@ module AssociationItem
37
37
  property :info => :array2single do
38
38
  fields = knowledge_base.index_fields(database)
39
39
  return [{}] * self.length if fields.nil? or fields.empty?
40
+
40
41
  value.collect{|v|
41
- Hash[*v.zip(fields).flatten]
42
+ Hash[*fields.zip(v).flatten]
42
43
  }
43
44
  end
44
45
  end
@@ -226,15 +226,24 @@ class KnowledgeBase
226
226
  end
227
227
 
228
228
  #{{{ Query
229
+
230
+ def setup(name, matches)
231
+ AssociationItem.setup matches, self, name, false
232
+ end
233
+
234
+ def all(name, options={})
235
+ repo = get_index name, options
236
+ setup name, repo.keys
237
+ end
229
238
 
230
239
  def children(name, entity)
231
240
  repo = get_index name
232
- AssociationItem.setup repo.match(entity), self, name, false
241
+ setup(name, repo.match(entity))
233
242
  end
234
243
 
235
244
  def parents(name, entity)
236
245
  repo = get_index name
237
- AssociationItem.setup repo.reverse.match(entity), self, name, true
246
+ setup(name, repo.reverse.match(entity))
238
247
  end
239
248
 
240
249
  def neighbours(name, entity)
@@ -256,7 +265,7 @@ class KnowledgeBase
256
265
  raise "Entities are not a Hash or an AnnotatedArray: #{Misc.fingerprint entities}"
257
266
  end
258
267
  repo = get_index name
259
- AssociationItem.setup repo.subset_entities(entities), self, name, false
268
+ setup(name, repo.subset_entities(entities))
260
269
  end
261
270
 
262
271
  def translate(entities, type)
@@ -55,7 +55,7 @@ module Path
55
55
  end
56
56
 
57
57
  SEARCH_PATHS = {
58
- :current => File.join(File.expand_path('.'), "{TOPLEVEL}", "{SUBPATH}"),
58
+ :current => File.join("{PWD}", "{TOPLEVEL}", "{SUBPATH}"),
59
59
  :user => File.join(ENV['HOME'], ".{PKGDIR}", "{TOPLEVEL}", "{SUBPATH}"),
60
60
  :global => File.join('/', "{TOPLEVEL}", "{PKGDIR}", "{SUBPATH}"),
61
61
  :local => File.join('/usr/local', "{TOPLEVEL}", "{PKGDIR}", "{SUBPATH}"),
@@ -98,13 +98,19 @@ module Path
98
98
  raise "Did not recognize the 'where' tag: #{where}. Options: #{search_paths.keys}" unless search_paths.include? where
99
99
  libdir = where == :lib ? Path.caller_lib_dir(caller_lib) : ""
100
100
  libdir ||= ""
101
- Path.setup search_paths[where].sub('{PKGDIR}', pkgdir).sub('{TOPLEVEL}', toplevel).sub('{SUBPATH}', subpath).sub('{LIBDIR}', libdir), @pkgdir, @resource
101
+ pwd = FileUtils.pwd
102
+ Path.setup search_paths[where].sub('{PKGDIR}', pkgdir).sub('{PWD}', pwd).sub('{TOPLEVEL}', toplevel).sub('{SUBPATH}', subpath).sub('{LIBDIR}', libdir), @pkgdir, @resource
102
103
  end
103
104
  end
104
105
 
105
106
  def find_all(caller_lib = nil, search_paths = nil)
106
107
  search_paths ||= SEARCH_PATHS
107
- search_paths.keys.collect{|where| find(where, Path.caller_lib_dir, search_paths)}.select{|file| file.exists?}.uniq
108
+ search_paths = search_paths.dup
109
+
110
+ search_paths.keys.
111
+ collect{|where| find(where, Path.caller_lib_dir, search_paths)}.
112
+ compact.select{|file| file.exists?}.uniq
113
+
108
114
  end
109
115
 
110
116
  #{{{ Methods
@@ -117,7 +117,7 @@ class Step
117
117
  Log.medium("Starting task #{task.name || ""} [#{Process.pid}]: #{ path }")
118
118
  set_info :status, :started
119
119
 
120
- set_info :started, Time.now
120
+ set_info :started, (start_time = Time.now)
121
121
 
122
122
  set_info :inputs, Misc.remove_long_items(Misc.zip2hash(task.inputs, @inputs)) unless task.inputs.nil?
123
123
 
@@ -154,7 +154,8 @@ class Step
154
154
  end
155
155
 
156
156
  set_info :status, :done
157
- set_info :done, Time.now
157
+ set_info :done, (done_time = Time.now)
158
+ set_info :time_elapsed, done_time - start_time
158
159
  Log.medium("Completed task #{task.name || ""} [#{Process.pid}]: #{ path }")
159
160
  res
160
161
  end
data/share/config.ru CHANGED
@@ -3,9 +3,9 @@ require 'rbbt/resource'
3
3
  require 'rbbt'
4
4
  load Rbbt.etc['app.d/init.rb'].find
5
5
 
6
- class_name = File.basename(FileUtils.pwd)
6
+ $class_name = class_name = File.basename(FileUtils.pwd)
7
7
 
8
- app = eval "class #{class_name} < Sinatra::Base; self end"
8
+ $app = app = eval "class #{class_name} < Sinatra::Base; self end"
9
9
 
10
10
  app.class_eval do
11
11
  Log.info{"Loading: " << Rbbt.etc['app.d/base.rb'].find}
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.5.4
4
+ version: 5.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-23 00:00:00.000000000 Z
11
+ date: 2013-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake