vayacondios-client 0.0.3 → 0.0.4

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.
@@ -17,7 +17,6 @@ require 'gorillib/string/inflections'
17
17
 
18
18
  require 'vayacondios/client/http_client'
19
19
  require 'vayacondios/client/notifier'
20
- require 'vayacondios/client/configliere'
21
20
 
22
21
 
23
22
 
@@ -1,7 +1,7 @@
1
1
  class Vayacondios
2
2
 
3
3
  class_attribute :notifier
4
-
4
+
5
5
  class Notifier < Vayacondios
6
6
  attr_accessor :client
7
7
 
@@ -14,18 +14,18 @@ class Vayacondios
14
14
  raise ArgumentError.new("Cannot notify '#{obj.inspect}' -- require a hash-like object.")
15
15
  end
16
16
  end
17
-
17
+
18
18
  def notify(topic, cargo = {})
19
19
  NoMethodError.unimplemented_method(self)
20
20
  end
21
21
  end
22
-
22
+
23
23
  class LogNotifier < Notifier
24
-
24
+
25
25
  def initialize(options = {})
26
26
  @client = options[:log] || Log
27
27
  end
28
-
28
+
29
29
  def notify(topic, cargo = {})
30
30
  prepped = prepare(cargo)
31
31
  level = prepped.delete(:level) || :info
@@ -37,18 +37,18 @@ class Vayacondios
37
37
  end
38
38
 
39
39
  class HttpNotifier < Notifier
40
-
40
+
41
41
  def initialize(options = {})
42
42
  @client = Vayacondios::HttpClient.receive(options)
43
43
  end
44
-
44
+
45
45
  def notify(topic, cargo = {})
46
46
  prepped = prepare(cargo)
47
47
  client.insert(prepped, :event, topic)
48
48
  nil
49
49
  end
50
50
  end
51
-
51
+
52
52
  class NotifierFactory
53
53
  def self.receive(attrs = {})
54
54
  type = attrs.delete(:type)
@@ -58,25 +58,25 @@ class Vayacondios
58
58
  else
59
59
  raise ArgumentError, "<#{type}> is not a valid build option"
60
60
  end
61
- end
62
- end
63
-
61
+ end
62
+ end
63
+
64
64
  def self.default_notifier() NotifierFactory.receive(type: 'http') ; end
65
-
66
- module Notifications
65
+
66
+ module Notifications
67
67
  extend Gorillib::Concern
68
68
  include Gorillib::Configurable
69
-
69
+
70
70
  def notify(topic, cargo = {})
71
71
  notifier.notify(topic, cargo)
72
72
  end
73
-
73
+
74
74
  included do
75
75
  class_eval do
76
76
  config(:notifier, Vayacondios::NotifierFactory, default: Vayacondios.default_notifier)
77
77
  end
78
78
  end
79
-
79
+
80
80
  end
81
81
 
82
82
  extend Notifications
@@ -1,9 +1,6 @@
1
- require 'spec_helper'
2
- require 'gorillib/builder'
3
- require 'configliere'
1
+ require 'vayacondios-client'
4
2
 
5
- require_relative '../../configurable/lib/gorillib_configurable_model'
6
- require 'vayacondios/notifier'
3
+ require 'spec_helper'
7
4
 
8
5
  class FakeModel
9
6
  include Vayacondios::Notifications
@@ -19,7 +16,7 @@ describe FakeModel do
19
16
  it 'adds a configurable attribute :notifier with default' do
20
17
  subject.notifier.should be_instance_of(Vayacondios.default_notifier.class)
21
18
  end
22
-
19
+
23
20
  end
24
21
  end
25
22
 
@@ -42,9 +39,9 @@ describe Vayacondios::Notifier do
42
39
  it 'raises an ArgumentError' do
