Module: BFS
- Defined in:
- lib/bfs.rb,
lib/bfs/blob.rb,
lib/bfs/bucket.rb,
lib/bfs/errors.rb,
lib/bfs/helpers.rb,
lib/bfs/bucket/fs.rb,
lib/bfs/bucket/in_mem.rb,
lib/bfs/bucket/abstract.rb
Defined Under Namespace
Modules: Bucket
Classes: Blob, FileInfo, FileNotFound, TempWriter
Class Method Summary
collapse
Class Method Details
.norm_path(path) ⇒ Object
19
20
21
22
23
24
|
# File 'lib/bfs.rb', line 19
def self.norm_path(path)
path = path.to_s.dup
path.gsub!(File::SEPARATOR, '/')
path.sub!(%r{^/+}, '')
path
end
|
.register(scheme, &resolver) ⇒ Object
6
7
8
9
|
# File 'lib/bfs.rb', line 6
def self.register(scheme, &resolver)
@registry ||= {}
@registry[scheme] = resolver
end
|
.resolve(url) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/bfs.rb', line 11
def self.resolve(url)
url = URI.parse(url) unless url.is_a?(::URI)
rsl = @registry[url.scheme]
raise ArgumentError, "Unable to resolve #{url}, scheme #{url.scheme} is not registered" unless rsl
rsl.call(url)
end
|