coinmarketcap.rb 0.6.0 → 0.6.2
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 +4 -4
- data/Gemfile +1 -0
- data/LICENSE +21 -0
- data/README.md +5 -0
- data/coinmarketcap.rb.gemspec +1 -0
- data/lib/CoinMarketCap/Client.rb +28 -0
- data/lib/CoinMarketCap/VERSION.rb +1 -1
- data/test/client_test.rb +145 -0
- data/test/helper.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ab3d042696a9e077079899528a5d3ff60dce12c03b9497e05dcdfa1971efedea
|
|
4
|
+
data.tar.gz: f94173227e3a59e8c59e5f2e3e473e64ddce2cfefa91530bf555976f0f3b2704
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: db17fa2b0bfce99db445d4bb22a85f410a8218a311e59ac8bbf9b1489d2d6af0b082647fed300318fac4cf3826e64b91d693b4d80c3badb8cfce2393c56b0de5
|
|
7
|
+
data.tar.gz: 1eae43388b3cbfa096459809cb4c1ae5bcfee0fd0984fa9fcf04ea8a0419efc0bd0756baf06a616f9c53cac1f4280fc834e3cc74a7dd48fc8a51b080acaef6a4
|
data/Gemfile
CHANGED
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 thoran
|
|
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 all
|
|
13
|
+
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 THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
data/coinmarketcap.rb.gemspec
CHANGED
data/lib/CoinMarketCap/Client.rb
CHANGED
|
@@ -75,6 +75,34 @@ module CoinMarketCap
|
|
|
75
75
|
v1_client.trending_latest
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
+
def exchange_assets(id:)
|
|
79
|
+
v1_client.exchange_assets(id: id)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def exchange_info(**args)
|
|
83
|
+
v1_client.exchange_info(**args)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def exchange_map(**args)
|
|
87
|
+
v1_client.exchange_map(**args)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def exchange_listings(**args)
|
|
91
|
+
v1_client.exchange_listings_latest(**args)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def exchange_market_pairs(**args)
|
|
95
|
+
v1_client.exchange_market_pairs_latest(**args)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def exchange_quotes(historical: false, **args)
|
|
99
|
+
if historical
|
|
100
|
+
v1_client.exchange_quotes_historical(**args)
|
|
101
|
+
else
|
|
102
|
+
v1_client.exchange_quotes_latest(**args)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
78
106
|
private
|
|
79
107
|
|
|
80
108
|
def initialize(api_key:)
|
data/test/client_test.rb
CHANGED
|
@@ -223,4 +223,149 @@ describe CoinMarketCap::Client do
|
|
|
223
223
|
mocked_client.verify
|
|
224
224
|
end
|
|
225
225
|
end
|
|
226
|
+
|
|
227
|
+
describe "#exchange_assets" do
|
|
228
|
+
it "calls the V1 client" do
|
|
229
|
+
mocked_client = Minitest::Mock.new
|
|
230
|
+
mocked_client.expect(:exchange_assets, {'data' => []}) do |kwargs|
|
|
231
|
+
kwargs[:id] == 1
|
|
232
|
+
end
|
|
233
|
+
client.stub :v1_client, mocked_client do
|
|
234
|
+
client.exchange_assets(id: 1)
|
|
235
|
+
end
|
|
236
|
+
mocked_client.verify
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
describe "#exchange_info" do
|
|
241
|
+
context "WITHOUT args" do
|
|
242
|
+
it "calls the V1 client" do
|
|
243
|
+
mocked_client = Minitest::Mock.new
|
|
244
|
+
mocked_client.expect(:exchange_info, true, [])
|
|
245
|
+
client.stub :v1_client, mocked_client do
|
|
246
|
+
client.exchange_info
|
|
247
|
+
end
|
|
248
|
+
mocked_client.verify
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
context "WITH args" do
|
|
253
|
+
it "calls the V1 client" do
|
|
254
|
+
mocked_client = Minitest::Mock.new
|
|
255
|
+
mocked_client.expect(:exchange_info, {'data' => []}) do |kwargs|
|
|
256
|
+
kwargs[:id] == 1
|
|
257
|
+
end
|
|
258
|
+
client.stub :v1_client, mocked_client do
|
|
259
|
+
client.exchange_info(id: 1)
|
|
260
|
+
end
|
|
261
|
+
mocked_client.verify
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
describe "#exchange_map" do
|
|
267
|
+
context "WITHOUT args" do
|
|
268
|
+
it "calls the V1 client" do
|
|
269
|
+
mocked_client = Minitest::Mock.new
|
|
270
|
+
mocked_client.expect(:exchange_map, true, [])
|
|
271
|
+
client.stub :v1_client, mocked_client do
|
|
272
|
+
client.exchange_map
|
|
273
|
+
end
|
|
274
|
+
mocked_client.verify
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
context "WITH args" do
|
|
279
|
+
it "calls the V1 client" do
|
|
280
|
+
mocked_client = Minitest::Mock.new
|
|
281
|
+
mocked_client.expect(:exchange_map, {'data' => []}) do |kwargs|
|
|
282
|
+
kwargs[:listing_status] == 'active'
|
|
283
|
+
end
|
|
284
|
+
client.stub :v1_client, mocked_client do
|
|
285
|
+
client.exchange_map(listing_status: 'active')
|
|
286
|
+
end
|
|
287
|
+
mocked_client.verify
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
describe "#exchange_listings" do
|
|
293
|
+
context "WITHOUT args" do
|
|
294
|
+
it "calls the V1 client exchange_listings_latest method" do
|
|
295
|
+
mocked_client = Minitest::Mock.new
|
|
296
|
+
mocked_client.expect(:exchange_listings_latest, true, [])
|
|
297
|
+
client.stub :v1_client, mocked_client do
|
|
298
|
+
client.exchange_listings
|
|
299
|
+
end
|
|
300
|
+
mocked_client.verify
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
context "WITH args" do
|
|
305
|
+
it "calls the V1 client exchange_listings_latest method" do
|
|
306
|
+
mocked_client = Minitest::Mock.new
|
|
307
|
+
mocked_client.expect(:exchange_listings_latest, {'data' => []}) do |kwargs|
|
|
308
|
+
kwargs[:limit] == 10
|
|
309
|
+
end
|
|
310
|
+
client.stub :v1_client, mocked_client do
|
|
311
|
+
client.exchange_listings(limit: 10)
|
|
312
|
+
end
|
|
313
|
+
mocked_client.verify
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
describe "#exchange_market_pairs" do
|
|
319
|
+
context "WITHOUT args" do
|
|
320
|
+
it "calls the V1 client exchange_market_pairs_latest method" do
|
|
321
|
+
mocked_client = Minitest::Mock.new
|
|
322
|
+
mocked_client.expect(:exchange_market_pairs_latest, true, [])
|
|
323
|
+
client.stub :v1_client, mocked_client do
|
|
324
|
+
client.exchange_market_pairs
|
|
325
|
+
end
|
|
326
|
+
mocked_client.verify
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
context "WITH args" do
|
|
331
|
+
it "calls the V1 client exchange_market_pairs_latest method" do
|
|
332
|
+
mocked_client = Minitest::Mock.new
|
|
333
|
+
mocked_client.expect(:exchange_market_pairs_latest, {'data' => []}) do |kwargs|
|
|
334
|
+
kwargs[:id] == 1
|
|
335
|
+
end
|
|
336
|
+
client.stub :v1_client, mocked_client do
|
|
337
|
+
client.exchange_market_pairs(id: 1)
|
|
338
|
+
end
|
|
339
|
+
mocked_client.verify
|
|
340
|
+
end
|
|
341
|
+
end
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
describe "#exchange_quotes" do
|
|
345
|
+
context "when historical is false (default)" do
|
|
346
|
+
it "calls the V1 client exchange_quotes_latest method" do
|
|
347
|
+
mocked_client = Minitest::Mock.new
|
|
348
|
+
mocked_client.expect(:exchange_quotes_latest, {'data' => []}) do |kwargs|
|
|
349
|
+
kwargs[:id] == 1
|
|
350
|
+
end
|
|
351
|
+
client.stub :v1_client, mocked_client do
|
|
352
|
+
client.exchange_quotes(id: 1)
|
|
353
|
+
end
|
|
354
|
+
mocked_client.verify
|
|
355
|
+
end
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
context "when historical is true" do
|
|
359
|
+
it "calls the V1 client exchange_quotes_historical method" do
|
|
360
|
+
mocked_client = Minitest::Mock.new
|
|
361
|
+
mocked_client.expect(:exchange_quotes_historical, {'data' => []}) do |kwargs|
|
|
362
|
+
kwargs[:id] == 1
|
|
363
|
+
end
|
|
364
|
+
client.stub :v1_client, mocked_client do
|
|
365
|
+
client.exchange_quotes(historical: true, id: 1)
|
|
366
|
+
end
|
|
367
|
+
mocked_client.verify
|
|
368
|
+
end
|
|
369
|
+
end
|
|
370
|
+
end
|
|
226
371
|
end
|
data/test/helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: coinmarketcap.rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thoran
|
|
@@ -30,6 +30,7 @@ extensions: []
|
|
|
30
30
|
extra_rdoc_files: []
|
|
31
31
|
files:
|
|
32
32
|
- Gemfile
|
|
33
|
+
- LICENSE
|
|
33
34
|
- README.md
|
|
34
35
|
- coinmarketcap.rb.gemspec
|
|
35
36
|
- lib/CoinMarketCap.rb
|
|
@@ -61,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
61
62
|
- !ruby/object:Gem::Version
|
|
62
63
|
version: '0'
|
|
63
64
|
requirements: []
|
|
64
|
-
rubygems_version: 4.0.
|
|
65
|
+
rubygems_version: 4.0.20
|
|
65
66
|
specification_version: 4
|
|
66
67
|
summary: Access the coinmarketcap.com API with Ruby.
|
|
67
68
|
test_files: []
|