Class: TDP::Patch

Inherits:
Object
  • Object
show all
Defined in:
lib/tdp.rb

Overview

A single patch.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(full_filename) ⇒ Patch

full_filename

full path to .sql file



114
115
116
117
118
119
# File 'lib/tdp.rb', line 114

def initialize(full_filename)
  @full_filename = full_filename
  _, @name = File.split(full_filename)
  @content = File.read(full_filename)
  @signature = Digest::SHA256.hexdigest(@content)
end

Instance Attribute Details

#contentObject (readonly)

Content of the patch.



100
101
102
# File 'lib/tdp.rb', line 100

def content
  @content
end

#full_filenameObject (readonly)

Full name of the patch file.



103
104
105
# File 'lib/tdp.rb', line 103

def full_filename
  @full_filename
end

#nameObject (readonly)

Name of the patch.



109
110
111
# File 'lib/tdp.rb', line 109

def name
  @name
end

#signatureObject (readonly)

SHA-256 hash of content.



106
107
108
# File 'lib/tdp.rb', line 106

def signature
  @signature
end

Instance Method Details

#<=>(other) ⇒ Object

Comparison function. Any permanent patch takes precedence over any volatile one, if both patches are permanent or both are volatile, ordering is based on name.



140
141
142
143
144
# File 'lib/tdp.rb', line 140

def <=>(other)
  return -1 if permanent? && other.volatile?
  return 1 if volatile? && other.permanent?
  @name <=> other.name
end

#permanent?Boolean

Returns true if patch is permanent.

Returns:

  • (Boolean)


131
132
133
# File 'lib/tdp.rb', line 131

def permanent?
  TDP.permanent_patch_file?(@name)
end

#volatile?Boolean

Returns true if patch is volatile.

Returns:

  • (Boolean)


124
125
126
# File 'lib/tdp.rb', line 124

def volatile?
  TDP.volatile_patch_file?(@name)
end