Class: Git::Trifle::PatchPatch
- Inherits:
-
String
- Object
- String
- Git::Trifle::PatchPatch
- Extended by:
- Pedlar
- Defined in:
- lib/git-patch-patch/patch_patcher.rb
Overview
patch model as a String for its primary interface, but it knows a lot more
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#first_commit ⇒ Object
Returns the value of attribute first_commit.
-
#second_commit ⇒ Object
Returns the value of attribute second_commit.
-
#work ⇒ Object
Returns the value of attribute work.
Instance Method Summary collapse
- #changed? ⇒ Boolean
-
#initialize(string, attributes = nil) ⇒ PatchPatch
constructor
A new instance of PatchPatch.
-
#reload_from_file ⇒ Object
patch content from file.
-
#save ⇒ Object
to file.
Constructor Details
#initialize(string, attributes = nil) ⇒ PatchPatch
Returns a new instance of PatchPatch.
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/git-patch-patch/patch_patcher.rb', line 172 def initialize(string, attributes=nil) # instance attributes in one line (attributes ||= {}).each { |k, v| send "#{k}=", v } file_with attributes[:file].to_s if attributes[:file] # job done ? ok then... if @work == true || @work == :done # give work the value we want @work = :done string = file.read end # changes handler @previous = string.to_s # vanilla super string end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
140 141 142 |
# File 'lib/git-patch-patch/patch_patcher.rb', line 140 def error @error end |
#first_commit ⇒ Object
Returns the value of attribute first_commit.
140 141 142 |
# File 'lib/git-patch-patch/patch_patcher.rb', line 140 def first_commit @first_commit end |
#second_commit ⇒ Object
Returns the value of attribute second_commit.
140 141 142 |
# File 'lib/git-patch-patch/patch_patcher.rb', line 140 def second_commit @second_commit end |
#work ⇒ Object
Returns the value of attribute work.
140 141 142 |
# File 'lib/git-patch-patch/patch_patcher.rb', line 140 def work @work end |
Instance Method Details
#changed? ⇒ Boolean
191 192 193 |
# File 'lib/git-patch-patch/patch_patcher.rb', line 191 def changed? self != @previous end |
#reload_from_file ⇒ Object
patch content from file
202 203 204 205 |
# File 'lib/git-patch-patch/patch_patcher.rb', line 202 def reload_from_file @previous = self.to_s replace file.read end |
#save ⇒ Object
to file
196 197 198 199 |
# File 'lib/git-patch-patch/patch_patcher.rb', line 196 def save # trailing \n or git complains file.save!(self + "\n") end |