Class: MultiRepo::MetaFile
- Inherits:
-
TrackingFile
- Object
- TrackingFile
- MultiRepo::MetaFile
- Defined in:
- lib/multirepo/files/meta-file.rb
Constant Summary collapse
- FILENAME =
".multirepo.meta"
Instance Attribute Summary collapse
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #encode_with(coder) ⇒ Object
- #ensure_access(file, error_message, &check) ⇒ Object
- #exists? ⇒ Boolean
- #file ⇒ Object
- #filename ⇒ Object
-
#initialize(path) ⇒ MetaFile
constructor
A new instance of MetaFile.
- #load ⇒ Object
- #update ⇒ Object
Methods inherited from TrackingFile
Constructor Details
#initialize(path) ⇒ MetaFile
Returns a new instance of MetaFile.
15 16 17 18 |
# File 'lib/multirepo/files/meta-file.rb', line 15 def initialize(path) @path = path @version = MultiRepo::VERSION end |
Instance Attribute Details
#version ⇒ Object
Returns the value of attribute version.
13 14 15 |
# File 'lib/multirepo/files/meta-file.rb', line 13 def version @version end |
Instance Method Details
#encode_with(coder) ⇒ Object
32 33 34 |
# File 'lib/multirepo/files/meta-file.rb', line 32 def encode_with(coder) coder["version"] = @version end |
#ensure_access(file, error_message, &check) ⇒ Object
47 48 49 |
# File 'lib/multirepo/files/meta-file.rb', line 47 def ensure_access(file, , &check) fail MultiRepoException, if File.exists?(file) && !check.call(File.stat(file)) end |
#exists? ⇒ Boolean
28 29 30 |
# File 'lib/multirepo/files/meta-file.rb', line 28 def exists? File.exist?(file) end |
#file ⇒ Object
20 21 22 |
# File 'lib/multirepo/files/meta-file.rb', line 20 def file File.join(@path, FILENAME) end |
#filename ⇒ Object
24 25 26 |
# File 'lib/multirepo/files/meta-file.rb', line 24 def filename FILENAME end |
#load ⇒ Object
36 37 38 39 |
# File 'lib/multirepo/files/meta-file.rb', line 36 def load ensure_access(file, "Can't read meta file (permissions)") { |stat| stat.readable? } Psych.load(File.read(file)) end |
#update ⇒ Object
41 42 43 44 45 |
# File 'lib/multirepo/files/meta-file.rb', line 41 def update ensure_access(file, "Can't write meta file (permissions)") { |stat| stat.writable? } content = Psych.dump(self) return update_internal(file, content) end |