Class: DBus::Systemd::Manager
Constant Summary
collapse
- NODE =
'/org/freedesktop/systemd1'
- INTERFACE =
'org.freedesktop.systemd1.Manager'
- UNIT_INDICES =
{
name: 0,
description: 1,
load_state: 2,
active_state: 3,
sub_state: 4,
following: 5,
object_path: 6,
job_id: 7,
job_type: 8,
job_object_path: 9
}
- JOB_INDICES =
{
id: 0,
unit: 1,
type: 2,
state: 3,
object_path: 4,
unit_object_path: 5
}
Instance Attribute Summary collapse
#object
Instance Method Summary
collapse
#method_missing, #respond_to_missing?
Constructor Details
#initialize(bus = Systemd::Helpers.system_bus) ⇒ Manager
Returns a new instance of Manager.
44
45
46
47
48
|
# File 'lib/dbus/systemd/manager.rb', line 44
def initialize(bus = Systemd::Helpers.system_bus)
@service = bus.service(Systemd::INTERFACE)
@object = @service.object(NODE)
.tap(&:introspect)
end
|
Instance Attribute Details
#service ⇒ Object
Returns the value of attribute service.
42
43
44
|
# File 'lib/dbus/systemd/manager.rb', line 42
def service
@service
end
|
Instance Method Details
#get_job_by_object_path(path) ⇒ Object
76
77
78
79
80
|
# File 'lib/dbus/systemd/manager.rb', line 76
def get_job_by_object_path(path)
obj = @service.object(path)
.tap(&:introspect)
Job.new(obj.Get(Job::INTERFACE, 'Id').first, self)
end
|
#get_unit_by_object_path(path) ⇒ Object
58
59
60
61
62
|
# File 'lib/dbus/systemd/manager.rb', line 58
def get_unit_by_object_path(path)
obj = @service.object(path)
.tap(&:introspect)
Unit.new(obj.Get(Unit::INTERFACE, 'Id').first, self)
end
|
#job(id) ⇒ Object
72
73
74
|
# File 'lib/dbus/systemd/manager.rb', line 72
def job(id)
Job.new(id, self)
end
|
#jobs ⇒ Object
68
69
70
|
# File 'lib/dbus/systemd/manager.rb', line 68
def jobs
self.ListJobs.first.map { |j| map_job(j) }
end
|
#map_job(job_array) ⇒ Object
82
83
84
|
# File 'lib/dbus/systemd/manager.rb', line 82
def map_job(job_array)
Helpers.map_array(job_array, JOB_INDICES)
end
|
#map_unit(unit_array) ⇒ Object
64
65
66
|
# File 'lib/dbus/systemd/manager.rb', line 64
def map_unit(unit_array)
Helpers.map_array(unit_array, UNIT_INDICES)
end
|
#unit(name) ⇒ Object
54
55
56
|
# File 'lib/dbus/systemd/manager.rb', line 54
def unit(name)
Unit.new(name, self)
end
|
#units ⇒ Object
50
51
52
|
# File 'lib/dbus/systemd/manager.rb', line 50
def units
self.ListUnits.first.map { |u| map_unit(u) }
end
|