openldap_monitor_extractor 0.0.2 → 0.0.3

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.
data/.gitignore CHANGED
@@ -8,7 +8,7 @@ Gemfile.lock
8
8
  InstalledFiles
9
9
  _yardoc
10
10
  coverage
11
- config
11
+ examples/production.yml
12
12
  doc/
13
13
  pkg
14
14
  rdoc
@@ -8,7 +8,11 @@ require 'yaml'
8
8
  require 'openldap_monitor_extractor'
9
9
 
10
10
 
11
- config = YAML.load_file(ARGV[0])
12
-
13
- OpenldapMonitorExtractor.configure(config)
14
- puts OpenldapMonitorExtractor.get(:total_connections)
11
+ if ARGV[0] && File.exist?(ARGV[0])
12
+
13
+ config = YAML.load_file(ARGV[0])
14
+ puts OpenldapMonitorExtractor.configure(config).get(:total_connections)
15
+ else
16
+
17
+ puts "usage: #{$0} config_file.yml"
18
+ end
@@ -2,4 +2,3 @@
2
2
  :url: 'ldaps://ldap.example.com'
3
3
  :username: 'cn=admin,dc=example,dc=com'
4
4
  :password: 'supersecret'
5
- :base: 'cn=Monitor'
@@ -7,6 +7,8 @@ module OpenldapMonitorExtractor
7
7
 
8
8
  class Connection
9
9
 
10
+ DEFAULT_MONITOR_BASE = "cn=Monitor"
11
+
10
12
  attr_reader :connection
11
13
 
12
14
  def self.builder(parameters={ })
@@ -21,7 +23,7 @@ module OpenldapMonitorExtractor
21
23
  cparameters = {
22
24
  :host =>uri.host,
23
25
  :port =>uri.port,
24
- :base =>parameters[:base],
26
+ :base =>DEFAULT_MONITOR_BASE,
25
27
  :auth =>auth
26
28
  }
27
29
 
@@ -1,4 +1,4 @@
1
1
  module OpenldapMonitorExtractor
2
2
 
3
- VERSION = "0.0.2"
4
- end
3
+ VERSION = "0.0.3"
4
+ end
@@ -1,4 +1,3 @@
1
- require "ostruct"
2
1
  require "openldap_monitor_extractor/version"
3
2
  require "openldap_monitor_extractor/connection"
4
3
 
@@ -6,7 +5,6 @@ require "openldap_monitor_extractor/connection"
6
5
  module OpenldapMonitorExtractor
7
6
  extend self
8
7
 
9
-
10
8
  MAPPER = {
11
9
  :total_connections =>{ :dn =>"cn=Total,cn=Connections,cn=Monitor", :attribute =>:monitorcounter },
12
10
  :referals_statistics =>{ :dn =>"cn=Referrals,cn=Statistics,cn=Monitor",:attribute =>:monitorcounter },
@@ -31,11 +29,16 @@ module OpenldapMonitorExtractor
31
29
  KEYS = MAPPER.keys
32
30
 
33
31
  def configure(config)
32
+
34
33
  @connection ||= Connection.new(config).connection
34
+
35
+ self
35
36
  end
36
37
 
37
38
  def get(key)
38
39
 
40
+ raise StandardError.new("The key: #{key} do not exist") unless KEYS.include?(key)
41
+
39
42
  dn = MAPPER[key][:dn]
40
43
  attribute = MAPPER[key][:attribute]
41
44
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openldap_monitor_extractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-25 00:00:00.000000000 Z
12
+ date: 2013-05-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-ldap
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
110
  version: '0'
111
111
  segments:
112
112
  - 0
113
- hash: -1701931666641725521
113
+ hash: -566327192966787389
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  none: false
116
116
  requirements:
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  segments:
121
121
  - 0
122
- hash: -1701931666641725521
122
+ hash: -566327192966787389
123
123
  requirements: []
124
124
  rubyforge_project:
125
125
  rubygems_version: 1.8.25