Class: Lapidarist::Gem
- Inherits:
-
Object
- Object
- Lapidarist::Gem
- Defined in:
- lib/lapidarist/gem.rb
Instance Attribute Summary collapse
-
#attempts ⇒ Object
readonly
Returns the value of attribute attempts.
-
#installed_version ⇒ Object
readonly
Returns the value of attribute installed_version.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#newest_version ⇒ Object
readonly
Returns the value of attribute newest_version.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other_gem) ⇒ Object
- #available_update_levels? ⇒ Boolean
- #current_status ⇒ Object
- #dependency? ⇒ Boolean
- #failed? ⇒ Boolean
- #groups ⇒ Object
-
#initialize(name:, position: nil, newest_version:, installed_version:, groups: [], attempts: {}) ⇒ Gem
constructor
A new instance of Gem.
- #latest_attempt ⇒ Object
- #latest_attempt_number ⇒ Object
- #log_s ⇒ Object
- #next_semver_level ⇒ Object
- #outdated?(recursive: false) ⇒ Boolean
- #skip? ⇒ Boolean
- #updated? ⇒ Boolean
- #updated_version ⇒ Object
- #what_changed ⇒ Object
Constructor Details
#initialize(name:, position: nil, newest_version:, installed_version:, groups: [], attempts: {}) ⇒ Gem
Returns a new instance of Gem.
26 27 28 29 30 31 32 33 |
# File 'lib/lapidarist/gem.rb', line 26 def initialize(name:, position: nil, newest_version:, installed_version:, groups: [], attempts: {}) @name = name @position = position @newest_version = newest_version @installed_version = installed_version @groups = groups @attempts = attempts end |
Instance Attribute Details
#attempts ⇒ Object (readonly)
Returns the value of attribute attempts.
24 25 26 |
# File 'lib/lapidarist/gem.rb', line 24 def attempts @attempts end |
#installed_version ⇒ Object (readonly)
Returns the value of attribute installed_version.
24 25 26 |
# File 'lib/lapidarist/gem.rb', line 24 def installed_version @installed_version end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
24 25 26 |
# File 'lib/lapidarist/gem.rb', line 24 def name @name end |
#newest_version ⇒ Object (readonly)
Returns the value of attribute newest_version.
24 25 26 |
# File 'lib/lapidarist/gem.rb', line 24 def newest_version @newest_version end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
24 25 26 |
# File 'lib/lapidarist/gem.rb', line 24 def position @position end |
Class Method Details
.from(gem, position: nil, attempt: 0, status: nil, reason: nil, updated_version: nil) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/lapidarist/gem.rb', line 35 def self.from(gem, position: nil, attempt: 0, status: nil, reason: nil, updated_version: nil) attempts = gem.attempts if status attempts = attempts.merge( attempt => Attempt.new( status: status, reason: reason, version: updated_version ) ) end new( name: gem.name, position: position || gem.position, newest_version: gem.newest_version, installed_version: gem.installed_version, groups: gem.groups, attempts: attempts ) end |
Instance Method Details
#==(other_gem) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/lapidarist/gem.rb', line 58 def ==(other_gem) current_status == other_gem.current_status && name == other_gem.name && installed_version == other_gem.installed_version && newest_version == other_gem.newest_version && groups == other_gem.groups end |
#available_update_levels? ⇒ Boolean
106 107 108 |
# File 'lib/lapidarist/gem.rb', line 106 def available_update_levels? failed? && !version_change.next_level.nil? end |
#current_status ⇒ Object
74 75 76 |
# File 'lib/lapidarist/gem.rb', line 74 def current_status latest_attempt&.status end |
#dependency? ⇒ Boolean
70 71 72 |
# File 'lib/lapidarist/gem.rb', line 70 def dependency? groups.any? end |
#failed? ⇒ Boolean
82 83 84 |
# File 'lib/lapidarist/gem.rb', line 82 def failed? current_status == :failed end |
#groups ⇒ Object
66 67 68 |
# File 'lib/lapidarist/gem.rb', line 66 def groups @groups.sort end |
#latest_attempt ⇒ Object
127 128 129 |
# File 'lib/lapidarist/gem.rb', line 127 def latest_attempt @latest_attempt ||= attempts[latest_attempt_number] || NullAttempt.new end |
#latest_attempt_number ⇒ Object
123 124 125 |
# File 'lib/lapidarist/gem.rb', line 123 def latest_attempt_number @latest_attempt_number ||= attempts.keys.last end |
#log_s ⇒ Object
114 115 116 117 118 119 120 121 |
# File 'lib/lapidarist/gem.rb', line 114 def log_s [ "outdated gem: #{name}", "installed: #{installed_version}", "newest: #{newest_version}", "updated: #{updated_version}" ].join(', ') end |
#next_semver_level ⇒ Object
110 111 112 |
# File 'lib/lapidarist/gem.rb', line 110 def next_semver_level version_change.next_level end |
#outdated?(recursive: false) ⇒ Boolean
78 79 80 |
# File 'lib/lapidarist/gem.rb', line 78 def outdated?(recursive: false) current_status.nil? || (recursive && available_update_levels?) end |
#skip? ⇒ Boolean
86 87 88 |
# File 'lib/lapidarist/gem.rb', line 86 def skip? current_status == :skipped end |
#updated? ⇒ Boolean
90 91 92 |
# File 'lib/lapidarist/gem.rb', line 90 def updated? current_status == :updated end |
#updated_version ⇒ Object
94 95 96 |
# File 'lib/lapidarist/gem.rb', line 94 def updated_version updated_attempt&.version end |
#what_changed ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/lapidarist/gem.rb', line 98 def what_changed if version_changed? "#{name} from #{installed_version} to #{updated_version}" else "#{name} dependencies" end end |