blade_coin 1.0.3 → 1.0.4

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: 6955494b1d74770a708f000dcf4ec7322e8409e267ce4fa45c655d40313fefb7
4
- data.tar.gz: 4fcec6cd579a7237d77c900626fb948667a0919d8ea3fda061c80e3261657e79
3
+ metadata.gz: 17aac38a9a56f33eee2d138c759650dbc16211551b7809a76ed4a7b0f8052972
4
+ data.tar.gz: 59ef62794d4815cad1e1512b237f5bd1eb640bcbbe5e2db149c8e93eacf1ee0d
5
5
  SHA512:
6
- metadata.gz: c20e7443df5d3a5783c0dbfae3001cb51108ce842ebb1ab19e3df065c99a9a087728b9b2c8557e4742ff23b2aa9d37cfcf4f47ccde2eb2c15f8faaef2fab70da
7
- data.tar.gz: 4e213fe3b6744c49e061ba2b7f5d6ed34099daf2079dc8a49f8b0fbdd7e68c6cb7a4d2b624cc976879956772ce80e3660ce6ed7a00989bbbb4ca84d8227fd851
6
+ metadata.gz: 25f94a401da17ee00c26507abf7c9fcb1f92d2c602cc5c76d80af3dbd1127e0b0984310d2e12dc0f76af65f9aeb0d5765c65283dd12869243bfa297e755adf60
7
+ data.tar.gz: 14f43c67422d03f772850b5ca0dda6a4b3c88e79406c0bc8788491f1e87862f18e86da37d51bac3098fc624c9fcd4868af38db1f2741e1cde979ab35bff2f60a
data/README.md CHANGED
@@ -57,6 +57,19 @@ You can use the `-h` (or `--help`) to find all valid options of coin
57
57
  $ coin -h
