Class: Ignore::Gitignore
- Inherits:
-
Object
- Object
- Ignore::Gitignore
- Defined in:
- lib/ignore/gitignore.rb
Instance Method Summary collapse
- #append(content, lang = "") ⇒ Object
- #exists? ⇒ Boolean
-
#initialize ⇒ Gitignore
constructor
A new instance of Gitignore.
- #path ⇒ Object
- #read ⇒ Object
Constructor Details
#initialize ⇒ Gitignore
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
22 23 24 |
# File 'lib/ignore/gitignore.rb', line 22 def exists? File.exists?( @path ) end |
#path ⇒ Object
26 27 28 |
# File 'lib/ignore/gitignore.rb', line 26 def path @path end |
#read ⇒ Object
17 18 19 20 |
# File 'lib/ignore/gitignore.rb', line 17 def read return File.open(@path,'r'){|f| f.read } if exists? "" end |