coinmarketcap_free 0.1.5 → 0.3.0
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/.rubocop.yml +204 -0
- data/Gemfile +7 -7
- data/Gemfile.lock +9 -8
- data/README.md +25 -5
- data/coinmarketcap_free.gemspec +37 -0
- data/lib/coinmarketcap_free/{coins.rb → coin.rb} +41 -57
- data/lib/coinmarketcap_free/coin_history.rb +28 -51
- data/lib/coinmarketcap_free/helper.rb +9 -4
- data/lib/coinmarketcap_free/{icons.rb → icon.rb} +4 -4
- data/lib/coinmarketcap_free/version.rb +8 -1
- data/lib/coinmarketcap_free.rb +2 -2
- metadata +15 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 552fa8d6dc0bd48c3d3038139498e4c87df3e593411d18cd0ca669e3257f3d43
|
4
|
+
data.tar.gz: e53685f824b0cf866cf8e0e7b0e29ffd235f37930253d56da98eff8c3416e7cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9771e08a82dcf2314d982c763ab1f6a230efa16bde1ca684cb4ec30a0b562fac29a027180cabeaa24a87df4280d19981e882dbf0565688950cd9fac0a448af7e
|
7
|
+
data.tar.gz: c33962fc9682813b91eea1177e53b7325d1b578c66a0c76f0357d1478493fbf0438168e8c876e59ad6c77c439e53bbcbaf758dd98603c511809bb8d687df9642
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
# The behavior of RuboCop can be controlled via the .rubocop.yml
|
2
|
+
# configuration file. It makes it possible to enable/disable
|
3
|
+
# certain cops (checks) and to alter their behavior if they accept
|
4
|
+
# any parameters. The file can be placed either in your home
|
5
|
+
# directory or in some project directory.
|
6
|
+
#
|
7
|
+
# RuboCop will start looking for the configuration file in the directory
|
8
|
+
# where the inspected file is and continue its way up to the root directory.
|
9
|
+
#
|
10
|
+
# See https://docs.rubocop.org/rubocop/configuration
|
11
|
+
|
12
|
+
AllCops:
|
13
|
+
NewCops: enable
|
14
|
+
|
15
|
+
Gemspec/DeprecatedAttributeAssignment: # new in 1.30
|
16
|
+
Enabled: true
|
17
|
+
Gemspec/DevelopmentDependencies: # new in 1.44
|
18
|
+
Enabled: true
|
19
|
+
Gemspec/RequireMFA: # new in 1.23
|
20
|
+
Enabled: true
|
21
|
+
Layout/LineContinuationLeadingSpace: # new in 1.31
|
22
|
+
Enabled: true
|
23
|
+
Layout/LineContinuationSpacing: # new in 1.31
|
24
|
+
Enabled: true
|
25
|
+
Layout/LineEndStringConcatenationIndentation: # new in 1.18
|
26
|
+
Enabled: true
|
27
|
+
Layout/SpaceBeforeBrackets: # new in 1.7
|
28
|
+
Enabled: true
|
29
|
+
Lint/AmbiguousAssignment: # new in 1.7
|
30
|
+
Enabled: true
|
31
|
+
Lint/AmbiguousOperatorPrecedence: # new in 1.21
|
32
|
+
Enabled: true
|
33
|
+
Lint/AmbiguousRange: # new in 1.19
|
34
|
+
Enabled: true
|
35
|
+
Lint/ConstantOverwrittenInRescue: # new in 1.31
|
36
|
+
Enabled: true
|
37
|
+
Lint/DeprecatedConstants: # new in 1.8
|
38
|
+
Enabled: true
|
39
|
+
Lint/DuplicateBranch: # new in 1.3
|
40
|
+
Enabled: true
|
41
|
+
Lint/DuplicateMagicComment: # new in 1.37
|
42
|
+
Enabled: true
|
43
|
+
Lint/DuplicateMatchPattern: # new in 1.50
|
44
|
+
Enabled: true
|
45
|
+
Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
|
46
|
+
Enabled: true
|
47
|
+
Lint/EmptyBlock: # new in 1.1
|
48
|
+
Enabled: true
|
49
|
+
Lint/EmptyClass: # new in 1.3
|
50
|
+
Enabled: true
|
51
|
+
Lint/EmptyInPattern: # new in 1.16
|
52
|
+
Enabled: true
|
53
|
+
Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
|
54
|
+
Enabled: true
|
55
|
+
Lint/LambdaWithoutLiteralBlock: # new in 1.8
|
56
|
+
Enabled: true
|
57
|
+
Lint/NoReturnInBeginEndBlocks: # new in 1.2
|
58
|
+
Enabled: true
|
59
|
+
Lint/NonAtomicFileOperation: # new in 1.31
|
60
|
+
Enabled: true
|
61
|
+
Lint/NumberedParameterAssignment: # new in 1.9
|
62
|
+
Enabled: true
|
63
|
+
Lint/OrAssignmentToConstant: # new in 1.9
|
64
|
+
Enabled: true
|
65
|
+
Lint/RedundantDirGlobSort: # new in 1.8
|
66
|
+
Enabled: true
|
67
|
+
Lint/RefinementImportMethods: # new in 1.27
|
68
|
+
Enabled: true
|
69
|
+
Lint/RequireRangeParentheses: # new in 1.32
|
70
|
+
Enabled: true
|
71
|
+
Lint/RequireRelativeSelfPath: # new in 1.22
|
72
|
+
Enabled: true
|
73
|
+
Lint/SymbolConversion: # new in 1.9
|
74
|
+
Enabled: true
|
75
|
+
Lint/ToEnumArguments: # new in 1.1
|
76
|
+
Enabled: true
|
77
|
+
Lint/TripleQuotes: # new in 1.9
|
78
|
+
Enabled: true
|
79
|
+
Lint/UnexpectedBlockArity: # new in 1.5
|
80
|
+
Enabled: true
|
81
|
+
Lint/UnmodifiedReduceAccumulator: # new in 1.1
|
82
|
+
Enabled: true
|
83
|
+
Lint/UselessRescue: # new in 1.43
|
84
|
+
Enabled: true
|
85
|
+
Lint/UselessRuby2Keywords: # new in 1.23
|
86
|
+
Enabled: true
|
87
|
+
Metrics/CollectionLiteralLength: # new in 1.47
|
88
|
+
Enabled: true
|
89
|
+
Naming/BlockForwarding: # new in 1.24
|
90
|
+
Enabled: true
|
91
|
+
Security/CompoundHash: # new in 1.28
|
92
|
+
Enabled: true
|
93
|
+
Security/IoMethods: # new in 1.22
|
94
|
+
Enabled: true
|
95
|
+
Style/ArgumentsForwarding: # new in 1.1
|
96
|
+
Enabled: true
|
97
|
+
Style/ArrayIntersect: # new in 1.40
|
98
|
+
Enabled: true
|
99
|
+
Style/CollectionCompact: # new in 1.2
|
100
|
+
Enabled: true
|
101
|
+
Style/ComparableClamp: # new in 1.44
|
102
|
+
Enabled: true
|
103
|
+
Style/ConcatArrayLiterals: # new in 1.41
|
104
|
+
Enabled: true
|
105
|
+
Style/DataInheritance: # new in 1.49
|
106
|
+
Enabled: true
|
107
|
+
Style/DirEmpty: # new in 1.48
|
108
|
+
Enabled: true
|
109
|
+
Style/DocumentDynamicEvalDefinition: # new in 1.1
|
110
|
+
Enabled: false
|
111
|
+
Style/EmptyHeredoc: # new in 1.32
|
112
|
+
Enabled: true
|
113
|
+
Style/EndlessMethod: # new in 1.8
|
114
|
+
Enabled: true
|
115
|
+
Style/EnvHome: # new in 1.29
|
116
|
+
Enabled: true
|
117
|
+
Style/FetchEnvVar: # new in 1.28
|
118
|
+
Enabled: true
|
119
|
+
Style/FileEmpty: # new in 1.48
|
120
|
+
Enabled: true
|
121
|
+
Style/FileRead: # new in 1.24
|
122
|
+
Enabled: true
|
123
|
+
Style/FileWrite: # new in 1.24
|
124
|
+
Enabled: true
|
125
|
+
Style/HashConversion: # new in 1.10
|
126
|
+
Enabled: true
|
127
|
+
Style/HashExcept: # new in 1.7
|
128
|
+
Enabled: true
|
129
|
+
Style/IfWithBooleanLiteralBranches: # new in 1.9
|
130
|
+
Enabled: true
|
131
|
+
Style/InPatternThen: # new in 1.16
|
132
|
+
Enabled: true
|
133
|
+
Style/MagicCommentFormat: # new in 1.35
|
134
|
+
Enabled: true
|
135
|
+
Style/MapCompactWithConditionalBlock: # new in 1.30
|
136
|
+
Enabled: true
|
137
|
+
Style/MapToHash: # new in 1.24
|
138
|
+
Enabled: true
|
139
|
+
Style/MapToSet: # new in 1.42
|
140
|
+
Enabled: true
|
141
|
+
Style/MinMaxComparison: # new in 1.42
|
142
|
+
Enabled: true
|
143
|
+
Style/MultilineInPatternThen: # new in 1.16
|
144
|
+
Enabled: true
|
145
|
+
Style/NegatedIfElseCondition: # new in 1.2
|
146
|
+
Enabled: true
|
147
|
+
Style/NestedFileDirname: # new in 1.26
|
148
|
+
Enabled: true
|
149
|
+
Style/NilLambda: # new in 1.3
|
150
|
+
Enabled: true
|
151
|
+
Style/NumberedParameters: # new in 1.22
|
152
|
+
Enabled: true
|
153
|
+
Style/NumberedParametersLimit: # new in 1.22
|
154
|
+
Enabled: true
|
155
|
+
Style/ObjectThen: # new in 1.28
|
156
|
+
Enabled: true
|
157
|
+
Style/OpenStructUse: # new in 1.23
|
158
|
+
Enabled: true
|
159
|
+
Style/OperatorMethodCall: # new in 1.37
|
160
|
+
Enabled: true
|
161
|
+
Style/QuotedSymbols: # new in 1.16
|
162
|
+
Enabled: true
|
163
|
+
Style/RedundantArgument: # new in 1.4
|
164
|
+
Enabled: true
|
165
|
+
Style/RedundantConstantBase: # new in 1.40
|
166
|
+
Enabled: true
|
167
|
+
Style/RedundantDoubleSplatHashBraces: # new in 1.41
|
168
|
+
Enabled: true
|
169
|
+
Style/RedundantEach: # new in 1.38
|
170
|
+
Enabled: true
|
171
|
+
Style/RedundantHeredocDelimiterQuotes: # new in 1.45
|
172
|
+
Enabled: true
|
173
|
+
Style/RedundantInitialize: # new in 1.27
|
174
|
+
Enabled: true
|
175
|
+
Style/RedundantLineContinuation: # new in 1.49
|
176
|
+
Enabled: true
|
177
|
+
Style/RedundantSelfAssignmentBranch: # new in 1.19
|
178
|
+
Enabled: true
|
179
|
+
Style/RedundantStringEscape: # new in 1.37
|
180
|
+
Enabled: true
|
181
|
+
Style/SelectByRegexp: # new in 1.22
|
182
|
+
Enabled: true
|
183
|
+
Style/StringChars: # new in 1.12
|
184
|
+
Enabled: true
|
185
|
+
Style/SwapValues: # new in 1.1
|
186
|
+
Enabled: true
|
187
|
+
|
188
|
+
Style/StringLiterals:
|
189
|
+
Enabled: false
|
190
|
+
|
191
|
+
Metrics/MethodLength:
|
192
|
+
Enabled: false
|
193
|
+
|
194
|
+
Metrics/CyclomaticComplexity:
|
195
|
+
Enabled: false
|
196
|
+
|
197
|
+
Metrics/PerceivedComplexity:
|
198
|
+
Enabled: false
|
199
|
+
|
200
|
+
Metrics/AbcSize:
|
201
|
+
Enabled: false
|
202
|
+
|
203
|
+
Layout/LineLength:
|
204
|
+
Enabled: false
|
data/Gemfile
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in coinmarketcap_free.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem '
|
9
|
-
gem
|
10
|
-
gem
|
11
|
-
gem
|
8
|
+
gem 'json', '~> 2.6'
|
9
|
+
gem 'net-http', '~> 0.3.0'
|
10
|
+
gem 'openssl', '~> 3.0'
|
11
|
+
gem 'uri', '~> 0.12.1'
|
12
12
|
|
13
13
|
group :test do
|
14
|
-
gem
|
15
|
-
gem
|
14
|
+
gem 'minitest', '~> 5.0'
|
15
|
+
gem 'rake', '~> 13.0'
|
16
16
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
coinmarketcap_free (0.
|
4
|
+
coinmarketcap_free (0.3.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
json (2.6.
|
10
|
-
minitest (5.
|
11
|
-
net-http (0.3.
|
9
|
+
json (2.6.3)
|
10
|
+
minitest (5.20.0)
|
11
|
+
net-http (0.3.2)
|
12
12
|
uri
|
13
|
-
openssl (3.0
|
13
|
+
openssl (3.2.0)
|
14
14
|
rake (13.0.6)
|
15
|
-
uri (0.12.
|
15
|
+
uri (0.12.2)
|
16
16
|
|
17
17
|
PLATFORMS
|
18
|
+
x86_64-darwin-22
|
18
19
|
x86_64-linux
|
19
20
|
|
20
21
|
DEPENDENCIES
|
@@ -24,7 +25,7 @@ DEPENDENCIES
|
|
24
25
|
net-http (~> 0.3.0)
|
25
26
|
openssl (~> 3.0)
|
26
27
|
rake (~> 13.0)
|
27
|
-
uri (~> 0.12.
|
28
|
+
uri (~> 0.12.1)
|
28
29
|
|
29
30
|
BUNDLED WITH
|
30
|
-
2.
|
31
|
+
2.4.20
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
15
15
|
## How to use?
|
16
16
|
|
17
17
|
``` Ruby
|
18
|
-
list = CoinmarketcapFree::
|
18
|
+
list = CoinmarketcapFree::Coin.list
|
19
19
|
```
|
20
20
|
|
21
21
|
Result:
|
@@ -106,19 +106,19 @@ Result:
|
|
106
106
|
If you want to sort in ascending, just write parameter:
|
107
107
|
|
108
108
|
``` Ruby
|
109
|
-
list = CoinmarketcapFree::
|
109
|
+
list = CoinmarketcapFree::Coin.list(limit: 100, start: 1, sort_type:'asc')
|
110
110
|
```
|
111
111
|
|
112
112
|
You can also adding sort by:
|
113
113
|
|
114
114
|
``` Ruby
|
115
|
-
list = CoinmarketcapFree::
|
115
|
+
list = CoinmarketcapFree::Coin.list(limit: 100, start: 1, sort_type:'asc', sort_by: 'name')
|
116
116
|
```
|
117
117
|
|
118
118
|
Convert all cryptocurrencies to USD,BTC,ETH:
|
119
119
|
|
120
120
|
``` Ruby
|
121
|
-
list = CoinmarketcapFree::
|
121
|
+
list = CoinmarketcapFree::Coin.list(limit: 100,
|
122
122
|
start: 1,
|
123
123
|
sort_type:'asc',
|
124
124
|
sort_by: 'name',
|
@@ -126,7 +126,7 @@ list = CoinmarketcapFree::Coins.get_list(limit: 100,
|
|
126
126
|
```
|
127
127
|
|
128
128
|
|
129
|
-
Parameters for CoinmarketcapFree::
|
129
|
+
Parameters for CoinmarketcapFree::Coin.list:
|
130
130
|
|
131
131
|
| Name | Type | Description | Examples |
|
132
132
|
|:------------------------------|:---------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------|
|
@@ -158,6 +158,10 @@ or
|
|
158
158
|
``` Ruby
|
159
159
|
coin = CoinmarketcapFree::CoinHistory.interval_day(1)
|
160
160
|
coin = CoinmarketcapFree::CoinHistory.interval_seven_days(1)
|
161
|
+
coin = CoinmarketcapFree::CoinHistory.interval_one_month(1)
|
162
|
+
coin = CoinmarketcapFree::CoinHistory.interval_three_months(1)
|
163
|
+
coin = CoinmarketcapFree::CoinHistory.interval_one_year(1)
|
164
|
+
coin = CoinmarketcapFree::CoinHistory.interval_current_year(1)
|
161
165
|
coin = CoinmarketcapFree::CoinHistory.interval_all_time(1)
|
162
166
|
```
|
163
167
|
|
@@ -201,6 +205,22 @@ Parameters for CoinmarketcapFree::CoinHistory.custom_time:
|
|
201
205
|
| ```id``` | Integer. | Cryptocurrency identifier from coinmarketcap. | Bitcoin has the number 1 |
|
202
206
|
| ```range_time``` | String. | Range time. | ```1D```, ```7D```, ```1M```, ```3M```, ```1Y```, ```YTD```, ```ALL``` or custom range ```1668981600~1671659999``` |
|
203
207
|
|
208
|
+
### Generation a link to access the picture:
|
209
|
+
|
210
|
+
``` Ruby
|
211
|
+
logo_coin_url = CoinmarketcapFree::Icon.generate_url(1, 64)
|
212
|
+
```
|
213
|
+
|
214
|
+
``` Ruby
|
215
|
+
"https://s2.coinmarketcap.com/static/img/coins/64x64/1.png"
|
216
|
+
```
|
217
|
+
|
218
|
+
| Name | Type | Description | Examples |
|
219
|
+
|:-----------------|:---------|:----------------------------------------------|:-------------------------------------------------------------------------------------------------------------------|
|
220
|
+
| ```id``` | Integer. | Cryptocurrency identifier from coinmarketcap. | Bitcoin has the number 1 |
|
221
|
+
| ```size``` | Integer. | Choose one size: 64, 128, 200. | If choose 64, it means 64x64 |
|
222
|
+
|
223
|
+
|
204
224
|
## Development
|
205
225
|
|
206
226
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/coinmarketcap_free/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "coinmarketcap_free"
|
7
|
+
spec.version = CoinmarketcapFree::VERSION
|
8
|
+
spec.authors = ["Vitalii Bakun"]
|
9
|
+
spec.email = ["crossdoh@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Cryptocurrency information from the Coinmarketcap site without a key."
|
12
|
+
spec.description = "Cryptocurrency information from the Coinmarketcap site without a key."
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.required_ruby_version = ">= 2.7.0"
|
15
|
+
|
16
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
17
|
+
|
18
|
+
spec.metadata["source_code_uri"] = 'https://github.com/vitalii-bakun/coinmarketcap_free'
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(__dir__) do
|
23
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
24
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
25
|
+
end
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
# Uncomment to register a new dependency of your gem
|
32
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
33
|
+
|
34
|
+
# For more information and examples about making a new gem, check out our
|
35
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
36
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
37
|
+
end
|
@@ -4,14 +4,13 @@ require_relative 'helper'
|
|
4
4
|
|
5
5
|
module CoinmarketcapFree
|
6
6
|
# All about cryptocurrencies and their prices.
|
7
|
-
module
|
8
|
-
|
9
|
-
private_constant :URL_API
|
7
|
+
module Coin
|
8
|
+
URI_API = "#{BASE_URI}#{VERSION_API}/cryptocurrency/listing"
|
10
9
|
|
11
10
|
class << self
|
12
11
|
# Get a list of cryptocurrencies
|
13
12
|
#
|
14
|
-
# list = CoinmarketcapFree::
|
13
|
+
# list = CoinmarketcapFree::Coin.list(limit: 100, start: 1)
|
15
14
|
#
|
16
15
|
# Result json:
|
17
16
|
#
|
@@ -104,72 +103,57 @@ module CoinmarketcapFree
|
|
104
103
|
#
|
105
104
|
# If you want to sort in ascending, just write parameter:
|
106
105
|
#
|
107
|
-
# list = CoinmarketcapFree::
|
106
|
+
# list = CoinmarketcapFree::Coin.list(limit: 100, start: 1, sort_type:'asc')
|
108
107
|
#
|
109
108
|
# or
|
110
109
|
#
|
111
|
-
# list = CoinmarketcapFree::
|
110
|
+
# list = CoinmarketcapFree::Coin.list(limit: 100, start: 1, sort_type:'desc')
|
112
111
|
#
|
113
112
|
# You can also adding sort by:
|
114
113
|
#
|
115
|
-
# list = CoinmarketcapFree::
|
114
|
+
# list = CoinmarketcapFree::Coin.list(limit: 100, start: 1, sort_type:'asc', sort_by: 'name')
|
116
115
|
#
|
117
116
|
# Convert cryptocurrency to::
|
118
117
|
#
|
119
|
-
# list = CoinmarketcapFree::
|
118
|
+
# list = CoinmarketcapFree::Coin.list(limit: 100, start: 1, convert: 'USD,BTC,ETH')
|
120
119
|
#
|
121
120
|
#
|
122
121
|
# @return [String]
|
123
|
-
# @param [Integer]
|
124
|
-
# @param [Integer]
|
125
|
-
# @param [String]
|
126
|
-
# @param [String]
|
127
|
-
# @param [String]
|
128
|
-
# @param [String]
|
129
|
-
# @param [String]
|
130
|
-
# @param [TrueClass, FalseClass]
|
131
|
-
# @param [String]
|
132
|
-
# @param [String]
|
133
|
-
# @param [String]
|
134
|
-
# @param [String]
|
135
|
-
# @param [String]
|
136
|
-
# @param [String]
|
137
|
-
# @param [String]
|
138
|
-
def
|
139
|
-
|
140
|
-
sort_by: 'market_cap',
|
141
|
-
sort_type: 'desc',
|
142
|
-
convert: 'USD',
|
143
|
-
crypto_type: 'all',
|
144
|
-
tag_type: 'all',
|
145
|
-
audited: false,
|
146
|
-
aux: nil,
|
147
|
-
tags: nil,
|
148
|
-
volume24h_range: nil,
|
149
|
-
percent_change24h_range: nil,
|
150
|
-
circulating_supply_range: nil,
|
151
|
-
price_range: nil,
|
152
|
-
market_cap_range: nil)
|
153
|
-
options = {
|
154
|
-
start: start, # Integer
|
155
|
-
limit: limit, # Integer
|
156
|
-
sortBy: sort_by, # String
|
157
|
-
sortType: sort_type, # String
|
158
|
-
convert: convert, # String
|
159
|
-
cryptoType: crypto_type, # String
|
160
|
-
tagType: tag_type, # String
|
161
|
-
audited: audited, # Boolean
|
162
|
-
aux: aux, # String
|
163
|
-
tags: tags, # String
|
164
|
-
volume24hRange: volume24h_range, # String
|
165
|
-
percentChange24hRange: percent_change24h_range, # String
|
166
|
-
circulatingSupplyRange: circulating_supply_range, # String
|
167
|
-
priceRange: price_range, # String
|
168
|
-
marketCapRange: market_cap_range # String
|
169
|
-
}
|
122
|
+
# @param start [Integer] Optionally offset the start (1-based index) of the paginated list of items to return.
|
123
|
+
# @param limit [Integer] Optionally specify the number of results to return. Use this parameter and the 'start' parameter to determine your own pagination size.
|
124
|
+
# @param sort_by [String] What field to sort the list of cryptocurrencies by. ('rank', 'name', 'symbol', 'date_added', 'market_cap', 'market_cap_strict', 'price', 'circulating_supply', 'total_supply', 'max_supply', 'num_market_pairs', 'volume_24h', 'percent_change_1h', 'percent_change_24h', 'percent_change_7d', 'market_cap_by_total_supply_strict', 'volume_7d', 'volume_30d")
|
125
|
+
# @param sort_type [String] The direction in which to order cryptocurrencies against the specified sort. ('asc', 'desc')
|
126
|
+
# @param convert [String] Select cryptocurrencies to exchange ('AUD', 'BRL', 'CAD', 'CHF', 'CLP', 'CNY', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'IDR', 'ILS', 'INR', 'JPY', 'KRW', 'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PKR', 'PLN', 'RUB', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'ZAR'). For example, many 'USD,BTC,ETH' to convert or only one 'USD'
|
127
|
+
# @param crypto_type [String] The type of cryptocurrency to include. ('all', 'coins', 'tokens')
|
128
|
+
# @param tag_type [String] The tag of cryptocurrency to include. ('all', 'defi', 'filesharing')
|
129
|
+
# @param audited [TrueClass, FalseClass] Show audited 'true' or not 'false'
|
130
|
+
# @param aux [String] Optionally specify a comma-separated list of supplemental data fields to return. Pass 'ath, atl, high24h, low24h, num_market_pairs, cmc_rank, date_added, max_supply, circulating_supply, total_supply, volume_7d, volume_30d, self_reported_circulating_supply, self_reported_market_cap' to include all auxiliary fields.
|
131
|
+
# @param tags [String] If you want to see cryptocurrencies that can be mined, just type 'mineable'.
|
132
|
+
# @param volume24h_range [String] Optionally specify a threshold 24 hour USD volume to filter results by. For example, '0~100000000000000000'
|
133
|
+
# @param percent_change24h_range [String] Optionally specify a threshold 24 hour percent change to filter results by. For example, '0~100' or '-10~100'
|
134
|
+
# @param circulating_supply_range [String] Optionally specify a threshold circulating supply to filter results by. For example, '0~100000000000000000'
|
135
|
+
# @param price_range [String] Optionally specify a threshold USD price to filter results by. For example, '0~100000000000000000'
|
136
|
+
# @param market_cap_range [String] Optionally specify a threshold market cap to filter results by. For example, '0~100000000000000000'
|
137
|
+
def list(**params)
|
138
|
+
options = {}
|
170
139
|
|
171
|
-
|
172
|
-
|
140
|
+
options[:start] = params[:start] || 1 # Integer
|
141
|
+
options[:limit] = params[:limit] || 100 # Integer
|
142
|
+
options[:sortBy] = params[:sort_by] || 'market_cap' # String
|
143
|
+
options[:sortType] = params[:sort_type] || 'desc' # String
|
144
|
+
options[:convert] = params[:convert] || 'USD' # String
|
145
|
+
options[:cryptoType] = params[:crypto_type] || 'all' # String
|
146
|
+
options[:tagType] = params[:tag_type] || 'all' # String
|
147
|
+
options[:audited] = params[:audited] || false # Boolean
|
148
|
+
options[:aux] = params[:aux] # String
|
149
|
+
options[:tags] = params[:tags] # String
|
150
|
+
options[:volume24hRange] = params[:volume24h_range] # String
|
151
|
+
options[:percentChange24hRange] = params[:percent_change24h_range] # String
|
152
|
+
options[:circulatingSupplyRange] = params[:circulating_supply_range] # String
|
153
|
+
options[:priceRange] = params[:price_range] # String
|
154
|
+
options[:marketCapRange] = params[:market_cap_range] # String
|
155
|
+
|
156
|
+
Helper.http_get(URI_API, options)
|
173
157
|
end
|
174
158
|
end
|
175
159
|
end
|
@@ -5,14 +5,31 @@ require_relative 'helper'
|
|
5
5
|
module CoinmarketcapFree
|
6
6
|
# All history cryptocurrency and their prices.
|
7
7
|
module CoinHistory
|
8
|
-
|
9
|
-
|
8
|
+
URI_API = "#{BASE_URI}#{VERSION_API}/cryptocurrency/detail/chart"
|
9
|
+
|
10
|
+
INTERVAL_TIME = {
|
11
|
+
one_day: '1D',
|
12
|
+
seven_days: '7D',
|
13
|
+
one_month: '1M',
|
14
|
+
three_months: '3M',
|
15
|
+
one_year: '1Y',
|
16
|
+
current_year: 'YTD',
|
17
|
+
all: 'ALL'
|
18
|
+
}.freeze
|
10
19
|
|
11
20
|
class << self
|
12
21
|
# Returns an interval of historic market quotes for any cryptocurrency based on time and interval parameters.
|
13
22
|
#
|
23
|
+
# You can use one of the following intervals: 1D, 7D, 1M, 3M, 1Y, YTD, ALL
|
24
|
+
#
|
14
25
|
# history = CoinmarketcapFree::CoinHistory.custom_time(1, '1D')
|
15
26
|
#
|
27
|
+
# Also you can use this method like this:
|
28
|
+
#
|
29
|
+
# history = CoinmarketcapFree::CoinHistory.interval_one_day(1)
|
30
|
+
#
|
31
|
+
# Just add a prefix to the method: interval_(one_day, seven_days, one_month, three_months, one_year, current_year, all)
|
32
|
+
#
|
16
33
|
# Result json:
|
17
34
|
#
|
18
35
|
# {
|
@@ -44,6 +61,7 @@ module CoinmarketcapFree
|
|
44
61
|
# }
|
45
62
|
# }
|
46
63
|
#
|
64
|
+
#
|
47
65
|
# 'data' - Results of your query returned as an object map.
|
48
66
|
# 'points' - Price range history
|
49
67
|
# 'status' - Standardized status object for API calls.
|
@@ -52,57 +70,16 @@ module CoinmarketcapFree
|
|
52
70
|
# @param range_time [String] Range time. For example, '1D', '7D', '1M', '3M', '1Y', 'YTD', 'ALL' or custom range '1668981600~1671659999'
|
53
71
|
# @return [String]
|
54
72
|
def custom_time(id, range_time)
|
55
|
-
|
56
|
-
Helper.request_to_read_data(uri)
|
73
|
+
Helper.http_get(URI_API, { id: id, range: range_time })
|
57
74
|
end
|
58
75
|
|
59
|
-
#
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
# Returns an interval of historic for the seven days
|
67
|
-
#
|
68
|
-
# @param [Integer] id Cryptocurrency identifier
|
69
|
-
def interval_seven_days(id)
|
70
|
-
custom_time(id, '7D')
|
71
|
-
end
|
72
|
-
|
73
|
-
# Returns an interval of historic for the one month
|
74
|
-
#
|
75
|
-
# @param [Integer] id Cryptocurrency identifier
|
76
|
-
def interval_one_month(id)
|
77
|
-
custom_time(id, '1M')
|
78
|
-
end
|
79
|
-
|
80
|
-
# Returns an interval of historic for the three months
|
81
|
-
#
|
82
|
-
# @param [Integer] id Cryptocurrency identifier
|
83
|
-
def interval_three_months(id)
|
84
|
-
custom_time(id, '3M')
|
85
|
-
end
|
86
|
-
|
87
|
-
# Returns an interval of historic for the one year
|
88
|
-
#
|
89
|
-
# @param [Integer] id Cryptocurrency identifier
|
90
|
-
def interval_one_year(id)
|
91
|
-
custom_time(id, '1Y')
|
92
|
-
end
|
93
|
-
|
94
|
-
# Returns an interval of historic for the current year
|
95
|
-
#
|
96
|
-
# @param [Integer] id Cryptocurrency identifier
|
97
|
-
def interval_current_year(id)
|
98
|
-
custom_time(id, 'YTD')
|
99
|
-
end
|
100
|
-
|
101
|
-
# Returns an interval of historic for the current year
|
102
|
-
#
|
103
|
-
# @param [Integer] id Cryptocurrency identifier
|
104
|
-
def interval_all_time(id)
|
105
|
-
custom_time(id, 'ALL')
|
76
|
+
# Creating interval methods
|
77
|
+
INTERVAL_TIME.each do |key, value|
|
78
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
79
|
+
def interval_#{key}
|
80
|
+
custom_time(id, '#{value}')
|
81
|
+
end
|
82
|
+
RUBY
|
106
83
|
end
|
107
84
|
end
|
108
85
|
end
|
@@ -6,16 +6,21 @@ require 'openssl'
|
|
6
6
|
require 'json'
|
7
7
|
|
8
8
|
module CoinmarketcapFree
|
9
|
+
BASE_URI = 'https://api.coinmarketcap.com/data-api/'
|
10
|
+
VERSION_API = 'v3'
|
11
|
+
|
9
12
|
# Helper module for CoinmarketcapFree
|
10
13
|
module Helper
|
11
14
|
class << self
|
12
|
-
def
|
13
|
-
uri = URI(
|
15
|
+
def http_get(url, data = nil)
|
16
|
+
uri = URI(generate_url(url, data))
|
14
17
|
Net::HTTP.get(uri)
|
15
18
|
end
|
16
19
|
|
17
|
-
|
18
|
-
|
20
|
+
private
|
21
|
+
|
22
|
+
def generate_url(url, data = nil)
|
23
|
+
"#{url}#{data ? '?' : ''}#{data.map { |key, value| "#{key}=#{value}" }.join('&')}"
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
module CoinmarketcapFree
|
4
4
|
# Get static image of a coin from coinmarketcap.com
|
5
|
-
module
|
5
|
+
module Icon
|
6
6
|
class << self
|
7
|
-
#
|
7
|
+
# Generate URI image of a coin
|
8
8
|
#
|
9
|
-
# logo = CoinmarketcapFree.img_coin(1, 64)
|
9
|
+
# logo = CoinmarketcapFree::Icon.img_coin(1, 64)
|
10
10
|
#
|
11
11
|
# Result:
|
12
12
|
# "https://s2.coinmarketcap.com/static/img/coins/64x64/1.png"
|
@@ -14,7 +14,7 @@ module CoinmarketcapFree
|
|
14
14
|
# @param [Integer] id_coin Identify coin. For example, bitcoin has 1
|
15
15
|
# @param [Integer] size Choose one size: 64, 128, 200
|
16
16
|
# @return [String] Return URI from coinmarketcap
|
17
|
-
def
|
17
|
+
def generate_url(id_coin, size)
|
18
18
|
size_x_size = case size
|
19
19
|
when 64, 128, 200
|
20
20
|
"#{size}x#{size}"
|
@@ -1,5 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Get data from Coinmarketcap API without requiring an API key.
|
3
4
|
module CoinmarketcapFree
|
4
|
-
|
5
|
+
MAJOR = 0
|
6
|
+
MINOR = 3
|
7
|
+
PATCH = 0
|
8
|
+
|
9
|
+
private_constant :MAJOR, :MINOR, :PATCH
|
10
|
+
|
11
|
+
VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
5
12
|
end
|
data/lib/coinmarketcap_free.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'coinmarketcap_free/coin_history'
|
4
|
-
require_relative 'coinmarketcap_free/
|
5
|
-
require_relative 'coinmarketcap_free/
|
4
|
+
require_relative 'coinmarketcap_free/coin'
|
5
|
+
require_relative 'coinmarketcap_free/icon'
|
6
6
|
require_relative 'coinmarketcap_free/version'
|
7
7
|
|
8
8
|
# Get data from Coinmarketcap API without requiring an API key.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coinmarketcap_free
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Vitalii Bakun
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Cryptocurrency information from the Coinmarketcap site without a key.
|
14
14
|
email:
|
@@ -17,24 +17,27 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".rubocop.yml"
|
20
21
|
- Gemfile
|
21
22
|
- Gemfile.lock
|
22
23
|
- LICENSE.txt
|
23
24
|
- README.md
|
24
25
|
- Rakefile
|
26
|
+
- coinmarketcap_free.gemspec
|
25
27
|
- lib/coinmarketcap_free.rb
|
28
|
+
- lib/coinmarketcap_free/coin.rb
|
26
29
|
- lib/coinmarketcap_free/coin_history.rb
|
27
|
-
- lib/coinmarketcap_free/coins.rb
|
28
30
|
- lib/coinmarketcap_free/helper.rb
|
29
|
-
- lib/coinmarketcap_free/
|
31
|
+
- lib/coinmarketcap_free/icon.rb
|
30
32
|
- lib/coinmarketcap_free/version.rb
|
31
|
-
homepage:
|
33
|
+
homepage:
|
32
34
|
licenses:
|
33
35
|
- MIT
|
34
36
|
metadata:
|
35
37
|
allowed_push_host: https://rubygems.org
|
36
|
-
source_code_uri: https://github.com/
|
37
|
-
|
38
|
+
source_code_uri: https://github.com/vitalii-bakun/coinmarketcap_free
|
39
|
+
rubygems_mfa_required: 'true'
|
40
|
+
post_install_message:
|
38
41
|
rdoc_options: []
|
39
42
|
require_paths:
|
40
43
|
- lib
|
@@ -42,15 +45,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
42
45
|
requirements:
|
43
46
|
- - ">="
|
44
47
|
- !ruby/object:Gem::Version
|
45
|
-
version: 2.
|
48
|
+
version: 2.7.0
|
46
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
50
|
requirements:
|
48
51
|
- - ">="
|
49
52
|
- !ruby/object:Gem::Version
|
50
53
|
version: '0'
|
51
54
|
requirements: []
|
52
|
-
rubygems_version: 3.
|
53
|
-
signing_key:
|
55
|
+
rubygems_version: 3.4.20
|
56
|
+
signing_key:
|
54
57
|
specification_version: 4
|
55
58
|
summary: Cryptocurrency information from the Coinmarketcap site without a key.
|
56
59
|
test_files: []
|