Class: A4Tools::DeploymentClient

Inherits:
CachingClient show all
Defined in:
lib/clients/deployment_client.rb

Instance Attribute Summary collapse

Attributes inherited from CachingClient

#timeout

Attributes inherited from AcresClient

#connect_time, #connected, #history, #password, #ready, #server_info, #start_time, #token, #uri, #username, #version

Instance Method Summary collapse

Methods inherited from CachingClient

#[], cache, #cache, #dirty, #ensure_fresh, #fresh?, #initialize, #query, query, #refresh, #refresh_async, #send_update_request, #timestamp_expired?, #update_from_method

Methods inherited from AcresClient

#add_message_to_history, #app_info, #attempt_snoop, #authenticate, #authenticate_if_needed, #connect, #connect_if_needed, #device_info, #disconnect, #empty_query, #initialize, #inject_token, #jsonrpc_message, #make_password, #next_msg_id, #response_body, #send_message, #snoop_token, #transport_connect, #wrapped_message

Methods included from EventGenerator

#on, #passthrough, #signal

Constructor Details

This class inherits a constructor from A4Tools::CachingClient

Instance Attribute Details

#cache_timeoutObject

Returns the value of attribute cache_timeout.



3
4
5
# File 'lib/clients/deployment_client.rb', line 3

def cache_timeout
  @cache_timeout
end

Instance Method Details

#builds_for_milestone(milestone, builds = nil) ⇒ Object



47
48
49
50
51
# File 'lib/clients/deployment_client.rb', line 47

def builds_for_milestone(milestone, builds=nil)
  index = index_list_by_app(builds)
  in_milestone = []
  (index.map { |app, builds| (builds.select { |b| b[:branches].is_a? Array and b[:branches].include? milestone }).last }).compact
end

#index_list_by_appObject



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/clients/deployment_client.rb', line 35

def index_list_by_app
  builds = cache(:buildList)
  apps = {}
  builds.each do |build|
    apps[build[:appId]] ||= []
    apps[build[:appId]].push build
  end

  apps.values.each { |app_builds| app_builds.sort! { |a,b| a[:postDate] <=> b[:postDate] } }
  apps
end

#publish_build(build, sites) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/clients/deployment_client.rb', line 18

def publish_build(build, sites)
  sites = [*sites]
  return false unless authenticate_if_needed

  request = {
    commitId:build[:commitId],
    appIds:[build[:appId]],
    publicationTime:0,
    siteIds:sites
  }

  result = send_message(wrapped_message("buildPublish", "com.acres4.common.info.build.BuildPublishRequest", request))
  return false unless result.code.to_i >= 200 and result.code.to_i < 300

  true
end