Class: Tapioca::RepoIndex

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRepoIndex

: -> void



24
25
26
# File 'lib/tapioca/repo_index.rb', line 24

def initialize
  @entries = Set.new #: Set[String]
end

Class Method Details

.from_hash(hash) ⇒ Object

: (Hash[String, Hash[untyped, untyped]] hash) -> RepoIndex



16
17
18
19
20
# File 'lib/tapioca/repo_index.rb', line 16

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

.from_json(json) ⇒ Object

: (String json) -> RepoIndex



11
12
13
# File 'lib/tapioca/repo_index.rb', line 11

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

Instance Method Details

#<<(gem_name) ⇒ Object

: (String gem_name) -> void



29
30
31
# File 'lib/tapioca/repo_index.rb', line 29

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

#gemsObject



34
35
36
# File 'lib/tapioca/repo_index.rb', line 34

def gems
  @entries.sort
end

#has_gem?(gem_name) ⇒ Boolean

: (String gem_name) -> bool

Returns:

  • (Boolean)


39
40
41
# File 'lib/tapioca/repo_index.rb', line 39

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