Skip to content

Commit 1b5f9d1

Browse files
committed
style: functions in tests to snake case
1 parent 0865ba5 commit 1b5f9d1

18 files changed

+155
-238
lines changed

.rubocop.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

Gemfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# frozen_string_literal: true
2-
source "https://rubygems.org"
32

4-
gem 'rest-client'
5-
gem 'openssl'
3+
source 'https://rubygems.org'
4+
65
gem 'eventmachine'
76
gem 'faye-websocket'
7+
gem 'openssl'
8+
gem 'rest-client'
89

910

1011
group :test do
11-
gem 'test-unit'
1212
gem 'rubocop'
13-
end
13+
gem 'test-unit'
14+
end

Gemfile.lock

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4+
ast (2.4.2)
45
domain_name (0.6.20240107)
56
eventmachine (1.2.7)
67
faye-websocket (0.11.3)
@@ -9,19 +10,44 @@ GEM
910
http-accept (1.7.0)
1011
http-cookie (1.0.5)
1112
domain_name (~> 0.5)
13+
json (2.7.1)
14+
language_server-protocol (3.17.0.3)
1215
mime-types (3.5.2)
1316
mime-types-data (~> 3.2015)
1417
mime-types-data (3.2024.0206)
1518
netrc (0.11.0)
1619
openssl (3.2.0)
20+
parallel (1.24.0)
21+
parser (3.3.0.5)
22+
ast (~> 2.4.1)
23+
racc
1724
power_assert (2.0.3)
25+
racc (1.7.3)
26+
rainbow (3.1.1)
27+
regexp_parser (2.9.0)
1828
rest-client (2.1.0)
1929
http-accept (>= 1.7.0, < 2.0)
2030
http-cookie (>= 1.0.2, < 2.0)
2131
mime-types (>= 1.16, < 4.0)
2232
netrc (~> 0.8)
33+
rexml (3.2.6)
34+
rubocop (1.60.2)
35+
json (~> 2.3)
36+
language_server-protocol (>= 3.17.0)
37+
parallel (~> 1.10)
38+
parser (>= 3.3.0.2)
39+
rainbow (>= 2.2.2, < 4.0)
40+
regexp_parser (>= 1.8, < 3.0)
41+
rexml (>= 3.2.5, < 4.0)
42+
rubocop-ast (>= 1.30.0, < 2.0)
43+
ruby-progressbar (~> 1.7)
44+
unicode-display_width (>= 2.4.0, < 3.0)
45+
rubocop-ast (1.30.0)
46+
parser (>= 3.2.1.0)
47+
ruby-progressbar (1.13.0)
2348
test-unit (3.6.2)
2449
power_assert
50+
unicode-display_width (2.5.0)
2551
websocket-driver (0.7.6)
2652
websocket-extensions (>= 0.1.0)
2753
websocket-extensions (0.1.5)
@@ -34,6 +60,7 @@ DEPENDENCIES
3460
faye-websocket
3561
openssl
3662
rest-client
63+
rubocop
3764
test-unit
3865

3966
BUNDLED WITH

lib/cryptomarket/client.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# frozen_string_literal: true
22

3+
# rubocop:disable Layout/LineLength
34
require_relative 'http_manager'
45

56
module Cryptomarket

lib/cryptomarket/credentials_factory.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
module Cryptomarket
1212
# Builds a credential used by the cryptomarket server
13-
class CredentialFactory
14-
def initialize(api_key:, api_secret:, window: nil)
13+
class CredentialsFactory
14+
def initialize(api_version:, api_key:, api_secret:, window: nil)
15+
@api_version = api_version
1516
@api_key = api_key
1617
@api_secret = api_secret
1718
@window = window
@@ -29,7 +30,7 @@ def get_credential(http_method, method, params)
2930
end
3031

3132
def build_credential_message(http_method, method, timestamp, params)
32-
msg = http_method + @@api_version + method
33+
msg = http_method + @api_version + method
3334
msg += if http_method.upcase == 'POST'
3435
params
3536
else

lib/cryptomarket/http_manager.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,35 @@
77
require 'rest-client'
88
require 'date'
99
require_relative 'exceptions'
10-
require_relative 'credential_factory'
10+
require_relative 'credentials_factory'
1111

1212
module Cryptomarket
1313
# Manager of http requests to the cryptomarket server
1414
class HttpManager
15-
Request = Data.define(:uri, :endpoint, :payload, :headers, :is_json)
1615
@@API_URL = 'https://api.exchange.cryptomkt.com' # rubocop:disable Naming/VariableName,Style/ClassVars
1716
@@API_VERSION = '/api/3/' # rubocop:disable Naming/VariableName,Style/ClassVars
1817

