Class: CF::TestRun

Inherits:
Object
  • Object
show all
Includes:
Client
Defined in:
lib/cf/test_run.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line, title, gold_standards_number) ⇒ TestRun

Initializes a new Run

Usage Example:

run = CF::Run.new("line_title", "run name", file_path)

OR

You can pass line object instead of passing line title:

run = CF::Run.new(line_object, "run name", file_path)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/cf/test_run.rb', line 26

def initialize(line, title, gold_standards_number)
  @gold_standards_number = gold_standards_number # a number that denotes how many goldstandard form line should be included to create units
  if line.class == CF::Line || line.class == Hashie::Mash
    @line = line
    @line_title = line.title
  elsif line.class == String
    if line.split("/").count == 2
      @account = line.split("/").first
      @line_title = line.split("/").last
    elsif line.split("/").count == 1
      @line_title = line
    end
  end
  @title = title
  if gold_standards_number
    options =
    {
      :body =>
      {
        :api_key => CF.api_key,
        :data =>{:run => { :title => @title ,:test =>"true"}, :gold_standard_inputs => @gold_standards_number}
      }
    }
    if line.class == String && line.split("/").count == 2
      run =  HTTParty.post("#{CF.api_url}#{CF.api_version}/lines/#{@account}/#{@line_title.downcase}/runs.json",options)
    else
      run =  HTTParty.post("#{CF.api_url}#{CF.api_version}/lines/#{CF.}/#{@line_title.downcase}/runs.json",options)
    end
    if run.code != 200
      self.errors = run.parsed_response['error']['message']
    end
  else
    self.errors = "Number of GoldStandards to be used is not provided"
  end
end

Instance Attribute Details

#errorsObject

Contains Error Message if any



16
17
18
# File 'lib/cf/test_run.rb', line 16

def errors
  @errors
end

#gold_standard_inputsObject

Input to be passed for Production Run



10
11
12
# File 'lib/cf/test_run.rb', line 10

def gold_standard_inputs
  @gold_standard_inputs
end

#lineObject

Line attribute with which run is associated



13
14
15
# File 'lib/cf/test_run.rb', line 13

def line
  @line
end

#titleObject

Title of the “run” object



7
8
9
# File 'lib/cf/test_run.rb', line 7

def title
  @title
end

Class Method Details

.create(line, title, input_number) ⇒ Object



62
63
64
# File 'lib/cf/test_run.rb', line 62

def self.create(line, title, input_number)
  TestRun.new(line, title, input_number)
end