Class: SensuGenerator::CheckFile

Inherits:
Object
  • Object
show all
Defined in:
lib/sensu_generator/check_file.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ CheckFile

Returns a new instance of CheckFile.



9
10
11
12
13
14
# File 'lib/sensu_generator/check_file.rb', line 9

def initialize(filename)
  @config   = Application.config
  @trigger  = Application.trigger
  @filename = filename
  @fullpath = File.join(@config.result_dir, @filename)
end

Class Method Details

.remove_all_with(prefix) ⇒ Object



5
6
7
# File 'lib/sensu_generator/check_file.rb', line 5

def self.remove_all_with(prefix)
  FileUtils.rm(Dir.glob("#{Application.config.result_dir}/#{prefix}*"))
end

Instance Method Details

#removeObject



23
24
25
# File 'lib/sensu_generator/check_file.rb', line 23

def remove
  FileUtils.rm @fullpath
end

#write(data) ⇒ Object



16
17
18
19
20
21
# File 'lib/sensu_generator/check_file.rb', line 16

def write(data)
  file = File.open(@fullpath, 'w+')
  file.write data
  file.close
  @trigger.touch
end