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
44 45 46 |
# File 'lib/gemirro/configuration.rb', line 44 def logger @logger ||= Logger.new($stdout) end |
#source ⇒ Object
Returns the value of attribute source.
27 28 29 |
# File 'lib/gemirro/configuration.rb', line 27 def source @source end |
Class Method Details
.default_configuration_file ⇒ String
Returns default configuration file path
83 84 85 |
# File 'lib/gemirro/configuration.rb', line 83 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.
93 94 95 |
# File 'lib/gemirro/configuration.rb', line 93 def self.marshal_identifier "Marshal.#{marshal_version}" end |
.marshal_version ⇒ String
Returns a String containing the Marshal version.
121 122 123 |
# File 'lib/gemirro/configuration.rb', line 121 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.
112 113 114 |
# File 'lib/gemirro/configuration.rb', line 112 def self.prerelease_versions_file "prerelease_specs.#{marshal_version}.gz" end |
.template_directory ⇒ String
Returns the template path to init directory
65 66 67 |
# File 'lib/gemirro/configuration.rb', line 65 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.
102 103 104 |
# File 'lib/gemirro/configuration.rb', line 102 def self.versions_file "specs.#{marshal_version}.gz" end |
.views_directory ⇒ String
Returns the views path to render templates
74 75 76 |
# File 'lib/gemirro/configuration.rb', line 74 def self.views_directory File.('../../../views', __FILE__) end |
Instance Method Details
#define_source(name, url, &block) ⇒ Object
Define the source to mirror.
204 205 206 207 208 209 |
# 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 ⇒ String
Returns gems directory
139 140 141 |
# File 'lib/gemirro/configuration.rb', line 139 def gems_directory File.join(destination.to_s, 'gems') end |
#gemspecs_directory ⇒ String
Returns gems directory
157 158 159 |
# 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) ⇒ Object
Adds a Gem to the list of Gems to ignore.
176 177 178 179 180 |
# 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) ⇒ TrueClass|FalseClass
Checks if a Gem should be ignored.
189 190 191 192 193 194 195 |
# 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 ⇒ Hash
Returns a Hash containing various Gems to ignore and their versions.
166 167 168 |
# File 'lib/gemirro/configuration.rb', line 166 def ignored_gems @ignored_gems ||= Hash.new { |hash, key| hash[key] = {} } end |
#logger_level=(level) ⇒ Logger
Set log level
55 56 57 58 |
# 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 ⇒ Gemirro::MirrorDirectory
Return mirror directory
130 131 132 |
# File 'lib/gemirro/configuration.rb', line 130 def mirror_gems_directory @mirror_gems_directory ||= MirrorDirectory.new(gems_directory) end |
#mirror_gemspecs_directory ⇒ Gemirro::MirrorDirectory
Return mirror directory
148 149 150 |
# File 'lib/gemirro/configuration.rb', line 148 def mirror_gemspecs_directory @mirror_gemspecs_directory ||= MirrorDirectory.new(gemspecs_directory) end |