class Mate::TmProperties

Public Class Methods

create(dir, options) click to toggle source
# File lib/mate/tm_properties.rb, line 6
def self.create(dir, options)
  new(Git.toplevel(dir) || dir, options).save
end
new(dir, options) click to toggle source
# 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

Public Instance Methods

cleanup() click to toggle source
# 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
save() click to toggle source
# File lib/mate/tm_properties.rb, line 18
def save
  ignores = Ignores.new(@dir, @options)

  write(ignores.lines + @other_lines)
end

Private Instance Methods

write(lines) click to toggle source
# File lib/mate/tm_properties.rb, line 34
def write(lines)
  return if lines == @lines

  @file.open('w') do |f|
    f.puts lines
  end
end