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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e2248fec84988c40e7973c1ada6f06019f2d1c07a5570af95c469a49de2afd2
4
- data.tar.gz: 3f030d0f7b25646ceba951e3c5271586f14794db38913e7b9d5dfc965f9c47ea
3
+ metadata.gz: ab3d042696a9e077079899528a5d3ff60dce12c03b9497e05dcdfa1971efedea
4
+ data.tar.gz: f94173227e3a59e8c59e5f2e3e473e64ddce2cfefa91530bf555976f0f3b2704
5
5
  SHA512:
6
- metadata.gz: 53aad33c51a71a6ef91f919bf5050c2925e12cc37ff5742c19843c8c2eb1b8def3e8d8e67762d14785bb654b9b4195530a83e2405c627158157b9a50ff83bbdc
7
- data.tar.gz: 3e7173c834af80b8004d4627c425c085144502d849dacc0c9d47105943f06792eca95a913af96f69eab187b0f16ffabdfb6b8b40d2032922d87208c5a893831f
6
+ metadata.gz: db17fa2b0bfce99db445d4bb22a85f410a8218a311e59ac8bbf9b1489d2d6af0b082647fed300318fac4cf3826e64b91d693b4d80c3badb8cfce2393c56b0de5
7
+ data.tar.gz: 1eae43388b3cbfa096459809cb4c1ae5bcfee0fd0984fa9fcf04ea8a0419efc0bd0756baf06a616f9c53cac1f4280fc834e3cc74a7dd48fc8a51b080acaef6a4
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ gem 'http.rb'
4
4
 
5
5
  group :development, :test do
6
6
  gem 'minitest'
7
+ gem 'minitest-mock'
7
8
  gem 'minitest-spec-context'
8
9
  gem 'vcr'
9
10
  gem 'webmock'
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
@@ -102,3 +102,8 @@ coinmarketcap_client.trending
102
102
  3. Commit your changes (`git commit -am 'Add some feature'`)
103
103
  4. Push to the branch (`git push origin my-new-feature`)
104
104
  5. Create a new pull request
105
+
106
+
107
+ ## License
108
+
109
+ MIT
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.files = [
19
19
  'coinmarketcap.rb.gemspec',
20
20
  'Gemfile',
21
+ 'LICENSE',
21
22
  Dir['lib/**/*.rb'],
22
23
  'README.md',
23
24
  Dir['test/**/*.rb']
@@ -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:)
@@ -2,5 +2,5 @@
2
2
  # CoinMarketCap::VERSION
3
3
 
4
4
  module CoinMarketCap
5
- VERSION = '0.6.0'
5
+ VERSION = '0.6.2'
6
6
  end
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
@@ -1,4 +1,5 @@
1
1
  require 'minitest/autorun'
2
+ require 'minitest/mock'
2
3
  require 'minitest-spec-context'
3
4
  require 'minitest/spec'
4
5
  require 'ostruct'
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.0
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.6
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: []