Class: TestRail::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/test_rail_integration/generator/command.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id_of_run) ⇒ Command

Returns a new instance of Command.



12
13
14
# File 'lib/test_rail_integration/generator/command.rb', line 12

def initialize(id_of_run)
  self.id = id_of_run
end

Instance Attribute Details

#commandObject

Returns the value of attribute command.



5
6
7
# File 'lib/test_rail_integration/generator/command.rb', line 5

def command
  @command
end

#envObject

Returns the value of attribute env.



5
6
7
# File 'lib/test_rail_integration/generator/command.rb', line 5

def env
  @env
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/test_rail_integration/generator/command.rb', line 5

def id
  @id
end

#tagsObject

Returns the value of attribute tags.



5
6
7
# File 'lib/test_rail_integration/generator/command.rb', line 5

def tags
  @tags
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/test_rail_integration/generator/command.rb', line 5

def type
  @type
end

#ventureObject

Returns the value of attribute venture.



5
6
7
# File 'lib/test_rail_integration/generator/command.rb', line 5

def venture
  @venture
end

Class Method Details

.execute_command(command) ⇒ Object



39
40
41
# File 'lib/test_rail_integration/generator/command.rb', line 39

def self.execute_command(command)
  exec("#{command}")
end

Instance Method Details

#executeObject



16
17
18
19
# File 'lib/test_rail_integration/generator/command.rb', line 16

def execute
  p "Gem will execute command: #{self.command}"
  TestRail::Command.execute_command("#{self.command}")
end

#generateObject



21
22
23
24
25
26
27
28
# File 'lib/test_rail_integration/generator/command.rb', line 21

def generate
  #TODO do smth with weird replacement
  if venture.nil? || env.nil?
    self.command = self.command + " " + get_tags
  else
    self.command = self.command.gsub("\#{parameters.venture}", self.venture).gsub("\#{parameters.environment}", self.env) + " " + get_tags
  end
end

#get_tagsObject



30
31
32
33
34
35
36
37
# File 'lib/test_rail_integration/generator/command.rb', line 30

def get_tags
  if self.type.nil?
    cases = Connection.cases_ids_by_default(self.id)
  else
    cases = Connection.cases_ids_by_type(self.id, self.type)
  end
  cases.map { |id| "@C"+id.to_s }.join(",")
end