serfx 0.0.9 → 0.1.0

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: 2dd4d0d83c82dae09204307da9088059768c893f
4
- data.tar.gz: 09a78e804e6b5067ea17b7cc46e493eb7de24935
3
+ metadata.gz: 683dd4d08bf7bae9fe1bbe8eb3be76bb374597b3
4
+ data.tar.gz: 86923b12a193f8ab737e714265d8880670d1f766
5
5
  SHA512:
6
- metadata.gz: cc00a2d6c5c365ceda4699e36824a16713bba12cc72ce3662b19f6fe993f77280e13482ae7312c5d85062c55c6b994c16c0ce6cca1ed57d0c1fa69d626bcdde7
7
- data.tar.gz: 84791215060afa1b18980f66a9fbb335e9bc536b14f952e2e8ca5ef73558c306a55d6cd036947d9acf99b5c120ae06159ba44a69cd878c912f2c40f15fc65359
6
+ metadata.gz: fe3a1c28e9036b08f59f75a092b71a067bca78a8f4f76c6dd852f2ae6df269b716ca99b275f942125ba071bfbb5d660e1bced14dd26d70b6cf1dec22d20aa8f4
7
+ data.tar.gz: 8272fad66e719ae2d779a4b1045275f118d4c8ea110b071e96cd855bc19231e33796ab9afb5fd3eb15ef305ae9fc4a595ee39d4edda0cfd0901948afef4e9af2
data/.travis.yml CHANGED
@@ -3,7 +3,6 @@ before_install:
3
3
  - bundle install --path .bundle
4
4
  rvm:
5
5
  - 2.0.0
6
- - 2.1.0
7
6
  branches:
8
7
  only:
9
8
  - master
data/download_serf CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/bin/bash
2
2
  mkdir serf_binaries
3
3
  cd serf_binaries
4
- wget -c https://dl.bintray.com/mitchellh/serf/0.6.0_linux_amd64.zip
5
- unzip 0.6.0_linux_amd64.zip
4
+ wget -c https://releases.hashicorp.com/serf/0.7.0/serf_0.7.0_linux_amd64.zip
5
+ unzip serf_0.7.0_linux_amd64.zip
@@ -205,5 +205,13 @@ module Serfx
205
205
  def stats
206
206
  request(:stats)
207
207
  end
208
+
209
+ # obtain network coordinate of a node
210
+ #
211
+ # @param node [String] Name of the node
212
+ # @return [Response]
213
+ def get_coordinate
214
+ request(:get_coordinate, 'Node' => node)
215
+ end
208
216
  end
209
217
  end
@@ -33,7 +33,8 @@ module Serfx
33
33
  use_key: [:header, :body],
34
34
  remove_key: [:header, :body],
35
35
  list_keys: [:header, :body],
36
- stats: [:header, :body]
36
+ stats: [:header, :body],
37
+ get_coordinate: [:header, :body]
37
38
  }
38
39
 
39
40
  include Serfx::Commands
@@ -69,7 +69,7 @@ module Serfx
69
69
  event = SerfEvent.new
70
70
  callbacks[event.type.downcase.to_sym].each do |cbk|
71
71
  if cbk.name
72
- cbk.block.call(event) if event.name === cbk.name
72
+ cbk.block.call(event) if cbk.name === event.name
73
73
  else
74
74
  cbk.block.call(event)
75
75
  end
data/lib/serfx/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  #
3
3
  # Provides version as a contsant for the serf gem
4
4
  module Serfx
5
- VERSION = '0.0.9'
5
+ VERSION = '0.1.0'
6
6
  end
@@ -133,16 +133,16 @@ describe Serfx do
133
133
  keys = @conn.list_keys.body['Keys'].keys
134
134
  expect(keys).to include('QHOYjmYlxSCBhdfiolhtDQ==')
135
135
  @conn.install_key('Ih6cZqutM33tMdoFo1iNyw==')
136
- sleep 2
136
+ sleep 5
137
137
  keys = @conn.list_keys.body['Keys'].keys
138
138
  expect(keys).to include('Ih6cZqutM33tMdoFo1iNyw==')
139
- sleep 2
139
+ sleep 5
140
140
  @conn.use_key('Ih6cZqutM33tMdoFo1iNyw==')
141
141
  new_keys = @conn.list_keys.body['Keys'].keys
142
- sleep 2
142
+ sleep 5
143
143
  expect(new_keys.first).to eq('Ih6cZqutM33tMdoFo1iNyw==')
144
144
  @conn.remove_key('QHOYjmYlxSCBhdfiolhtDQ==')
145
- sleep 2
145
+ sleep 5
146
146
  final_keys = @conn.list_keys.body['Keys'].keys
147
147
  expect(final_keys.first).to_not include('QHOYjmYlxSCBhdfiolhtDQ==')
148
148
  end
@@ -15,7 +15,25 @@ describe Serfx::Utils::Handler do
15
15
  end
16
16
  ENV['SERF_EVENT'] = 'query'
17
17
  ENV['SERF_QUERY_NAME'] = 'foo'
18
- STDIN.should_receive(:read_nonblock).and_return('yeah')
18
+ expect(STDIN).to receive(:read_nonblock).and_return('yeah')
19
+ CustomHandler.run
20
+ expect(CustomHandler.state[:payload]).to eq('yeah')
21
+ end
22
+
23
+ it 'accepts event payload as regex' do
24
+ class CustomHandler
25
+ extend Serfx::Utils::Handler
26
+ @@state = {}
27
+ def self.state
28
+ @@state
29
+ end
30
+ on :query, /foo:\w+/ do |event|
31
+ @@state[:payload] = event.payload
32
+ end
33
+ end
34
+ ENV['SERF_EVENT'] = 'query'
35
+ ENV['SERF_QUERY_NAME'] = 'foo:bar'
36
+ expect(STDIN).to receive(:read_nonblock).and_return('yeah')
19
37
  CustomHandler.run
20
38
  expect(CustomHandler.state[:payload]).to eq('yeah')
21
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serfx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rnjib Dey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-17 00:00:00.000000000 Z
11
+ date: 2016-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  version: '0'
192
192
  requirements: []
193
193
  rubyforge_project:
194
- rubygems_version: 2.2.2
194
+ rubygems_version: 2.4.5.1
195
195
  signing_key:
196
196
  specification_version: 4
197
197
  summary: A barebone ruby client for serf