cexio-websocket 0.1.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 +7 -0
- data/.gitignore +8 -0
- data/.rubocop.yml +46 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +39 -0
- data/LICENSE.txt +21 -0
- data/README.md +75 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/cexio-websocket.gemspec +30 -0
- data/lib/cex/websocket/client.rb +38 -0
- data/lib/cex/websocket/version.rb +7 -0
- data/lib/cex/websocket.rb +24 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 82604cd63b3ca2a3a27514221422c4004b5ba3fb
|
4
|
+
data.tar.gz: 6edf446172e12216fd5d70c8385019716b523c54
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 96faaa6813f231f7dc0cb89c9ae2cff2b78daa430f2557f082d1db360fc8688bbd02a150278883aeee031a160c260cb865f46c3e378c0902e2b5d1a6ca2c82ef
|
7
|
+
data.tar.gz: 8aae661ba863f97e41b93b3d7ba47fcee46e6efd6647553f4633bf0127f158fff17b848160489e11ec580efb277279c6ecb6fe4c0cdbbd9fd4720664327337f0
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.3
|
3
|
+
|
4
|
+
##################### Styles ##################################
|
5
|
+
|
6
|
+
Style/Documentation:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Style/SymbolArray:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Style/ClassAndModuleChildren:
|
13
|
+
Exclude:
|
14
|
+
- "app/controllers/*_controller.rb"
|
15
|
+
- "app/controllers/**/*_controller.rb"
|
16
|
+
|
17
|
+
#################### Lint ##################################
|
18
|
+
|
19
|
+
Lint/AmbiguousBlockAssociation:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
##################### Metrics ##################################
|
23
|
+
|
24
|
+
Metrics/LineLength:
|
25
|
+
Max: 110
|
26
|
+
|
27
|
+
Metrics/ClassLength:
|
28
|
+
Max: 200
|
29
|
+
|
30
|
+
Metrics/ModuleLength:
|
31
|
+
Max: 200
|
32
|
+
Exclude:
|
33
|
+
- "**/*_spec.rb"
|
34
|
+
|
35
|
+
Metrics/BlockLength:
|
36
|
+
Max: 50
|
37
|
+
Exclude:
|
38
|
+
- "**/*_spec.rb"
|
39
|
+
|
40
|
+
##################### Rails ##################################
|
41
|
+
|
42
|
+
Rails:
|
43
|
+
Enabled: true
|
44
|
+
|
45
|
+
Rails/SkipsModelValidations:
|
46
|
+
Enabled: false
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cexio-websocket (0.1.0)
|
5
|
+
activesupport (~> 4.0)
|
6
|
+
kontena-websocket-client (~> 0.1.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (4.2.10)
|
12
|
+
i18n (~> 0.7)
|
13
|
+
minitest (~> 5.1)
|
14
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
15
|
+
tzinfo (~> 1.1)
|
16
|
+
concurrent-ruby (1.0.5)
|
17
|
+
i18n (0.9.1)
|
18
|
+
concurrent-ruby (~> 1.0)
|
19
|
+
kontena-websocket-client (0.1.1)
|
20
|
+
websocket-driver (~> 0.6.5)
|
21
|
+
minitest (5.11.1)
|
22
|
+
rake (10.5.0)
|
23
|
+
thread_safe (0.3.6)
|
24
|
+
tzinfo (1.2.4)
|
25
|
+
thread_safe (~> 0.1)
|
26
|
+
websocket-driver (0.6.5)
|
27
|
+
websocket-extensions (>= 0.1.0)
|
28
|
+
websocket-extensions (0.1.3)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
bundler (~> 1.16)
|
35
|
+
cexio-websocket!
|
36
|
+
rake (~> 10.0)
|
37
|
+
|
38
|
+
BUNDLED WITH
|
39
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Igor Malinovskiy
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# CEX.io Websocket
|
2
|
+
|
3
|
+
This gem is a simple implementation for [CEX.io](https://cex.io/websocket-api) websocket API
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'cexio-websocket'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```
|
22
|
+
$ gem install cexio-websocket
|
23
|
+
```
|
24
|
+
|
25
|
+
## Configuration
|
26
|
+
|
27
|
+
Default configuration:
|
28
|
+
|
29
|
+
`config/initializers/cex.rb`
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
CEX::Websocket.setup do |config|
|
33
|
+
config.uri = 'wss://ws.cex.io/ws/'
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
## Usage
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
client = CEX::Websocket::Client.new
|
41
|
+
client.listen_tickers do |message|
|
42
|
+
puts message
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
This code will output:
|
47
|
+
|
48
|
+
```json
|
49
|
+
{"e":"connected"}
|
50
|
+
{"e":"tick","data":{"symbol1":"ETH","symbol2":"USD","price":"997.0053","open24":"926.8021","volume":"10043.73349200"}}
|
51
|
+
```
|
52
|
+
|
53
|
+
## TODO
|
54
|
+
|
55
|
+
Current version only implements `listen tickers` method.
|
56
|
+
|
57
|
+
Next versions features:
|
58
|
+
|
59
|
+
* Authentication
|
60
|
+
* Signature generation
|
61
|
+
* Implement private methods
|
62
|
+
|
63
|
+
## Development
|
64
|
+
|
65
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
66
|
+
|
67
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
68
|
+
|
69
|
+
## Contributing
|
70
|
+
|
71
|
+
Bug reports and pull requests are welcome on GitHub at [cexio-websocket](https://github.com/psyipm/cexio-websocket).
|
72
|
+
|
73
|
+
## License
|
74
|
+
|
75
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'cex/websocket'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'cex/websocket/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'cexio-websocket'
|
9
|
+
spec.version = CEX::Websocket::VERSION
|
10
|
+
spec.authors = ['Igor Malinovskiy']
|
11
|
+
spec.email = ['igor.malinovskiy@netfixllc.org']
|
12
|
+
|
13
|
+
spec.summary = 'CEX.io websocket client'
|
14
|
+
spec.description = 'Gem to listen CEX.io updates via websocket'
|
15
|
+
spec.homepage = 'https://github.com/psyipm/cexio-websocket'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.bindir = 'exe'
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
|
28
|
+
spec.add_dependency 'activesupport', '~> 4.0'
|
29
|
+
spec.add_dependency 'kontena-websocket-client', '~> 0.1.1'
|
30
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'kontena-websocket-client'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module CEX
|
7
|
+
module Websocket
|
8
|
+
class Client
|
9
|
+
def listen_tickers(&_block)
|
10
|
+
payload = { e: :subscribe, rooms: ['tickers'] }
|
11
|
+
|
12
|
+
subscribe(payload) do |message|
|
13
|
+
yield message
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def subscribe(payload = {}, &_block)
|
20
|
+
raise 'BlockMissingError' unless block_given?
|
21
|
+
|
22
|
+
Kontena::Websocket::Client.connect(config_uri) do |client|
|
23
|
+
client.send(payload.to_json)
|
24
|
+
|
25
|
+
client.read do |message|
|
26
|
+
yield message
|
27
|
+
end
|
28
|
+
|
29
|
+
client.close(1000)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def config_uri
|
34
|
+
CEX::Websocket.uri
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cex/websocket/version'
|
4
|
+
require 'active_support'
|
5
|
+
|
6
|
+
module CEX
|
7
|
+
module Websocket
|
8
|
+
autoload :Client, 'cex/websocket/client'
|
9
|
+
|
10
|
+
mattr_accessor :uri
|
11
|
+
self.uri = 'wss://ws.cex.io/ws/'
|
12
|
+
|
13
|
+
# Setup
|
14
|
+
# @example
|
15
|
+
#
|
16
|
+
# CEX::Websocket.setup do |config|
|
17
|
+
# config.uri = 'wss://ws.cex.io/ws/'
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
def self.setup
|
21
|
+
yield self
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cexio-websocket
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Igor Malinovskiy
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: kontena-websocket-client
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.1.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.1.1
|
69
|
+
description: Gem to listen CEX.io updates via websocket
|
70
|
+
email:
|
71
|
+
- igor.malinovskiy@netfixllc.org
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rubocop.yml"
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- cexio-websocket.gemspec
|
86
|
+
- lib/cex/websocket.rb
|
87
|
+
- lib/cex/websocket/client.rb
|
88
|
+
- lib/cex/websocket/version.rb
|
89
|
+
homepage: https://github.com/psyipm/cexio-websocket
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.5.2
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: CEX.io websocket client
|
113
|
+
test_files: []
|