1918
def initialize(api_key:, api_secret:, window: nil)
20-
@credential_factory = CredentialFactory(api_key, api_secret, window)
19+
@credential_factory = Cryptomarket::CredentialsFactory.new(
20+
api_version: @@API_VERSION, api_key: api_key, api_secret: api_secret, window: window
21+
)
2122
end
2223

2324
def make_request(method:, endpoint:, params: nil, public: false)
24-
uri = URI(@@API_URL + version_as_str + endpoint)
25+
uri = URI(@@API_URL + @@API_VERSION + endpoint)
2526
payload = build_payload(params)
2627
headers = build_headers(method, endpoint, params, public)
2728
if ((method.upcase == 'GET') || (method.upcase == 'PUT')) && !payload.nil?
28-
payload = nil
2929
uri.query = URI.encode_www_form payload
30+
payload = nil
3031
end
31-
do_request(Request[method, uri, payload, headers, false])
32+
do_request(method, uri, payload, headers)
3233
end
3334

3435
def make_post_request(method:, endpoint:, params: nil)
35-
uri = URI(@@API_URL + version_as_str + endpoint)
36+
uri = URI(@@API_URL + @@API_VERSION + endpoint)
3637
payload = build_payload(params)
37-
do_request(Request[method, uri, payload, build_post_headers(endpoint, payload), true])
38+
do_request(method, uri, payload, build_post_headers(endpoint, payload), is_json: true)
3839
end
3940

4041
def build_headers(method, endpoint, params, public)
@@ -51,12 +52,11 @@ def build_payload(params)
5152
payload
5253
end
5354

54-
def do_request(request:)
55+
def do_request(method, uri, payload, headers, is_json: false)
5556
response = RestClient::Request.execute(
56-
method: request.method.downcase.to_sym, url: request.uri.to_s,
57-
payload: request.payload.to_json, headers: request.headers
57+
method: method.downcase.to_sym, url: uri.to_s, payload: payload.to_json, headers: headers
5858
)
59-
response[:content_type] = :json if request.is_json
59+
response[:content_type] = :json if is_json
6060
handle_response(response)
6161
rescue RestClient::ExceptionWithResponse => e
6262
handle_response(e.response)

lib/cryptomarket/websocket/market_data_client.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# frozen_string_literal: true
22

3+
# rubocop:disable Layout/LineLength
34
require 'securerandom'
45

56
require_relative 'market_data_client_core'
@@ -269,9 +270,7 @@ def subscribe_to_top_of_book_in_batches(callback:, speed:, symbols: ['*'], resul
269270

270271
def subscribe_to_price_rates(callback:, speed:, target_currency:, currencies: ['*'], result_callback: nil)
271272
params = {
272-
speed: speed,
273-
target_currency: target_currency,
274-
currencies: currencies
273+
speed: speed, target_currency: target_currency, currencies: currencies
275274
}
276275
send_channel_subscription("price/rate/#{speed}", params, callback,
277276
intercept_result_callback(result_callback))
@@ -295,9 +294,7 @@ def subscribe_to_price_rates(callback:, speed:, target_currency:, currencies: ['
295294
def subscribe_to_price_rates_in_batches(callback:, speed:, target_currency:, currencies: ['*'],
296295
result_callback: nil)
297296
params = {
298-
speed: speed,
299-
target_currency: target_currency,
300-
currencies: currencies
297+
speed: speed, target_currency: target_currency, currencies: currencies
301298
}
302299
send_channel_subscription("price/rate/#{speed}/batch", params, callback,
303300
intercept_result_callback(result_callback))

lib/cryptomarket/websocket/trading_client.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# frozen_string_literal: true
22

3+
# rubocop:disable Layout/LineLength
34
require_relative 'auth_client'
45
require_relative '../constants'
56

@@ -177,10 +178,7 @@ def create_spot_order( # rubocop:disable Metrics/ParameterLists
177178
# +Proc+ +callback+:: Optional. A +Proc+ of two arguments, An exception and a result, called either with the exception or with the result, a list of reports of the created orders
178179

179180
def create_spot_order_list(
180-
orders:,
181-
contingency_type:,
182-
order_list_id: nil,
183-
callback: nil
181+
orders:, contingency_type:, order_list_id: nil, callback: nil
184182
)
185183
request('spot_new_order_list', callback, {
186184
orders: orders, contingency_type: contingency_type, order_list_id: order_list_id

lib/cryptomarket/websocket/wallet_client.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# frozen_string_literal: true
22

3+
# rubocop:disable Layout/LineLength
34
require_relative 'auth_client'
45
require_relative '../constants'
56

0 commit comments

Comments
 (0)