Class: XCCache::SPM::Package::Dependency

Inherits:
BaseObject show all
Defined in:
lib/xccache/spm/desc/dep.rb

Constant Summary

Constants inherited from BaseObject

BaseObject::ATTRS

Instance Attribute Summary

Attributes inherited from HashRepresentable

#raw

Instance Method Summary collapse

Methods inherited from BaseObject

#cast_to, #fetch, #full_name, #inspect, #name, #pkg_desc_of, #pkg_name, #pkg_slug, #src_dir, #to_s

Methods included from Config::Mixin

#config

Methods inherited from JSONRepresentable

#load, #save

Methods inherited from HashRepresentable

#[], #[]=, #initialize, #load, #merge!, #reload, #save

Constructor Details

This class inherits a constructor from XCCache::HashRepresentable

Instance Method Details

#display_nameObject



7
8
9
# File 'lib/xccache/spm/desc/dep.rb', line 7

def display_name
  slug
end

#hashObject



15
16
17
# File 'lib/xccache/spm/desc/dep.rb', line 15

def hash
  @hash ||= local? ? raw["fileSystem"].first : raw["sourceControl"].first
end

#local?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/xccache/spm/desc/dep.rb', line 11

def local?
  raw.key?("fileSystem")
end

#pathObject



30
31
32
# File 'lib/xccache/spm/desc/dep.rb', line 30

def path
  @path ||= Pathname(hash["path"]).expand_path if local?
end

#pkg_descObject



34
35
36
# File 'lib/xccache/spm/desc/dep.rb', line 34

def pkg_desc
  @pkg_desc ||= pkg_desc_of(slug)
end

#slugObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/xccache/spm/desc/dep.rb', line 19

def slug
  @slug ||=
    if hash.key?("path")
      File.basename(hash["path"])
    elsif (location = hash["location"]) && location.key?("remote")
      File.basename(location["remote"].flat_map(&:values)[0], ".*")
    else
      hash["identity"]
    end
end