Class: Gemirro::Configuration
- Inherits:
-
Confstruct::Configuration
- Object
- Confstruct::Configuration
- Gemirro::Configuration
- Defined in:
- lib/gemirro/configuration.rb
Overview
Configuration class used for storing data about a mirror such as the destination directory, source, ignored Gems, etc.
Constant Summary collapse
- LOGGER_LEVEL =
{ 'debug' => Logger::DEBUG, 'warning' => Logger::WARN, 'info' => Logger::INFO, 'unknown' => Logger::UNKNOWN, 'error' => Logger::ERROR, 'fatal' => Logger::FATAL }.freeze
Instance Attribute Summary collapse
-
#logger ⇒ Logger
Returns the logger.
-
#source ⇒ Object
Returns the value of attribute source.
Class Method Summary collapse
-
.default_configuration_file ⇒ String
Returns default configuration file path.
-
.marshal_identifier ⇒ String
Returns the name of the directory that contains the quick specification files.
-
.marshal_version ⇒ String
Returns a String containing the Marshal version.
-
.prerelease_versions_file ⇒ String
Returns the name of the file that contains an index of all the prerelease versions.
-
.template_directory ⇒ String
Returns the template path to init directory.
-
.versions_file ⇒ String
Returns the name of the file that contains an index of all the versions.
-
.views_directory ⇒ String
Returns the views path to render templates.
Instance Method Summary collapse
-
#define_source(name, url, &block) ⇒ Object
Define the source to mirror.
-
#gems_directory ⇒ String
Returns gems directory.
-
#gemspecs_directory ⇒ String
Returns gems directory.
-
#ignore_gem(name, version, platform) ⇒ Object
Adds a Gem to the list of Gems to ignore.
-
#ignore_gem?(name, version, platform) ⇒ TrueClass|FalseClass
Checks if a Gem should be ignored.
-
#ignored_gems ⇒ Hash
Returns a Hash containing various Gems to ignore and their versions.
-
#logger_level=(level) ⇒ Logger
Set log level.
-
#mirror_gems_directory ⇒ Gemirro::MirrorDirectory
Return mirror directory.
-
#mirror_gemspecs_directory ⇒ Gemirro::MirrorDirectory
Return mirror directory.
Instance Attribute Details
#logger ⇒ Logger
Returns the logger
42 43 44 |
# File 'lib/gemirro/configuration.rb', line 42 def logger @logger ||= Logger.new(STDOUT) end |
#source ⇒ Object
Returns the value of attribute source.
25 26 27 |
# File 'lib/gemirro/configuration.rb', line 25 def source @source end |
Class Method Details
.default_configuration_file ⇒ String
Returns default configuration file path
81 82 83 |
# File 'lib/gemirro/configuration.rb', line 81 def self.default_configuration_file File.('config.rb', Dir.pwd) end |
.marshal_identifier ⇒ String
Returns the name of the directory that contains the quick specification files.
91 92 93 |
# File 'lib/gemirro/configuration.rb', line 91 def self.marshal_identifier "Marshal.#{marshal_version}" end |
.marshal_version ⇒ String
Returns a String containing the Marshal version.
119 120 121 |
# File 'lib/gemirro/configuration.rb', line 119 def self.marshal_version "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}" end |
.prerelease_versions_file ⇒ String
Returns the name of the file that contains an index of all the prerelease versions.
110 111 112 |
# File 'lib/gemirro/configuration.rb', line 110 def self.prerelease_versions_file "prerelease_specs.#{marshal_version}.gz" end |
.template_directory ⇒ String
Returns the template path to init directory
63 64 65 |
# File 'lib/gemirro/configuration.rb', line 63 def self.template_directory File.('../../../template', __FILE__) end |
.versions_file ⇒ String
Returns the name of the file that contains an index of all the versions.
100 101 102 |
# File 'lib/gemirro/configuration.rb', line 100 def self.versions_file "specs.#{marshal_version}.gz" end |
.views_directory ⇒ String
Returns the views path to render templates
72 73 74 |
# File 'lib/gemirro/configuration.rb', line 72 def self.views_directory File.('../../../views', __FILE__) end |
Instance Method Details
#define_source(name, url, &block) ⇒ Object
Define the source to mirror.
202 203 204 205 206 207 |
# File 'lib/gemirro/configuration.rb', line 202 def define_source(name, url, &block) source = Source.new(name, url) source.instance_eval(&block) @source = source end |
#gems_directory ⇒ String
Returns gems directory
137 138 139 |
# File 'lib/gemirro/configuration.rb', line 137 def gems_directory File.join(destination.to_s, 'gems') end |
#gemspecs_directory ⇒ String
Returns gems directory
155 156 157 |
# File 'lib/gemirro/configuration.rb', line 155 def gemspecs_directory File.join(destination.to_s, 'quick', self.class.marshal_identifier) end |
#ignore_gem(name, version, platform) ⇒ Object
Adds a Gem to the list of Gems to ignore.
174 175 176 177 178 |
# File 'lib/gemirro/configuration.rb', line 174 def ignore_gem(name, version, platform) ignored_gems[platform] ||= {} ignored_gems[platform][name] ||= [] ignored_gems[platform][name] << version end |
#ignore_gem?(name, version, platform) ⇒ TrueClass|FalseClass
Checks if a Gem should be ignored.
187 188 189 190 191 192 193 |
# File 'lib/gemirro/configuration.rb', line 187 def ignore_gem?(name, version, platform) if ignored_gems[platform][name] ignored_gems[platform][name].include?(version) else false end end |
#ignored_gems ⇒ Hash
Returns a Hash containing various Gems to ignore and their versions.
164 165 166 |
# File 'lib/gemirro/configuration.rb', line 164 def ignored_gems @ignored_gems ||= Hash.new { |hash, key| hash[key] = {} } end |
#logger_level=(level) ⇒ Logger
Set log level
53 54 55 56 |
# File 'lib/gemirro/configuration.rb', line 53 def logger_level=(level) logger.level = LOGGER_LEVEL[level] if LOGGER_LEVEL.key?(level) logger end |
#mirror_gems_directory ⇒ Gemirro::MirrorDirectory
Return mirror directory
128 129 130 |
# File 'lib/gemirro/configuration.rb', line 128 def mirror_gems_directory @mirror_gems_directory ||= MirrorDirectory.new(gems_directory) end |
#mirror_gemspecs_directory ⇒ Gemirro::MirrorDirectory
Return mirror directory
146 147 148 |
# File 'lib/gemirro/configuration.rb', line 146 def mirror_gemspecs_directory @mirror_gemspecs_directory ||= MirrorDirectory.new(gemspecs_directory) end |