Class: RoxClient::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/rox-client-ruby/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(server, options = {}) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rox-client-ruby/client.rb', line 7

def initialize server, options = {}

  @server = server
  @publish, @local_mode, @workspace = options[:publish], options[:local_mode], options[:workspace]
  @cache_payload, @print_payload, @save_payload = options[:cache_payload], options[:print_payload], options[:save_payload]
  @client_name = options[:client_name]
  
  cache_options = { workspace: @workspace }
  cache_options.merge! server_name: @server.name, project_api_id: @server.project_api_id if @server
  cache_options.merge! client_name: @client_name if @client_name
  @cache = Cache.new cache_options

  @uid = UID.new workspace: @workspace
end

Instance Method Details

#process(test_run) ⇒ Object



22
23
24
25
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
# File 'lib/rox-client-ruby/client.rb', line 22

def process test_run

  puts
  return fail "No server to publish results to" unless @server
  return fail "Client name must be specified" unless @client_name

  test_run.uid = @uid.load_uid

  payload_options = @server.payload_options

  cache_enabled = @cache_payload && load_cache
  payload_options[:cache] = @cache if cache_enabled

  return false unless payload = build_payload(test_run, payload_options)

  published = if !@publish
    puts Paint["ROX - Publishing disabled", :yellow]
    false
  elsif publish_payload payload
    @cache.save test_run if cache_enabled
    true
  else
    false
  end

  save_payload payload if @save_payload
  print_payload payload if @print_payload

  published
end