smi-ffi 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,21 +1,4 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in smi-ffi.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'rspec'
8
+ end
data/README.rdoc CHANGED
@@ -1,6 +1,19 @@
1
1
  = smi-ffi
2
2
 
3
- Description goes here.
3
+ FFI wrapper around libsmi. Useful for translating SNMP oids.
4
+ You should have libsmi installed, and a directory with any MIB files you want to use.
5
+
6
+ # Set path to MIBs, initialize libsmi, and load the standard RFC1213 MIB
7
+ Smi::Config.set_path('/usr/local/share/mibs')
8
+ Smi::Config.init(nil) # You MUST call this
9
+ Smi::Config.load_module("RFC1213-MIB")
10
+
11
+ # get the oid for sysDescr
12
+ Smi.translate("sysDescr") => ".1.3.6.1.2.1.2.1.1"
13
+
14
+ You may have to add smilib to LD_LIBRARY_PATH. For example
15
+ export LD_LIBRARY_PATH=/opt/local/lib
16
+
4
17
 
5
18
  == Note on Patches/Pull Requests
6
19
 
data/Rakefile CHANGED
@@ -1,45 +1,2 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "smi-ffi"
8
- gem.summary = %Q{Ruby Interface to libsmi}
9
- gem.description = %Q{ffi bindings for libsmi}
10
- gem.email = "ronmcclain75@gmail.com"
11
- gem.homepage = "http://github.com/mixtli/smi-ffi"
12
- gem.authors = ["mixtli"]
13
- gem.add_development_dependency "rspec", ">= 2.0.0"
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
- end
20
-
21
- #require 'spec/rake/spectask'
22
- #Spec::Rake::SpecTask.new(:spec) do |spec|
23
- # spec.libs << 'lib' << 'spec'
24
- # spec.spec_files = FileList['spec/**/*_spec.rb']
25
- #end
26
-
27
- #Spec::Rake::SpecTask.new(:rcov) do |spec|
28
- # spec.libs << 'lib' << 'spec'
29
- # spec.pattern = 'spec/**/*_spec.rb'
30
- # spec.rcov = true
31
- #end
32
-
33
- task :spec => :check_dependencies
34
-
35
- task :default => :spec
36
-
37
- require 'rake/rdoctask'
38
- Rake::RDocTask.new do |rdoc|
39
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
-
41
- rdoc.rdoc_dir = 'rdoc'
42
- rdoc.title = "smi-ffi #{version}"
43
- rdoc.rdoc_files.include('README*')
44
- rdoc.rdoc_files.include('lib/**/*.rb')
45
- end
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/lib/smi/node.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Smi
2
2
  class Node
3
3
  extend Forwardable
4
- attr_accessor :struct
4
+ attr_accessor :struct, :index
5
5
  def_delegators :@struct, :pointer, :name, :decl, :access, :status, :format, :value, :units, :description, :reference, :indexkind, :implied, :create, :nodekind
6
6
  def initialize(ptr)
7
7
  @struct = ptr
@@ -13,7 +13,9 @@ module Smi
13
13
 
14
14
  def self.get_node(oid)
15
15
  struct = Wrapper::smiGetNode(nil, oid)
16
- new(struct)
16
+ n = new(struct)
17
+ n.index = oid.split("#{n.oid}.").last
18
+ n
17
19
  end
18
20
 
19
21
  def children
@@ -0,0 +1,5 @@
1
+ module Smi
2
+ module Ffi
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
data/smi-ffi.gemspec CHANGED
@@ -1,69 +1,22 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "smi/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{smi-ffi}
8
- s.version = "0.0.0"
6
+ s.name = "smi-ffi"
7
+ s.version = Smi::Ffi::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Ron McClain"]
10
+ s.email = ["mixtli@github.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Wrapper around libsmi}
13
+ s.description = %q{Provides methods to translate SMI names to OIDs.}
9
14
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["mixtli"]
12
- s.date = %q{2010-12-29}
13
- s.default_executable = %q{smidump.rb}
14
- s.description = %q{ffi bindings for libsmi}
15
- s.email = %q{ronmcclain75@gmail.com}
16
- s.executables = ["smidump.rb"]
17
- s.extra_rdoc_files = [
18
- "LICENSE",
19
- "README.rdoc"
20
- ]
21
- s.files = [
22
- ".document",
23
- ".gitignore",
24
- "LICENSE",
25
- "README.rdoc",
26
- "Rakefile",
27
- "VERSION",
28
- "bin/smidump.rb",
29
- "c/Makefile",
30
- "c/a.out",
31
- "c/test",
32
- "c/test.c",
33
- "c/test.o",
34
- "interface/smi.h",
35
- "lib/smi.rb",
36
- "lib/smi/config.rb",
37
- "lib/smi/module.rb",
38
- "lib/smi/node.rb",
39
- "lib/smi/wrapper.rb",
40
- "smi-ffi.gemspec",
41
- "spec/mibs/IF-MIB",
42
- "spec/mibs/RFC1213-MIB",
43
- "spec/smi-ffi_spec.rb",
44
- "spec/spec_helper.rb"
45
- ]
46
- s.homepage = %q{http://github.com/mixtli/smi-ffi}
47
- s.rdoc_options = ["--charset=UTF-8"]
48
- s.require_paths = ["lib"]
49
- s.rubygems_version = %q{1.3.7}
50
- s.summary = %q{Ruby Interface to libsmi}
51
- s.test_files = [
52
- "spec/smi-ffi_spec.rb",
53
- "spec/spec_helper.rb"
54
- ]
55
-
56
- if s.respond_to? :specification_version then
57
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
58
- s.specification_version = 3
15
+ s.rubyforge_project = "smi-ffi"
59
16
 
60
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
61
- s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
62
- else
63
- s.add_dependency(%q<rspec>, [">= 2.0.0"])
64
- end
65
- else
66
- s.add_dependency(%q<rspec>, [">= 2.0.0"])
67
- end
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ s.add_dependency('nice-ffi')
68
22
  end
69
-
data/spec/smi-ffi_spec.rb CHANGED
@@ -59,6 +59,12 @@ describe "Smi::Node" do
59
59
  Smi.translate("ifDescr.5").should eql("1.3.6.1.2.1.2.2.1.2.5")
60
60
  end
61
61
 
62
+ it "should set index in get_node" do
63
+ node = Smi::Node.get_node("1.3.6.1.2.1.2.2.1.2.1")
64
+ node.oid.should eql("1.3.6.1.2.1.2.2.1.2")
65
+ node.index.should eql("1")
66
+ end
67
+
62
68
  #it "should do stuff" do
63
69
  #node = Smi::Node.get_node("ipAdEntIfIndex")
64
70
  #puts node.struct.inspect
data/spec/spec_helper.rb CHANGED
@@ -4,8 +4,8 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'ffi'
5
5
  require 'smi'
6
6
 
7
- require 'rspec'
8
- require 'rspec/autorun'
7
+ #require 'rspec'
8
+ #require 'rspec/autorun'
9
9
 
10
10
  #Spec::Runner.configure do |config|
11
11
 
metadata CHANGED
@@ -5,20 +5,20 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 0
9
- version: 0.0.0
8
+ - 1
9
+ version: 0.0.1
10
10
  platform: ruby
11
11
  authors:
12
- - mixtli
12
+ - Ron McClain
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-29 00:00:00 -06:00
18
- default_executable: smidump.rb
17
+ date: 2011-03-19 00:00:00 -05:00
18
+ default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: rspec
21
+ name: nice-ffi
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
@@ -26,24 +26,23 @@ dependencies:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  segments:
29
- - 2
30
- - 0
31
29
  - 0
32
- version: 2.0.0
33
- type: :development
30
+ version: "0"
31
+ type: :runtime
34
32
  version_requirements: *id001
35
- description: ffi bindings for libsmi
36
- email: ronmcclain75@gmail.com
33
+ description: Provides methods to translate SMI names to OIDs.
34
+ email:
35
+ - mixtli@github.com
37
36
  executables:
38
37
  - smidump.rb
39
38
  extensions: []
40
39
 
41
- extra_rdoc_files:
42
- - LICENSE
43
- - README.rdoc
40
+ extra_rdoc_files: []
41
+
44
42
  files:
45
43
  - .document
46
44
  - .gitignore
45
+ - Gemfile
47
46
  - LICENSE
48
47
  - README.rdoc
49
48
  - Rakefile
@@ -59,6 +58,7 @@ files:
59
58
  - lib/smi/config.rb
60
59
  - lib/smi/module.rb
61
60
  - lib/smi/node.rb
61
+ - lib/smi/version.rb
62
62
  - lib/smi/wrapper.rb
63
63
  - smi-ffi.gemspec
64
64
  - spec/mibs/IF-MIB
@@ -66,12 +66,12 @@ files:
66
66
  - spec/smi-ffi_spec.rb
67
67
  - spec/spec_helper.rb
68
68
  has_rdoc: true
69
- homepage: http://github.com/mixtli/smi-ffi
69
+ homepage: ""
70
70
  licenses: []
71
71
 
72
72
  post_install_message:
73
- rdoc_options:
74
- - --charset=UTF-8
73
+ rdoc_options: []
74
+
75
75
  require_paths:
76
76
  - lib
77
77
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -92,11 +92,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  version: "0"
93
93
  requirements: []
94
94
 
95
- rubyforge_project:
95
+ rubyforge_project: smi-ffi
96
96
  rubygems_version: 1.3.7
97
97
  signing_key:
98
98
  specification_version: 3
99
- summary: Ruby Interface to libsmi
99
+ summary: Wrapper around libsmi
100
100
  test_files:
101
+ - spec/mibs/IF-MIB
102
+ - spec/mibs/RFC1213-MIB
101
103
  - spec/smi-ffi_spec.rb
102
104
  - spec/spec_helper.rb