rbbt-util 5.5.34 → 5.5.35

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.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/rbbt/resource/path.rb +25 -14
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzliNGFhOTdhZmJjMzhmZDJhNzU4ZDUwZWQzNjgxNjE3NzQ3MTkyZg==
4
+ ZjM2NWExYzgzODc2ZDUwYWI3N2NkZmRlYjY0MTE4MDkwOGY0ZWMyMQ==
5
5
  data.tar.gz: !binary |-
6
- Y2M1ZTJmMjJkZjE4NGQxM2NhMGYyNDBlZjA0ODYxMWJhMGJjMWI3ZA==
6
+ YmFjOTY5NDgzMmE4ODI5NjE1NTdhZTVkZDFlN2Y0MTRjMTMxZjIxZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODQ1OWQ0NmUwOTM1MDRjNTk5MGY5MTUxZjcyNTJjNzQ1N2M4NzMxNmVmMmVm
10
- ZGI3NzFmN2I1MzliYmM4ZTE0NjZhZjJlMWUyYTVhZDZhZGQxN2IxMTIxZjkx
11
- MzUyOWQwNTg4MmIxMzQyYjIxNTJmYjhiNGNjZDZiNzc3Y2RjODc=
9
+ MGIyZmU0MzYyZmVkMzlhMzgyNGZhNzQ1OGRjOWZlMWJmYzgyMDhlZTg0OTk1
10
+ N2MwMTYzZDA1M2VjNjliMjUxMTQxMDdiNDM0OWNmOGNlYzI1OTJiZjMxZDIw
11
+ OTI1MmQ1ZjUyOTdlNGNlMjg3OWMyYmU0ZDgyMjNkYWEzOTM5ZmE=
12
12
  data.tar.gz: !binary |-
13
- MjBiYWZiNmYyYThiY2Q0YTM4NmE4NWZlZDRmMzI2YTM4ZmIwMmI4MmY3ZmY0
14
- NWJhNDI0OTQxYTM4Y2UzOGYwZjY1N2M3ODAwNTk4MzgxMGMxOTY3NmQ0NzVi
15
- OWM2Y2I1YzU3MjUwNWFlMWUyZmMyZTEzMGIyODg1YTg3YzZmYzI=
13
+ MDgwOGEwYTMzZGY3NjkzN2JmZjE4ODhjZjdkMTM2NzljOGU2ZDNjYjIxMmUw
14
+ MGM1NDJmY2NkMjY2MDA3MWU5ZDRiNDYxNjVmZGM1ZWRjZWRjZDU2Y2U1NmQy
15
+ M2FmOGU0ZWE0ZTVmZGYwMGNkMDYzN2Q0NjQ2NmRhZTNmYjFhY2I=
@@ -2,22 +2,27 @@ require 'rbbt/resource/util'
2
2
  require 'yaml'
3
3
 
4
4
  module Path
5
- attr_accessor :resource, :pkgdir
5
+ attr_accessor :resource, :pkgdir, :search_paths
6
6
 
7
- def self.setup(string, pkgdir = nil, resource = nil)
7
+ def self.setup(string, pkgdir = nil, resource = nil, search_paths = nil)
8
8
  string.extend Path
9
9
  string.pkgdir = pkgdir || 'rbbt'
10
10
  string.resource = resource
11
+ string.search_paths = search_paths
11
12
  string
12
13
  end
13
14
 
15
+ def sub(*args)
16
+ self.annotate super(*args)
17
+ end
18
+
14
19
  def annotate(name)
15
- Path.setup name.to_s, @pkgdir, @resource
20
+ Path.setup name.to_s, @pkgdir, @resource, @search_paths
16
21
  end
17
22
 
18
23
  def join(name)
19
24
  if self.empty?
20
- self.annotate name.to_s
25
+ self.annotate name.to_s.dup
21
26
  else
22
27
  self.annotate File.join(self, name.to_s)
23
28
  end
@@ -77,9 +82,9 @@ module Path
77
82
  end
78
83
  end
79
84
 
80
- def find(where = nil, caller_lib = nil, search_paths = nil)
81
- where = search_paths[:default] if where == :default
82
- search_paths ||= SEARCH_PATHS
85
+ def find(where = nil, caller_lib = nil, paths = nil)
86
+ paths = (self.search_paths || SEARCH_PATHS).merge(paths || {})
87
+ where = paths[:default] if where == :default
83
88
  return self if located?
84
89
  if self.match(/(.*?)\/(.*)/)
85
90
  toplevel, subpath = self.match(/(.*?)\/(.*)/).values_at 1, 2
@@ -91,22 +96,28 @@ module Path
91
96
  if where.nil?
92
97
  %w(current user local global lib).each do |w|
93
98
  w = w.to_sym
94
- next unless search_paths.include? w
95
- path = find(w, caller_lib, search_paths)
99
+ next unless paths.include? w
100
+ path = find(w, caller_lib, paths)
96
101
  return path if File.exists? path
97
102
  end
98
- if search_paths.include? :default
99
- find((search_paths[:default] || :user), caller_lib, search_paths)
103
+ if paths.include? :default
104
+ find((paths[:default] || :user), caller_lib, paths)
100
105
  else
101
- raise "Path '#{ path }' not found, and no default specified in search paths: #{search_paths.inspect}"
106
+ raise "Path '#{ path }' not found, and no default specified in search paths: #{paths.inspect}"
102
107
  end
103
108
  else
104
109
  where = where.to_sym
105
- raise "Did not recognize the 'where' tag: #{where}. Options: #{search_paths.keys}" unless search_paths.include? where
110
+ raise "Did not recognize the 'where' tag: #{where}. Options: #{paths.keys}" unless paths.include? where
106
111
  libdir = where == :lib ? Path.caller_lib_dir(caller_lib) : ""
107
112
  libdir ||= ""
108
113
  pwd = FileUtils.pwd
109
- Path.setup search_paths[where].sub('{PKGDIR}', pkgdir).sub('{PWD}', pwd).sub('{TOPLEVEL}', toplevel).sub('{SUBPATH}', subpath).sub('{LIBDIR}', libdir), @pkgdir, @resource
114
+ self.annotate paths[where].
115
+ sub('{PKGDIR}', pkgdir).
116
+ sub('{PWD}', pwd).
117
+ sub('{TOPLEVEL}', toplevel).
118
+ sub('{SUBPATH}', subpath).
119
+ sub('{PATH}', self).
120
+ sub('{LIBDIR}', libdir) #, @pkgdir, @resource, @search_paths
110
121
  end
111
122
  end
112
123
 
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.34
4
+ version: 5.5.35
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-11-14 00:00:00.000000000 Z
11
+ date: 2013-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake