dbus-systemd 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ea53af0fec820f37809e129092b1473434e59575
4
+ data.tar.gz: b4bbf209b0133adb70962a75a6491c1ae6da98dc
5
+ SHA512:
6
+ metadata.gz: 5c3d6d5454127c8c6ff7887fbe4e5801d7646af8c541d7d138ce68264a249d0bfbb521f303eef8f2aaf86af0ab0c6e0685ae9a0b82fd0715f47848c8545c628d
7
+ data.tar.gz: 6ca8c7c10100204029d81af055ed25d771170880994ca87f2847b71172e014a9bbf05d29fd2f561ff179c9e01ce00f1646ea0cf45e9d880b3ef80cfa51165cf8
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.vagrant/
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.12.5
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Nathan Williams
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Dbus::Systemd
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dbus/systemd`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'dbus-systemd'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install dbus-systemd
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nathwill/ruby-dbus-systemd.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/Vagrantfile ADDED
@@ -0,0 +1,11 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure("2") do |config|
5
+ config.vm.box = "bento/fedora-24"
6
+ config.vm.box_check_update = true
7
+
8
+ config.vm.provision "shell", inline: <<-SHELL
9
+ dnf install -y git ruby rubygem-bundler
10
+ SHELL
11
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "dbus/systemd"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dbus/systemd/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dbus-systemd"
8
+ spec.version = DBus::Systemd::VERSION
9
+ spec.authors = ["Nathan Williams"]
10
+ spec.email = ["nath.e.will@gmail.com"]
11
+
12
+ spec.summary = 'library for interfacing with systemd over dbus'
13
+ spec.description = spec.summary
14
+ spec.homepage = "https://github.com/nathwill/ruby-dbus-systemd"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_runtime_dependency "ruby-dbus", "~> 0.13"
31
+
32
+ spec.add_development_dependency "bundler", "~> 1.10"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "rspec", "~> 3.0"
35
+ end
@@ -0,0 +1,22 @@
1
+ require_relative "systemd/version"
2
+ require_relative "systemd/manager"
3
+ require_relative "systemd/unit"
4
+ require_relative "systemd/job"
5
+
6
+ require "dbus"
7
+
8
+ module DBus
9
+ module Systemd
10
+ INTERFACE = 'org.freedesktop.systemd1'
11
+
12
+ def system_bus
13
+ DBus::SystemBus.instance
14
+ end
15
+
16
+ def session_bus
17
+ DBus::SessionBus.instance
18
+ end
19
+
20
+ module_function :system_bus, :session_bus
21
+ end
22
+ end
@@ -0,0 +1,12 @@
1
+ module DBus
2
+ module Systemd
3
+ class Job
4
+ INTERFACE = 'org.freedesktop.systemd1.Job'
5
+
6
+ def initialize(id, manager = DBus::Systemd::Manager.new)
7
+ job_path = manager.object.GetJob(id).first
8
+ @object = manager.service.object(job_path).tap(&:introspect)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,83 @@
1
+ require_relative '../systemd'
2
+ require_relative 'unit'
3
+
4
+ module DBus
5
+ module Systemd
6
+ class Manager
7
+ OBJECT = '/org/freedesktop/systemd1'
8
+ INTERFACE = 'org.freedesktop.systemd1.Manager'
9
+
10
+ UNIT_INDICES = {
11
+ name: 0,
12
+ description: 1,
13
+ load_state: 2,
14
+ active_state: 3,
15
+ sub_state: 4,
16
+ following: 5,
17
+ object_path: 6,
18
+ job_id: 7,
19
+ job_type: 8,
20
+ job_object_path: 9
21
+ }
22
+
23
+ JOB_INDICES = {
24
+ id: 0,
25
+ unit: 1,
26
+ type: 2,
27
+ state: 3,
28
+ object_path: 4,
29
+ unit_object_path: 5
30
+ }
31
+
32
+ attr_accessor :service, :object
33
+
34
+ def initialize(bus = DBus::Systemd.system_bus)
35
+ @service = bus.service(DBus::Systemd::INTERFACE)
36
+ @object = @service.object(OBJECT)
37
+ .tap(&:introspect)
38
+ end
39
+
40
+ def units
41
+ @object.ListUnits.first.map { |u| u[UNIT_INDICES[:name]] }
42
+ end
43
+
44
+ def unit(name)
45
+ Unit.new(name, self)
46
+ end
47
+
48
+ def get_unit_by_object_path(path)
49
+ obj = @service.object(path).tap(&:introspect)
50
+ Unit.new(obj.Get(Unit::INTERFACE, 'Id').first, self)
51
+ end
52
+
53
+ def map_unit(unit_array)
54
+ mapped = {}
55
+
56
+ unit_array.each_with_index do |item, index|
57
+ mapped[UNIT_INDICES.key(index)] = item
58
+ end
59
+
60
+ mapped
61
+ end
62
+
63
+ def job(id)
64
+ Job.new(id, self)
65
+ end
66
+
67
+ def get_job_by_object_path(path)
68
+ obj = @service.object(path).tap(&:introspect)
69
+ Job.new(obj.Get(Job::INTERFACE, 'Id').first, self)
70
+ end
71
+
72
+ def map_job(job_array)
73
+ mapped = {}
74
+
75
+ job_array.each_with_index do |item, index|
76
+ mapped[JOB_INDICES.key(index)] = item
77
+ end
78
+
79
+ mapped
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,16 @@
1
+ require_relative 'manager'
2
+
3
+ module DBus
4
+ module Systemd
5
+ class Unit
6
+ INTERFACE = 'org.freedesktop.systemd1.Unit'
7
+
8
+ attr_accessor :object
9
+
10
+ def initialize(name, manager = DBus::Systemd::Manager.new)
11
+ unit_path = manager.object.GetUnit(name).first
12
+ @object = manager.service.object(unit_path).tap(&:introspect)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../unit'
2
+
3
+ module DBus::Systemd
4
+ class Unit
5
+ class Automount < Unit
6
+ INTERFACE = 'org.freedesktop.systemd1.Service'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../unit'
2
+
3
+ module DBus::Systemd
4
+ class Unit
5
+ class Device < Unit
6
+ INTERFACE = 'org.freedesktop.systemd1.Device'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../unit'
2
+
3
+ module DBus::Systemd
4
+ class Unit
5
+ class Mount < Unit
6
+ INTERFACE = 'org.freedesktop.systemd1.Mount'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../unit'
2
+
3
+ module DBus::Systemd
4
+ class Unit
5
+ class Path < Unit
6
+ INTERFACE = 'org.freedesktop.systemd1.Path'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../unit'
2
+
3
+ module DBus::Systemd
4
+ class Unit
5
+ class Scope < Unit
6
+ INTERFACE = 'org.freedesktop.systemd1.Scope'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../unit'
2
+
3
+ module DBus::Systemd
4
+ class Unit
5
+ class Service < Unit
6
+ INTERFACE = 'org.freedesktop.systemd1.Service'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../unit'
2
+
3
+ module DBus::Systemd
4
+ class Unit
5
+ class Slice < Unit
6
+ INTERFACE = 'org.freedesktop.systemd1.Slice'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../unit'
2
+
3
+ module DBus::Systemd
4
+ class Unit
5
+ class Snapshot < Unit
6
+ INTERFACE = 'org.freedesktop.systemd1.Snapshot'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../unit'
2
+
3
+ module DBus::Systemd
4
+ class Unit
5
+ class Socket < Unit
6
+ INTERFACE = 'org.freedesktop.systemd1.Socket'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../unit'
2
+
3
+ module DBus::Systemd
4
+ class Unit
5
+ class Swap < Unit
6
+ INTERFACE = 'org.freedesktop.systemd1.Swap'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../unit'
2
+
3
+ module DBus::Systemd
4
+ class Unit
5
+ class Target < Unit
6
+ INTERFACE = 'org.freedesktop.systemd1.Target'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../unit'
2
+
3
+ module DBus::Systemd
4
+ class Unit
5
+ class Timer < Unit
6
+ INTERFACE = 'org.freedesktop.systemd1.Unit'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module DBus
2
+ module Systemd
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dbus-systemd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Williams
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-10-02 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.13'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: library for interfacing with systemd over dbus
70
+ email:
71
+ - nath.e.will@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - Vagrantfile
84
+ - bin/console
85
+ - bin/setup
86
+ - dbus-systemd.gemspec
87
+ - lib/dbus/systemd.rb
88
+ - lib/dbus/systemd/job.rb
89
+ - lib/dbus/systemd/manager.rb
90
+ - lib/dbus/systemd/unit.rb
91
+ - lib/dbus/systemd/unit/automount.rb
92
+ - lib/dbus/systemd/unit/device.rb
93
+ - lib/dbus/systemd/unit/mount.rb
94
+ - lib/dbus/systemd/unit/path.rb
95
+ - lib/dbus/systemd/unit/scope.rb
96
+ - lib/dbus/systemd/unit/service.rb
97
+ - lib/dbus/systemd/unit/slice.rb
98
+ - lib/dbus/systemd/unit/snapshot.rb
99
+ - lib/dbus/systemd/unit/socket.rb
100
+ - lib/dbus/systemd/unit/swap.rb
101
+ - lib/dbus/systemd/unit/target.rb
102
+ - lib/dbus/systemd/unit/timer.rb
103
+ - lib/dbus/systemd/version.rb
104
+ homepage: https://github.com/nathwill/ruby-dbus-systemd
105
+ licenses:
106
+ - MIT
107
+ metadata:
108
+ allowed_push_host: https://rubygems.org
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.6.4
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: library for interfacing with systemd over dbus
129
+ test_files: []