Class: AutoPilot::PassFailFile

Inherits:
Object
  • Object
show all
Defined in:
lib/auto_pilot/files.rb

Overview

File to which “pass” or “fail” is written for each suite run by autopilot.

Constant Summary collapse

FILE_NAME =
"result.txt"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ PassFailFile

Returns a new instance of PassFailFile.



10
11
12
13
# File 'lib/auto_pilot/files.rb', line 10

def initialize(dir)
  @dir = dir
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



8
9
10
# File 'lib/auto_pilot/files.rb', line 8

def data
  @data
end

#dirObject (readonly)

Returns the value of attribute dir.



8
9
10
# File 'lib/auto_pilot/files.rb', line 8

def dir
  @dir
end

Class Method Details

.clean(dir) ⇒ Object



29
30
31
32
# File 'lib/auto_pilot/files.rb', line 29

def self.clean(dir)
  path = dir + File::SEPARATOR + FILE_NAME
  FileUtils.rm_f path if File.exist? path
end

Instance Method Details

#append(data) ⇒ Object



20
21
22
23
# File 'lib/auto_pilot/files.rb', line 20

def append(data)
  FileUtils.mkdir(@dir) unless File.exist?(@dir)
  File.open(self.path, 'a'){|out| out.write "#{data}\n"}
end

#clean!Object



25
26
27
# File 'lib/auto_pilot/files.rb', line 25

def clean!
  FileUtils.rm_f self.path if File.exist? self.path
end

#pathObject

TODO make a default and configurable name for the file



35
36
37
# File 'lib/auto_pilot/files.rb', line 35

def path
  @dir + File::SEPARATOR + FILE_NAME
end

#write(data) ⇒ Object

TODO just make alias or make write destructive?



16
17
18
# File 'lib/auto_pilot/files.rb', line 16

def write data
  append(data)
end