ruby-network-manager 1.0.12 → 1.0.16

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.12
1
+ 1.0.16
@@ -1,8 +1,12 @@
1
1
  # encoding: utf-8
2
+ require 'pry'
3
+
2
4
  class NetworkManager
3
5
  class Modem
4
6
  attr_reader :bus_path, :service
5
7
 
8
+ class NotValid < StandardError ; end
9
+
6
10
  def initialize(opts = {})
7
11
  opts.each do |k,v|
8
12
  instance_variable_set("@#{k}", v) unless v.nil?
@@ -17,7 +21,8 @@ class NetworkManager
17
21
  @proxy = @service.object(@bus_path)
18
22
  @proxy.introspect
19
23
 
20
- @properties = @proxy[NetworkManager::DBUS_PROPERTIES]
24
+ @properties = @proxy.dup
25
+ @properties.default_iface = NetworkManager::DBUS_PROPERTIES
21
26
  @properties.introspect
22
27
 
23
28
  @s_modem = @proxy[NetworkManager::MM_DBUS_INTERFACE_MODEM_SIMPLE]
@@ -26,6 +31,11 @@ class NetworkManager
26
31
  @ussd = @proxy[NetworkManager::MM_DBUS_INTERFACE_MODEM_GSM_USSD]
27
32
 
28
33
  @device_info = @properties.GetInfo[0] rescue nil
34
+ raise NetworkManager::Modem::NotValid unless valid?
35
+ end
36
+
37
+ def valid?
38
+ @properties.interfaces.size > 0
29
39
  end
30
40
 
31
41
  def enable!
@@ -131,7 +141,11 @@ class NetworkManager
131
141
  def fetch(paths_array, opts = {})
132
142
  devices = []
133
143
  paths_array.compact.reject {|x| x && x.size <= 0 }.each do |path|
134
- devices << self.new(opts.merge({bus_path: path}))
144
+ begin
145
+ devices << self.new(opts.merge({bus_path: path}))
146
+ rescue NetworkManager::Modem::NotValid => e
147
+ puts "Bus #{path} contains empty object, skipping"
148
+ end
135
149
  end
136
150
  devices
137
151
  end
@@ -18,12 +18,12 @@ class NetworkManager
18
18
  def initialize(opts = {})
19
19
  set_options opts
20
20
  @bus = DBus::SystemBus.instance
21
- @mm_service = @bus.service(@modem_service)
22
- @mm_object = @mm_service.object(@modem_bus_path)
23
21
  end
24
22
 
25
23
  # Discover all enabled devices
26
24
  def modems(opts = {})
25
+ @mm_service = @bus.service(@modem_service)
26
+ @mm_object = @mm_service.object(@modem_bus_path)
27
27
  @mm_object.introspect
28
28
  NetworkManager::Modem.fetch(@mm_object.EnumerateDevices()[0], service: @mm_service)
29
29
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ruby-network-manager"
8
- s.version = "1.0.12"
8
+ s.version = "1.0.16"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ernest Bursa"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-network-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.0.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -143,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  segments:
145
145
  - 0
146
- hash: -2938569556196178749
146
+ hash: -1380551862488981491
147
147
  required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  none: false
149
149
  requirements: