atlasats 1.0.5 → 1.0.6
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 +8 -8
- data/lib/atlasats.rb +13 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Mzg4OTdiODE2MGNlZTllM2RjNDE0NGZkMmZkZjgxNWQ0ZGI2YmZhNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDYwYmI2YTcxN2Y3N2U0MzJjNWExNTIxYWRmNGE2ZGZkYzE3MmViOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWYxOWMyYzRkMDYyNzk3OGMyYTM3ZDAxOTMwNzIxOTY3ZmIwOGJhMGRmMzI2
|
10
|
+
MjA1MzIzZGJhZGQ1OTE4NzMwYzVmZWQxZTA1ODE4Nzk3YWU3NzllMDQ2ODE0
|
11
|
+
MzMzMDA4YmYzOTEzZDM2MmI5OTM3MDY0OWNhM2VkZjk0YjBlOWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjNkMjVhNDU1MmU4NWIxMjA0MzMxNzdjOGFkYTMyYjEwOWU4NDQ3OGE5ZTE2
|
14
|
+
MGQzN2Q0ODBmNTNhNDM0ZjQyM2Q3OWIwYzM0YjJhYjc4YmMxZGU2MTA1ODRi
|
15
|
+
OTJhZGFlY2ViYmFmN2RkNDI2MmQ3OTYxZjNiMmU1NTA4NDhhNDM=
|
data/lib/atlasats.rb
CHANGED
@@ -10,7 +10,15 @@ class AtlasClient
|
|
10
10
|
include HTTParty
|
11
11
|
|
12
12
|
def initialize(buri, apikey)
|
13
|
-
|
13
|
+
# strip out 'http://' or 'https://' since it's no longer the user's choice
|
14
|
+
cleanuri = buri.gsub(/http:\/\/|https:\/\//, '')
|
15
|
+
## Only production environments require HTTPS
|
16
|
+
# Use HTTP if the base URI matches either:
|
17
|
+
# - 'test.*' OR
|
18
|
+
# - 'dev.*'
|
19
|
+
prefix = /^test\.|^dev\./.match(cleanuri).nil? ? 'https://' : 'http://'
|
20
|
+
# produce the correct @baseuri
|
21
|
+
@baseuri = prefix + cleanuri
|
14
22
|
@options = { :headers => { "Authorization" => "Token token=\"#{apikey}\"" }, :base_uri => HTTParty.normalize_base_uri(@baseuri) }
|
15
23
|
end
|
16
24
|
|
@@ -67,7 +75,7 @@ class AtlasClient
|
|
67
75
|
def subscribe_quotes(&block)
|
68
76
|
Thread.new do
|
69
77
|
EM.run {
|
70
|
-
client = Faye::Client.new("
|
78
|
+
client = Faye::Client.new("#{@baseuri}:4000/api")
|
71
79
|
client.subscribe("/quotes") do |msg|
|
72
80
|
block.call(msg)
|
73
81
|
end
|
@@ -78,7 +86,7 @@ class AtlasClient
|
|
78
86
|
def subscribe_trades(&block)
|
79
87
|
Thread.new do
|
80
88
|
EM.run {
|
81
|
-
client = Faye::Client.new("
|
89
|
+
client = Faye::Client.new("#{@baseuri}:4000/api")
|
82
90
|
client.subscribe("/trades") do |msg|
|
83
91
|
begin
|
84
92
|
pmsg = JSON.parse(msg)
|
@@ -90,11 +98,11 @@ class AtlasClient
|
|
90
98
|
}
|
91
99
|
end
|
92
100
|
end
|
93
|
-
|
101
|
+
|
94
102
|
def subscribe_book_updates(item, currency, &block)
|
95
103
|
Thread.new do
|
96
104
|
EM.run {
|
97
|
-
client = Faye::Client.new("
|
105
|
+
client = Faye::Client.new("#{@baseuri}:4000/api")
|
98
106
|
client.subscribe("/market/#{item}/#{currency}") do |msg|
|
99
107
|
pmsg = nil
|
100
108
|
begin
|