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.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/atlasats.rb +13 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDVhNTY0NWY4MWU3MjE2ZjdjNzFkMjU0ZmY0MzZmOTI2NTI4ZWI1MA==
4
+ Mzg4OTdiODE2MGNlZTllM2RjNDE0NGZkMmZkZjgxNWQ0ZGI2YmZhNw==
5
5
  data.tar.gz: !binary |-
6
- N2Y1ZWEzOWNhNzUyNjRlMzE4MTA5OTZhOTk5ZTBkMjljZmNjY2FjOQ==
6
+ ZDYwYmI2YTcxN2Y3N2U0MzJjNWExNTIxYWRmNGE2ZGZkYzE3MmViOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDg4ZjA5YjVkOGVhMzQ2OTcwZTYxYTQ1ODEwZGY5YjlhNzBlZDI3ZjkzYzhj
10
- YWFmMzMyODdkNTFhMjlhODVkNGVmZjhjYmU5OTg3ODcxMTNmYWE3NzY3MjM5
11
- YjdiODNlOTczMzFiOTlmODdlOTY3YmY3YzAyZWRjZGIwOTk2ZmI=
9
+ YWYxOWMyYzRkMDYyNzk3OGMyYTM3ZDAxOTMwNzIxOTY3ZmIwOGJhMGRmMzI2
10
+ MjA1MzIzZGJhZGQ1OTE4NzMwYzVmZWQxZTA1ODE4Nzk3YWU3NzllMDQ2ODE0
11
+ MzMzMDA4YmYzOTEzZDM2MmI5OTM3MDY0OWNhM2VkZjk0YjBlOWE=
12
12
  data.tar.gz: !binary |-
13
- NDYwNWE2NzhmM2VlYWMzODlkYjI4YzViMmMwZGFhZjAyOTRlNTQ3ZmFjNTU1
14
- Y2U4MjY5MTIxNzFlZmM4YmFkYWExMWQwZGU1NTQ1ZDAzYWE5NGY1ZmQ2ZGFi
15
- ZmEwNzU0NmFhNjUxNjhjZWVmOGZkMWExNmNmZDU0Nzg3MDQ5MWY=
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
- @baseuri = buri
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("https://#{@baseuri}:4000/api")
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("https://#{@baseuri}:4000/api")
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("https://#{@baseuri}:4000/api")
105
+ client = Faye::Client.new("#{@baseuri}:4000/api")
98
106
  client.subscribe("/market/#{item}/#{currency}") do |msg|
99
107
  pmsg = nil
100
108
  begin
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atlasats
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Habeel Ahmed