Class: Greenhouse::Resources::IgnoreFile

Inherits:
Object
  • Object
show all
Includes:
FileResource
Defined in:
lib/greenhouse/resources/ignore_file.rb

Defined Under Namespace

Classes: IgnoredFile, IgnoredFiles

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FileResource

included

Constructor Details

#initialize(path) ⇒ IgnoreFile

Returns a new instance of IgnoreFile.



109
110
111
112
# File 'lib/greenhouse/resources/ignore_file.rb', line 109

def initialize(path)
  super
  reload
end

Instance Attribute Details

#ignoredObject

Returns the value of attribute ignored.



82
83
84
# File 'lib/greenhouse/resources/ignore_file.rb', line 82

def ignored
  @ignored
end

Instance Method Details

#reloadObject



94
95
96
97
98
99
100
101
102
# File 'lib/greenhouse/resources/ignore_file.rb', line 94

def reload
  @ignored = IgnoredFiles.new(self)
  return @ignored unless exists?
  read do |line,l|
    next if line.strip[0] == "#" || line.strip.empty?
    @ignored << IgnoredFile.new(line,l)
  end
  @ignored
end


104
105
106
107
# File 'lib/greenhouse/resources/ignore_file.rb', line 104

def unlink
  super
  reload
end

#writeObject Also known as: save



84
85
86
87
88
89
90
91
# File 'lib/greenhouse/resources/ignore_file.rb', line 84

def write
  ignored.each { |ignored| lines[ignored.line] = ignored.to_s}
  open('w') do |ifile|
    lines.each do |line|
      ifile.write "#{line}\n"
    end
  end
end