class Relaxo::Dataset
Public Class Methods
new(repository, tree)
click to toggle source
# File lib/relaxo/dataset.rb, line 27 def initialize(repository, tree) @repository = repository @tree = tree @directories = {} end
Public Instance Methods
directory?(path)
click to toggle source
# File lib/relaxo/dataset.rb, line 52 def directory?(path) @directories.key?(path) or @tree.path(path)[:type] == :tree rescue Rugged::TreeError return false end
each(path = '', &block)
click to toggle source
# File lib/relaxo/dataset.rb, line 58 def each(path = '', &block) return to_enum(:each, path) unless block_given? directory = fetch_directory(path) directory.each(&block) end
exist?(path)
click to toggle source
# File lib/relaxo/dataset.rb, line 48 def exist?(path) read(path) or directory?(path) end
file?()
click to toggle source
# File lib/relaxo/dataset.rb, line 44 def file? read(path) end
read(path)
click to toggle source
# File lib/relaxo/dataset.rb, line 34 def read(path) if entry = @tree.path(path) and entry[:type] == :blob and oid = entry[:oid] @repository.read(oid) end rescue Rugged::TreeError return nil end
Also aliased as: []
Protected Instance Methods
fetch_directory(path)
click to toggle source
# File lib/relaxo/dataset.rb, line 68 def fetch_directory(path) @directories[path] ||= Directory.new(@repository, @tree, path) end