coinmarketcap_free 0.1.5 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 669d745040747a98dbe9ffc2842a39b4b7bb7da5c31229c445a3e5d8d7c2a18a
4
- data.tar.gz: 954e9acd92f61f5aa4974660bd76d360e8e329d1c1c59a1e6589eda8f2fdb3ff
3
+ metadata.gz: 0c559f0f1d6dea4119d9c1c6fd6fb9d44b03559c80c694c9c18e4a452a285ed5
4
+ data.tar.gz: c1927861d0070f84d8c4aabaf6045de7b2da4d0a1230349bf19e257995d51d84
5
5
  SHA512:
6
- metadata.gz: 5d9c32b8e9e77b00cd8a4b50bbd74716115b9c5661c9483fba51d40855394b1e63091827b5e66e7660881bc019c81534ea7ee0602d05091bdf721c7d9a7b6206
7
- data.tar.gz: 2b9bce59829077e729b8e4da1c915ae08cd82f6c7fe5a4853767e664a39232da34917d3f0a9b9c879df4e218fed5a54b5d0f435113d41142cec58512abc8da95
6
+ metadata.gz: 94665066f532975bcfd68ed72feb3b9905e9372d9b01562ea6d5a0929a3f8604358feb578f0ffcf42e86464e103877d5549e22d4fc1e7e31565df40be64d8c13
7
+ data.tar.gz: 4f43a77dd4718c0be2760aabda58338741ee29e38318a5f3eb3d0b0cc06009bf4ea852f34260c0eb4b2aa50fbefa6c1157d331ae4b019b4533281f61574ff93c
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: true
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 "https://rubygems.org"
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 'uri', "~> 0.12.0"
9
- gem "net-http", "~> 0.3.0"
10
- gem "openssl", "~> 3.0"
11
- gem "json", "~> 2.6"
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 "rake", "~> 13.0"
15
- gem "minitest", "~> 5.0"
14
+ gem 'minitest', '~> 5.0'
15
+ gem 'rake', '~> 13.0'
16
16
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coinmarketcap_free (0.1.5)
4
+ coinmarketcap_free (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -12,7 +12,7 @@ GEM
12
12
  uri
13
13
  openssl (3.0.1)
14
14
  rake (13.0.6)
15
- uri (0.12.0)
15
+ uri (0.12.1)
16
16
 
17
17
  PLATFORMS
18
18
  x86_64-linux
@@ -24,7 +24,7 @@ DEPENDENCIES
24
24
  net-http (~> 0.3.0)
25
25
  openssl (~> 3.0)
26
26
  rake (~> 13.0)
27
- uri (~> 0.12.0)
27
+ uri (~> 0.12.1)
28
28
 
29
29
  BUNDLED WITH
30
- 2.3.26
30
+ 2.4.10
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::Coins.get_list()
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::Coins.get_list(limit: 100, start: 1, sort_type:'asc')
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::Coins.get_list(limit: 100, start: 1, sort_type:'asc', sort_by: 'name')
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::Coins.get_list(limit: 100,
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::Coins.get_list:
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 = ["cosmic-1"]
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.6.0"
15
+
16
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
+
18
+ spec.metadata["source_code_uri"] = 'https://github.com/Cosmic-1/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'] = 'false'
37
+ end
@@ -4,14 +4,14 @@ require_relative 'helper'
4
4
 
5
5
  module CoinmarketcapFree
6
6
  # All about cryptocurrencies and their prices.
7
- module Coins
7
+ module Coin
8
8
  URL_API = 'https://api.coinmarketcap.com/data-api/v3/cryptocurrency/listing'
9
9
  private_constant :URL_API
10
10
 
11
11
  class << self
12
12
  # Get a list of cryptocurrencies
13
13
  #
14
- # list = CoinmarketcapFree::Coins.get_list(limit: 100, start: 1)
14
+ # list = CoinmarketcapFree::Coin.list(limit: 100, start: 1)
15
15
  #
16
16
  # Result json:
17
17
  #
@@ -104,19 +104,19 @@ module CoinmarketcapFree
104
104
  #
105
105
  # If you want to sort in ascending, just write parameter:
106
106
  #
107
- # list = CoinmarketcapFree::Coins.get_list(limit: 100, start: 1, sort_type:'asc')
107
+ # list = CoinmarketcapFree::Coin.list(limit: 100, start: 1, sort_type:'asc')
108
108
  #
109
109
  # or
110
110
  #
111
- # list = CoinmarketcapFree::Coins.get_list(limit: 100, start: 1, sort_type:'desc')
111
+ # list = CoinmarketcapFree::Coin.list(limit: 100, start: 1, sort_type:'desc')
112
112
  #
113
113
  # You can also adding sort by:
114
114
  #
115
- # list = CoinmarketcapFree::Coins.get_list(limit: 100, start: 1, sort_type:'asc', sort_by: 'name')
115
+ # list = CoinmarketcapFree::Coin.list(limit: 100, start: 1, sort_type:'asc', sort_by: 'name')
116
116
  #
117
117
  # Convert cryptocurrency to::
118
118
  #
119
- # list = CoinmarketcapFree::Coins.get_list(limit: 100, start: 1, convert: 'USD,BTC,ETH')
119
+ # list = CoinmarketcapFree::Coin.list(limit: 100, start: 1, convert: 'USD,BTC,ETH')
120
120
  #
121
121
  #
122
122
  # @return [String]
@@ -135,41 +135,26 @@ module CoinmarketcapFree
135
135
  # @param [String] circulating_supply_range Optionally specify a threshold circulating supply to filter results by. For example, '0~100000000000000000'
136
136
  # @param [String] price_range Optionally specify a threshold USD price to filter results by. For example, '0~100000000000000000'
137
137
  # @param [String] market_cap_range Optionally specify a threshold market cap to filter results by. For example, '0~100000000000000000'
138
- def get_list(start: 1,
139
- limit: 100,
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
- }
138
+ def list(**params)
139
+ options = {}
170
140
 
171
- uri = Helper.generate_uri_for_data(URL_API, options)
172
- Helper.request_to_read_data(uri)
141
+ options[:start] = params[:start] || 1 # Integer
142
+ options[:limit] = params[:limit] || 100 # Integer
143
+ options[:sortBy] = params[:sort_by] || 'market_cap' # String
144
+ options[:sortType] = params[:sort_type] || 'desc' # String
145
+ options[:convert] = params[:convert] || 'USD' # String
146
+ options[:cryptoType] = params[:crypto_type] || 'all' # String
147
+ options[:tagType] = params[:tag_type] || 'all' # String
148
+ options[:audited] = params[:audited] || false # Boolean
149
+ options[:aux] = params[:aux] # String
150
+ options[:tags] = params[:tags] # String
151
+ options[:volume24hRange] = params[:volume24h_range] # String
152
+ options[:percentChange24hRange] = params[:percent_change24h_range] # String
153
+ options[:circulatingSupplyRange] = params[:circulating_supply_range] # String
154
+ options[:priceRange] = params[:price_range] # String
155
+ options[:marketCapRange] = params[:market_cap_range] # String
156
+
157
+ Helper.http_get(URL_API, options)
173
158
  end
174
159
  end
175
160
  end
@@ -52,8 +52,7 @@ module CoinmarketcapFree
52
52
  # @param range_time [String] Range time. For example, '1D', '7D', '1M', '3M', '1Y', 'YTD', 'ALL' or custom range '1668981600~1671659999'
53
53
  # @return [String]
54
54
  def custom_time(id, range_time)
55
- uri = Helper.generate_uri_for_data(URL_API, { id: id, range: range_time })
56
- Helper.request_to_read_data(uri)
55
+ Helper.http_get(URL_API, { id: id, range: range_time })
57
56
  end
58
57
 
59
58
  # Returns an interval of historic for the day
@@ -9,13 +9,15 @@ module CoinmarketcapFree
9
9
  # Helper module for CoinmarketcapFree
10
10
  module Helper
11
11
  class << self
12
- def request_to_read_data(uri_string)
13
- uri = URI(uri_string)
12
+ def http_get(url, data = nil)
13
+ uri = URI(generate_url(url, data))
14
14
  Net::HTTP.get(uri)
15
15
  end
16
16
 
17
- def generate_uri_for_data(url, data)
18
- "#{url}?#{data.map { |key, value| "#{key}=#{value}" }.join('&')}"
17
+ private
18
+
19
+ def generate_url(url, data = nil)
20
+ "#{url}#{data ? '?' : ''}#{data.map { |key, value| "#{key}=#{value}" }.join('&')}"
19
21
  end
20
22
  end
21
23
  end
@@ -2,11 +2,11 @@
2
2
 
3
3
  module CoinmarketcapFree
4
4
  # Get static image of a coin from coinmarketcap.com
5
- module Icons
5
+ module Icon
6
6
  class << self
7
7
  # Get coin logo URI
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 get_coin_logo_uri(id_coin, size)
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,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CoinmarketcapFree
4
- VERSION = '0.1.5'
4
+ VERSION = '0.2.0'
5
5
  end
@@ -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/coins'
5
- require_relative 'coinmarketcap_free/icons'
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.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - cosmic-1
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-27 00:00:00.000000000 Z
11
+ date: 2023-05-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Cryptocurrency information from the Coinmarketcap site without a key.
14
14
  email:
@@ -17,16 +17,18 @@ 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/icons.rb
31
+ - lib/coinmarketcap_free/icon.rb
30
32
  - lib/coinmarketcap_free/version.rb
31
33
  homepage:
32
34
  licenses:
@@ -34,6 +36,7 @@ licenses:
34
36
  metadata:
35
37
  allowed_push_host: https://rubygems.org
36
38
  source_code_uri: https://github.com/Cosmic-1/coinmarketcap_free
39
+ rubygems_mfa_required: 'false'
37
40
  post_install_message:
38
41
  rdoc_options: []
39
42
  require_paths:
@@ -49,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
52
  - !ruby/object:Gem::Version
50
53
  version: '0'
51
54
  requirements: []
52
- rubygems_version: 3.3.26
55
+ rubygems_version: 3.4.10
53
56
  signing_key:
54
57
  specification_version: 4
55
58
  summary: Cryptocurrency information from the Coinmarketcap site without a key.