Class: Relaxo::Dataset
- Inherits:
-
Object
- Object
- Relaxo::Dataset
- Defined in:
- lib/relaxo/dataset.rb
Direct Known Subclasses
Instance Method Summary collapse
- #directory?(path) ⇒ Boolean
- #each(path = '', &block) ⇒ Object
- #exist?(path) ⇒ Boolean
- #file? ⇒ Boolean
-
#initialize(repository, tree) ⇒ Dataset
constructor
A new instance of Dataset.
- #read(path) ⇒ Object (also: #[])
Constructor Details
#initialize(repository, tree) ⇒ Dataset
Returns a new instance of Dataset.
27 28 29 30 31 32 |
# File 'lib/relaxo/dataset.rb', line 27 def initialize(repository, tree) @repository = repository @tree = tree @directories = {} end |
Instance Method Details
#directory?(path) ⇒ Boolean
52 53 54 55 56 |
# 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) ⇒ Object
58 59 60 61 62 63 64 |
# 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) ⇒ Boolean
48 49 50 |
# File 'lib/relaxo/dataset.rb', line 48 def exist?(path) read(path) or directory?(path) end |
#file? ⇒ Boolean
44 45 46 |
# File 'lib/relaxo/dataset.rb', line 44 def file? read(path) end |
#read(path) ⇒ Object Also known as: []
34 35 36 37 38 39 40 |
# 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 |