Class: Tapioca::RepoIndex

Inherits:
Object
  • Object
show all
Extended by:
T::Generic, T::Sig
Defined in:
lib/tapioca/repo_index.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from T::Generic::TypeStoragePatch

#[], #has_attached_class!, #type_member, #type_template

Constructor Details

#initializeRepoIndex

Returns a new instance of RepoIndex.



26
27
28
# File 'lib/tapioca/repo_index.rb', line 26

def initialize
  @entries = T.let(Set.new, T::Set[String])
end

Class Method Details

.from_hash(hash) ⇒ Object



18
19
20
21
22
# File 'lib/tapioca/repo_index.rb', line 18

def from_hash(hash)
  hash.each_with_object(RepoIndex.new) do |(name, _), index|
    index << name
  end
end

.from_json(json) ⇒ Object



13
14
15
# File 'lib/tapioca/repo_index.rb', line 13

def from_json(json)
  RepoIndex.from_hash(JSON.parse(json))
end

Instance Method Details

#<<(gem_name) ⇒ Object



31
32
33
# File 'lib/tapioca/repo_index.rb', line 31

def <<(gem_name)
  @entries.add(gem_name)
end

#gemsObject



36
37
38
# File 'lib/tapioca/repo_index.rb', line 36

def gems
  @entries.sort
end

#has_gem?(gem_name) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/tapioca/repo_index.rb', line 41

def has_gem?(gem_name)
  @entries.include?(gem_name)
end