Class: Greenhouse::Resources::IgnoreFile
- Inherits:
-
Object
- Object
- Greenhouse::Resources::IgnoreFile
- Includes:
- FileResource
- Defined in:
- lib/greenhouse/resources/ignore_file.rb
Defined Under Namespace
Classes: IgnoredFile, IgnoredFiles
Instance Attribute Summary collapse
-
#ignored ⇒ Object
Returns the value of attribute ignored.
Instance Method Summary collapse
-
#initialize(path) ⇒ IgnoreFile
constructor
A new instance of IgnoreFile.
- #reload ⇒ Object
- #unlink ⇒ Object
- #write ⇒ Object (also: #save)
Methods included from FileResource
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
#ignored ⇒ Object
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
#reload ⇒ Object
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 |
#unlink ⇒ Object
104 105 106 107 |
# File 'lib/greenhouse/resources/ignore_file.rb', line 104 def unlink super reload end |
#write ⇒ Object 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 |