Class: FlatHash::Repository
- Inherits:
-
Directory
show all
- Extended by:
- Forwardable
- Defined in:
- lib/flat_hash/repository.rb
Instance Method Summary
collapse
Methods inherited from Directory
#<<, #destroy, #each, #exist?, #read, #write
Constructor Details
#initialize(serialiser, path) ⇒ Repository
Returns a new instance of Repository.
10
11
12
13
14
|
# File 'lib/flat_hash/repository.rb', line 10
def initialize serialiser, path
super
@vcs = FlatHash::Git.new if File.exist?('.git')
@vcs = FlatHash::Hg.new if File.exist?('.hg')
end
|
Instance Method Details
#element_at(changeset, key) ⇒ Object
26
27
28
29
30
|
# File 'lib/flat_hash/repository.rb', line 26
def element_at changeset, key
return {} unless vcs_supported?
content = @vcs.content_at(File.join(@path, key),changeset)
@serialiser.read StringIO.new(content)
end
|
#history(key = nil) ⇒ Object
20
21
22
23
24
|
# File 'lib/flat_hash/repository.rb', line 20
def history key=nil
return [] unless vcs_supported?
path = key ? File.join(@path, key) : @path
@vcs.changesets(path).map {|cs| @vcs.changeset cs }
end
|
#vcs_supported? ⇒ Boolean
16
17
18
|
# File 'lib/flat_hash/repository.rb', line 16
def vcs_supported?
!@vcs.nil?
end
|