CryptoPriceFinder 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/CryptoPriceFinder/crypto.rb +80 -0
- data/lib/CryptoPriceFinder/version.rb +1 -1
- metadata +8 -10
- data/README.md +0 -30
- data/Rakefile +0 -43
- data/sig/CryptoPriceFinder.rbs +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb4df3a5bca6acee44250193ee69d9b0efeaa7625a2f725b7983f5af035e064a
|
4
|
+
data.tar.gz: 7387fbd1ae46338c5437c28495b74805ac43f132d8bae7860bb9933eb1d25e7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2cb18c22c75464048bb61afa5d89c7560980632d24a66e41845fefcb59c226622b9c7124e2a72447aeab4fb60b663d695425e59e2e9e0f88608de8e3c2f9d45
|
7
|
+
data.tar.gz: 1005391cd894adadb1f9c6709ee63bcd4f2095457b2bfad89acc50266ab9c373d2574fcd68ff14f5a412ab83b269425a64940d45c1cd07c69254fbac2350973e
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
module CryptoPriceFinder
|
5
|
+
class << self
|
6
|
+
URL = "https://duckduckgo.com/js/spice/cryptocurrency/"
|
7
|
+
def clean(input)
|
8
|
+
input.gsub("ddg_spice_cryptocurrency(", "").gsub(");", "").strip
|
9
|
+
end
|
10
|
+
private
|
11
|
+
def http(crypto, fiat, amount)
|
12
|
+
r = HTTParty.get(File.join(URL, crypto, fiat, amount.to_s)).body
|
13
|
+
r_clean = clean(r)
|
14
|
+
json = JSON.parse(r_clean)["data"]["quote"]
|
15
|
+
q = json.keys.shift.to_s
|
16
|
+
json[q]["price"].round(4)
|
17
|
+
end
|
18
|
+
public
|
19
|
+
def monero(amount)
|
20
|
+
http("xmr", "usd", amount)
|
21
|
+
end
|
22
|
+
def stellar(amount)
|
23
|
+
http("xlm", "usd", amount)
|
24
|
+
end
|
25
|
+
def bitcoin(amount)
|
26
|
+
http("btc", "usd", amount)
|
27
|
+
end
|
28
|
+
def dogecoin(amount)
|
29
|
+
http("doge", "usd", amount)
|
30
|
+
end
|
31
|
+
def ethereum(amount)
|
32
|
+
http("eth", "usd", amount)
|
33
|
+
end
|
34
|
+
def ripple(amount)
|
35
|
+
http("xrp", "usd", amount)
|
36
|
+
end
|
37
|
+
def tron(amount)
|
38
|
+
http("trx", "usd", amount)
|
39
|
+
end
|
40
|
+
def tether(amount)
|
41
|
+
http("usdt", "usd", amount)
|
42
|
+
end
|
43
|
+
def solana(amount)
|
44
|
+
http("sol", "usd", amount)
|
45
|
+
end
|
46
|
+
def bitcoin_cash(amount)
|
47
|
+
http("bch", "usd", amount)
|
48
|
+
end
|
49
|
+
def pepe(amount)
|
50
|
+
http("pepe", "usd", amount)
|
51
|
+
end
|
52
|
+
def litecoin(amount)
|
53
|
+
http("ltc", "usd", amount)
|
54
|
+
end
|
55
|
+
def polkadot(amount)
|
56
|
+
http("dot", "usd", amount)
|
57
|
+
end
|
58
|
+
def chainlink(amount)
|
59
|
+
http("link", "usd", amount)
|
60
|
+
end
|
61
|
+
def shiba_inu(amount)
|
62
|
+
http("shib", "usd", amount)
|
63
|
+
end
|
64
|
+
def filecoin(amount)
|
65
|
+
http("fil", "usd", amount)
|
66
|
+
end
|
67
|
+
def bat(amount)
|
68
|
+
http("bat", "usd", amount)
|
69
|
+
end
|
70
|
+
def bnb(amount)
|
71
|
+
http("bnb", "usd", amount)
|
72
|
+
end
|
73
|
+
def bonk(amount)
|
74
|
+
http("bonk", "usd", amount)
|
75
|
+
end
|
76
|
+
def ravencoin(amount)
|
77
|
+
http("rvn", "usd", amount)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: CryptoPriceFinder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael-Meade
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.22.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.22.0
|
27
27
|
description: Fetches Cryptocurrency prices from DuckDuckGo.
|
28
28
|
email:
|
29
29
|
- noway@lol.com
|
@@ -31,12 +31,10 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
- README.md
|
35
|
-
- Rakefile
|
36
34
|
- lib/CryptoPriceFinder.rb
|
35
|
+
- lib/CryptoPriceFinder/crypto.rb
|
37
36
|
- lib/CryptoPriceFinder/version.rb
|
38
|
-
|
39
|
-
homepage:
|
37
|
+
homepage: https://github.com/Michael-Meade/CryptoPriceFinder
|
40
38
|
licenses:
|
41
39
|
- Ruby
|
42
40
|
metadata: {}
|
data/README.md
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# CryptoPriceFinder
|
2
|
-
|
3
|
-
Fetches cryptocurrency prices from DuckDuckGo. Converts crypto prices into USD prices.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
```ruby
|
7
|
-
gem install httparty
|
8
|
-
gem install CryptoPriceFinder
|
9
|
-
```
|
10
|
-
|
11
|
-
## Usage
|
12
|
-
|
13
|
-
```ruby
|
14
|
-
puts "Monero"
|
15
|
-
CryptoPriceFinder::monero(6.6)
|
16
|
-
puts "Bitcoin"
|
17
|
-
CryptoPriceFinder::bitcoin(3)
|
18
|
-
puts "Stellar"
|
19
|
-
CryptoPriceFinder::stellar(4)
|
20
|
-
puts "DogeCoin"
|
21
|
-
CryptoPriceFinder::dogecoin(4)
|
22
|
-
Puts "Ethereum"
|
23
|
-
CryptoPriceFinder::ethereum(4)
|
24
|
-
puts "Ripple"
|
25
|
-
CryptoPriceFinder::ripple(5)
|
26
|
-
```
|
27
|
-
|
28
|
-
## Contributing
|
29
|
-
|
30
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/CryptoPriceFinder.
|
data/Rakefile
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "bundler/gem_tasks"
|
4
|
-
task default: %i[]
|
5
|
-
namespace "gems" do
|
6
|
-
desc "Building gem, Push gem, Install Gem"
|
7
|
-
task :all do
|
8
|
-
begin
|
9
|
-
require "colorize"
|
10
|
-
gemfile = Dir.glob("*.gem").each { |f| f }.shift
|
11
|
-
if !gemfile.nil?
|
12
|
-
if File.exist?(gemfile)
|
13
|
-
puts "Deleting #{gemfile}...\n".red
|
14
|
-
File.delete(gemfile)
|
15
|
-
puts "Building gem...\n".red
|
16
|
-
%x(gem build CryptoPriceFinder.gemspec)
|
17
|
-
puts "Pushing Gem...\n".red
|
18
|
-
begin
|
19
|
-
sh "gem push #{Dir.glob("*.gem").each { |f| f }.shift}"
|
20
|
-
rescue
|
21
|
-
puts "ERROR in Pushing...\n".red
|
22
|
-
end
|
23
|
-
puts "[+] Installing gem...\n"
|
24
|
-
sh "gem install #{Dir.glob("*.gem").each { |f| f }.shift}"
|
25
|
-
end
|
26
|
-
else
|
27
|
-
puts "No gem file found..."
|
28
|
-
puts "Building gem...\n".red
|
29
|
-
%x(gem build CryptoPriceFinder.gemspec)
|
30
|
-
puts "Pushing Gem...\n".red
|
31
|
-
begin
|
32
|
-
sh "gem push #{Dir.glob("*.gem").each { |f| f }.shift}"
|
33
|
-
rescue
|
34
|
-
puts "ERROR in Pushing...\n".red
|
35
|
-
end
|
36
|
-
puts "[+] Installing gem...\n"
|
37
|
-
sh "gem install #{Dir.glob("*.gem").each { |f| f }.shift}"
|
38
|
-
end
|
39
|
-
rescue => e
|
40
|
-
puts e
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/sig/CryptoPriceFinder.rbs
DELETED