Class: XCCache::Lockfile::Pkg

Inherits:
Hash
  • Object
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

#idObject



14
15
16
# File 'lib/xccache/core/lockfile.rb', line 14

def id
  self[key]
end

#keyObject



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

Returns:

  • (Boolean)


18
19
20
# File 'lib/xccache/core/lockfile.rb', line 18

def local?
  key != "repositoryURL"
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

#slugObject



22
23
24
# File 'lib/xccache/core/lockfile.rb', line 22

def slug
  @slug ||= File.basename(id, ".*")
end