Class: XCCache::Lockfile::Pkg
- Inherits:
-
Hash
- Object
- Hash
- XCCache::Lockfile::Pkg
show all
- Defined in:
- lib/xccache/core/lockfile.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Hash
#deep_merge, #deep_merge!
Class Method Details
.from_h(h) ⇒ Object
6
7
8
|
# File 'lib/xccache/core/lockfile.rb', line 6
def self.from_h(h)
Pkg.new.merge(h)
end
|
Instance Method Details
#id ⇒ Object
14
15
16
|
# File 'lib/xccache/core/lockfile.rb', line 14
def id
self[key]
end
|
#key ⇒ Object
10
11
12
|
# File 'lib/xccache/core/lockfile.rb', line 10
def key
@key ||= ["repositoryURL", "path_from_root", "relative_path"].find { |x| key?(x) }
end
|
#local? ⇒ Boolean
18
19
20
|
# File 'lib/xccache/core/lockfile.rb', line 18
def local?
key != "repositoryURL"
end
|
#local_absolute_path ⇒ Object
31
32
33
|
# File 'lib/xccache/core/lockfile.rb', line 31
def local_absolute_path
Pathname.pwd / self["path_from_root"] if local?
end
|
#relative_path_from_dir(dir) ⇒ Object
26
27
28
29
|
# File 'lib/xccache/core/lockfile.rb', line 26
def relative_path_from_dir(dir)
return id if key == "relative_path"
(Pathname.pwd / id).relative_path_from(dir) if key == "path_from_root"
end
|
#slug ⇒ Object
22
23
24
|
# File 'lib/xccache/core/lockfile.rb', line 22
def slug
@slug ||= File.basename(id, ".*")
end
|