Class: Mighost::OrphanDetector::OrphanedMigration
- Inherits:
-
Object
- Object
- Mighost::OrphanDetector::OrphanedMigration
- Defined in:
- lib/mighost/orphan_detector.rb
Instance Attribute Summary collapse
-
#author_email ⇒ Object
readonly
Returns the value of attribute author_email.
-
#author_name ⇒ Object
readonly
Returns the value of attribute author_name.
-
#branch_name ⇒ Object
readonly
Returns the value of attribute branch_name.
-
#dismissed ⇒ Object
readonly
Returns the value of attribute dismissed.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#git_sha ⇒ Object
readonly
Returns the value of attribute git_sha.
-
#migrated_at ⇒ Object
readonly
Returns the value of attribute migrated_at.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#actionable? ⇒ Boolean
Is actionable? (recoverable OR not old enough to suggest dismissal).
-
#created_at ⇒ Object
Parse version timestamp (YYYYMMDDHHmmss) -> Time.
-
#initialize(version:, filename: nil, branch_name: nil, git_sha: nil, migrated_at: nil, source: nil, dismissed: false, author_name: nil, author_email: nil) ⇒ OrphanedMigration
constructor
A new instance of OrphanedMigration.
-
#old?(threshold: Mighost.configuration.dismiss_old_threshold) ⇒ Boolean
Is migration older than threshold?.
- #recoverable? ⇒ Boolean
- #recovery_source ⇒ Object
-
#suggested_for_dismiss? ⇒ Boolean
Should suggest dismissal? (unrecoverable AND old).
Constructor Details
#initialize(version:, filename: nil, branch_name: nil, git_sha: nil, migrated_at: nil, source: nil, dismissed: false, author_name: nil, author_email: nil) ⇒ OrphanedMigration
Returns a new instance of OrphanedMigration.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mighost/orphan_detector.rb', line 14 def initialize(version:, filename: nil, branch_name: nil, git_sha: nil, migrated_at: nil, source: nil, dismissed: false, author_name: nil, author_email: nil) @version = version @filename = filename @branch_name = branch_name @git_sha = git_sha @migrated_at = migrated_at @source = source @dismissed = dismissed @author_name = @author_email = end |
Instance Attribute Details
#author_email ⇒ Object (readonly)
Returns the value of attribute author_email.
12 13 14 |
# File 'lib/mighost/orphan_detector.rb', line 12 def @author_email end |
#author_name ⇒ Object (readonly)
Returns the value of attribute author_name.
12 13 14 |
# File 'lib/mighost/orphan_detector.rb', line 12 def @author_name end |
#branch_name ⇒ Object (readonly)
Returns the value of attribute branch_name.
12 13 14 |
# File 'lib/mighost/orphan_detector.rb', line 12 def branch_name @branch_name end |
#dismissed ⇒ Object (readonly)
Returns the value of attribute dismissed.
12 13 14 |
# File 'lib/mighost/orphan_detector.rb', line 12 def dismissed @dismissed end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
12 13 14 |
# File 'lib/mighost/orphan_detector.rb', line 12 def filename @filename end |
#git_sha ⇒ Object (readonly)
Returns the value of attribute git_sha.
12 13 14 |
# File 'lib/mighost/orphan_detector.rb', line 12 def git_sha @git_sha end |
#migrated_at ⇒ Object (readonly)
Returns the value of attribute migrated_at.
12 13 14 |
# File 'lib/mighost/orphan_detector.rb', line 12 def migrated_at @migrated_at end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
12 13 14 |
# File 'lib/mighost/orphan_detector.rb', line 12 def source @source end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
12 13 14 |
# File 'lib/mighost/orphan_detector.rb', line 12 def version @version end |
Instance Method Details
#actionable? ⇒ Boolean
Is actionable? (recoverable OR not old enough to suggest dismissal)
64 65 66 |
# File 'lib/mighost/orphan_detector.rb', line 64 def actionable? !suggested_for_dismiss? end |
#created_at ⇒ Object
Parse version timestamp (YYYYMMDDHHmmss) -> Time
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/mighost/orphan_detector.rb', line 39 def created_at return @created_at if defined?(@created_at) @created_at = begin if version =~ /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/ Time.new($1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i) end rescue ArgumentError nil end end |
#old?(threshold: Mighost.configuration.dismiss_old_threshold) ⇒ Boolean
Is migration older than threshold?
52 53 54 55 56 |
# File 'lib/mighost/orphan_detector.rb', line 52 def old?(threshold: Mighost.configuration.dismiss_old_threshold) return false unless created_at created_at < threshold.ago end |
#recoverable? ⇒ Boolean
26 27 28 |
# File 'lib/mighost/orphan_detector.rb', line 26 def recoverable? source.present? end |
#recovery_source ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/mighost/orphan_detector.rb', line 30 def recovery_source case source when "file" then :snapshot when "git" then :branch when "worktree" then :worktree end end |
#suggested_for_dismiss? ⇒ Boolean
Should suggest dismissal? (unrecoverable AND old)
59 60 61 |
# File 'lib/mighost/orphan_detector.rb', line 59 def suggested_for_dismiss? !recoverable? && old? end |