pagoda 0.7.0 → 0.7.1

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: ebf5df5a892dae6f2ab3422cd715a3e3dce31821
4
- data.tar.gz: eb90b58aa1084ea3e5a640dbc00d4d208cdfcf00
3
+ metadata.gz: b82fbafabb8913d4b309f98147a55e3e92429845
4
+ data.tar.gz: 0af5c92fb2d6c0e2fe0e187a4732b0daf7cabc42
5
5
  SHA512:
6
- metadata.gz: afa8eb59341f072e6f998b7fe0bbfe9a7ae9f30ce6c1d42a09c73cd3bed90d16e7b0ad6fa5fc78e9fe9bf0775bcd74a3e0f2f8768d5bcf026e3050a23e590e0f
7
- data.tar.gz: 2d58c7d5fbe50277938bc50ebd0a7ee27ccb4ad5f0acb631533cc0799cf297de6da1f577a88add8a7577de09899dd974172536fb922c140a5fd251897e3243d3
6
+ metadata.gz: 0c98df4a9e79fea3407038412b118bd77476d0307c25a133bf4b97b868c9ae16acbc0e10a2c6c334d3632d3109eaa4d6751c9d4e03ae43f23dad9f5abdb1aa4e
7
+ data.tar.gz: 2e7a3493cd6f28eeca0d7ad3d1be955e37a05562db3f3024cd1f4e1a0635cdd93712010da81ce2a3fdd83746763acfaf2f3af5e893cd930414ba8cb2199da78f
@@ -1,8 +1,7 @@
1
- require 'faye/websocket'
2
- require "msgpack"
1
+ require 'websocket-client-simple'
2
+ # require "msgpack"
3
3
  require 'json'
4
4
  require 'pp'
5
- require 'eventmachine'
6
5
  require "base64"
7
6
 
8
7
  module Pagoda::Command
@@ -28,59 +27,41 @@ module Pagoda::Command
28
27
 
29
28
  app_id = client.app_info(app)[:id]
30
29
  if options[:live]
31
- EM.run do
32
- STDOUT.sync = true
33
- # socket = WebSocket::EventMachine::Client.connect(:uri => "wss://#{user}:#{password}@live.pagodabox.com/stormpack/websocket/pagodabox?protocol=1&client=ruby&version=1.0.0&batch=false&adapter=msgpack&flash=false")
34
- socket = Faye::WebSocket::Client.new("wss://live.pagodabox.com/stormpack/websocket/pagodabox?protocol=1&client=ruby&version=1.0.0&batch=false&adapter=msgpack&flash=false&authorization=Basic%20#{Base64.encode64("#{user}:#{password}").chop.gsub(/\=/, '%3D')}")
35
-
36
- # puts "Connecting to #{socket.inspect}"
37
-
38
- # socket.onopen do
39
- # puts "Connected"
40
- # socket.send({"event"=>"stormpack:subscribe","data"=>{"channel"=>"app-log-#{app_id}"}}.to_msgpack, :type => :binary)
41
- # end
42
- socket.onopen = lambda do |event|
43
- # puts 'connection open'
44
- socket.send({"event"=>"stormpack:subscribe","data"=>{"channel"=>"app-log-#{app_id}"}}.to_msgpack.bytes.to_a)
45
- # puts "listening to app: #{app}"
46
- puts "Now tailing your live stream"
47
- puts "press 'ctrl+c to exit"
48
- puts "----------------------------"
49
- end
50
-
51
- # socket.onmessage do |msg, type|
52
- # puts "Received message: #{msg}"
53
- # end
54
- socket.onmessage = lambda do |event|
55
- # p [:message, MessagePack.unpack(event.data.pack("c*"))]
56
- data = MessagePack.unpack(event.data.pack("c*"))
57
- if data['keypath']
58
- colorize "[#{Time.at(data['data']['time'].to_i / 1000000) rescue Time.now}] #{(data['data']['log'].split(':').first rescue '')} : ", (data['data']['log'].split(':').first rescue 'str'), false
59
- puts data['data']['log'].to_s.split(':')[1..-1].join(":").strip
60
- # else
61
- # puts data
62
- end
30
+ STDOUT.sync = true
31
+ socket = WebSocket::Client::Simple.connect("wss://live.pagodabox.com/stormpack/websocket/pagodabox?protocol=1&client=ruby&version=1.0.0&batch=false&adapter=json&flash=false&authorization=Basic%20#{Base64.encode64("#{user}:#{password}").chop.gsub(/\=/, '%3D')}")
32
+
33
+ socket.on :open do
34
+ socket.send({"event"=>"stormpack:subscribe","data"=>{"channel"=>"app-log-#{app_id}"}}.to_json, {:type => :binary})
35
+ puts "Now tailing your live stream"
36
+ puts "press 'ctrl+c to exit"
37
+ puts "----------------------------"
38
+ end
39
+
40
+ socket.on :message do |msg|
41
+ data = JSON.parse(msg.to_s)
42
+ if (data['keypath'] rescue false)
43
+ @cla ||= Pagoda::Command::Log.new(nil, nil, nil)
44
+ @cla.colorize "[#{Time.at(data['data']['time'].to_i / 1000000) rescue Time.now}] #{(data['data']['log'].split(':').first rescue '')} : ", (data['data']['log'].split(':').first rescue 'str'), false
45
+ puts data['data']['log'].to_s.split(':')[1..-1].join(":").strip
63
46
  end
47
+ end
64
48
 
65
- # socket.onclose do
66
- # puts "Disconnected"
67
- # end
68
- socket.onclose = lambda do |event|
69
- # puts 'Server connection closed'
70
- EM.stop
71
- end
49
+ socket.on :close do |e|
50
+ p e
51
+ exit 1
52
+ end
72
53
 
73
- [:INT, :TERM].each do |sig|
74
- Signal.trap(sig) do
75
- STDOUT.sync = false
76
- # socket.close 1000, 'Going away'
77
- puts "Log closing."
78
- puts "----------------------------"
79
- puts
80
- socket.close
81
- end
54
+ [:INT, :TERM].each do |sig|
55
+ Signal.trap(sig) do
56
+ STDOUT.sync = false
57
+ # socket.close 1000, 'Going away'
58
+ puts "Log closing."
59
+ puts "----------------------------"
60
+ puts
61
+ exit 1
82
62
  end
83
63
  end
64
+ sleep
84
65
  else
85
66
  count = (options[:count] || 100).to_i
86
67
 
@@ -1,5 +1,5 @@
1
1
  module Pagoda
2
2
  module CLI
3
- VERSION = "0.7.0"
3
+ VERSION = "0.7.1"
4
4
  end
5
5
  end
data/pagoda.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |gem|
22
22
  gem.add_dependency "pagoda-tunnel"
23
23
  gem.add_dependency "rest-client"
24
24
  gem.add_dependency "gli", '~> 2.0.0'
25
- gem.add_dependency 'faye-websocket'
26
- gem.add_dependency 'msgpack'
27
- gem.add_dependency 'eventmachine'
25
+ gem.add_dependency "websocket-client-simple"
26
+ # gem.add_dependency 'msgpack'
27
+ # gem.add_dependency 'eventmachine'
28
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagoda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lyon Hill
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-29 00:00:00.000000000 Z
11
+ date: 2013-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -95,35 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: 2.0.0
97
97
  - !ruby/object:Gem::Dependency
98
- name: faye-websocket
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - '>='
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: msgpack
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - '>='
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: eventmachine
98
+ name: websocket-client-simple
127
99
  requirement: !ruby/object:Gem::Requirement
128
100
  requirements:
129
101
  - - '>='