cloud_powers 0.2.7.19 → 0.2.7.20

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: add8b897e6b88171351687b3569a5dc467db297b
4
- data.tar.gz: 63247946561f1847a897027f02c1207cf2ee86b6
3
+ metadata.gz: b1330146d000a13aee319704a78f3c5004c840ae
4
+ data.tar.gz: 2054b12b0dea8add6a54eb7ec067012c6d1ed2aa
5
5
  SHA512:
6
- metadata.gz: c863eb713865222925ba6e93d3c3dfd1f63a8150e2092834839f6a2728e84f6352c0a429c4c856797269cd658ba7875ebc2c0cae0a7499f86ee00e227e424273
7
- data.tar.gz: 3d57a7d912c85c21b35f8fbb72ef6c65f21b31ca407cbd55ff609f6a8ee83916ace37ee7f258777773169621a53ecddb7b2b3dd30c430ce33518b502d7ee5353
6
+ metadata.gz: abe4c93e185385357d00f1fbf90fd4ef3d9d7a8614cac1434237f4ccfd2c15f7a1fab8d06752f9c090a832ae2a01e9cd372d0d885c34125ed317272cd928fa9c
7
+ data.tar.gz: 6018ca2cdf684460ad3935d9a721cf1848a811bf54a870c6adcd5b650624d1df236bd1aaedf5d01e9e1423770977bd41590d9f25d02532f65dd7fdd8baed1f39
data/.gitignore CHANGED
@@ -14,3 +14,4 @@ lib/cloud_powers/synapse/.DS_Store
14
14
  .DS_Store
15
15
  ./**/.DS_Store
16
16
  lib/tasks
17
+ .idea
data/cloud_powers.gemspec CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |spec|
7
7
  spec.required_ruby_version = '~> 2.3.0'
8
8
  spec.name = 'cloud_powers'
9
9
  spec.version = CloudPowers::VERSION
10
- spec.authors = ['Adam Phillipps', 'Faisal Irfan']
11
- spec.email = ['adam.phillipps@gmail.com', 'Faisal@smashanalytics.com']
10
+ spec.authors = ['Adam Phillipps', 'Faisal Irfan', 'Gerardo Parajeles']
11
+ spec.email = ['adam.phillipps@gmail.com', 'faisal@smashanalytics.com', 'gerardo@smashanalytics.com']
12
12
  spec.summary = %q{Cloud providers wrapper. Currently only AWS is supported.}
13
13
  spec.description = <<-EOF
14
14
  CloudPowers is a wrapper around AWS and in the future, other cloud service Providers.
@@ -4,34 +4,54 @@ module Smash
4
4
  module CloudPowers
5
5
  module Synapse
6
6
  module WebSocClient
7
- def create_websoc_client( host, port )
7
+
8
+ def create_websoc_client(opts = {})
9
+
8
10
  EM.run do
9
11
 
10
- ws = WebSocket::EventMachine::Client.connect(:uri => 'ws://' + host + ':' + port)
12
+ ws = WebSocket::EventMachine::Client.connect(:uri => 'ws://' + opts[:host] + ':' + opts[:port])
13
+ add_to_clients(opts[:name],ws)
11
14
 
12
- ws.onopen do
15
+ open_callback = opts[:on_open] || Proc.new do
13
16
  puts "Connected"
14
17
  end
15
18
 
16
- ws.onmessage do |msg, type|
19
+ ws.onopen &open_callback
20
+
21
+ on_message_callback = opts[:on_message] || Proc.new do |msg, type|
17
22
  puts "Received message: #{msg}"
18
23
  end
19
-
20
- ws.onerror do |error|
24
+
25
+ ws.onmessage &on_message_callback
26
+
27
+ on_error_callback = opts[:on_error] || Proc.new do |error|
21
28
  puts "Error ==> #{error}"
22
29
  end
23
30
 
24
- ws.onclose do |code, reason|
31
+ ws.onerror &on_error_callback
32
+
33
+ on_close_callback = opts[:on_close] || Proc.new do |code, reason|
25
34
  puts "Disconnected with status code: #{code}"
26
35
  puts "Disconnected with status message: #{reason}"
27
36
  end
28
37
 
29
- EventMachine.next_tick do
30
- ws.send "Hello Server!"
31
- end
38
+ ws.onclose &on_close_callback
39
+
40
+ end
41
+
42
+ end
43
+
44
+ def add_to_clients(name,client)
45
+ begin
46
+ @clients[name] = client
47
+ rescue NoMethodError => e
48
+ puts e.backtrace
49
+ puts "no client hash is available"
32
50
  end
33
51
  end
34
52
  end
35
53
  end
36
54
  end
37
55
  end
56
+
57
+
@@ -1,43 +1,46 @@
1
1
  require 'websocket-eventmachine-server'
2
-
3
2
  module Smash
4
3
  module CloudPowers
5
4
  module Synapse
6
5
  module WebSocServer
