Class: TTNT::MetaData

Inherits:
Object
  • Object
show all
Defined in:
lib/ttnt/metadata.rb

Constant Summary collapse

STORAGE_SECTION =
'meta'

Instance Method Summary collapse

Constructor Details

#initialize(repo, sha = nil) ⇒ MetaData

Returns a new instance of MetaData.

Parameters:

  • repo (Rugged::Repository)
  • sha (String) (defaults to: nil)

    sha of commit which metadata is read from. nil means to read from current working tree. See Storage for more.



10
11
12
13
# File 'lib/ttnt/metadata.rb', line 10

def initialize(repo, sha = nil)
  @storage = Storage.new(repo, sha)
  read!
end

Instance Method Details

#[](name) ⇒ Object



15
16
17
# File 'lib/ttnt/metadata.rb', line 15

def [](name)
  @data[name]
end

#[]=(name, value) ⇒ Object



19
20
21
# File 'lib/ttnt/metadata.rb', line 19

def []=(name, value)
  @data[name] = value
end

#read!Object



23
24
25
# File 'lib/ttnt/metadata.rb', line 23

def read!
  @data = @storage.read(STORAGE_SECTION)
end

#write!Object



27
28
29
# File 'lib/ttnt/metadata.rb', line 27

def write!
  @storage.write!(STORAGE_SECTION, @data)
end