gecko-api 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +29 -0
- data/lib/gecko/autoloader.rb +41 -0
- data/lib/gecko/base.rb +16 -0
- data/lib/gecko/resources/coin.rb +31 -0
- data/lib/gecko/resources/request.rb +31 -0
- data/lib/gecko/version.rb +5 -0
- data/lib/gecko.rb +33 -0
- metadata +176 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f500a52fbca5e1a944d3d8be977d633c60e4834114bd79c97e4b5841299887d0
|
4
|
+
data.tar.gz: f37c9108cc676e90c4176742cd650a2efee136f57b74c089ee982765a961f30c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4aff1156a513baa6f522f332c91305b9b747f4e85b2fcd900982a619b0b5e8c757228187103b7bacbdac0608ff8d50e90d5de70bb582b5e9499415b2e7892279
|
7
|
+
data.tar.gz: e6e7af0fa4f580be0944f253187c7d3174c345d5a7f1d7ff77f7cc41ef744253f5ac3ced2c255117525aad0d5875e13876b9afcd010ca3615ae1b8e04d86a2de
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Gecko
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gecko`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Install the gem and add to the application's Gemfile by executing:
|
10
|
+
|
11
|
+
$ bundle add gecko
|
12
|
+
|
13
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
14
|
+
|
15
|
+
$ gem install gecko
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
TODO: Write usage instructions here
|
20
|
+
|
21
|
+
## Development
|
22
|
+
|
23
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
24
|
+
|
25
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gecko.
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'zeitwerk'
|
4
|
+
|
5
|
+
module Gecko
|
6
|
+
class Autoloader
|
7
|
+
class Inflector < ::Zeitwerk::Inflector
|
8
|
+
INFLECTIONS_MAP = {
|
9
|
+
version: 'VERSION'
|
10
|
+
}.freeze
|
11
|
+
|
12
|
+
def camelize(basename, _abspath)
|
13
|
+
INFLECTIONS_MAP[basename.to_sym] || super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class << self
|
18
|
+
LIB_PATH = ::File.dirname(__dir__).freeze
|
19
|
+
|
20
|
+
def setup!
|
21
|
+
loader = ::Zeitwerk::Loader.new
|
22
|
+
loader.tag = 'gecko'
|
23
|
+
loader.inflector = Inflector.new
|
24
|
+
loader.push_dir(LIB_PATH)
|
25
|
+
loader.collapse(::File.join(LIB_PATH, 'gecko', 'resources'))
|
26
|
+
|
27
|
+
ignored_paths.each { |path| loader.ignore(path) }
|
28
|
+
|
29
|
+
loader.setup
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def ignored_paths
|
35
|
+
[
|
36
|
+
::File.join(LIB_PATH, 'gecko', 'patches')
|
37
|
+
].freeze
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/gecko/base.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require 'net/http'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
module Gecko
|
8
|
+
class Base
|
9
|
+
class << self
|
10
|
+
attr_accessor :app_info, :path_prefix
|
11
|
+
end
|
12
|
+
|
13
|
+
self.app_info = ::ENV['APP_INFO'] || "#{::Gecko::NAME} V#{::Gecko.version}"
|
14
|
+
self.path_prefix = 'https://api.coingecko.com/api/v3'
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gecko
|
4
|
+
class Coin < Base
|
5
|
+
class << self
|
6
|
+
# GET /coins/#{coin}
|
7
|
+
# Description: Acquire data of a crypto
|
8
|
+
# Parameter: /
|
9
|
+
|
10
|
+
def exchanges(name)
|
11
|
+
formatting(detail(name.downcase))
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def detail(name)
|
17
|
+
uri = URI("https://api.coingecko.com/api/v3/coins/#{name}")
|
18
|
+
Gecko::Request.request(uri: uri, method: 'GET')
|
19
|
+
end
|
20
|
+
|
21
|
+
def formatting(payload)
|
22
|
+
tickers = payload['tickers']
|
23
|
+
if !tickers.nil?
|
24
|
+
tickers.map { |x| x.dig('market', 'name') }.uniq
|
25
|
+
else
|
26
|
+
[]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gecko
|
4
|
+
class Request < Base
|
5
|
+
class << self
|
6
|
+
def request(uri:, method:)
|
7
|
+
req = get_method(name: method, uri: uri)
|
8
|
+
req['Content-Type'] = 'application/json'
|
9
|
+
|
10
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
11
|
+
http.request(req)
|
12
|
+
end
|
13
|
+
|
14
|
+
JSON.parse(res.body)
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_method(name:, uri:)
|
18
|
+
case name
|
19
|
+
when 'GET'
|
20
|
+
req = Net::HTTP::Get.new(uri)
|
21
|
+
# when 'POST'
|
22
|
+
# req = Net::HTTP::Post.new(uri)
|
23
|
+
# when 'DELETE'
|
24
|
+
# req = Net::HTTP::Delete.new(uri)
|
25
|
+
end
|
26
|
+
|
27
|
+
req
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/gecko.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './gecko/autoloader'
|
4
|
+
|
5
|
+
module Gecko
|
6
|
+
NAME = 'Gecko Ruby'
|
7
|
+
|
8
|
+
@mutex = ::Mutex.new
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def app_info=(value)
|
12
|
+
::Gecko::Base.app_info = value
|
13
|
+
end
|
14
|
+
|
15
|
+
def ping
|
16
|
+
{ status: 200 }
|
17
|
+
end
|
18
|
+
|
19
|
+
def path=(value)
|
20
|
+
@mutex.synchronize { ::Gecko::Base.path_prefix = value }
|
21
|
+
end
|
22
|
+
|
23
|
+
def path
|
24
|
+
@mutex.synchronize { ::Gecko::Base.path_prefix }
|
25
|
+
end
|
26
|
+
|
27
|
+
def version
|
28
|
+
VERSION
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
::Gecko::Autoloader.setup!
|
metadata
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gecko-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stefano Baldazzi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-12-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: zeitwerk
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bump
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.8'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: digest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.1.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.1.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '13.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '13.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.8'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.8'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.16'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.16'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.14'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.14'
|
139
|
+
description: Gecko Ruby is a lightweight gem for accessing the Gecko API web services.
|
140
|
+
email:
|
141
|
+
- stefanobaldazzi40@gmail.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- README.md
|
147
|
+
- lib/gecko.rb
|
148
|
+
- lib/gecko/autoloader.rb
|
149
|
+
- lib/gecko/base.rb
|
150
|
+
- lib/gecko/resources/coin.rb
|
151
|
+
- lib/gecko/resources/request.rb
|
152
|
+
- lib/gecko/version.rb
|
153
|
+
homepage: https://github.com/Baldaz02/gecko-ruby
|
154
|
+
licenses:
|
155
|
+
- MIT
|
156
|
+
metadata: {}
|
157
|
+
post_install_message:
|
158
|
+
rdoc_options: []
|
159
|
+
require_paths:
|
160
|
+
- lib
|
161
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '2.7'
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
requirements: []
|
172
|
+
rubygems_version: 3.3.24
|
173
|
+
signing_key:
|
174
|
+
specification_version: 4
|
175
|
+
summary: gecko0.0.0
|
176
|
+
test_files: []
|