Class: Aidp::AutoUpdate::UpdateCheck
- Inherits:
-
Object
- Object
- Aidp::AutoUpdate::UpdateCheck
- Defined in:
- lib/aidp/auto_update/update_check.rb
Overview
Value object representing the result of an update check
Instance Attribute Summary collapse
-
#available_version ⇒ Object
readonly
Returns the value of attribute available_version.
-
#checked_at ⇒ Object
readonly
Returns the value of attribute checked_at.
-
#current_version ⇒ Object
readonly
Returns the value of attribute current_version.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#policy_reason ⇒ Object
readonly
Returns the value of attribute policy_reason.
-
#update_allowed ⇒ Object
readonly
Returns the value of attribute update_allowed.
-
#update_available ⇒ Object
readonly
Returns the value of attribute update_available.
Class Method Summary collapse
-
.failed(error_message, current_version: Aidp::VERSION) ⇒ UpdateCheck
Create a failed update check.
-
.from_h(hash) ⇒ UpdateCheck
Create from hash.
-
.unavailable(current_version: Aidp::VERSION) ⇒ UpdateCheck
Create an unavailable update check (service temporarily unavailable).
Instance Method Summary collapse
-
#failed? ⇒ Boolean
Check if update check failed.
-
#initialize(current_version:, available_version:, update_available:, update_allowed:, policy_reason: nil, checked_at: Time.now, error: nil) ⇒ UpdateCheck
constructor
A new instance of UpdateCheck.
-
#should_update? ⇒ Boolean
Check if update should be performed.
-
#success? ⇒ Boolean
Check if update check was successful.
-
#to_h ⇒ Hash
Convert to hash for serialization.
Constructor Details
#initialize(current_version:, available_version:, update_available:, update_allowed:, policy_reason: nil, checked_at: Time.now, error: nil) ⇒ UpdateCheck
Returns a new instance of UpdateCheck.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/aidp/auto_update/update_check.rb', line 12 def initialize( current_version:, available_version:, update_available:, update_allowed:, policy_reason: nil, checked_at: Time.now, error: nil ) @current_version = current_version @available_version = available_version @update_available = update_available @update_allowed = update_allowed @policy_reason = policy_reason @checked_at = checked_at @error = error end |
Instance Attribute Details
#available_version ⇒ Object (readonly)
Returns the value of attribute available_version.
9 10 11 |
# File 'lib/aidp/auto_update/update_check.rb', line 9 def available_version @available_version end |
#checked_at ⇒ Object (readonly)
Returns the value of attribute checked_at.
9 10 11 |
# File 'lib/aidp/auto_update/update_check.rb', line 9 def checked_at @checked_at end |
#current_version ⇒ Object (readonly)
Returns the value of attribute current_version.
9 10 11 |
# File 'lib/aidp/auto_update/update_check.rb', line 9 def current_version @current_version end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
9 10 11 |
# File 'lib/aidp/auto_update/update_check.rb', line 9 def error @error end |
#policy_reason ⇒ Object (readonly)
Returns the value of attribute policy_reason.
9 10 11 |
# File 'lib/aidp/auto_update/update_check.rb', line 9 def policy_reason @policy_reason end |
#update_allowed ⇒ Object (readonly)
Returns the value of attribute update_allowed.
9 10 11 |
# File 'lib/aidp/auto_update/update_check.rb', line 9 def update_allowed @update_allowed end |
#update_available ⇒ Object (readonly)
Returns the value of attribute update_available.
9 10 11 |
# File 'lib/aidp/auto_update/update_check.rb', line 9 def update_available @update_available end |
Class Method Details
.failed(error_message, current_version: Aidp::VERSION) ⇒ UpdateCheck
Create a failed update check
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/aidp/auto_update/update_check.rb', line 34 def self.failed(, current_version: Aidp::VERSION) new( current_version: current_version, available_version: current_version, update_available: false, update_allowed: false, policy_reason: "Update check failed", error: ) end |
.from_h(hash) ⇒ UpdateCheck
Create from hash
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/aidp/auto_update/update_check.rb', line 93 def self.from_h(hash) new( current_version: hash[:current_version] || hash["current_version"], available_version: hash[:available_version] || hash["available_version"], update_available: hash[:update_available] || hash["update_available"], update_allowed: hash[:update_allowed] || hash["update_allowed"], policy_reason: hash[:policy_reason] || hash["policy_reason"], checked_at: Time.parse(hash[:checked_at] || hash["checked_at"]), error: hash[:error] || hash["error"] ) end |
.unavailable(current_version: Aidp::VERSION) ⇒ UpdateCheck
Create an unavailable update check (service temporarily unavailable)
48 49 50 51 52 53 54 55 56 |
# File 'lib/aidp/auto_update/update_check.rb', line 48 def self.unavailable(current_version: Aidp::VERSION) new( current_version: current_version, available_version: current_version, update_available: false, update_allowed: false, policy_reason: "Update service temporarily unavailable" ) end |
Instance Method Details
#failed? ⇒ Boolean
Check if update check failed
66 67 68 |
# File 'lib/aidp/auto_update/update_check.rb', line 66 def failed? !success? end |
#should_update? ⇒ Boolean
Check if update should be performed
72 73 74 |
# File 'lib/aidp/auto_update/update_check.rb', line 72 def should_update? success? && @update_available && @update_allowed end |
#success? ⇒ Boolean
Check if update check was successful
60 61 62 |
# File 'lib/aidp/auto_update/update_check.rb', line 60 def success? @error.nil? end |
#to_h ⇒ Hash
Convert to hash for serialization
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/aidp/auto_update/update_check.rb', line 78 def to_h { current_version: @current_version, available_version: @available_version, update_available: @update_available, update_allowed: @update_allowed, policy_reason: @policy_reason, checked_at: @checked_at.utc.iso8601, error: @error } end |