CryptoPriceFinder 0.2.0 → 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/lib/CryptoPriceFinder/crypto.rb +83 -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: 9328ebe22ba165216244abb489809a2081c797a8fd75a14105660a9c1ac1b26a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 4eb5f1e22538f3315ab7a9a04dd6dc7507b7971cc3c0e524240766492ca33831
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c448b6e677682f326e4d26bf90ebb8126f715bb874958a6d6390b66b0b31a8bae6379df7bc8da5801250f08e5c5089bd2fa69069e1869bf99af778b31746047e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: a5b519d97844234cf37894f95d4ea8c7d0e886771101bbc2e8fe2ee85c4ca98744146b33c269b7d51677fc8dfa2f7264c19c7b12f7d0eb2134746088c27c3bc1
         
     | 
| 
         @@ -0,0 +1,83 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
            		def grin(amount)
         
     | 
| 
      
 80 
     | 
    
         
            +
            			http("grin", "usd", amount)
         
     | 
| 
      
 81 
     | 
    
         
            +
            		end
         
     | 
| 
      
 82 
     | 
    
         
            +
            	end	
         
     | 
| 
      
 83 
     | 
    
         
            +
            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.3.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