Class: Bundler::Settings::MirrorConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/mirror.rb

Overview

Class used to parse one configuration line

Gets the configuration line and the value.

This object provides a `update_mirror` method
used to setup the given mirror value.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_line, value) ⇒ MirrorConfig

Returns a new instance of MirrorConfig.


121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/bundler/mirror.rb', line 121

def initialize(config_line, value)
  uri, fallback =
    config_line.match(%r{\Amirror\.(all|.+?)(\.fallback_timeout)?\/?\z}).captures
  @fallback = !fallback.nil?
  @all = false
  if uri == "all"
    @all = true
  else
    @uri = Bundler::URI(uri).absolute? ? Settings.normalize_uri(uri) : uri
  end
  @value = value
end

Instance Attribute Details

#uriObject

Returns the value of attribute uri


119
120
121
# File 'lib/bundler/mirror.rb', line 119

def uri
  @uri
end

#valueObject

Returns the value of attribute value


119
120
121
# File 'lib/bundler/mirror.rb', line 119

def value
  @value
end

Instance Method Details

#all?Boolean

Returns:

  • (Boolean)

134
135
136
# File 'lib/bundler/mirror.rb', line 134

def all?
  @all
end

#update_mirror(mirror) ⇒ Object


138
139
140
141
142
143
144
# File 'lib/bundler/mirror.rb', line 138

def update_mirror(mirror)
  if @fallback
    mirror.fallback_timeout = @value
  else
    mirror.uri = Settings.normalize_uri(@value)
  end
end