ctfc 0.3.1 → 0.3.3
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/README.md +76 -51
- data/ctfc.gemspec +2 -0
- data/lib/ctfc/base.rb +4 -4
- data/lib/ctfc/version.rb +1 -1
- data/lib/ctfc.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9eb6a110a8c9249570c3581febbeda07c970d4265e2f4e28c72e63cfd3007e58
|
4
|
+
data.tar.gz: 291e835ae45d67bbc37ac7eaad33fbf74e581e21c5e4e760dcca39acb8cbd8ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 624349dc7c81ec34cfa33d46869482fab91f2d8e02f57a3723b220135e3db4ce2fe607d738fdcd565b91b22dc342c6fe342f22af9a55ae4b90e4be50b0cd6d18
|
7
|
+
data.tar.gz: b051e5169a7c2cf0724c9d2af55477731e8dc5163e04951c9d5f333278e064b2ec95b28d8b932018eeeb9a89dfc8b9c4e6bc8d9c37b13c7d90cc97633378c953
|
data/README.md
CHANGED
@@ -1,19 +1,24 @@
|
|
1
1
|
# About
|
2
|
-
|
3
2
|
Convert any crypto to fiat currency, gather all data and/or save in `.csv` table.
|
4
3
|
For now only prices are printed/saved, while all data remain easily accessible from variable (for developers).
|
5
4
|
|
6
5
|
|
7
6
|
# How to install
|
7
|
+
Make sure you have ruby and git installed
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
Install from source:
|
11
10
|
```bash
|
12
11
|
git clone https://github.com/alx3dev/ctfc.git
|
13
12
|
cd ctfc && bundle install
|
14
13
|
```
|
15
|
-
|
14
|
+
|
15
|
+
Install from rubygems:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
gem install ctfc
|
19
|
+
```
|
16
20
|
# How to run
|
21
|
+
- **Read documentation on:** https://rubydoc.info/gems/ctfc/0.3.1/CTFC/Data
|
17
22
|
|
18
23
|
```bash
|
19
24
|
ruby bin/ctfc fiat_1 fiat_2 fiat_3
|
@@ -28,13 +33,12 @@ This command also accept multiple arguments:
|
|
28
33
|
|
29
34
|
|
30
35
|
# Script Examples
|
31
|
-
|
32
36
|
1 - Run script without arguments (default options)
|
33
37
|
|
34
|
-
```
|
38
|
+
```ruby
|
35
39
|
ruby bin/ctfc
|
36
40
|
|
37
|
-
|
41
|
+
return:
|
38
42
|
print EUR rates for default coins (BTC, LTC, XMR, ETH, BCH, ZEC)
|
39
43
|
do not save '.csv' table
|
40
44
|
```
|
@@ -42,92 +46,113 @@ This command also accept multiple arguments:
|
|
42
46
|
|
43
47
|
2 - Add fiat currencies as arguments
|
44
48
|
|
45
|
-
```
|
49
|
+
```ruby
|
46
50
|
ruby bin/ctfc eur usd rsd
|
47
51
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
+
=> return:
|
53
|
+
print EUR, USD, RSD rates for default coins
|
54
|
+
save data in '.csv' table with pattern: 'crypto_#{CURRENCY}.csv'
|
55
|
+
-> './crypto_eur.csv', './crypto_usd.csv', './crypto_rsd.csv'
|
52
56
|
```
|
53
57
|
|
54
58
|
3 - Use `--no-save` and/or `--no-print`
|
55
59
|
|
56
|
-
```
|
60
|
+
```ruby
|
57
61
|
ruby bin/ctfc eur --no-print --coins btc xmr ltc
|
58
62
|
|
59
|
-
|
60
|
-
|
61
|
-
|
63
|
+
=> return:
|
64
|
+
save EUR rates for BTC, XMR and LTC
|
65
|
+
do not print output
|
62
66
|
|
63
67
|
|
64
68
|
ruby bin/ctfc rsd --no-save --coins btc xmr
|
65
69
|
|
66
|
-
|
67
|
-
|
70
|
+
=> return:
|
71
|
+
print RSD rates for BTC and XMR
|
68
72
|
|
69
73
|
```
|
70
74
|
|
71
75
|
|
72
76
|
# Developer Examples
|
73
|
-
|
74
|
-
|
75
77
|
```ruby
|
76
|
-
# define coins to scrap
|
78
|
+
# define coins to scrap
|
77
79
|
COINS = %w[ BTC XMR LTC ETH ]
|
78
80
|
|
79
|
-
# initialize Data class
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
=> #<CTFC::Data:0x000055715a6ce898 @coins=["BTC", "LTC", "XMR", "ETH", "BCH", "ZEC"], @currency="EUR", @print=true, @save=false>
|
81
|
+
# initialize Data class
|
82
|
+
@data = Ctfc.new :eur, save: false, print: false, coins: COINS
|
83
|
+
=> return Ctfc object to work with
|
84
|
+
=> #<Ctfc:0x000055b5c8b61a38 @coins=["BTC", "LTC", "XMR", "ETH", "BCH", "ZEC"], @fiat="EUR", @print=true, @save=true>
|
84
85
|
|
85
|
-
# execute request
|
86
|
+
# execute request
|
86
87
|
@data.get
|
87
|
-
|
88
|
+
=> return Hash with upcase string coins as keys, and float prices
|
88
89
|
=> {"BTC"=>36760.11, "XMR"=>169.55, "LTC"=>114.4, "ETH"=>2746.22}
|
89
90
|
|
90
|
-
# now you can use ::Data instance methods
|
91
|
+
# now you can use ::Data instance methods
|
91
92
|
@data.response
|
92
|
-
|
93
|
+
=> return RestClient response to cryptocomare API
|
93
94
|
=> <RestClient::Response 200 "{\"RAW\":{\"BT...">
|
94
|
-
|
95
|
+
|
96
|
+
# check request url
|
95
97
|
@data.url
|
96
|
-
|
98
|
+
=> return Cryptocompare API url
|
97
99
|
=> "https://min-api.cryptocompare.com/data/pricemultifull?fsyms=BTC&fsyms=LTC&fsyms=XMR&fsyms=ETH&fsyms=BCH&fsyms=ZEC&tsyms=EUR"
|
98
|
-
|
100
|
+
|
101
|
+
# name of csv table (saved in working directory)
|
99
102
|
@data.table
|
100
|
-
|
103
|
+
=> return '.csv' table name
|
101
104
|
=> 'ctfc_eur.csv'
|
102
|
-
|
105
|
+
|
106
|
+
# array of coins to work with
|
103
107
|
@data.coins
|
104
|
-
|
108
|
+
=> return coins for scrap, also allow setter method @data.coins = [...]
|
105
109
|
=> ['BTC', 'XMR', 'LTC', 'ETH']
|
106
|
-
|
110
|
+
|
111
|
+
# get all data about all coins (json api response)
|
107
112
|
@data.data
|
108
|
-
|
109
|
-
=>
|
113
|
+
=> return all data returned by cryptocompare API
|
114
|
+
=> {"RAW"=>
|
115
|
+
{"BTC"=>
|
116
|
+
{"EUR"=>
|
117
|
+
{"TYPE"=>"5",
|
118
|
+
"MARKET"=>"CCCAGG",
|
119
|
+
"FROMSYMBOL"=>"BTC",
|
120
|
+
"TOSYMBOL"=>"EUR",
|
121
|
+
"FLAGS"=>"2049",
|
122
|
+
"PRICE"=>33851.17,
|
123
|
+
"LASTUPDATE"=>1642773847,
|
124
|
+
"MEDIAN"=>33853.8,
|
125
|
+
"LASTVOLUME"=>0.1,
|
126
|
+
"LASTVOLUMETO"=>3384.3676,
|
127
|
+
"LASTTRADEID"=>"2024043",
|
128
|
+
... ... ... ... ... ... ...
|
110
129
|
|
111
130
|
|
112
131
|
TO BE CONTINIUED ...
|
113
132
|
```
|
114
133
|
|
115
|
-
**Class methods
|
134
|
+
**Class methods as shortcuts:**
|
116
135
|
|
117
136
|
```ruby
|
118
|
-
#
|
137
|
+
# get default coins in EUR, save output without printing
|
138
|
+
prices = Ctfc.to :eur, print: false
|
119
139
|
|
120
|
-
|
140
|
+
# get default coins in RSD, print output, don't save
|
141
|
+
Ctfc.to :rsd, save: false
|
142
|
+
|
143
|
+
# For those who don't like name `Ctfc`, you can use `Crypto` too:
|
144
|
+
prices = Crypto.to :eur, coins: %w[BTC XMR]
|
145
|
+
```
|
121
146
|
|
122
|
-
#
|
147
|
+
# Contribution
|
148
|
+
Any contribution is highly appreciated, as long as you follow Code of Conduct.
|
123
149
|
|
124
|
-
|
150
|
+
- Fork repository
|
151
|
+
- Make your changes
|
152
|
+
- Submit pull request
|
125
153
|
|
126
|
-
#
|
154
|
+
# License
|
155
|
+
Don't be a dick - it's MIT.
|
127
156
|
|
128
|
-
|
129
|
-
|
130
|
-
```
|
131
|
-
|
132
|
-
# TO-DO:
|
133
|
-
Write documentation, examples and use-cases as gem dependency
|
157
|
+
# To-Do:
|
158
|
+
See **Projects**
|
data/ctfc.gemspec
CHANGED
@@ -19,6 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.metadata['homepage_uri'] = 'https://github.com/alx3dev/ctfc'
|
20
20
|
s.metadata['source_code_uri'] = 'https://github.com/alx3dev/ctfc'
|
21
21
|
s.metadata['bug_tracker_uri'] = 'https://github.com/alx3dev/ctfc/issues'
|
22
|
+
s.metadata['documentation_uri'] = "https://rubydoc.info/gems/#{s.name}/#{s.version}"
|
23
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
22
24
|
|
23
25
|
s.files = ['bin/ctfc', 'bin/console', 'lib/ctfc.rb', 'LICENSE', 'README.md', 'ctfc.gemspec',
|
24
26
|
'lib/ctfc/config.rb', 'lib/ctfc/version.rb', 'lib/ctfc/base.rb']
|
data/lib/ctfc/base.rb
CHANGED
@@ -104,7 +104,7 @@ module CTFC
|
|
104
104
|
# @return [true || false]
|
105
105
|
#
|
106
106
|
def save=(opt)
|
107
|
-
@save = opt.is_a?(TrueClass)
|
107
|
+
@save = opt.is_a?(TrueClass)
|
108
108
|
end
|
109
109
|
|
110
110
|
##
|
@@ -113,7 +113,7 @@ module CTFC
|
|
113
113
|
# @return [true || false]
|
114
114
|
#
|
115
115
|
def print=(opt)
|
116
|
-
@print = opt.is_a?(TrueClass)
|
116
|
+
@print = opt.is_a?(TrueClass)
|
117
117
|
end
|
118
118
|
|
119
119
|
##
|
@@ -159,8 +159,8 @@ module CTFC
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def prepare_uri
|
162
|
-
@prices =
|
163
|
-
@data_array =
|
162
|
+
@prices = {}
|
163
|
+
@data_array = []
|
164
164
|
coin_uri = String.new ''
|
165
165
|
@coins.collect { |coin| coin_uri << "fsyms=#{coin}&" }
|
166
166
|
@url = URL + "#{coin_uri}tsyms=#{@fiat}"
|
data/lib/ctfc/version.rb
CHANGED
data/lib/ctfc.rb
CHANGED
@@ -6,6 +6,8 @@ require_relative 'ctfc/base'
|
|
6
6
|
# For easier job use Ctfc, instead of typing CTFC::Data.
|
7
7
|
# You can define default coins with Ctfc::COINS=
|
8
8
|
#
|
9
|
+
# @note For instance methods look at CTFC::Data.
|
10
|
+
#
|
9
11
|
class Ctfc < CTFC::Data
|
10
12
|
##
|
11
13
|
# @todo Allow Ctfc to use proxy and/or tor
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ctfc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alx3dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -117,6 +117,8 @@ metadata:
|
|
117
117
|
homepage_uri: https://github.com/alx3dev/ctfc
|
118
118
|
source_code_uri: https://github.com/alx3dev/ctfc
|
119
119
|
bug_tracker_uri: https://github.com/alx3dev/ctfc/issues
|
120
|
+
documentation_uri: https://rubydoc.info/gems/ctfc/0.3.3
|
121
|
+
rubygems_mfa_required: 'true'
|
120
122
|
post_install_message:
|
121
123
|
rdoc_options: []
|
122
124
|
require_paths:
|