Class: Indexer::Conflict

Inherits:
Model
  • Object
show all
Defined in:
lib/indexer/components/conflict.rb

Overview

The Conflict class models the name and versions of packages that have know incompatibilities.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#[], #[]=, attr_reader, attr_writer, #initialize, #initialize_attributes, #key?, #merge!, #method_missing, #store, #to_yaml, #validate

Constructor Details

This class inherits a constructor from Indexer::Model

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Indexer::Model

Instance Attribute Details

#nameObject

The name of the package that causes the conflict.

Yea it's ALWAYS THEIR fault ;-)



53
54
55
# File 'lib/indexer/components/conflict.rb', line 53

def name
  @name
end

#versionObject

The versions constraint of the conflicting package. This is used when only certain versions of the package are the problem.



67
68
69
# File 'lib/indexer/components/conflict.rb', line 67

def version
  @version
end

Class Method Details

.parse(data) ⇒ Object

Parse data into a Dependency instance.

TODO: What about respond_to?(:to_str) for String, etc.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/indexer/components/conflict.rb', line 11

def self.parse(data)
  case data
  when String
    parse_string(data)
  when Array
    parse_array(data)
  when Hash
    parse_hash(data)
  else
    raise(ValidationError, "Conflict")
  end
end

.parse_array(data) ⇒ Object (private)



35
36
37
38
# File 'lib/indexer/components/conflict.rb', line 35

def self.parse_array(data)
  name, version = *data
  new(:name=>name, :version=>version)
end

.parse_hash(data) ⇒ Object (private)



42
43
44
# File 'lib/indexer/components/conflict.rb', line 42

def self.parse_hash(data)
  new(data)
end

.parse_string(data) ⇒ Object (private)



28
29
30
31
# File 'lib/indexer/components/conflict.rb', line 28

def self.parse_string(data)
  name, version = data.split(/\s+/)
  new(:name=>name, :version=>version)
end

Instance Method Details

#to_hObject



79
80
81
# File 'lib/indexer/components/conflict.rb', line 79

def to_h
  {'name'=>name, 'version'=>version.to_s}
end