systemd-bindings 0.0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a03f6e3e1cfe60294e119462d1f31d1cdf58ce25
4
+ data.tar.gz: dc3ecd6eca4283b9732acba7363502da8dcb4b22
5
+ SHA512:
6
+ metadata.gz: cbb3e4aea9e49af019a3a6f01952ade066688246eaad81935519adc2be2c7267bc1d30630f1b8ec4c784be12824da7172de14e0e2d8289d4a087fc7d4bad8c0e
7
+ data.tar.gz: 20a693988871c22f72430e5f8aa8cd7f931d7893fdae5ccf05d990b78df2a4f7b4fae970c2d2b0003377e950b8f472fbc8a14abe23a6d9d14d2590aa50510a84
@@ -0,0 +1,2 @@
1
+ require_relative 'systemd/systemd_manager'
2
+ require_relative 'systemd/unit/service_unit'
@@ -0,0 +1,32 @@
1
+ require 'dbus'
2
+ require_relative 'unit/service_unit'
3
+ module Systemd
4
+ # Main class to interact with systemd
5
+ class SystemdManager
6
+ def initialize
7
+ dbus = DBus::SystemBus.instance
8
+ systemd_service = dbus.service('org.freedesktop.systemd1')
9
+ @systemd_object = systemd_service.object('/org/freedesktop/systemd1')
10
+ @systemd_object.introspect
11
+ @units = {}
12
+ refresh_units
13
+ end
14
+
15
+ def units
16
+ @units.values
17
+ end
18
+
19
+ def get_unit(unit_name)
20
+ @units[unit_name]
21
+ end
22
+
23
+ def refresh_units
24
+ @units.clear
25
+ unit_list = @systemd_object.ListUnits()
26
+ unit_list.first.each do |unit|
27
+ current_unit = Systemd::Unit::ServiceUnit.new(unit)
28
+ @units[current_unit.name] = current_unit
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,20 @@
1
+ module Systemd
2
+ # Systemd unit definitons
3
+ module Unit
4
+ # Object representation of a Systemd Service Unit object
5
+ class ServiceUnit
6
+ # Systemd mapping of properties to array index
7
+ # see https://www.freedesktop.org/wiki/Software/systemd/dbus/
8
+ # rubocop:disable Style/ClassVars
9
+ @@indices = { name: 0, human_name: 1, load_state: 2,
10
+ active_state: 3, sub_state: 4, follower: 5, object_path: 6,
11
+ job_id: 7, job_type: 8, job_path: 9 }
12
+ # rubocop:enable Style/ClassVars
13
+ attr_accessor(*@@indices.keys)
14
+
15
+ def initialize(unit_entry)
16
+ @@indices.each { |key, value| send("#{key}=", unit_entry[value]) }
17
+ end
18
+ end
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: systemd-bindings
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Bobby Martin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby-dbus
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.11.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.11.0
27
+ description: Ruby bindings for systemd via DBUS api calls
28
+ email: nyxcharon@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/systemd.rb
34
+ - lib/systemd/systemd_manager.rb
35
+ - lib/systemd/unit/service_unit.rb
36
+ homepage: http://github.com/nyxcharon/ruby-systemd
37
+ licenses:
38
+ - MIT
39
+ metadata: {}
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project:
56
+ rubygems_version: 2.4.8
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: Ruby bindings for systemd
60
+ test_files: []
61
+ has_rdoc: