Permalink
Browse files

moving forward

  • Loading branch information...
1 parent b85552e commit 919f948b4b2ccf07969b00f718d2b83c4fd22dda @swistaczek committed Mar 30, 2013
Showing with 71 additions and 11 deletions.
  1. +10 −10 .gitignore
  2. +4 −1 Gemfile
  3. +21 −0 lib/network_manager/modem.rb
  4. +36 −0 lib/ruby-network-manager.rb
View
@@ -27,23 +27,23 @@ pkg
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
#
# For MacOS:
-#
-#.DS_Store
+
+.DS_Store
# For TextMate
-#*.tmproj
-#tmtags
+*.tmproj
+tmtags
# For emacs:
-#*~
-#\#*
-#.\#*
+*~
+\#*
+.\#*
# For vim:
-#*.swp
+*.swp
# For redcar:
-#.redcar
+.redcar
# For rubinius:
-#*.rbc
+*.rbc
View
@@ -1,8 +1,10 @@
-source "http://rubygems.org"
+source "https://rubygems.org"
# Add dependencies required to use your gem here.
# Example:
# gem "activesupport", ">= 2.3.5"
+gem 'ruby-dbus', require: 'dbus', git: 'git://github.com/mvidner/ruby-dbus.git'
+
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
@@ -11,4 +13,5 @@ group :development do
gem "bundler", "~> 1.0.0"
gem "jeweler", "~> 1.8.4"
gem "rcov", ">= 0"
+ gem 'pry'
end
@@ -0,0 +1,21 @@
+# encoding: utf-8
+class NetworkManager::Modem
+ attr_reader :bus_path
+
+ def initialize(opts)
+ args.each do |k,v|
+ instance_variable_set("@#{k}", v) unless v.nil?
+ end
+ end
+
+ class << self
+ def fetch(paths_array)
+ devices = []
+ paths_array.each do |path|
+ devices << self.new(bus_path: path)
+ end
+ devices
+ end
+ end
+
+end
@@ -0,0 +1,36 @@
+# encoding: utf-8
+class NetworkManager
+ attr_reader :service, :bus_path, :mm_object
+
+ def initialize(opts = {})
+ set_options opts
+ @bus = DBus::SystemBus.instance
+ @mm_service = @bus[@service]
+ @mm_object = @mm_service.object(@bus_path)
+ @mm_object.introspect
+ end
+
+ # Discover all enabled devices
+ def devices(opts = {})
+ @devices = []
+ @mm_object.introspect
+ @mm_object.EnumerateDevices()
+
+ end
+
+ class << self
+
+ end
+
+ protected
+
+ def set_options(opts = {})
+ @service ||= 'org.freedesktop.ModemManager'
+ @bus_path ||= '/org/freedesktop/ModemManager'
+
+ args.each do |k,v|
+ instance_variable_set("@#{k}", v) unless v.nil?
+ end
+ end
+
+end

0 comments on commit 919f948

Please sign in to comment.