58
58
  ```
59
59
 
60
+ # Donate
61
+
62
+ <div style="display: flex; gap: 20px;">
63
+ <div style="text-align: center">
64
+ <img style="width: 200px" src="./wechat.jpg" alt="微信" />
65
+ <p>WeChat Pay</p>
66
+ </div>
67
+ <div style="text-align: center">
68
+ <img style="width: 200px" src="./alipay.jpg" alt="支付宝" />
69
+ <p>Alipay</p>
70
+ </div>
71
+ </div>
72
+
60
73
  ## Contributing
61
74
 
62
75
  Bug reports and pull requests are welcome on GitHub at https://github.com/gith-u-b/blade_coin. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
data/alipay.jpg ADDED
Binary file
data/blade_coin.gemspec CHANGED
@@ -2,8 +2,6 @@
2
2
  lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require "blade/coin/version"
5
- require 'bundler/setup'
6
- require 'bundler/version'
7
5
 
8
6
  Gem::Specification.new do |spec|
9
7
  spec.name = "blade_coin"
@@ -15,11 +13,7 @@ Gem::Specification.new do |spec|
15
13
  spec.description = "A cryptocurrency price monitoring tool, you can run 'coin -h' for more help, or read the 'README.md'."
16
14
  spec.homepage = "https://github.com/gith-u-b/blade_coin"
17
15
  spec.license = "MIT"
18
- if Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('2.0.0')
19
- spec.add_dependency 'rainbow', "~> 3.1"
20
- else
21
- spec.add_dependency 'rainbow', "~> 2.1"
22
- end
16
+ spec.add_dependency 'rainbow', "~> 3.1"
23
17
  spec.add_dependency 'terminal-table', '~> 1.8'
24
18
 
25
19
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
@@ -29,11 +23,7 @@ Gem::Specification.new do |spec|
29
23
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
30
24
  spec.require_paths = ["lib"]
31
25
 
32
- if Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('2.0.0')
33
- spec.add_development_dependency "bundler", "~> 2.0"
34
- else
35
- spec.add_development_dependency "bundler", "~> 1.17"
36
- end
26
+ spec.add_development_dependency "bundler", "~> 2.0"
37
27
  spec.add_development_dependency "rake", "~> 13.0"
38
28
  spec.add_development_dependency "rspec", "~> 3.0"
39
29
  end
@@ -1,5 +1,5 @@
1
1
  module Blade
2
2
  module Coin
3
- VERSION = "1.0.3"
3
+ VERSION = "1.0.4"
4
4
  end
5
5
  end
data/lib/blade/coin.rb CHANGED
@@ -8,26 +8,40 @@ module Blade
8
8
  class Coin
9
9
  def initialize(input)
10
10
  @coin = input
11
- query_for_hash
12
11
  end
13
12
 
14
13
  def query_for_hash
15
14
  query_url = get_mxc_single_market(@coin)
16
- @result_hash = make_http_request(query_url)
15
+ raw = make_http_request(query_url)
16
+ # Gate.io returns an array, wrap it to match the legacy MEXC format: { data: [...] }
17
+ @result_hash = raw.is_a?(Array) ? { data: raw } : raw
17
18
  end
18
19
 
19
20
  def get_mxc_single_market(coin)
20
- "https://www.mexc.com/open/api/v2/market/ticker?symbol=#{coin}_USDT"
21
+ "https://api.gateio.ws/api/v4/spot/tickers?currency_pair=#{coin.upcase}_USDT"
21
22
  end
22
23
 
23
24
  def get_top_markets(top = 10)
24
- query_url = "https://api.coincap.io/v2/assets?limit=#{top}"
25
+ query_url = "https://min-api.cryptocompare.com/data/top/mktcapfull?limit=#{top}&tsym=USD"
25
26
  result_json = make_http_request(query_url)
26
- data = result_json[:data]
27
+ raw_data = result_json[:Data]
27
28
 
28
- timestamp = result_json[:timestamp] / 1000 rescue ''
29
- formatted_time = Time.at(timestamp).strftime("%I:%M:%S %p")
30
- puts green_colorize("Data source from coincap.io at #{formatted_time}")
29
+ puts green_colorize("Data source from cryptocompare.com at #{Time.now.strftime('%I:%M:%S %p')}")
30
+
31
+ data = raw_data.each_with_index.map do |item, i|
32
+ coin = item[:CoinInfo]
33
+ usd = item.dig(:RAW, :USD)
34
+ next unless usd
35
+ {
36
+ rank: i + 1,
37
+ symbol: coin[:Name],
38
+ priceUsd: usd[:PRICE],
39
+ changePercent24Hr: usd[:CHANGEPCT24HOUR],
40
+ vwap24Hr: usd[:MEDIAN],
41
+ marketCapUsd: usd[:MKTCAP]
42
+ }
43
+ end
44
+ data.compact!
31
45
 
32
46
  display_market_data(data)
33
47
  end
@@ -38,8 +52,8 @@ module Blade
38
52
  t.headings = [orange_colorize('Rank'), orange_colorize('Coin'), orange_colorize('Price (USD)'), orange_colorize('ChangePercent24Hr'), orange_colorize('Vwap24Hr'), orange_colorize('Market Cap (USD)')]
39
53
  t.rows = data.map do |d|
40
54
  [
41
- green_colorize(d[:rank] || 0),
42
- green_colorize(d[:symbol] || 0),
55
+ green_colorize((d[:rank] || 0).to_s),
56
+ green_colorize((d[:symbol] || 0).to_s),
43
57
  green_colorize(format("%.4f", d[:priceUsd].to_f)),
44
58
  yellow_colorize(format("%.2f", d[:changePercent24Hr].to_f)),
45
59
  yellow_colorize(format("%.2f", d[:vwap24Hr].to_f)),
@@ -57,11 +71,14 @@ module Blade
57
71
  end
58
72
 
59
73
  def usdt_result
74
+ query_for_hash unless @result_hash
60
75
  return [] unless @result_hash[:data]
61
76
  lines = []
62
77
  data = @result_hash[:data][0]
63
- lines << data[:symbol].color(:red)
64
- lines << data[:last].color(:green)
78
+ symbol = data[:symbol] || data[:currency_pair]
79
+ price = data[:last]
80
+ lines << symbol.to_s.color(:red)
81
+ lines << price.to_s.color(:green)
65
82
  lines << ""
66
83
  end
67
84
 
data/wechat.jpg ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blade_coin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - sai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-02 00:00:00.000000000 Z
11
+ date: 2026-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
@@ -100,6 +100,7 @@ files:
100
100
  - LICENSE.txt
101
101
  - README.md
102
102
  - Rakefile
103
+ - alipay.jpg
103
104
  - bin/coin
104
105
  - bin/coin-cli
105
106
  - bin/console
@@ -108,6 +109,7 @@ files:
108
109
  - lib/blade/coin.rb
109
110
  - lib/blade/coin/version.rb
110
111
  - top_10.png
112
+ - wechat.jpg
111
113
  homepage: https://github.com/gith-u-b/blade_coin
112
114
  licenses:
113
115
  - MIT
@@ -127,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
129
  - !ruby/object:Gem::Version
128
130
  version: '0'
129
131
  requirements: []
130
- rubygems_version: 3.2.32
132
+ rubygems_version: 3.4.19
131
133
  signing_key:
132
134
  specification_version: 4
133
135
  summary: A cryptocurrency price monitoring tool