vayacondios-server 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # -*- ruby -*-
2
+
1
3
  source 'http://rubygems.org'
2
4
 
3
5
  gemspec name: 'vayacondios-server'
@@ -2,7 +2,7 @@ require 'gorillib/logger/log'
2
2
  require 'net/http'
3
3
  require 'multi_json'
4
4
  require_relative 'config'
5
- require_relative '../legacy_switch'
5
+ require_relative 'legacy_switch'
6
6
 
7
7
  class Vayacondios
8
8
  class Client
@@ -0,0 +1,46 @@
1
+ require 'gorillib/logger/log'
2
+
3
+ class Vayacondios
4
+ # Are we operating on JSON Hashes (Vayacondios) or on JSON arrays
5
+ # (Vayacondios Legacy)? These classes determine which to use.
6
+
7
+ class StandardContentsHandler
8
+ def wrap_contents(contents) {contents: contents} end
9
+ def extract_contents(document) document['contents'] end
10
+ def extract_response(document) document['contents'] end
11
+ def proper_request(document)
12
+ document.is_a? Hash and document.fetch('_json', {}).is_a? Hash
13
+ end
14
+ end
15
+
16
+ class LegacyContentsHandler
17
+ def wrap_contents(contents) contents end
18
+ def extract_contents(document) document.fetch('_json', {}) end
19
+ def extract_response(document) document end
20
+ def proper_request(document)
21
+ document.is_a? Array or document.fetch('_json', {}).is_a? Array
22
+ end
23
+ end
24
+
25
+ @@legacy_switch = nil
26
+
27
+ def self.legacy_switch
28
+ legacy_mode_on = Settings[:vayacondios][:legacy]
29
+ if @@legacy_switch.nil?
30
+ @@legacy_switch = get_legacy_switch(legacy_mode_on)
31
+ Log.info("using #{legacy_mode_on ? 'legacy' : 'standard'} mode")
32
+ end
33
+ @@legacy_switch
34
+ end
35
+
36
+ def self.force_legacy_mode on
37
+ @@legacy_switch = get_legacy_switch on
38
+ end
39
+
40
+ private
41
+
42
+ def self.get_legacy_switch on
43
+ (on ? LegacyContentsHandler : StandardContentsHandler).new
44
+ end
45
+ end
46
+
@@ -0,0 +1,46 @@
1
+ require 'gorillib/logger/log'
2
+
3
+ class Vayacondios
4
+ # Are we operating on JSON Hashes (Vayacondios) or on JSON arrays
5
+ # (Vayacondios Legacy)? These classes determine which to use.
6
+
7
+ class StandardContentsHandler
8
+ def wrap_contents(contents) {contents: contents} end
9
+ def extract_contents(document) document['contents'] end
10
+ def extract_response(document) document['contents'] end
11
+ def proper_request(document)
12
+ document.is_a? Hash and document.fetch('_json', {}).is_a? Hash
13
+ end
14
+ end
15
+
16
+ class LegacyContentsHandler
17
+ def wrap_contents(contents) contents end
18
+ def extract_contents(document) document.fetch('_json', {}) end
19
+ def extract_response(document) document end
20
+ def proper_request(document)
21
+ document.is_a? Array or document.fetch('_json', {}).is_a? Array
22
+ end
23
+ end
24
+
25
+ @@legacy_switch = nil
26
+
27
+ def self.legacy_switch
28
+ legacy_mode_on = Settings[:vayacondios][:legacy]
29
+ if @@legacy_switch.nil?
30
+ @@legacy_switch = get_legacy_switch(legacy_mode_on)
31
+ Log.info("using #{legacy_mode_on ? 'legacy' : 'standard'} mode")
32
+ end
33
+ @@legacy_switch
34
+ end
35
+
36
+ def self.force_legacy_mode on
37
+ @@legacy_switch = get_legacy_switch on
38
+ end
39
+
40
+ private
41
+
42
+ def self.get_legacy_switch on
43
+ (on ? LegacyContentsHandler : StandardContentsHandler).new
44
+ end
45
+ end
46
+
@@ -1,5 +1,5 @@
1
1
  require 'vayacondios/server/model/document'
2
- require 'vayacondios/legacy_switch'
2
+ require 'vayacondios/server/legacy_switch'
3
3
 
4
4
  # The configuration model
5
5
  #
@@ -1,3 +1,3 @@
1
1
  class Vayacondios
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.4'
3
3
  end
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
- require_relative '../../lib/vayacondios/legacy_switch'
2
+ require_relative '../../lib/vayacondios/server/legacy_switch'
3
3
 
4
4
  require 'multi_json'
5
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vayacondios-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -208,6 +208,7 @@ files:
208
208
  - lib/vayacondios/client/cube_client.rb
209
209
  - lib/vayacondios/client/http_client.rb
210
210
  - lib/vayacondios/client/itemset.rb
211
+ - lib/vayacondios/client/legacy_switch.rb
211
212
  - lib/vayacondios/client/notifier.rb
212
213
  - lib/vayacondios/client/zabbix_client.rb
213
214
  - lib/vayacondios/legacy_switch.rb
@@ -216,6 +217,7 @@ files:
216
217
  - lib/vayacondios/server/handlers/config_handler.rb
217
218
  - lib/vayacondios/server/handlers/event_handler.rb
218
219
  - lib/vayacondios/server/handlers/itemset_handler.rb
220
+ - lib/vayacondios/server/legacy_switch.rb
219
221
  - lib/vayacondios/server/model/config_document.rb
220
222
  - lib/vayacondios/server/model/document.rb
221
223
  - lib/vayacondios/server/model/event_document.rb
@@ -277,7 +279,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
277
279
  version: '0'
278
280
  segments:
279
281
  - 0
280
- hash: -2368824716653400706
282
+ hash: -3470064849041831815
281
283
  required_rubygems_version: !ruby/object:Gem::Requirement
282
284
  none: false
283
285
  requirements:
@@ -286,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
286
288
  version: '0'
287
289
  segments:
288
290
  - 0
289
- hash: -2368824716653400706
291
+ hash: -3470064849041831815
290
292
  requirements: []
291
293
  rubyforge_project:
292
294
  rubygems_version: 1.8.25