Class: XamarinTestCloud::TestFile

Inherits:
Object
  • Object
show all
Defined in:
lib/xamarin-test-cloud/test_file.rb

Overview

Appropriate for files under features/, <tmpdir>/ and test_servers/

Not appropriate for app and dysm files.

To create a Cucumber configuration instance, use ‘TestFile.cucumber_config`.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, basedir) ⇒ TestFile

Returns a new instance of TestFile.

Parameters:

  • path (String)

    Needs to be expanded

  • basedir (String)

    Needs to be the beginning of the path



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/xamarin-test-cloud/test_file.rb', line 39

def initialize(path, basedir)
  @path = path
  @basedir = basedir

  expanded = File.expand_path(path)
  if path != File.expand_path(expanded)
    raise ArgumentError, %Q[Path must be expanded:

path: #{path}
expanded: #{expanded}
]
  end

  if !path.start_with?(basedir)
    raise ArgumentError, %Q[Path must start with basedir:

path: #{path}
 basedir: #{basedir}

]
  end
end

Instance Attribute Details

#digestObject (readonly)

Returns the value of attribute digest.



35
36
37
# File 'lib/xamarin-test-cloud/test_file.rb', line 35

def digest
  @digest
end

#file_instanceObject (readonly)

Returns the value of attribute file_instance.



35
36
37
# File 'lib/xamarin-test-cloud/test_file.rb', line 35

def file_instance
  @file_instance
end

#pathObject (readonly)

Returns the value of attribute path.



35
36
37
# File 'lib/xamarin-test-cloud/test_file.rb', line 35

def path
  @path
end

#remote_pathObject (readonly)

Returns the value of attribute remote_path.



35
36
37
# File 'lib/xamarin-test-cloud/test_file.rb', line 35

def remote_path
  @remote_path
end

Class Method Details

.cucumber_config(file) ⇒ Object

Special handling for Cucumber configuration files.

The server expects the remote file name to be exactly config/cucumber.yml



29
30
31
32
33
# File 'lib/xamarin-test-cloud/test_file.rb', line 29

def self.cucumber_config(file)
  test_file = TestFile.new(file, File.dirname(file))
  test_file.instance_variable_set(:@remote_path, "config/cucumber.yml")
  test_file
end

.file_digest(file, digest = :SHA256) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/xamarin-test-cloud/test_file.rb', line 11

def self.file_digest(file, digest=:SHA256)
  case digest
    when :SHA256
      require "digest"
      Digest::SHA256.file(file).hexdigest
    when :MD5
      require "digest/md5"
      Digest::MD5.file(file).hexdigest
    else
      raise ArgumentError, %Q[Invalid digest type: #{digest}.
Only :SHA256 or :MD5 are supported
]
  end
end

Instance Method Details

#inspectObject



66
67
68
# File 'lib/xamarin-test-cloud/test_file.rb', line 66

def inspect
  to_s
end

#to_sObject



62
63
64
# File 'lib/xamarin-test-cloud/test_file.rb', line 62

def to_s
  %Q[#<TestFile: #{@path} #{@digest} #{@remote_path}>]
end