Class: TeutonFile

Inherits:
Object
  • Object
show all
Defined in:
lib/teuton/case/builtin/teuton_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(teuton_host, param) ⇒ TeutonFile

Returns a new instance of TeutonFile.



2
3
4
5
6
7
8
# File 'lib/teuton/case/builtin/teuton_file.rb', line 2

def initialize(teuton_host, param)
  @teuton_host = teuton_host
  @parent = teuton_host.parent
  @result = @parent.result
  @host = teuton_host.host
  @param = param
end

Instance Method Details

#directory?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'lib/teuton/case/builtin/teuton_file.rb', line 16

def directory?
  @parent.target("File #{@param} is directory?")
  @parent.run "file #{@param}", on: @host
  @parent.expect @result.grep_v("cannot open").grep(@param).grep("directory").count.eq 1
end

#exist?Boolean

Returns:

  • (Boolean)


10
11
12
13
14
# File 'lib/teuton/case/builtin/teuton_file.rb', line 10

def exist?
  @parent.target("File #{@param} exists?")
  @parent.run "file #{@param}", on: @host
  @parent.expect @result.grep_v("cannot open").grep(@param).count.eq 1
end

#regular?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
# File 'lib/teuton/case/builtin/teuton_file.rb', line 22

def regular?
  @parent.target("File #{@param} is regular?")
  @parent.run "file #{@param}", on: @host
  @parent.expect @result.grep(@param).grep("directory").count.eq 0
end