bitget 0.6.8

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.
@@ -0,0 +1,6 @@
1
+ # Bitget/VERSION.rb
2
+ # Bitget::VERSION
3
+
4
+ module Bitget
5
+ VERSION = '0.6.8'
6
+ end
data/lib/Bitget.rb ADDED
@@ -0,0 +1,9 @@
1
+ # bitget.rb
2
+
3
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
5
+
6
+ require_relative './Bitget/VERSION'
7
+ require_relative './Bitget/Client'
8
+
9
+ module Bitget; end
@@ -0,0 +1,7 @@
1
+ # String/url_encode.rb
2
+ # String#url_encode
3
+
4
+ # 20250402
5
+ # 0.3.0
6
+
7
+ require 'Thoran/String/UrlEncode/url_encode'
@@ -0,0 +1,26 @@
1
+ # Thoran/String/UrlEncode/url_encode.rb
2
+ # Thoran::String::UrlEncode#url_encode
3
+
4
+ # 20160505
5
+ # 0.3.0
6
+
7
+ # Acknowledgements: I've simply ripped off and refashioned the code from the CGI module!...
8
+
9
+ # Changes since 0.2:
10
+ # 1. + Thoran namespace.
11
+
12
+ module Thoran
13
+ module String
14
+ module UrlEncode
15
+
16
+ def url_encode
17
+ self.gsub(/([^ a-zA-Z0-9_.-]+)/n) do
18
+ '%' + $1.unpack('H2' * $1.size).join('%').upcase
19
+ end.tr(' ', '+')
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+
26
+ String.send(:include, Thoran::String::UrlEncode)
@@ -0,0 +1,87 @@
1
+ require_relative './helper'
2
+
3
+ describe Bitget::Configuration do
4
+ describe "#initialize" do
5
+ it "sets default values" do
6
+ config = Bitget::Configuration.new
7
+ _(config.debug).must_equal(false)
8
+ _(config.api_key).must_be_nil
9
+ _(config.api_secret).must_be_nil
10
+ _(config.api_passphrase).must_be_nil
11
+ _(config.logger).must_be_nil
12
+ end
13
+
14
+ it "declares a setting for everything a client reads" do
15
+ _(Bitget::Configuration.new.public_methods(false).grep(/[^=]\z/).sort) \
16
+ .must_equal(%i{api_key api_passphrase api_secret debug logger})
17
+ end
18
+ end
19
+
20
+ # The credentials are named arguments and fall back upon nil, having no
21
+ # meaningful nil of their own. The options are given under options: and fall
22
+ # back upon the key being absent, nil being a value a caller may mean.
23
+ describe "the credentials, which are named arguments" do
24
+ before do
25
+ Bitget.configure do |config|
26
+ config.api_key = 'configured_key'
27
+ config.api_secret = 'configured_secret'
28
+ config.api_passphrase = 'configured_passphrase'
29
+ end
30
+ end
31
+
32
+ it "supplies every one, so that a client needs no arguments at all" do
33
+ client = Bitget::Client.new
34
+ _(client.api_key).must_equal('configured_key')
35
+ _(client.api_secret).must_equal('configured_secret')
36
+ _(client.api_passphrase).must_equal('configured_passphrase')
37
+ end
38
+
39
+ it "yields to each one given, and only to that one" do
40
+ _(Bitget::Client.new(api_key: 'given').api_key).must_equal('given')
41
+ _(Bitget::Client.new(api_key: 'given').api_secret).must_equal('configured_secret')
42
+ _(Bitget::Client.new(api_secret: 'given').api_secret).must_equal('given')
43
+ _(Bitget::Client.new(api_secret: 'given').api_key).must_equal('configured_key')
44
+ _(Bitget::Client.new(api_passphrase: 'given').api_passphrase).must_equal('given')
45
+ _(Bitget::Client.new(api_passphrase: 'given').api_key).must_equal('configured_key')
46
+ end
47
+
48
+ it "is unreachable where nothing is configured and nothing is given" do
49
+ Bitget.reset_configuration!
50
+ client = Bitget::Client.new
51
+ _(client.api_key).must_be_nil
52
+ _(client.api_secret).must_be_nil
53
+ _(client.api_passphrase).must_be_nil
54
+ end
55
+ end
56
+
57
+ describe "the options, which are given under options:" do
58
+ let(:logger){Logger.new(StringIO.new)}
59
+
60
+ before do
61
+ Bitget.configure do |config|
62
+ config.debug = true
63
+ config.logger = logger
64
+ end
65
+ end
66
+
67
+ it "supplies every one" do
68
+ client = Bitget::Client.new
69
+ _(client.debug).must_equal(true)
70
+ _(client.logger).must_equal(logger)
71
+ end
72
+
73
+ it "yields to each one given, and only to that one" do
74
+ other = Logger.new(StringIO.new)
75
+ _(Bitget::Client.new(options: {debug: false}).debug).must_equal(false)
76
+ _(Bitget::Client.new(options: {debug: false}).logger).must_equal(logger)
77
+ _(Bitget::Client.new(options: {logger: other}).logger).must_equal(other)
78
+ _(Bitget::Client.new(options: {logger: other}).debug).must_equal(true)
79
+ end
80
+
81
+ it "takes nil as a value rather than as an absence" do
82
+ client = Bitget::Client.new(options: {logger: nil})
83
+ _(client.logger).must_be_nil
84
+ _(client.send(:use_logging?)).must_equal(false)
85
+ end
86
+ end
87
+ end