Class: Applitools::BatchInfo

Inherits:
Object
  • Object
show all
Extended by:
Helpers
Defined in:
lib/applitools/core/batch_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

abstract_attr_accessor, abstract_method, env_variable, environment_attribute, environment_variables

Constructor Details

#initialize(args = nil, started_at = Time.now) ⇒ BatchInfo

Returns a new instance of BatchInfo.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/applitools/core/batch_info.rb', line 20

def initialize(args = nil, started_at = Time.now)
  case args
    when String
      name = args
    when Hash
      sym_args = Applitools::Utils.symbolize_keys args
      id ||= sym_args[:id]
      name ||= sym_args[:name]
      sequence_name ||= sym_args[:sequence_name]
      properties ||= sym_args[:properties]
  end
  self.name = name if name
  self.sequence_name = sequence_name if sequence_name
  @started_at = started_at
  if id
    self.id = id
  elsif self.id.nil? || self.id.empty?
    self.id = PROCESS_DEFAULT_BATCH_ID
  end
  self.properties = properties if properties
  unless env_notify_on_completion.nil?
    self.notify_on_completion = 'true'.casecmp(env_notify_on_completion || '') == 0 ? true : false
  end
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



12
13
14
# File 'lib/applitools/core/batch_info.rb', line 12

def id
  @id
end

#notify_on_completionObject

Returns the value of attribute notify_on_completion.



12
13
14
# File 'lib/applitools/core/batch_info.rb', line 12

def notify_on_completion
  @notify_on_completion
end

#propertiesObject

Returns the value of attribute properties.



12
13
14
# File 'lib/applitools/core/batch_info.rb', line 12

def properties
  @properties
end

#started_atObject

Returns the value of attribute started_at.



12
13
14
# File 'lib/applitools/core/batch_info.rb', line 12

def started_at
  @started_at
end

Instance Method Details

#json_dataObject



45
46
47
48
49
50
51
52
53
54
# File 'lib/applitools/core/batch_info.rb', line 45

def json_data
  {
      'id' => id,
      'name' => name,
      'startedAt' => @started_at.iso8601,
      'sequenceName' => sequence_name,
      'notifyOnCompletion' => notify_on_completion,
      'properties' => properties
  }
end

#to_hashObject

export type Batch =

id?: string
name?: string
sequenceName?: string
startedAt?: Date | string
notifyOnCompletion?: boolean
properties?: CustomProperty[]

export type CustomProperty =

name: string
value: string



68
69
70
71
72
73
74
75
76
77
# File 'lib/applitools/core/batch_info.rb', line 68

def to_hash
  {
    id: id,
    name: name, # 'Ruby Coverage Tests',
    startedAt: @started_at.iso8601,
    sequenceName: sequence_name,
    notifyOnCompletion: notify_on_completion,
    properties: properties
  }.compact
end

#to_sObject



79
80
81
# File 'lib/applitools/core/batch_info.rb', line 79

def to_s
  to_hash.to_s
end