Class: Gemirro::Source
- Inherits:
-
Object
- Object
- Gemirro::Source
- Defined in:
- lib/gemirro/source.rb
Overview
The Source class is used for storing information about an external source such as the name and the Gems to mirror.
Instance Attribute Summary collapse
- #gems ⇒ Array readonly
- #host ⇒ String readonly
- #name ⇒ String readonly
Instance Method Summary collapse
-
#fetch_gem(filename) ⇒ String
Fetches the ‘.gem` file of a given Gem and version.
-
#fetch_gemspec(filename) ⇒ String
Fetches the ‘.gemspec.rz` file of a given Gem and version.
-
#fetch_prerelease_versions ⇒ String
Fetches a list of all the available Gems and their versions.
-
#fetch_versions ⇒ String
Fetches a list of all the available Gems and their versions.
-
#gem(name, requirement = nil) ⇒ Object
Adds a new Gem to the source.
-
#initialize(name, host, gems = []) ⇒ Source
constructor
A new instance of Source.
Constructor Details
#initialize(name, host, gems = []) ⇒ Source
Returns a new instance of Source.
21 22 23 24 25 |
# File 'lib/gemirro/source.rb', line 21 def initialize(name, host, gems = []) @name = name.downcase.gsub(/\s+/, '_') @host = host.chomp('/') @gems = gems end |
Instance Attribute Details
#gems ⇒ Array (readonly)
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/gemirro/source.rb', line 13 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 Utils.logger.info( "Fetching #{Configuration.versions_file} on #{@name} (#{@host})" ) Http.get(host + '/' + Configuration.versions_file).body end ## # Fetches a list of all the available Gems and their versions. # # @return [String] # def fetch_prerelease_versions Utils.logger.info( "Fetching #{Configuration.prerelease_versions_file}" \ " on #{@name} (#{@host})" ) Http.get(host + '/' + Configuration.prerelease_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(filename) Utils.logger.info( "Fetching gem #{filename} on #{@host}" ) Http.get(host + "/gems/#{filename}").body end ## # Fetches the `.gemspec.rz` file of a given Gem and version. # # @param [String] filename # @return [String] # def fetch_gemspec(filename) Utils.logger.info( "Fetching gemspec #{filename} on #{@host}" ) marshal = Gemirro::Configuration.marshal_identifier Http.get(host + "/quick/#{marshal}/#{filename}").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 |
#host ⇒ String (readonly)
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/gemirro/source.rb', line 13 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 Utils.logger.info( "Fetching #{Configuration.versions_file} on #{@name} (#{@host})" ) Http.get(host + '/' + Configuration.versions_file).body end ## # Fetches a list of all the available Gems and their versions. # # @return [String] # def fetch_prerelease_versions Utils.logger.info( "Fetching #{Configuration.prerelease_versions_file}" \ " on #{@name} (#{@host})" ) Http.get(host + '/' + Configuration.prerelease_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(filename) Utils.logger.info( "Fetching gem #{filename} on #{@host}" ) Http.get(host + "/gems/#{filename}").body end ## # Fetches the `.gemspec.rz` file of a given Gem and version. # # @param [String] filename # @return [String] # def fetch_gemspec(filename) Utils.logger.info( "Fetching gemspec #{filename} on #{@host}" ) marshal = Gemirro::Configuration.marshal_identifier Http.get(host + "/quick/#{marshal}/#{filename}").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 |
#name ⇒ String (readonly)
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/gemirro/source.rb', line 13 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 Utils.logger.info( "Fetching #{Configuration.versions_file} on #{@name} (#{@host})" ) Http.get(host + '/' + Configuration.versions_file).body end ## # Fetches a list of all the available Gems and their versions. # # @return [String] # def fetch_prerelease_versions Utils.logger.info( "Fetching #{Configuration.prerelease_versions_file}" \ " on #{@name} (#{@host})" ) Http.get(host + '/' + Configuration.prerelease_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(filename) Utils.logger.info( "Fetching gem #{filename} on #{@host}" ) Http.get(host + "/gems/#{filename}").body end ## # Fetches the `.gemspec.rz` file of a given Gem and version. # # @param [String] filename # @return [String] # def fetch_gemspec(filename) Utils.logger.info( "Fetching gemspec #{filename} on #{@host}" ) marshal = Gemirro::Configuration.marshal_identifier Http.get(host + "/quick/#{marshal}/#{filename}").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 |
Instance Method Details
#fetch_gem(filename) ⇒ String
Fetches the ‘.gem` file of a given Gem and version.
60 61 62 63 64 65 |
# File 'lib/gemirro/source.rb', line 60 def fetch_gem(filename) Utils.logger.info( "Fetching gem #{filename} on #{@host}" ) Http.get(host + "/gems/#{filename}").body end |
#fetch_gemspec(filename) ⇒ String
Fetches the ‘.gemspec.rz` file of a given Gem and version.
73 74 75 76 77 78 79 |
# File 'lib/gemirro/source.rb', line 73 def fetch_gemspec(filename) Utils.logger.info( "Fetching gemspec #{filename} on #{@host}" ) marshal = Gemirro::Configuration.marshal_identifier Http.get(host + "/quick/#{marshal}/#{filename}").body end |
#fetch_prerelease_versions ⇒ String
Fetches a list of all the available Gems and their versions.
45 46 47 48 49 50 51 |
# File 'lib/gemirro/source.rb', line 45 def fetch_prerelease_versions Utils.logger.info( "Fetching #{Configuration.prerelease_versions_file}" \ " on #{@name} (#{@host})" ) Http.get(host + '/' + Configuration.prerelease_versions_file).body end |
#fetch_versions ⇒ String
Fetches a list of all the available Gems and their versions.
32 33 34 35 36 37 38 |
# File 'lib/gemirro/source.rb', line 32 def fetch_versions Utils.logger.info( "Fetching #{Configuration.versions_file} on #{@name} (#{@host})" ) Http.get(host + '/' + Configuration.versions_file).body end |