Sha256: 620d719436c0536471929c3adf3eee67ac3b3ba914cf51456c3b7f0aa6c2accb

Contents?: true

Size: 1.25 KB

Versions: 19

Compression:

Stored size: 1.25 KB

Contents

# -*- coding: utf-8 -*-
module Gemirro
  ##
  # The Source class is used for storing information about an external source
  # such as the name and the Gems to mirror.
  #
  # @!attribute [r] name
  #  @return [String]
  # @!attribute [r] host
  #  @return [String]
  # @!attribute [r] gems
  #  @return [Array]
  #
  class Source
    attr_reader :name, :host, :gems

    ##
    # @param [String] name
    # @param [String] host
    # @param [Array] gems
    #
    def initialize(name, host, gems = [])
      @name = name.downcase.gsub(/\s+/, '_')
      @host = host.chomp('/')
      @gems = gems
    end

    ##
    # Fetches a list of all the available Gems and their versions.
    #
    # @return [String]
    #
    def fetch_versions
      Http.get(host + '/' + Configuration.versions_file).body
    end

    ##
    # Fetches the `.gem` file of a given Gem and version.
    #
    # @param [String] name
    # @param [String] version
    # @return [String]
    #
    def fetch_gem(name, version)
      Http.get(host + "/gems/#{name}-#{version}.gem").body
    end

    ##
    # Adds a new Gem to the source.
    #
    # @param [String] name
    # @param [String] requirement
    #
    def gem(name, requirement = nil)
      gems << Gem.new(name, requirement)
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
gemirro-0.10.5 lib/gemirro/source.rb
gemirro-0.10.4 lib/gemirro/source.rb
gemirro-0.10.3 lib/gemirro/source.rb
gemirro-0.10.2 lib/gemirro/source.rb
gemirro-0.10.1 lib/gemirro/source.rb
gemirro-0.10.0 lib/gemirro/source.rb
gemirro-0.9.1 lib/gemirro/source.rb
gemirro-0.9.0 lib/gemirro/source.rb
gemirro-0.8.1 lib/gemirro/source.rb
gemirro-0.8.0 lib/gemirro/source.rb
gemirro-0.7.0 lib/gemirro/source.rb
gemirro-0.6.0 lib/gemirro/source.rb
gemirro-0.5.0 lib/gemirro/source.rb
gemirro-0.4.0 lib/gemirro/source.rb
gemirro-0.3.0 lib/gemirro/source.rb
gemirro-0.2.0 lib/gemirro/source.rb
gemirro-0.1.0 lib/gemirro/source.rb
gemirro-0.0.2 lib/gemirro/source.rb
gemirro-0.0.1 lib/gemirro/source.rb