Class Services
In: vendor/plugins/services/lib/services.rb
Parent: Object

Methods

Public Class methods

Returns an array containing the name, UUID, ID, and version of each service that is currently loaded (basically, we’re passing on @@loadedServices)

[Source]

    # File vendor/plugins/services/lib/services.rb, line 95
95:         def Services.getLoadedServices()
96:                 value = @@loadedServices
97:                 return value
98:         end

Prints out the loaded services in a human-readable format. NOTE: will likely be replaced in the future!

[Source]

     # File vendor/plugins/services/lib/services.rb, line 101
101:         def Services.printLoadedServices()
102:                 print "MacroDeck Services\n"
103:                 print "==================\n"
104:                 print "\n"
105:                 @@loadedServices.each do |service|
106:                         print "Name: " + service[:name] + "\n"
107:                         print "Athr: " + service[:author] + "\n"
108:                         print "UUID: " + service[:uuid] + "\n"
109:                         print "ID  : " + service[:id] + "\n"
110:                         print "Ver : " + service[:version][:major].to_s + "." + service[:version][:minor].to_s + "." + service[:version][:revision].to_s +  "\n"
111:                         print "\n"
112:                 end
113:                 return nil
114:         end

Used by the services themselves to register themselves with Services.

[Source]

    # File vendor/plugins/services/lib/services.rb, line 32
32:         def Services.registerService(serviceObj)
33:                 name = serviceObj.serviceName
34:                 versionMajor = serviceObj.serviceVersionMajor
35:                 versionMinor = serviceObj.serviceVersionMinor
36:                 versionRevision = serviceObj.serviceVersionRevision
37:                 uuid = serviceObj.serviceUUID
38:                 id = serviceObj.serviceID
39:                 author = serviceObj.serviceAuthor
40:                 servicehash = Hash.new
41:                 servicehash = { :name => name, :version => { :major => versionMajor, :minor => versionMinor, :revision => versionRevision }, :uuid => uuid, :id => id, :class => serviceObj, :author => author }
42:                 @@loadedServices = @@loadedServices << servicehash
43:                 return nil
44:         end

Returns true if the service specified is started. Otherwise, returns false. Expects a UUID or a hash. If you specify a hash, it should look like this:

:id => "com.macrodeck.WhateverService"

But the symbol can be either :id, :uuid, or :name.

[Source]

    # File vendor/plugins/services/lib/services.rb, line 52
52:         def Services.serviceStarted?(serviceId)
53:                 if serviceId.class == Hash
54:                         # figure out what to look for

55:                         if serviceId[:uuid] != nil
56:                                 search = serviceId[:uuid]
57:                                 searchType = :uuid
58:                         elsif serviceId[:id] != nil
59:                                 search = serviceId[:id]
60:                                 searchType = :id
61:                         elsif serviceId[:name] != nil
62:                                 search = serviceId[:name]
63:                                 searchType = :name
64:                         end
65:                 else
66:                         # UUID specified (we hope?)

67:                         search = serviceId
68:                         searchType = :uuid
69:                 end
70:                 # Now iterate!

71:                 foundService = false
72:                 @@loadedServices.each do |service|
73:                         if searchType == :uuid
74:                                 # lowercase the UUID, since we may have uppercase

75:                                 # UUIDs for some reason.

76:                                 if service[:uuid].downcase == search.downcase
77:                                         foundService = true
78:                                 end
79:                         elsif searchType == :id
80:                                 if service[:id] == search
81:                                         foundService = true
82:                                 end
83:                         elsif searchType == :name
84:                                 if service[:name] == search
85:                                         foundService = true
86:                                 end
87:                         end
88:                 end
89:                 return foundService
90:         end

Starts a service from fileName. Returns true if successful, false if service could not be loaded, and nil if some other error occured.

[Source]

    # File vendor/plugins/services/lib/services.rb, line 21
21:         def Services.startService(fileName)
22:                 begin
23:                         require fileName
24:                         return true
25:                 rescue LoadError
26:                         return false
27:                 end
28:                 
29:         end

[Validate]