Exception: Rip::VersionConflict

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/rip/package_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, bad_version, requester, real_version, owners) ⇒ VersionConflict

Returns a new instance of VersionConflict.



9
10
11
12
13
14
15
# File 'lib/rip/package_manager.rb', line 9

def initialize(name, bad_version, requester, real_version, owners)
  @name = name
  @bad_version = bad_version
  @requester = requester
  @real_version = real_version
  @owners = owners
end

Instance Method Details

#messageObject Also known as: to_s



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rip/package_manager.rb', line 17

def message
  message = []
  message << "version conflict!"

  requested  = "#{@name} requested at #{@bad_version}"
  requested += " by #{@requester}" if @requester
  message << requested

  if @owners.size == 1
    owners = @owners[0]
  elsif @owners.size == 2
    owners = "#{@owners[0]} and #{@owners[1]}"
  elsif @owners.size > 2
    owners = [ @owners[0...-1], "and #{@owners[-1]}" ].join(', ')
  end

  previously_requested  = "#{@name} previously requested at #{@real_version}"
  previously_requested += " by #{owners}" if owners
  message << previously_requested

  message.join("\n")
end