Class: Aidp::AutoUpdate::UpdatePolicy
- Inherits:
-
Object
- Object
- Aidp::AutoUpdate::UpdatePolicy
- Defined in:
- lib/aidp/auto_update/update_policy.rb
Overview
Value object representing auto-update configuration policy
Constant Summary collapse
- VALID_POLICIES =
%w[off exact patch minor major].freeze
- VALID_SUPERVISORS =
%w[none supervisord s6 runit].freeze
Instance Attribute Summary collapse
-
#allow_prerelease ⇒ Object
readonly
Returns the value of attribute allow_prerelease.
-
#check_interval_seconds ⇒ Object
readonly
Returns the value of attribute check_interval_seconds.
-
#enabled ⇒ Object
readonly
Returns the value of attribute enabled.
-
#max_consecutive_failures ⇒ Object
readonly
Returns the value of attribute max_consecutive_failures.
-
#policy ⇒ Object
readonly
Returns the value of attribute policy.
-
#supervisor ⇒ Object
readonly
Returns the value of attribute supervisor.
Class Method Summary collapse
-
.disabled ⇒ UpdatePolicy
Create a disabled policy.
-
.from_config(config) ⇒ UpdatePolicy
Create from configuration hash.
Instance Method Summary collapse
-
#disabled? ⇒ Boolean
Check if updates are completely disabled.
-
#initialize(enabled: false, policy: "off", allow_prerelease: false, check_interval_seconds: 3600, supervisor: "none", max_consecutive_failures: 3) ⇒ UpdatePolicy
constructor
A new instance of UpdatePolicy.
-
#supervised? ⇒ Boolean
Check if a supervisor is configured.
-
#to_h ⇒ Hash
Convert to hash for serialization.
Constructor Details
#initialize(enabled: false, policy: "off", allow_prerelease: false, check_interval_seconds: 3600, supervisor: "none", max_consecutive_failures: 3) ⇒ UpdatePolicy
Returns a new instance of UpdatePolicy.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/aidp/auto_update/update_policy.rb', line 13 def initialize( enabled: false, policy: "off", allow_prerelease: false, check_interval_seconds: 3600, supervisor: "none", max_consecutive_failures: 3 ) @enabled = enabled @policy = validate_policy(policy) @allow_prerelease = allow_prerelease @check_interval_seconds = validate_interval(check_interval_seconds) @supervisor = validate_supervisor(supervisor) @max_consecutive_failures = validate_max_failures(max_consecutive_failures) end |
Instance Attribute Details
#allow_prerelease ⇒ Object (readonly)
Returns the value of attribute allow_prerelease.
7 8 9 |
# File 'lib/aidp/auto_update/update_policy.rb', line 7 def allow_prerelease @allow_prerelease end |
#check_interval_seconds ⇒ Object (readonly)
Returns the value of attribute check_interval_seconds.
7 8 9 |
# File 'lib/aidp/auto_update/update_policy.rb', line 7 def check_interval_seconds @check_interval_seconds end |
#enabled ⇒ Object (readonly)
Returns the value of attribute enabled.
7 8 9 |
# File 'lib/aidp/auto_update/update_policy.rb', line 7 def enabled @enabled end |
#max_consecutive_failures ⇒ Object (readonly)
Returns the value of attribute max_consecutive_failures.
7 8 9 |
# File 'lib/aidp/auto_update/update_policy.rb', line 7 def max_consecutive_failures @max_consecutive_failures end |
#policy ⇒ Object (readonly)
Returns the value of attribute policy.
7 8 9 |
# File 'lib/aidp/auto_update/update_policy.rb', line 7 def policy @policy end |
#supervisor ⇒ Object (readonly)
Returns the value of attribute supervisor.
7 8 9 |
# File 'lib/aidp/auto_update/update_policy.rb', line 7 def supervisor @supervisor end |
Class Method Details
.disabled ⇒ UpdatePolicy
Create a disabled policy
47 48 49 |
# File 'lib/aidp/auto_update/update_policy.rb', line 47 def self.disabled new(enabled: false, policy: "off") end |
.from_config(config) ⇒ UpdatePolicy
Create from configuration hash
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/aidp/auto_update/update_policy.rb', line 32 def self.from_config(config) return disabled unless config new( enabled: config[:enabled] || config["enabled"] || false, policy: config[:policy] || config["policy"] || "off", allow_prerelease: config[:allow_prerelease] || config["allow_prerelease"] || false, check_interval_seconds: config[:check_interval_seconds] || config["check_interval_seconds"] || 3600, supervisor: config[:supervisor] || config["supervisor"] || "none", max_consecutive_failures: config[:max_consecutive_failures] || config["max_consecutive_failures"] || 3 ) end |
Instance Method Details
#disabled? ⇒ Boolean
Check if updates are completely disabled
53 54 55 |
# File 'lib/aidp/auto_update/update_policy.rb', line 53 def disabled? !@enabled || @policy == "off" end |
#supervised? ⇒ Boolean
Check if a supervisor is configured
59 60 61 |
# File 'lib/aidp/auto_update/update_policy.rb', line 59 def supervised? @supervisor != "none" end |
#to_h ⇒ Hash
Convert to hash for serialization
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/aidp/auto_update/update_policy.rb', line 65 def to_h { enabled: @enabled, policy: @policy, allow_prerelease: @allow_prerelease, check_interval_seconds: @check_interval_seconds, supervisor: @supervisor, max_consecutive_failures: @max_consecutive_failures } end |