Class: Gemsurance::GemInfoRetriever::GemInfo
- Inherits:
-
Object
- Object
- Gemsurance::GemInfoRetriever::GemInfo
- Defined in:
- lib/gemsurance/gem_info_retriever.rb
Constant Summary collapse
- GEM_ATTRIBUTES =
[:name, :current_version, :newest_version, :in_gem_file, :homepage_uri, :source_code_uri, :documentation_uri, :status, :vulnerabilities]
- STATUS_OUTDATED =
'outdated'- STATUS_CURRENT =
'current'- STATUS_VULNERABLE =
'vulnerable'
Instance Attribute Summary collapse
-
#current_version ⇒ Object
readonly
Returns the value of attribute current_version.
-
#documentation_uri ⇒ Object
readonly
Returns the value of attribute documentation_uri.
-
#homepage_uri ⇒ Object
readonly
Returns the value of attribute homepage_uri.
-
#in_gem_file ⇒ Object
readonly
Returns the value of attribute in_gem_file.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#newest_version ⇒ Object
readonly
Returns the value of attribute newest_version.
-
#source_code_uri ⇒ Object
readonly
Returns the value of attribute source_code_uri.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#vulnerabilities ⇒ Object
readonly
Returns the value of attribute vulnerabilities.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #add_vulnerability!(vulnerability) ⇒ Object
- #current? ⇒ Boolean
-
#initialize(name, current_version, newest_version, in_gem_file, homepage_uri, source_code_uri, documentation_uri, status = STATUS_CURRENT) ⇒ GemInfo
constructor
A new instance of GemInfo.
- #outdated? ⇒ Boolean
- #to_csv ⇒ Object
- #to_hash ⇒ Object
- #vulnerable? ⇒ Boolean
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.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gemsurance/gem_info_retriever.rb', line 14 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_version ⇒ Object (readonly)
Returns the value of attribute current_version.
11 12 13 |
# File 'lib/gemsurance/gem_info_retriever.rb', line 11 def current_version @current_version end |
#documentation_uri ⇒ Object (readonly)
Returns the value of attribute documentation_uri.
11 12 13 |
# File 'lib/gemsurance/gem_info_retriever.rb', line 11 def documentation_uri @documentation_uri end |
#homepage_uri ⇒ Object (readonly)
Returns the value of attribute homepage_uri.
11 12 13 |
# File 'lib/gemsurance/gem_info_retriever.rb', line 11 def homepage_uri @homepage_uri end |
#in_gem_file ⇒ Object (readonly)
Returns the value of attribute in_gem_file.
11 12 13 |
# File 'lib/gemsurance/gem_info_retriever.rb', line 11 def in_gem_file @in_gem_file end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/gemsurance/gem_info_retriever.rb', line 11 def name @name end |
#newest_version ⇒ Object (readonly)
Returns the value of attribute newest_version.
11 12 13 |
# File 'lib/gemsurance/gem_info_retriever.rb', line 11 def newest_version @newest_version end |
#source_code_uri ⇒ Object (readonly)
Returns the value of attribute source_code_uri.
11 12 13 |
# File 'lib/gemsurance/gem_info_retriever.rb', line 11 def source_code_uri @source_code_uri end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
11 12 13 |
# File 'lib/gemsurance/gem_info_retriever.rb', line 11 def status @status end |
#vulnerabilities ⇒ Object (readonly)
Returns the value of attribute vulnerabilities.
11 12 13 |
# File 'lib/gemsurance/gem_info_retriever.rb', line 11 def vulnerabilities @vulnerabilities end |
Instance Method Details
#==(other) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/gemsurance/gem_info_retriever.rb', line 43 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
26 27 28 29 |
# File 'lib/gemsurance/gem_info_retriever.rb', line 26 def add_vulnerability!(vulnerability) @status = STATUS_VULNERABLE @vulnerabilities << vulnerability end |
#current? ⇒ Boolean
35 36 37 |
# File 'lib/gemsurance/gem_info_retriever.rb', line 35 def current? @status == STATUS_CURRENT end |
#outdated? ⇒ Boolean
31 32 33 |
# File 'lib/gemsurance/gem_info_retriever.rb', line 31 def outdated? @status == STATUS_OUTDATED end |
#to_csv ⇒ Object
51 52 53 |
# File 'lib/gemsurance/gem_info_retriever.rb', line 51 def to_csv formatted_values.to_csv end |
#to_hash ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/gemsurance/gem_info_retriever.rb', line 55 def to_hash { 'in_gem_file' => in_gem_file, 'bundle_version' => current_version.to_s, 'newest_version' => newest_version.to_s, 'status' => human_status, 'homepage_url' => homepage_uri, 'source_code_url' => source_code_uri, 'documentation_url' => documentation_uri, 'vulnerabilities' => vulns_to_hash } end |
#vulnerable? ⇒ Boolean
39 40 41 |
# File 'lib/gemsurance/gem_info_retriever.rb', line 39 def vulnerable? @status == STATUS_VULNERABLE end |