Class: Ignore::Gitignore

Inherits:
Object
  • Object
show all
Defined in:
lib/ignore/gitignore.rb

Instance Method Summary collapse

Constructor Details

#initializeGitignore

Returns a new instance of Gitignore.



6
7
8
# File 'lib/ignore/gitignore.rb', line 6

def initialize
  @path = File.join(Dir.pwd(),'.gitignore')
end

Instance Method Details

#append(content, lang = "") ⇒ Object



10
11
12
13
14
15
# File 'lib/ignore/gitignore.rb', line 10

def append( content , lang = "" )
  FileUtils.touch @path
  data="#\n#AutoGenerated #{lang} Gitignore\n#\n"+content+"\n##\n"
  File.open(@path, 'a'){|f| f.write(data) }
  Command.output "Updated .gitignore"
end

#exists?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/ignore/gitignore.rb', line 22

def exists?
  File.exists?( @path )
end

#pathObject



26
27
28
# File 'lib/ignore/gitignore.rb', line 26

def path
  @path
end

#readObject



17
18
19
20
# File 'lib/ignore/gitignore.rb', line 17

def read
  return File.open(@path,'r'){|f| f.read } if exists? 
  ""
end