boutons 0.3.5 → 0.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 395a488c36000d58f046a462efd3c3f99e948c38
4
- data.tar.gz: eed04265d3dce468adacfaa3689e8890d93305e4
3
+ metadata.gz: 51727c2ed0f15675876579d355fdf01aa2edbae0
4
+ data.tar.gz: ddd212a3a02675be8aad3e7853924c1fb691dd89
5
5
  SHA512:
6
- metadata.gz: 5ad7ce5ff7eeee4004a73fbd9f2283d13f05383cd94980af99ed70a27e929ac31b4b255205130727f84253e9d408fdfbeb9bb039219eb104db4d3eac181b9131
7
- data.tar.gz: 6f7d5c886d71329a31e353742d3288273f2dae1bac14b8aca8e385c05b62045e8d86dbeed12e774b598e8c9716caa9bed6be7d8122d9cfd4e8a9a777be5c279c
6
+ metadata.gz: 0271103992aa33d3f24b40a3ba5e4f8d8d8ce1a6ef227a6ad3fc0ba188e5192f74d86ad43f19bdbdec600b9e6d09b8fa8ec2f0fd9af614f0a30c4be54f20285d
7
+ data.tar.gz: 2402112f0f91ad4aa9f176dcb6fda1570e8b8a314a72d74cd858841cc3e117510fd57112a4a89a3079b2da56997aa8f2cc4ba82faeff1036686d50ad70495f2e
data/lib/boutons/uri.rb CHANGED
@@ -10,8 +10,26 @@ module Boutons
10
10
  def service
11
11
  @uri.scheme
12
12
  end
13
+
13
14
  def zk_hosts
14
- Config.registry.send(service).hosts
15
+ @hosts = []
16
+ if @uri.host
17
+ if ::URI.unescape(@uri.host)=~/\{(.*)\}/
18
+ uris = ::URI.unescape(@uri.host).split(",").select do |x|
19
+ x=~/\{(.*)\}/
20
+ end.collect do |x|
21
+ URI "#{@uri.scheme}://#{x[1..-2].reverse.sub(';',':').reverse}/"
22
+ end
23
+ uris.each do |uri|
24
+ @hosts << "#{uri.host}:#{uri.port || 2181 }"
25
+ end
26
+ else
27
+ @hosts << "#{@uri.host}:#{@uri.port || 2181 }"
28
+ end
29
+ else
30
+ @hosts = Config.registry.send(service).hosts
31
+ end
32
+ @hosts
15
33
  end
16
34
  def zk
17
35
  begin
@@ -46,20 +64,12 @@ module Boutons
46
64
  end
47
65
  end
48
66
  def zk_path
49
- return @zk_path if @zk_path
50
- paths = []
51
- paths << "nerve"
52
- paths += @uri.path.split("/")[1..-1].join("/#{@uri.host}/").split("/")
53
- paths << "services"
54
- paths.inject([Pathname.new("/")]) do |path,dir|
55
- path << path.last.join(dir)
56
- end.map{|p|p.to_s}.reverse.each do |path|
57
- return @zk_path = path unless zk.children(path).empty?
58
- end
67
+ @uri.path
59
68
  end
60
69
  end
61
70
  def initialize uri
62
- @uri ||= URI uri
71
+ uri = ::URI.escape uri
72
+ @uri ||= URI(uri)
63
73
  end
64
74
  def registry
65
75
  @registry ||= Registry.new @uri
@@ -1,3 +1,3 @@
1
1
  module Boutons
2
- VERSION = "0.3.5"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/boutons.rb CHANGED
@@ -128,12 +128,12 @@ module Boutons
128
128
  params[:method] = uri.registry.service
129
129
  params[:path] = uri.registry.zk_path
130
130
  params[:hosts] = uri.registry.zk_hosts
131
- params[:name] = uri.registry.zk_path[1..-1].gsub(/\//,"_")
131
+ params[:name] = service
132
132
  add Synapse::Easy::Service.new params
133
133
  end
134
134
  end
135
135
  def connectable? service
136
- Boutons::Config.services.keys.include?(service) rescue false
136
+ available.include?(service) rescue false
137
137
  end
138
138
  def connection service
139
139
  services[mapping[service]]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boutons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathias Kaufmann
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-25 00:00:00.000000000 Z
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: synapse