Class: Gemsurance::GemInfoRetriever::GemInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/gemsurance/gem_info_retriever.rb

Constant Summary collapse

STATUS_OUTDATED =
'outdated'
STATUS_CURRENT =
'current'
STATUS_VULNERABLE =
'vulnerable'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, current_version, newest_version, in_gem_file, homepage_uri, source_code_uri, documentation_uri, status = STATUS_CURRENT) ⇒ GemInfo

Returns a new instance of GemInfo.



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

def initialize(name, current_version, newest_version, in_gem_file, homepage_uri, source_code_uri, documentation_uri, status = STATUS_CURRENT)
  @name = name
  @current_version = current_version
  @newest_version = newest_version
  @in_gem_file = in_gem_file
  @homepage_uri = homepage_uri
  @documentation_uri = documentation_uri
  @source_code_uri = source_code_uri
  @status = status
  @vulnerabilities = []
  
end

Instance Attribute Details

#current_versionObject (readonly)

Returns the value of attribute current_version.



8
9
10
# File 'lib/gemsurance/gem_info_retriever.rb', line 8

def current_version
  @current_version
end

#documentation_uriObject (readonly)

Returns the value of attribute documentation_uri.



8
9
10
# File 'lib/gemsurance/gem_info_retriever.rb', line 8

def documentation_uri
  @documentation_uri
end

#homepage_uriObject (readonly)

Returns the value of attribute homepage_uri.



8
9
10
# File 'lib/gemsurance/gem_info_retriever.rb', line 8

def homepage_uri
  @homepage_uri
end

#in_gem_fileObject (readonly)

Returns the value of attribute in_gem_file.



8
9
10
# File 'lib/gemsurance/gem_info_retriever.rb', line 8

def in_gem_file
  @in_gem_file
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/gemsurance/gem_info_retriever.rb', line 8

def name
  @name
end

#newest_versionObject (readonly)

Returns the value of attribute newest_version.



8
9
10
# File 'lib/gemsurance/gem_info_retriever.rb', line 8

def newest_version
  @newest_version
end

#source_code_uriObject (readonly)

Returns the value of attribute source_code_uri.



8
9
10
# File 'lib/gemsurance/gem_info_retriever.rb', line 8

def source_code_uri
  @source_code_uri
end

#vulnerabilitiesObject (readonly)

Returns the value of attribute vulnerabilities.



8
9
10
# File 'lib/gemsurance/gem_info_retriever.rb', line 8

def vulnerabilities
  @vulnerabilities
end

Instance Method Details

#==(other) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/gemsurance/gem_info_retriever.rb', line 41

def ==(other)
  @name == other.name &&
    @current_version == other.current_version &&
    @newest_version == other.newest_version &&
    @status == other.instance_variable_get(:@status) &&
    @vulnerabilities == other.vulnerabilities
end

#add_vulnerability!(vulnerability) ⇒ Object



24
25
26
27
# File 'lib/gemsurance/gem_info_retriever.rb', line 24

def add_vulnerability!(vulnerability)
  @status = STATUS_VULNERABLE
  @vulnerabilities << vulnerability
end

#current?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/gemsurance/gem_info_retriever.rb', line 33

def current?
  @status == STATUS_CURRENT
end

#outdated?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/gemsurance/gem_info_retriever.rb', line 29

def outdated?
  @status == STATUS_OUTDATED
end

#vulnerable?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/gemsurance/gem_info_retriever.rb', line 37

def vulnerable?
  @status == STATUS_VULNERABLE
end