class Gemirro::Configuration

Configuration class used for storing data about a mirror such as the destination directory, source, ignored Gems, etc.

Constants

LOGGER_LEVEL

Attributes

logger[W]
source[RW]

Public Class Methods

default_configuration_file() click to toggle source

Returns default configuration file path

@return [String]

# File lib/gemirro/configuration.rb, line 83
def self.default_configuration_file
  File.expand_path('config.rb', Dir.pwd)
end
marshal_identifier() click to toggle source

Returns the name of the directory that contains the quick specification files.

@return [String]

# File lib/gemirro/configuration.rb, line 93
def self.marshal_identifier
  "Marshal.#{marshal_version}"
end
marshal_version() click to toggle source

Returns a String containing the Marshal version.

@return [String]

# File lib/gemirro/configuration.rb, line 121
def self.marshal_version
  "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}"
end
prerelease_versions_file() click to toggle source

Returns the name of the file that contains an index of all the prerelease versions.

@return [String]

# File lib/gemirro/configuration.rb, line 112
def self.prerelease_versions_file
  "prerelease_specs.#{marshal_version}.gz"
end
template_directory() click to toggle source

Returns the template path to init directory

@return [String]

# File lib/gemirro/configuration.rb, line 65
def self.template_directory
  File.expand_path('../../../template', __FILE__)
end
versions_file() click to toggle source

Returns the name of the file that contains an index of all the versions.

@return [String]

# File lib/gemirro/configuration.rb, line 102
def self.versions_file
  "specs.#{marshal_version}.gz"
end
views_directory() click to toggle source

Returns the views path to render templates

@return [String]

# File lib/gemirro/configuration.rb, line 74
def self.views_directory
  File.expand_path('../../../views', __FILE__)
end

Public Instance Methods

define_source(name, url, &block) click to toggle source

Define the source to mirror.

@param [String] name @param [String] url @param [Proc] block

# File lib/gemirro/configuration.rb, line 204
def define_source(name, url, &block)
  source = Source.new(name, url)
  source.instance_eval(&block)

  @source = source
end
gems_directory() click to toggle source

Returns gems directory

@return [String]

# File lib/gemirro/configuration.rb, line 139
def gems_directory
  File.join(destination.to_s, 'gems')
end
gemspecs_directory() click to toggle source

Returns gems directory

@return [String]

# File lib/gemirro/configuration.rb, line 157
def gemspecs_directory
  File.join(destination.to_s, 'quick', self.class.marshal_identifier)
end
ignore_gem(name, version, platform) click to toggle source

Adds a Gem to the list of Gems to ignore.

@param [String] name @param [String] version

# File lib/gemirro/configuration.rb, line 176
def ignore_gem(name, version, platform)
  ignored_gems[platform] ||= {}
  ignored_gems[platform][name] ||= []
  ignored_gems[platform][name] << version
end
ignore_gem?(name, version, platform) click to toggle source

Checks if a Gem should be ignored.

@param [String] name @param [String] version @return [TrueClass|FalseClass]

# File lib/gemirro/configuration.rb, line 189
def ignore_gem?(name, version, platform)
  if ignored_gems[platform][name]
    ignored_gems[platform][name].include?(version)
  else
    false
  end
end
ignored_gems() click to toggle source

Returns a Hash containing various Gems to ignore and their versions.

@return [Hash]

# File lib/gemirro/configuration.rb, line 166
def ignored_gems
  @ignored_gems ||= Hash.new { |hash, key| hash[key] = {} }
end
logger() click to toggle source

Returns the logger

@return [Logger]

# File lib/gemirro/configuration.rb, line 44
def logger
  @logger ||= Logger.new($stdout)
end
logger_level=(level) click to toggle source

Set log level

@param [string]

@return [Logger]

# File lib/gemirro/configuration.rb, line 55
def logger_level=(level)
  logger.level = LOGGER_LEVEL[level] if LOGGER_LEVEL.key?(level)
  logger
end
mirror_gems_directory() click to toggle source

Return mirror directory

@return [Gemirro::MirrorDirectory]

# File lib/gemirro/configuration.rb, line 130
def mirror_gems_directory
  @mirror_gems_directory ||= MirrorDirectory.new(gems_directory)
end
mirror_gemspecs_directory() click to toggle source

Return mirror directory

@return [Gemirro::MirrorDirectory]

# File lib/gemirro/configuration.rb, line 148
def mirror_gemspecs_directory
  @mirror_gemspecs_directory ||= MirrorDirectory.new(gemspecs_directory)
end