7
- def create_websoc_server( host, port )
8
- @channel = EM::Channel.new
6
+ def create_websoc_server(opts = {})
7
+ channel = opts[:channel] || EM::Channel.new
9
8
  Thread.new do
10
9
  EM.run do
11
- WebSocket::EventMachine::Server.start(:host => host, :port => port) do |ws|
10
+ WebSocket::EventMachine::Server.start(:host => opts[:host], :port => opts[:port]) do |ws|
12
11
  sid = nil
13
12
 
14
- ws.onopen do
13
+ open_callback = opts[:on_open] || Proc.new do
15
14
  puts "Client connected"
16
- sid = @channel.subscribe { |msg| ws.send msg }
15
+ sid = channel.subscribe { |msg| ws.send msg }
17
16
  end
17
+ ws.onopen &open_callback
18
18
 
19
- ws.onmessage do |msg, type|
20
- puts "Received message: #{msg}"
21
- @channel.push "<#{sid}>: #{msg}"
19
+ on_message_callback = opts[:on_message] || Proc.new do |msg, type|
20
+ @current_websocket_message = msg
22
21
  end
22
+ ws.onmessage &on_message_callback
23
23
 
24
- ws.onerror do |error|
24
+ on_error_callback = opts[:on_error] || Proc.new do |error|
25
25
  puts "Error occured: #{error}"
26
26
  end
27
+ ws.onerror &on_error_callback
27
28
 
28
- ws.onclose do
29
+ on_close_callback = opts[:on_close] || Proc.new do
29
30
  puts "Client disconnected"
30
- @channel.unsubscribe(sid) unless @channel.nil?
31
+ channel.unsubscribe(sid) unless channel.nil?
31
32
  end
33
+ ws.onclose &on_close_callback
32
34
  end
33
35
  end
34
36
  end
37
+ channel
35
38
  end
36
39
 
37
- def send( msg )
38
- @channel.push "#{msg}" unless @channel.nil?
40
+ def send(channel, msg)
41
+ channel.push msg
39
42
  end
40
43
  end
41
44
  end
42
45
  end
43
- end
46
+ end
@@ -1,3 +1,3 @@
1
1
  module CloudPowers
2
- VERSION = '0.2.7.19'
2
+ VERSION = '0.2.7.20'
3
3
  end
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud_powers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7.19
4
+ version: 0.2.7.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Phillipps
8
8
  - Faisal Irfan
9
+ - Gerardo Parajeles
9
10
  autorequire:
10
11
  bindir: exe
11
12
  cert_chain: []
12
- date: 2016-10-24 00:00:00.000000000 Z
13
+ date: 2016-10-26 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: activesupport-core-ext
@@ -211,7 +212,8 @@ description: |2
211
212
  Enjoy!
212
213
  email:
213
214
  - adam.phillipps@gmail.com
214
- - Faisal@smashanalytics.com
215
+ - faisal@smashanalytics.com
216
+ - gerardo@smashanalytics.com
215
217
  executables: []
216
218
  extensions: []
217
219
  extra_rdoc_files: []
@@ -245,7 +247,6 @@ files:
245
247
  - lib/cloud_powers/synapse/queue/queue.rb
246
248
  - lib/cloud_powers/synapse/synapse.rb
247
249
  - lib/cloud_powers/synapse/websocket/websocclient.rb
248
- - lib/cloud_powers/synapse/websocket/websocket_adam.rb
249
250
  - lib/cloud_powers/synapse/websocket/websocserver.rb
250
251
  - lib/cloud_powers/version.rb
251
252
  - lib/cloud_powers/workflow_factory.rb
@@ -1,46 +0,0 @@
1
- require 'websocket-eventmachine-server'
2
- module Smash
3
- module CloudPowers
4
- module Synapse
5
- module WebSocServer
6
- def create_wesoc_server(opts = {})
7
- channel = opts[:channel] || EM::Channel.new
8
- Thread.new do
9
- Em.run do
10
- WebSocket::EventMachine::Server.start(:host => host, :port => port) do |ws|
11
- sid = nil
12
-
13
- open_callback = opts[:on_open] || Proc.new do
14
- puts "Client connected"
15
- sid = channel.subscribe { |msg| ws.send msg }
16
- end
17
- ws.onopen { open_callback }
18
-
19
- on_message_callback = opts[:on_message] || Proc.new do |msg, type|
20
- @current_websocket_message = msg
21
- end
22
- ws.onmessage { on_message_callback }
23
-
24
- on_error_callback = opts[:on_error] || Proc.new do |error|
25
- puts "Error occured: #{error}"
26
- end
27
- ws.onerror { on_error_callback }
28
-
29
- on_close_callback = opts[:on_close] || Proc.new do
30
- puts "Client disconnected"
31
- channel.unsubscribe(sid) unless channel.nil?
32
- end
33
- ws.onclose { on_close_callback }
34
- end
35
- end
36
- end
37
- channel
38
- end
39
-
40
- def send(channel, msg)
41
- channel.push msg
42
- end
43
- end
44
- end
45
- end
46
- end