module Ellipses::Server
Constants
- Error
Attributes
intersperse[R]
paths[R]
Public Class Methods
new(paths, intersperse: "\n")
click to toggle source
# File lib/ellipses/server/application.rb, line 22 def initialize(paths, intersperse: "\n") @paths = setup_paths(paths) @intersperse = intersperse @instances = {} end
Private Class Methods
dump(path, *symbols, **kwargs)
click to toggle source
# File lib/ellipses/server/application.rb, line 75 def dump(path, *symbols, **kwargs) new([Support.dir!(path, error: Error)], **kwargs).dump(uri: '.', symbols: symbols) end
validate(path, **kwargs)
click to toggle source
# File lib/ellipses/server/application.rb, line 79 def validate(path, **kwargs) new([Support.dir!(path, error: Error)], **kwargs).validate('.') end
Public Instance Methods
available!(uri)
click to toggle source
# File lib/ellipses/server/application.rb, line 44 def available!(uri) return if available?(uri) raise Error, "Repository not found in path: #{uri}" end
available?(uri)
click to toggle source
# File lib/ellipses/server/application.rb, line 40 def available?(uri) !scan(uri).nil? end
dump(uri:, symbols:, port: nil)
click to toggle source
# File lib/ellipses/server/application.rb, line 32 def dump(uri:, symbols:, port: nil) Support.intersperse_arrays(out(uri: uri, symbols: symbols, port: port), intersperse).flatten end
out(uri:, symbols:, port: nil)
click to toggle source
# File lib/ellipses/server/application.rb, line 28 def out(uri:, symbols:, port: nil) [].tap { |chunks| symbols.each { |symbol| chunks.append(*instance(uri, port).repository[symbol]) } } end
validate(uri)
click to toggle source
# File lib/ellipses/server/application.rb, line 36 def validate(uri) raise NotImplementedError end
Private Instance Methods
instance(uri, port = nil)
click to toggle source
# File lib/ellipses/server/application.rb, line 52 def instance(uri, port = nil) ident = Instance.ident(uri, port) return @instances[ident] if @instances.key? ident directory = scan(uri) raise Error, "No repository instance found: #{uri}" unless directory instance = Instance.new uri: uri, repository: Repository.load(directory), port: port @instances[ident] = instance end
scan(uri)
click to toggle source
# File lib/ellipses/server/application.rb, line 70 def scan(uri) paths.map { |path| ::File.join(path, uri) }.find { |path| MetaFile.valid?(path) } end
setup_paths(paths)
click to toggle source
# File lib/ellipses/server/application.rb, line 63 def setup_paths(paths) paths = paths.filter_map { |path| Support.dir(path) }.uniq raise Error, 'No valid path found' if paths.empty? paths end