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.



116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/bundler/mirror.rb', line 116

def initialize(config_line, value)
  uri, fallback =
    config_line.match(%r{^mirror\.(all|.+?)(\.fallback_timeout)?\/?$}).captures
  @fallback = !fallback.nil?
  @all = false
  if uri == "all"
    @all = true
  else
    @uri = Settings.normalize_uri(uri)
  end
  @value = value
end

Instance Attribute Details

#uriObject

Returns the value of attribute uri.



114
115
116
# File 'lib/bundler/mirror.rb', line 114

def uri
  @uri
end

#valueObject

Returns the value of attribute value.



114
115
116
# File 'lib/bundler/mirror.rb', line 114

def value
  @value
end

Instance Method Details

#all?Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/bundler/mirror.rb', line 129

def all?
  @all
end

#update_mirror(mirror) ⇒ Object



133
134
135
136
137
138
139
# File 'lib/bundler/mirror.rb', line 133

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