Class: Mate::TmProperties

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

Defined Under Namespace

Classes: Ignores

Class Method Summary collapse

Instance Method Summary collapse

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, options)
  @dir = Pathname(dir).expand_path
  @file = @dir + '.tm_properties'
  @lines = @file.exist? ? @file.read.split("\n") : []
  @other_lines = @lines.reject{ |line| line =~ Ignores::GENERATED_R }
  @options = options
end

Class Method Details

.create(dir, options) ⇒ Object



6
7
8
# File 'lib/mate/tm_properties.rb', line 6

def self.create(dir, options)
  new(Git.toplevel(dir) || dir, options).save
end

Instance Method Details

#cleanupObject



24
25
26
27
28
29
30
# File 'lib/mate/tm_properties.rb', line 24

def cleanup
  if @other_lines.empty?
    @file.unlink if @file.exist?
  else
    write(@other_lines)
  end
end

#saveObject



18
19
20
21
22
# File 'lib/mate/tm_properties.rb', line 18

def save
  ignores = Ignores.new(@dir, @options)

  write(ignores.lines + @other_lines)
end