43
40
  expect{ subject.prepare(bad_arg) }.to raise_error(ArgumentError, /Cannot notify.*#{bad_arg}.*require a hash-like object/)
44
41
  end
45
- end
42
+ end
46
43
  end
47
-
44
+
48
45
  end
49
46
 
50
47
  describe Vayacondios::HttpNotifier do
@@ -57,8 +54,8 @@ describe Vayacondios::HttpNotifier do
57
54
  let(:topic) { 'weeeeeeeeeee' }
58
55
  let(:cargo) { Hash.new }
59
56
 
60
- before do
61
- subject.stub(:client).and_return(test_client)
57
+ before do
58
+ subject.stub(:client).and_return(test_client)
62
59
  subject.stub(:prepare).and_return(cargo)
63
60
  end
64
61
 
@@ -79,7 +76,7 @@ describe Vayacondios::LogNotifier do
79
76
  let(:topic) { 'weeeeeeeeeee' }
80
77
  let(:cargo) { Hash.new }
81
78
 
82
- before do
79
+ before do
83
80
  subject.stub(:client).and_return(test_client)
84
81
  subject.stub(:prepare).and_return(cargo)
85
82
  end
@@ -99,13 +96,13 @@ describe Vayacondios::NotifierFactory do
99
96
  described_class.receive(type: 'http').should be_instance_of(Vayacondios::HttpNotifier)
100
97
  end
101
98
  end
102
-
99
+
103
100
  context 'given :log' do
104
101
  it 'builds a LogNotifier' do
105
102
  described_class.receive(type: 'log').should be_instance_of(Vayacondios::LogNotifier)
106
103
  end
107
104
  end
108
-
105
+
109
106
  context 'given a bad argument' do
110
107
  it 'raises an ArgumentError' do
111
108
  expect{ described_class.receive(type: 'bad') }.to raise_error(ArgumentError, /not a valid build option/)
@@ -115,7 +112,7 @@ describe Vayacondios::NotifierFactory do
115
112
  end
116
113
 
117
114
  describe Vayacondios do
118
-
115
+
119
116
  it 'has a class method notify()' do
120
117
  described_class.should respond_to(:notify)
121
118
  end
metadata CHANGED
@@ -1,21 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vayacondios-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Philip (flip) Kromer
9
9
  - Travis Dempsey
10
10
  - Huston Hoburg
11
+ - Logan Lowell
11
12
  autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2012-08-16 00:00:00.000000000Z
15
+ date: 2012-08-28 00:00:00.000000000 Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: configliere
18
- requirement: &2170425660 !ruby/object:Gem::Requirement
19
+ requirement: !ruby/object:Gem::Requirement
19
20
  none: false
20
21
  requirements:
21
22
  - - ! '>='
@@ -23,10 +24,15 @@ dependencies:
23
24
  version: 0.4.16
24
25
  type: :runtime
25
26
  prerelease: false
26
- version_requirements: *2170425660
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.4.16
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: multi_json
29
- requirement: &2170425160 !ruby/object:Gem::Requirement
35
+ requirement: !ruby/object:Gem::Requirement
30
36
  none: false
31
37
  requirements:
32
38
  - - ~>
@@ -34,28 +40,84 @@ dependencies:
34
40
  version: '1.1'
35
41
  type: :runtime
36
42
  prerelease: false
37
- version_requirements: *2170425160
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: '1.1'
38
49
  - !ruby/object:Gem::Dependency
39
50
  name: gorillib
40
- requirement: &2170424700 !ruby/object:Gem::Requirement
51
+ requirement: !ruby/object:Gem::Requirement
41
52
  none: false
42
53
  requirements:
43
- - - =
54
+ - - '='
44
55
  - !ruby/object:Gem::Version
45
56
  version: 0.4.0pre
46
57
  type: :runtime
47
58
  prerelease: false
48
- version_requirements: *2170424700
49
- description: ! " \nSimple
50
- enough to use in a shell script, performant enough to use everywhere. Why the hell
51
- wouldn't you record that metric, ese?\n\n* Client code\n\n"
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - '='
63
+ - !ruby/object:Gem::Version
64
+ version: 0.4.0pre
65
+ - !ruby/object:Gem::Dependency
66
+ name: rake
67
+ requirement: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ type: :development
74
+ prerelease: false
75
+ version_requirements: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ - !ruby/object:Gem::Dependency
82
+ name: yard
83
+ requirement: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0.7'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '2.8'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '2.8'
113
+ description: Simple enough to use in a shell script, performant enough to use everywhere.
114
+ Dios mío! Record that metric, ese!
52
115
  email:
53
116
  executables: []
54
117
  extensions: []
55
118
  extra_rdoc_files: []
56
119
  files:
57
120
  - lib/vayacondios-client.rb
58
- - lib/vayacondios/client/configliere.rb
59
121
  - lib/vayacondios/client/http_client.rb
60
122
  - lib/vayacondios/client/notifier.rb
61
123
  - spec/client/notifier_spec.rb
@@ -73,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
135
  version: '0'
74
136
  segments:
75
137
  - 0
76
- hash: 546804456992730553
138
+ hash: -2208816957646596471
77
139
  required_rubygems_version: !ruby/object:Gem::Requirement
78
140
  none: false
79
141
  requirements:
@@ -82,10 +144,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
144
  version: '0'
83
145
  segments:
84
146
  - 0
85
- hash: 546804456992730553
147
+ hash: -2208816957646596471
86
148
  requirements: []
87
149
  rubyforge_project:
88
- rubygems_version: 1.8.15
150
+ rubygems_version: 1.8.23
89
151
  signing_key:
90
152
  specification_version: 3
91
153
  summary: Data goes in. The right thing happens
@@ -1,38 +0,0 @@
1
- class Vayacondios
2
- module Configliere
3
-
4
- def load_from_vayacondios(organization, id, options = {})
5
- options.symbolize_keys!.deep_merge!(organization: organization)
6
-
7
- client = ::Vayacondios::HttpClient.receive(options.deep_compact!)
8
- id = [id, options[:env]].compact.join('.')
9
-
10
- begin
11
- new_data = client.fetch(:config, id)
12
- rescue ::Vayacondios::HttpClient::Error
13
- warn "Unable to load vayacondios config '#{id}' for #{organization} at: #{client.host}:#{client.port}"
14
- new_data = {}
15
- end
16
- deep_merge! new_data
17
- self
18
- end
19
-
20
- def save_to_vayacondios(organization, id, options = {})
21
- options.symbolize_keys!.deep_merge!(organization: organization)
22
-
23
- client = ::Vayacondios::HttpClient.receive(options.deep_compact!)
24
- id = [id, options[:env]].compact.join('.')
25
-
26
- begin
27
- client.insert(self.to_hash, :config, id)
28
- rescue ::Vayacondios::HttpClient::Error
29
- warn "Unable to save vayacondios config '#{id}' for #{organization} at: #{client.host}:#{client.port}"
30
- end
31
- self
32
- end
33
- end
34
- end
35
-
36
- ::Configliere::Param.class_eval do
37
- include ::Vayacondios::Configliere
38
- end