peatio 0.3.0 → 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
  SHA256:
3
- metadata.gz: e0654fc5cd21783e8e22ca88db407d01f1c268032f09b347dfed2f49ca3aae8e
4
- data.tar.gz: 3346353884ce7fd78c47d8b6f8bad7f2a3d360a4366ba1b1f635e8eb750b87ba
3
+ metadata.gz: b0d3ce673d8d8f9b77484da9a2cd33c8cc7183aeb6211e59a52b0a983a6cee79
4
+ data.tar.gz: 830772aa7d66c0503dd0a1b5c99feeb90730c9b78a920da57245d15efa666aaa
5
5
  SHA512:
6
- metadata.gz: d5d538caf05569e94c3f812d5f15cfa49a5cbcfa0d23c1ccbc2f76a3c66fbb56c8c4f0e83e61dba96c1550bdc9b7a816bd7c3093e5b0e50b6fc0f5cce47f34e7
7
- data.tar.gz: 9a5304ac15012c2488aadb4990bc62c331bb7e7f0f8cbd3f044ad3dd7ae1a0cc51f524f062b0abd46f7df31a8003486bcd70b0d0d2b9690547ecc4b8bfb0916e
6
+ metadata.gz: 419ec676861d611c1aa5ba4c3c136904837f23faf277875a6e94218d0f5ac35fac30216fa8ee0db12336b0177a9bbf117a22df0a6fe7cde944f6411ac6832ff1
7
+ data.tar.gz: 859f0b584f43cd9ed0b798fec7e27c4e6705d2822a6242dad4b3eb7c4650b19a034ec36af76c54790b825f8ee36864cf7a15e4d42f92a11926e3ca3a18f3bcf9
@@ -1,5 +1,9 @@
1
1
  sudo: false
2
2
  language: ruby
3
+ cache: bundler
3
4
  rvm:
4
5
  - 2.5.1
5
- before_install: gem install bundler -v 1.16.2
6
+ before_install: gem install bundler -v 1.16.3
7
+ env:
8
+ - WEBSOCKET_HOST: localhost
9
+ WEBSOCKET_PORT: 8081
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- peatio (0.2.0)
4
+ peatio (0.4.0)
5
5
  amqp
6
6
  bunny
7
7
  clamp
@@ -11,8 +11,7 @@ module Peatio::Auth
11
11
 
12
12
  super(
13
13
  code: 2001,
14
- text: "Authorization failed: #{reason}",
15
- status: 401,
14
+ text: "Authorization failed".tap { |t| t << ": #{reason}" if reason },
16
15
  )
17
16
  end
18
17
  end
@@ -96,7 +96,7 @@ module Peatio::Auth
96
96
  when Peatio::Auth::Error
97
97
  raise(error)
98
98
  else
99
- raise(Peatio::Auth::Error, e.inspect)
99
+ raise(Peatio::Auth::Error, error.message)
100
100
  end
101
101
  end
102
102
 
@@ -121,7 +121,7 @@ module Peatio::Auth
121
121
 
122
122
  payload
123
123
  rescue JWT::DecodeError => e
124
- raise(Peatio::Auth::Error, "Failed to decode and verify JWT: #{e.inspect}.")
124
+ raise(Peatio::Auth::Error, "Failed to decode and verify JWT")
125
125
  end
126
126
  end
127
127
  end
@@ -1,6 +1,5 @@
1
1
  class Peatio::Error < ::StandardError
2
2
  @@default_code = 2000
3
- @@default_status = 400
4
3
 
5
4
  attr :code, :text
6
5
 
@@ -8,7 +7,6 @@ class Peatio::Error < ::StandardError
8
7
  @code = opts[:code] || @@default_code
9
8
  @text = opts[:text] || ""
10
9
 
11
- @status = opts[:status] || @@default_status
12
10
  @message = {error: {code: @code, message: @text}}
13
11
 
14
12
  if @text != ""
@@ -17,11 +15,4 @@ class Peatio::Error < ::StandardError
17
15
  super("#{@code}")
18
16
  end
19
17
  end
20
-
21
- def inspect
22
- message = @text
23
- message += " (#{@reason})" unless @reason.nil?
24
-
25
- %[#<#{self.class.name}: #{message}>]
26
- end
27
18
  end
@@ -46,7 +46,7 @@ module Peatio::MQ::Events
46
46
  end
47
47
 
48
48
  def send_payload(message)
49
- @socket.send message
49
+ @socket.send message.to_json
50
50
  end
51
51
  end
52
52
 
@@ -58,6 +58,11 @@ module Peatio::MQ::Events
58
58
  end
59
59
 
60
60
  def connect!
61
+ if Peatio::MQ::Client.channel.nil?
62
+ Peatio::MQ::Client.new
63
+ Peatio::MQ::Client.connect!
64
+ Peatio::MQ::Client.create_channel!
65
+ end
61
66
  @exchange = Peatio::MQ::Client.channel.topic(@exchange_name)
62
67
  end
63
68
 
@@ -98,11 +103,12 @@ module Peatio::MQ::Events
98
103
  end
99
104
 
100
105
  type, id, event = routing_key.split(".")
106
+ payload_decoded = JSON.parse payload
101
107
 
102
108
  if type == "private"
103
109
  Client.user(id) do |client|
104
110
  if client.streams.include?(event)
105
- client.send_payload payload
111
+ client.send_payload [event, payload_decoded]
106
112
  end
107
113
  end
108
114
 
@@ -112,8 +118,8 @@ module Peatio::MQ::Events
112
118
  stream = [id, event].join(".")
113
119
 
114
120
  Client.all.each do |handler|
115
- if handler.streams.include?(stream)
116
- handler.send_payload payload
121
+ if handler.streams.include?(id) or handler.streams.include?(stream)
122
+ handler.send_payload [stream, payload_decoded]
117
123
  end
118
124
  end
119
125
  end
@@ -1,3 +1,3 @@
1
1
  module Peatio
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency "mysql2"
30
30
  spec.add_dependency "jwt"
31
31
  spec.add_dependency "bunny"
32
+
32
33
  spec.add_development_dependency "bundler", "~> 1.16"
33
34
  spec.add_development_dependency "rake", "~> 10.0"
34
35
  spec.add_development_dependency "rspec", "~> 3.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peatio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis B.
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-08-17 00:00:00.000000000 Z
12
+ date: 2018-08-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clamp
@@ -310,7 +310,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
310
310
  version: '0'
311
311
  requirements: []
312
312
  rubyforge_project:
313
- rubygems_version: 2.7.3
313
+ rubygems_version: 2.7.7
314
314
  signing_key:
315
315
  specification_version: 4
316
316
  summary: Peatio is a gem for running critical core services