aubergine 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 562f6680a0104694f8e86348797adb4c4df3a8fd
4
- data.tar.gz: f952535eb798a7fec393a9a5c992ac8d8f328e4c
3
+ metadata.gz: 5c3d50334ff0e755f7f6116cf0c3218d73332d5f
4
+ data.tar.gz: 2b129603dea71b8b0352cd2275a448c60b08da76
5
5
  SHA512:
6
- metadata.gz: 5925cf3d5875e7d335a22de85955b3d88279e3646b932631cce9c72d16f4171c4ffc628ce26f1f03926a91ed2fb4a0496c35acb288af4f24bf27563b3db81f84
7
- data.tar.gz: 275aff7878771f199a2e3439263ed6971f4c31ed085d2abb0635ab798b041f87d685a8b4aa0919133d7dab9ae65e73e3406c1da656968a65ea45b46e3242960a
6
+ metadata.gz: 068ad1e8002fe6685e84d370f174b6df09490895cc6c0a494ee47566eaea3270459366d69747c76d3611e5fbaaa7971931a4df54422b16756ca697ac5aad7188
7
+ data.tar.gz: da03df792f862595497c2f8afb8e6b5e98bf29b69dbaeeb7abd0ee057c5fc4452a1cf21cef0c47089af0574fba918e506344fed42743d77c819c9b86a1bc159d
@@ -0,0 +1,17 @@
1
+ module Aubergine
2
+ class Device < Struct.new(:ip, :vendor, :login, :password, :enable)
3
+ def self.build(hash)
4
+ new(hash[:ip], hash[:vendor], hash[:login], hash[:password], hash[:enable])
5
+ end
6
+
7
+ def to_map
8
+ map = Hash.new
9
+ self.members.each { |m| map[m] = self[m] if self[m] }
10
+ map
11
+ end
12
+
13
+ def to_json(*a)
14
+ to_map.to_json(*a)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ module Aubergine
2
+ class FileSatelliteProvider < SatelliteProvider
3
+ def initialize(all)
4
+ @all = all
5
+ end
6
+
7
+ def find(key)
8
+ satellite = @all.find { |satellite| satellite[:key] == key }
9
+ if satellite
10
+ Satellite.new(satellite[:name], satellite[:devices].map { |device| Device.build(device) })
11
+ else
12
+ nil
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,27 +1,22 @@
1
1
  module Aubergine
2
2
  class Satellite
3
- attr_reader :devices
3
+ attr_reader :devices, :name
4
4
 
5
5
  def initialize(name, devices)
6
6
  @name = name
7
7
  @devices = devices
8
8
  end
9
9
 
10
- def self.find(key)
11
- satellite = @@all.find { |satellite| satellite[:key] == key }
12
- if satellite
13
- new(satellite[:name], satellite[:devices])
14
- else
15
- nil
16
- end
17
- end
18
-
19
10
  def to_s
20
11
  @name
21
12
  end
22
13
 
23
- def self.all=(data)
24
- @@all = data
14
+ def self.find(*args)
15
+ @@backend.find(*args)
16
+ end
17
+
18
+ def self.backend=(data)
19
+ @@backend = data
25
20
  end
26
21
  end
27
22
  end
@@ -0,0 +1,7 @@
1
+ module Aubergine
2
+ class SatelliteProvider
3
+ def find(key)
4
+ raise "Not implemented"
5
+ end
6
+ end
7
+ end
data/lib/aubergine.rb CHANGED
@@ -3,13 +3,20 @@ require 'json'
3
3
 
4
4
  require 'git'
5
5
 
6
+ require_relative './aubergine/device.rb'
6
7
  require_relative './aubergine/satellite.rb'
8
+ require_relative './aubergine/satellite_provider.rb'
9
+ require_relative './aubergine/file_satellite_provider.rb'
7
10
  require_relative './aubergine/path.rb'
8
11
  require_relative './aubergine/server.rb'
9
12
 
10
13
  module Aubergine
11
14
  def self.register(data)
12
- Satellite.all = data
15
+ Satellite.backend = FileSatelliteProvider.new(data)
16
+ end
17
+
18
+ def self.backend=(backend)
19
+ Satellite.backend = backend
13
20
  end
14
21
 
15
22
  def self.repository=(repository)
data/lib/courgette/hp.rb CHANGED
@@ -22,7 +22,7 @@ module Courgette
22
22
  data
23
23
  end
24
24
  end
25
-
25
+
26
26
  def save
27
27
  end
28
28
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aubergine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Rose
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-05 00:00:00.000000000 Z
11
+ date: 2013-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commutateurs
@@ -102,7 +102,10 @@ extra_rdoc_files: []
102
102
  files:
103
103
  - lib/aubergine/path.rb
104
104
  - lib/aubergine/satellite.rb
105
+ - lib/aubergine/satellite_provider.rb
106
+ - lib/aubergine/file_satellite_provider.rb
105
107
  - lib/aubergine/server.rb
108
+ - lib/aubergine/device.rb
106
109
  - lib/courgette/hp.rb
107
110
  - lib/courgette/client.rb
108
111
  - lib/courgette/device.rb