coincap 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 400102f77c2de8996aed21a75f3dd351998cceb7fe88130814474dce51ddef33
4
- data.tar.gz: d1cf37117aeb04e4d956fdbd0c4de56d9dc93537e3672e0ca2016ffeedb370d4
3
+ metadata.gz: 5f64f28f94bf1c7bfc899d6493f0f9e2512ce9f413adad7073d5cbd3b3aeb510
4
+ data.tar.gz: 7d5ac910e50b8c06611849fe7859d0a30bfa9d017cb7b33b2890c292b52eef67
5
5
  SHA512:
6
- metadata.gz: 57971399dfeb1d52affcb456202ced30853b1d21f2adc6812fc6a68105833c4445f8c7d1c1848f1930befe1d914ab42000da101204e034b9fe84e42cf385805f
7
- data.tar.gz: 340c5c6cbaeacd4990955e51faed298b93ebbbffc80cb4944887cc61bf68d1a7219fdf3fd34eaef5affd17be3867216e8b7ebe0d8ab24f1861069434917232dc
6
+ metadata.gz: e5b4e8f2fda02bc248ddd777eaeccdaa20950980a3039e90572e4e9daeaf58bf001a734fdc925e0d1414cc9af6b0221bb420fe0f626d0267e9553bf253881e9b
7
+ data.tar.gz: fa99b3052e9dd464070aee8465fbd7d8ae45fd5a6a2d457d34a78dd9ef2f3d72f37e3fa63654a200c49e96401560cd1a8ba3db5ee8d3c054783456fed01401ce
data/Gemfile CHANGED
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
- gem 'json'
8
- gem 'net-http'
9
- gem 'openssl'
10
- gem 'uri'
7
+ gem 'json', '~> 2.6'
8
+ gem 'net-http', '~> 0.3.2'
9
+ gem 'openssl', '~> 3.1'
10
+ gem 'uri', '~> 0.12.1'
11
11
 
12
12
  group :test do
13
- gem 'minitest'
14
- gem 'rake'
15
- end
13
+ gem 'minitest', '~> 5.18'
14
+ gem 'rake', '~> 13.0'
15
+ end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coincap (0.1.0)
4
+ coincap (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -19,12 +19,12 @@ PLATFORMS
19
19
 
20
20
  DEPENDENCIES
21
21
  coincap!
22
- json
23
- minitest
24
- net-http
25
- openssl
26
- rake
27
- uri
22
+ json (~> 2.6)
23
+ minitest (~> 5.18)
24
+ net-http (~> 0.3.2)
25
+ openssl (~> 3.1)
26
+ rake (~> 13.0)
27
+ uri (~> 0.12.1)
28
28
 
29
29
  BUNDLED WITH
30
30
  2.4.10
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 cosmic-1
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -4,6 +4,7 @@ CoinCap is a useful tool for real-time pricing and market activity for over 1,00
4
4
  If you want to add 'api key' or change 'accept encoding', just call the 'configure' method.
5
5
 
6
6
  No API Key: 200 requests per minute
7
+
7
8
  API Key: 500 requests per minute
8
9
 
9
10
  Generate API KEY [here](https://coincap.io/api-key).
@@ -211,4 +212,4 @@ data = Coincap::Markets.list
211
212
  ],
212
213
  "timestamp": 1533581173350
213
214
  }
214
- ```
215
+ ```
data/coincap.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/coincap/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'coincap'
7
+ spec.version = Coincap::VERSION
8
+ spec.authors = ['cosmic-1']
9
+ spec.email = ['crossdoh@gmail.com']
10
+
11
+ spec.summary = 'CoinCap is a useful tool for real-time pricing and market activity for over 1,000 cryptocurrencies.'
12
+ spec.description = 'CoinCap is a useful tool for real-time pricing and market activity for over 1,000 cryptocurrencies.'
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/coincap'
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
+ end
@@ -45,20 +45,13 @@ module Coincap
45
45
  # "timestamp": 1533581088278
46
46
  # }
47
47
  #
