rbbt-util 5.5.11 → 5.5.12

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
- NDE0NzQ4YmI0Y2EzMmY4NDVjMWE4YTIwYTdlMTllMTc1YzFjY2M3ZQ==
4
+ Zjg3YjYwNzBjODk3NmYzYTQ4MTI2NDRkZGYyNmUzMGMzNWZjOGVkMA==
5
5
  data.tar.gz: !binary |-
6
- OWIzNDFlMDBjYjMxMDM5OGM1ZjA1NzIwZWNmZGQyZmU5ZjVhZjhhOA==
6
+ MmExODdlZjVkYWZkN2E0M2YyYzc4NjA0MGU2YjA1ZjhhYzY2MjE0ZQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YjNiNWExNzE2ZmVjNTRlM2I1MjBlZTM3NjAyZGMwNWQyOGY0MGViMTQ3NWIz
10
- ZmUwNTllNzNlNWFhMjE0YWQxZjQxZjc3MTg0MDlhMDZjMThmNmEyNDNmMjg2
11
- ODYyMTFiMjE5ZGMyZWRhMjg1ZWFmZjZhMTk0YTZlOWNiY2YxNjQ=
9
+ OTllODgwMzFhZDFmYzJjMWNjZWZjMmQ3MTBjNDdhZjJkY2FiNTliM2IxYjQ4
10
+ YjQ4ZjNmODg5M2ZiMjBhOTMzY2EwN2IyY2M3ZTRjNTkzOWZlMzc2MDhlZDI3
11
+ Mjk2MzJlYWY0MTRjZDgwOTY1YjgwMWExNThiZTk2YjlhMmI1ODg=
12
12
  data.tar.gz: !binary |-
13
- NzFmNGQ2ZjdiMzEyY2UzZmQ0NjhmYjJjMDAxNTg5NDYwYTJiNTUyZDFhODYw
14
- ZTI2MjFlMmI2YzA5NWQ1ZjNiODgzZmY2ODkyZGNiNmRjZWFhM2JlNDlhZWRh
15
- YmE5MzBiMDcyZjJlNTc2MmQ3NWE3YjAzMGNlYWExYjZlOTIzMTU=
13
+ YzdmZWU4YjMxN2M2ZTJkNTNjNTBlYzZhYTZmZTI5MWM1N2ZlNTMyMWQ3MTZl
14
+ YzdlNDFjMmNiZjI1ZThhMzNhYTMzY2RmZjY5NWU2ZjQ5ZGU2ZDZmMGRhNWI0
15
+ ZTcxY2MzNWVhZTBkMTI2ZTllNjkyMGQxYzI4MjUwYmFhZDk5OWE=
@@ -3,20 +3,21 @@ require 'rbbt/util/log'
3
3
  require 'rbbt/resource/path'
4
4
 
5
5
  module Resource
6
- def self.extended(base)
7
- if not base.respond_to? :pkgdir
8
- class << base
9
- attr_accessor :pkgdir, :subdir, :resources, :rake_dirs
10
- end
6
+ def self.remote_servers
7
+ @remote_servers = Rbbt.etc.file_servers.exists? ? Rbbt.etc.file_servers.yaml : {}
8
+ end
11
9
 
12
- base.pkgdir = 'rbbt'
13
- base.subdir = ''
14
- base.resources = {}
15
- base.rake_dirs = {}
16
- end
10
+ def self.extended(base)
11
+ base.pkgdir = 'rbbt'
12
+ base.subdir = ''
13
+ base.resources = {}
14
+ base.rake_dirs = {}
15
+ base.remote_server = Resource.remote_servers[base.to_s]
17
16
  base
18
17
  end
19
18
 
19
+ attr_accessor :pkgdir, :subdir, :resources, :rake_dirs, :remote_server
20
+
20
21
  def root()
21
22
  Path.setup @subdir || "", @pkgdir, self
22
23
  end
@@ -52,6 +53,20 @@ module Resource
52
53
  end
53
54
  end
54
55
 
56
+ def get_from_server(path, final_path)
57
+ url = File.join(remote_server, '/resource/', self.to_s, 'get_file')
58
+ url << "?" << Misc.hash2GET_params(:file => path, :create => false)
59
+ begin
60
+ Open.write(final_path, Open.read(url, :nocache => true))
61
+ return true
62
+ rescue
63
+ Log.warn "Could not retrieve (#{self.to_s}) #{ path } from #{ remote_server }"
64
+ Log.error $!.message
65
+ FileUtils.rm final_path if File.exists? final_path
66
+ return false
67
+ end
68
+ end
69
+
55
70
  def produce(path, force = false)
56
71
  case
57
72
  when @resources.include?(path)
@@ -68,6 +83,7 @@ module Resource
68
83
  if not File.exists? final_path or force
69
84
  Log.medium "Producing: #{ final_path }"
70
85
  Misc.lock final_path + '.produce' do
86
+ (remote_server and get_from_server(path, final_path)) or
71
87
  begin
72
88
  case type
73
89
  when :string
@@ -1,6 +1,7 @@
1
1
  require 'lockfile'
2
2
  require 'net/smtp'
3
3
  require 'digest/md5'
4
+ require 'cgi'
4
5
 
5
6
  class Hash
6
7
  def chunked_values_at(keys, max = 5000)
@@ -60,8 +60,16 @@ class TestTSV < Test::Unit::TestCase
60
60
  end
61
61
 
62
62
  def test_libdir
63
- assert File.exists? TestResource[].share.lib.R["util.R"].find :lib
64
- assert File.exists? TestResource[].share.lib.R["util.R"].find
63
+ assert File.exists? TestResource[].share.Rlib["util.R"].find :lib
64
+ assert File.exists? TestResource[].share.Rlib["util.R"].find
65
+ end
66
+
67
+ def __test_server
68
+ require 'rbbt/sources/organism'
69
+ TmpFile.with_file do |tmp|
70
+ Organism.get_from_server("Hsa/jun2011/identifiers", tmp)
71
+ assert Open.read(tmp).length > 10000
72
+ end
65
73
  end
66
74
 
67
75
  end
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.11
4
+ version: 5.5.12
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-31 00:00:00.000000000 Z
11
+ date: 2013-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake