Class: Mate::TmProperties
- Inherits:
-
Object
- Object
- Mate::TmProperties
- Defined in:
- lib/mate/tm_properties.rb
Defined Under Namespace
Classes: Ignores
Class Method Summary collapse
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#initialize(dir, options) ⇒ TmProperties
constructor
A new instance of TmProperties.
- #save ⇒ Object
Constructor Details
#initialize(dir, options) ⇒ TmProperties
Returns a new instance of TmProperties.
10 11 12 13 14 15 16 |
# File 'lib/mate/tm_properties.rb', line 10 def initialize(dir, ) @dir = Pathname(dir). @file = @dir + '.tm_properties' @lines = @file.exist? ? @file.read.split("\n") : [] @other_lines = @lines.reject{ |line| line =~ Ignores::GENERATED_R } @options = end |
Class Method Details
Instance Method Details
#cleanup ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/mate/tm_properties.rb', line 31 def cleanup if @other_lines.empty? @file.unlink if @file.exist? else write(@other_lines) end end |
#save ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mate/tm_properties.rb', line 18 def save if @file.exist? return warn("#{@file} is not writable, skipping") unless @file.writable? else return warn("#{@dir} is not writable, not creating #{@file.basename}") unless @dir.writable? return warn("#{@dir} is not traversable, not creating #{@file.basename}") unless @dir.executable? end ignores = Ignores.new(@dir, @options) write(ignores.lines + @other_lines) end |