48
- # @param [Hash] options
49
- # @option options [String] :search (nil) Search by asset id (bitcoin) or symbol (BTC)
50
- # @option options [String] :ids (nil) Query with multiple ids=bitcoin,ethereum,monero
51
- # @option options [Integer] :limit (nil) Max limit of 2000
52
- # @option options [Integer] :offset (nil) Offset
53
- # @return [Hash]
54
- def self.cryptocurrencies(**options)
55
- quries = {
56
- 'search': options[:search],
57
- 'ids': options[:ids],
58
- 'limit': options[:limit],
59
- 'offset': options[:offset]
60
- }
61
- Helper.request_to_read_data(URI_API, **quries)
48
+ # @param [String] search (nil) Search by asset id (bitcoin) or symbol (BTC)
49
+ # @param [String] ids (nil) Query with multiple ids=bitcoin,ethereum,monero
50
+ # @param [Integer] limit (nil) Max limit of 2000
51
+ # @param [Integer] offset (nil) Offset
52
+ # @return [String]
53
+ def self.cryptocurrencies(search: nil, ids: nil, limit: nil, offset: nil)
54
+ Helper.request_to_read_data(URI_API, search: search, ids: ids, limit: limit, offset: offset)
62
55
  end
63
56
 
64
57
  # Get single cryptocurrency
@@ -81,7 +74,7 @@ module Coincap
81
74
  # }
82
75
  #
83
76
  # @param [String] asset_id Asset id, for example, bitcoin
84
- # @return [Hash]
77
+ # @return [String]
85
78
  def self.cryptocurrency(asset_id)
86
79
  Helper.request_to_read_data("#{URI_API}/#{asset_id}")
87
80
  end
@@ -101,6 +94,7 @@ module Coincap
101
94
  #
102
95
  # @param [String] asset_id Asset id, for example, bitcoin
103
96
  # @param [Symbol] interval Select one from the list m1,m5,m15,m30,h1,h2,h6,h12,d1, for example, m1 or write a symbol, for example, :one_minute
97
+ # @return [String]
104
98
  def self.cryptocurrency_history(asset_id, interval)
105
99
  Helper.request_to_read_data("#{URI_API}/#{asset_id}/history",
106
100
  interval: interval.is_a?(Symbol) ? TIME_INTERVAL[interval] : interval)
@@ -128,6 +122,7 @@ module Coincap
128
122
  # @param [String] asset_id Asset id, for example, bitcoin
129
123
  # @param [Integer] limit Max limit of 2000
130
124
  # @param [Integer] offset Offset
125
+ # @return [String]
131
126
  def self.cryptocurrency_with_markets(asset_id, limit: nil, offset: nil)
132
127
  Helper.request_to_read_data("#{URI_API}/#{asset_id}/markets", limit: limit, offset: offset)
133
128
  end
@@ -33,7 +33,7 @@ module Coincap
33
33
  # "timestamp": 1536605835421
34
34
  # }
35
35
  #
36
- # @return [Hash]
36
+ # @return [String]
37
37
  def self.list
38
38
  Helper.request_to_read_data(URI_API)
39
39
  end
@@ -56,7 +56,7 @@ module Coincap
56
56
  # }
57
57
  #
58
58
  # @param exchange_id [String]
59
- # @return [Hash]
59
+ # @return [String]
60
60
  def self.single(exchange_id)
61
61
  Helper.request_to_read_data("#{URI_API}/#{exchange_id}")
62
62
  end
@@ -8,10 +8,14 @@ require 'openssl'
8
8
  module Coincap
9
9
  # Helper module
10
10
  module Helper
11
- def self.request_to_read_data(uri_string, **queries_hash)
12
- uri = convert_hash_to_uri(uri_string, **queries_hash)
13
-
14
- data_str = http_get(uri)
11
+ class << self
12
+ # Request to read data
13
+ # @param uri_string [String] string of the uri
14
+ # @param queries_hash [Hash] queries hash for the request
15
+ # @return [String]
16
+ def request_to_read_data(uri_string, **queries_hash)
17
+ http_get convert_hash_to_uri(uri_string, **queries_hash)
18
+ end
15
19
 
16
20
  JSON.parse(data_str)
17
21
  end
@@ -23,11 +27,9 @@ module Coincap
23
27
  config = Coincap.instance_variable_get(:@config)
24
28
 
25
29
  headers = {
26
- 'Accept-Encoding': config.accept_encoding,
30
+ 'Accept-Encoding': config.accept_encoding.nil? ? nil : config.accept_encoding,
27
31
  'Authorization': config.api_key.nil? ? nil : "Bearer #{config.api_key}"
28
- }
29
-
30
- headers.compact!
32
+ }.compact
31
33
 
32
34
  Net::HTTP.get(uri, headers)
33
35
  end
@@ -35,30 +35,27 @@ module Coincap
35
35
  # "timestamp": 1533581173350
36
36
  # }
37
37
  #
