Class: TDP::Patch
- Inherits:
-
Object
- Object
- TDP::Patch
- Defined in:
- lib/tdp.rb
Overview
A single patch.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Content of the patch.
-
#full_filename ⇒ Object
readonly
Full name of the patch file.
-
#name ⇒ Object
readonly
Name of the patch.
-
#signature ⇒ Object
readonly
SHA-256 hash of content.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Comparison function.
-
#initialize(full_filename) ⇒ Patch
constructor
- full_filename
-
full path to
.sqlfile.
-
#permanent? ⇒ Boolean
Returns true if patch is permanent.
-
#volatile? ⇒ Boolean
Returns true if patch is volatile.
Constructor Details
#initialize(full_filename) ⇒ Patch
- full_filename
-
full path to
.sqlfile
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
#content ⇒ Object (readonly)
Content of the patch.
100 101 102 |
# File 'lib/tdp.rb', line 100 def content @content end |
#full_filename ⇒ Object (readonly)
Full name of the patch file.
103 104 105 |
# File 'lib/tdp.rb', line 103 def full_filename @full_filename end |
#name ⇒ Object (readonly)
Name of the patch.
109 110 111 |
# File 'lib/tdp.rb', line 109 def name @name end |
#signature ⇒ Object (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.
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.
124 125 126 |
# File 'lib/tdp.rb', line 124 def volatile? TDP.volatile_patch_file?(@name) end |