Class: CcTray::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/cctray/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ Server

Returns a new instance of Server.



11
12
13
14
15
16
# File 'lib/cctray/server.rb', line 11

def initialize(url, options = {})
  self.url = url
  self.options = options

  self.projects = {}
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



9
10
11
# File 'lib/cctray/server.rb', line 9

def options
  @options
end

#projectsObject

Returns the value of attribute projects.



9
10
11
# File 'lib/cctray/server.rb', line 9

def projects
  @projects
end

#urlObject

Returns the value of attribute url.



9
10
11
# File 'lib/cctray/server.rb', line 9

def url
  @url
end

Instance Method Details

#[](name) ⇒ Object



31
32
33
# File 'lib/cctray/server.rb', line 31

def [](name)
  projects[name]
end

#building?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/cctray/server.rb', line 40

def building?
  any?(&:building?)
end

#failure?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/cctray/server.rb', line 48

def failure?
  any?(&:failure?)
end

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cctray/server.rb', line 18

def run
  deferred = EventMachine::Q.defer

  http = request.get request_options
  http.errback { deferred.reject 'request failed' }
  http.callback {
    parse http.response
    deferred.resolve self.projects
  }

  deferred.promise
end

#sleeping?Boolean

summary methods

Returns:

  • (Boolean)


36
37
38
# File 'lib/cctray/server.rb', line 36

def sleeping?
  all?.(&:sleeping?)
end

#success?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/cctray/server.rb', line 44

def success?
  all?(&:success?)
end