Class: KnifeSolo::Gitignore
- Inherits:
-
Object
- Object
- KnifeSolo::Gitignore
- Includes:
- Enumerable
- Defined in:
- lib/knife-solo/gitignore.rb
Instance Attribute Summary collapse
-
#ignore_file ⇒ Object
Returns the value of attribute ignore_file.
Instance Method Summary collapse
- #add(*new_entries) ⇒ Object
- #each ⇒ Object
-
#initialize(dir) ⇒ Gitignore
constructor
A new instance of Gitignore.
Constructor Details
#initialize(dir) ⇒ Gitignore
Returns a new instance of Gitignore.
7 8 9 |
# File 'lib/knife-solo/gitignore.rb', line 7 def initialize(dir) @ignore_file = File.join(dir, '.gitignore') end |
Instance Attribute Details
#ignore_file ⇒ Object
Returns the value of attribute ignore_file.
5 6 7 |
# File 'lib/knife-solo/gitignore.rb', line 5 def ignore_file @ignore_file end |
Instance Method Details
#add(*new_entries) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/knife-solo/gitignore.rb', line 19 def add(*new_entries) new_entries = (entries + new_entries.flatten).uniq File.open(ignore_file, 'w') do |f| f.puts new_entries end end |
#each ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/knife-solo/gitignore.rb', line 11 def each if File.exist? ignore_file File.new(ignore_file).each do |line| yield line.chomp end end end |