Class: GemMirror::Configuration
- Inherits:
-
Confstruct::Configuration
- Object
- Confstruct::Configuration
- GemMirror::Configuration
- Defined in:
- lib/gem_mirror/configuration.rb
Overview
Configuration class used for storing data about a mirror such as the destination directory, sources, ignored Gems, etc.
Class Method Summary collapse
- .default_configuration_file ⇒ String
-
.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.
- .template_directory ⇒ String
-
.versions_file ⇒ String
Returns the name of the file that contains an index of all the versions.
Instance Method Summary collapse
- #gems_directory ⇒ String
-
#ignore_gem(name, version) ⇒ Object
Adds a Gem to the list of Gems to ignore.
-
#ignore_gem?(name, version) ⇒ TrueClass|FalseClass
Checks if a Gem should be ignored.
-
#ignored_gems ⇒ Hash
Returns a Hash containing various Gems to ignore and their versions.
- #logger ⇒ Logger
- #mirror_directory ⇒ GemMirror::MirrorDirectory
-
#source(name, url, &block) {|source| ... } ⇒ Object
Adds a new source to mirror.
-
#sources ⇒ Array
Returns a list of sources to mirror.
Class Method Details
.default_configuration_file ⇒ String
39 40 41 |
# File 'lib/gem_mirror/configuration.rb', line 39 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.
49 50 51 |
# File 'lib/gem_mirror/configuration.rb', line 49 def self.marshal_identifier "Marshal.#{marshal_version}" end |
.marshal_version ⇒ String
Returns a String containing the Marshal version.
67 68 69 |
# File 'lib/gem_mirror/configuration.rb', line 67 def self.marshal_version "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}" end |
.template_directory ⇒ String
32 33 34 |
# File 'lib/gem_mirror/configuration.rb', line 32 def self.template_directory File.("../../template", __dir__) end |
.versions_file ⇒ String
Returns the name of the file that contains an index of all the versions.
58 59 60 |
# File 'lib/gem_mirror/configuration.rb', line 58 def self.versions_file "specs.#{marshal_version}.gz" end |
Instance Method Details
#gems_directory ⇒ String
81 82 83 |
# File 'lib/gem_mirror/configuration.rb', line 81 def gems_directory File.join(destination, "gems") end |
#ignore_gem(name, version) ⇒ Object
Adds a Gem to the list of Gems to ignore.
100 101 102 103 |
# File 'lib/gem_mirror/configuration.rb', line 100 def ignore_gem(name, version) ignored_gems[name] ||= [] ignored_gems[name] << version end |
#ignore_gem?(name, version) ⇒ TrueClass|FalseClass
Checks if a Gem should be ignored.
112 113 114 |
# File 'lib/gem_mirror/configuration.rb', line 112 def ignore_gem?(name, version) ignored_gems[name].include?(version) end |
#ignored_gems ⇒ Hash
Returns a Hash containing various Gems to ignore and their versions.
90 91 92 |
# File 'lib/gem_mirror/configuration.rb', line 90 def ignored_gems @ignored_gems ||= Hash.new { |hash, key| hash[key] = [] } end |
#logger ⇒ Logger
20 21 22 23 24 25 26 27 |
# File 'lib/gem_mirror/configuration.rb', line 20 def logger @logger = Logger.new($stdout, progname: "gem_mirror", formatter: proc do |severity, datetime, progname, msg| d_format = datetime.strftime("%Y%m%dT%H%M%S%z") "[#{d_format}] severity=#{severity} prog=#{progname} pid=#{Process.pid} message=#{msg}\n" end) end |
#mirror_directory ⇒ GemMirror::MirrorDirectory
74 75 76 |
# File 'lib/gem_mirror/configuration.rb', line 74 def mirror_directory @mirror_directory ||= MirrorDirectory.new(gems_directory) end |
#source(name, url, &block) {|source| ... } ⇒ Object
Adds a new source to mirror.
133 134 135 136 137 138 |
# File 'lib/gem_mirror/configuration.rb', line 133 def source(name, url, &block) source = Source.new(name, url) source.instance_eval(&block) sources << source end |
#sources ⇒ Array
Returns a list of sources to mirror.
121 122 123 |
# File 'lib/gem_mirror/configuration.rb', line 121 def sources @sources ||= [] end |