Class: Onboard::Patch
- Inherits:
-
Object
- Object
- Onboard::Patch
- Defined in:
- lib/onboard/patch.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
Instance Method Summary collapse
- #cleanup ⇒ Object
- #close(patch_file = '') ⇒ Object
-
#initialize(dir = '/tmp/onboard/patches') ⇒ Patch
constructor
A new instance of Patch.
- #open(project) ⇒ Object
- #patch_dir ⇒ Object
Constructor Details
#initialize(dir = '/tmp/onboard/patches') ⇒ Patch
Returns a new instance of Patch.
12 13 14 |
# File 'lib/onboard/patch.rb', line 12 def initialize(dir = '/tmp/onboard/patches') @dir = dir end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
10 11 12 |
# File 'lib/onboard/patch.rb', line 10 def dir @dir end |
Instance Method Details
#cleanup ⇒ Object
20 21 22 23 24 25 |
# File 'lib/onboard/patch.rb', line 20 def cleanup Dir.foreach(dir) do |item| file = "#{dir}/#{item}" FileUtils.rm_r file if File.zero?(file) end end |
#close(patch_file = '') ⇒ Object
33 34 35 36 |
# File 'lib/onboard/patch.rb', line 33 def close(patch_file = '') patch_file.close cleanup end |
#open(project) ⇒ Object
27 28 29 30 31 |
# File 'lib/onboard/patch.rb', line 27 def open(project) patch_dir patch_file = File.open("#{dir}/#{Time.now.to_i}_#{project}.patch", 'w') patch_file end |
#patch_dir ⇒ Object
16 17 18 |
# File 'lib/onboard/patch.rb', line 16 def patch_dir FileUtils.mkdir_p(dir) unless File.directory?(dir) end |