38
- # @param options [Hash] options for the request
39
- # @option options [String] :exchange_id (nil) Search by exchange id (e.g. 'binance')
40
- # @option options [String] :base_symbol (nil) Returns all containing the base symbol
41
- # @option options [String] :quote_symbol (nil) Returns all containing the quote symbol
42
- # @option options [String] :base_id (nil) Returns all containing the base id
43
- # @option options [String] :quote_id (nil) Returns all containing the quote id
44
- # @option options [String] :asset_symbol (nil) Returns all assets containing symbol (base and quote)
45
- # @option options [String] :asset_id (nil) Returns all assets containing id (base and quote)
46
- # @option options [Integer] :limit (nil) Max limit of 2000
47
- # @option options [Integer] :offset (nil) The number of results to skip
48
- # @return [Hash]
38
+ # @param [String] exchange_id (nil) Search by exchange id (e.g. 'binance')
39
+ # @param [String] base_symbol (nil) Returns all containing the base symbol
40
+ # @param [String] quote_symbol (nil) Returns all containing the quote symbol
41
+ # @param [String] base_id (nil) Returns all containing the base id
42
+ # @param [String] quote_id (nil) Returns all containing the quote id
43
+ # @param [String] asset_symbol (nil) Returns all assets containing symbol (base and quote)
44
+ # @param [String] asset_id (nil) Returns all assets containing id (base and quote)
45
+ # @param [Integer] limit (nil) Max limit of 2000
46
+ # @param [Integer] offset (nil) The number of results to skip
47
+ # @return [String]
49
48
  def self.list(**options)
50
- queries = {
51
- 'exchangeId': options[:exchange_id],
52
- 'baseSymbol': options[:base_symbol],
53
- 'quoteSymbol': options[:quote_symbol],
54
- 'baseId': options[:base_id],
55
- 'quoteId': options[:quote_id],
56
- 'assetSymbol': options[:asset_symbol],
57
- 'assetId': options[:asset_id],
58
- 'limit': options[:limit],
59
- 'offset': options[:offset]
60
- }
61
- Helper.request_to_read_data(URI_API, **queries)
49
+ Helper.request_to_read_data(URI_API,
50
+ 'exchangeId': options[:exchange_id],
51
+ 'baseSymbol': options[:base_symbol],
52
+ 'quoteSymbol': options[:quote_symbol],
53
+ 'baseId': options[:base_id],
54
+ 'quoteId': options[:quote_id],
55
+ 'assetSymbol': options[:asset_symbol],
56
+ 'assetId': options[:asset_id],
57
+ 'limit': options[:limit],
58
+ 'offset': options[:offset])
62
59
  end
63
60
  end
64
61
  end
data/lib/coincap/rates.rb CHANGED
@@ -26,7 +26,7 @@ module Coincap
26
26
  # "timestamp": 1536347807471
27
27
  # }
28
28
  #
29
- # @return [Hash]
29
+ # @return [String]
30
30
  def self.list
31
31
  Helper.request_to_read_data(URI_API)
32
32
  end
@@ -45,7 +45,7 @@ module Coincap
45
45
  # }
46
46
  #
47
47
  # @param asset_id [String] The asset id (bitcoin)
48
- # @return [Hash]
48
+ # @return [String]
49
49
  def self.single(asset_id)
50
50
  Helper.request_to_read_data("#{URI_API}/#{asset_id}")
51
51
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Coincap
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.2'
5
5
  end
data/lib/coincap.rb CHANGED
@@ -31,9 +31,8 @@ module Coincap
31
31
 
32
32
  @config = Configuration.new
33
33
 
34
+ # Configuration the Coincap API
34
35
  def self.configure
35
- # @yield [Coincap::Configuration]
36
36
  yield @config
37
- @config.accept_encoding
38
37
  end
39
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coincap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
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-04-12 00:00:00.000000000 Z
11
+ date: 2023-05-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: CoinCap is a useful tool for real-time pricing and market activity for
14
14
  over 1,000 cryptocurrencies.
@@ -20,8 +20,10 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - Gemfile
22
22
  - Gemfile.lock
23
+ - LICENSE.txt
23
24
  - README.md
24
25
  - Rakefile
26
+ - coincap.gemspec
25
27
  - lib/coincap.rb
26
28
  - lib/coincap/assets_price.rb
27
29
  - lib/coincap/exchanges.rb
@@ -30,7 +32,8 @@ files:
30
32
  - lib/coincap/rates.rb
31
33
  - lib/coincap/version.rb
32
34
  homepage:
33
- licenses: []
35
+ licenses:
36
+ - MIT
34
37
  metadata:
35
38
  allowed_push_host: https://rubygems.org
36
39
  source_code_uri: https://github.com/Cosmic-1/coincap