mintpal_ruby 0.0.10

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.
Files changed (3) hide show
  1. checksums.yaml +15 -0
  2. data/lib/mintpal_ruby.rb +70 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NmQ3MWFjN2FhZmZmNTc0MGZiMzc4Y2Y3YTk1NzYyNmZjZjNkMWJiNg==
5
+ data.tar.gz: !binary |-
6
+ MzViMGI2ZGNhNTlhNDgyMzI3MTgwZDg0ZTU2M2JjZTY3ZWRjZDEyYw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZTFiYTUyYTU2YmRlYTAzZDE4MzEyYjgzMTVjNzI3Y2JiNWVkYWIyYzk5YWY1
10
+ YjQ3NjAzZjI0MmYyZGZlMjNiOWUxNWZkMzNmM2RhZWRkODBhZDQ1MmQyMzlj
11
+ M2U5YmZhNDRlNzNjZGQzYWEyMDY1NjUzZDUzZmRiYjE3MDJjZjY=
12
+ data.tar.gz: !binary |-
13
+ NDY5ZmJmM2ZhMDQ2MzZhOWJjMzc4ZDI3MGYxMmJhMGU3ODE2NTA1ZmUxN2U1
14
+ MDg2OTc4MjU0ODJjYmViM2IyOTBlYmE0NmE4YzM1Y2M1MTRmZjdjMDExOTAx
15
+ Mzg3YWRkZDlmMzg4ZjEyMDlhNDQ3MjczODAxYjhkNGZhZWM5YWM=
@@ -0,0 +1,70 @@
1
+ require 'mechanize'
2
+ require 'json'
3
+ require 'hashie'
4
+ require 'bigdecimal'
5
+
6
+ module Mintpal
7
+
8
+ VERSION = '0.0.10'
9
+
10
+ API_URL = 'https://api.mintpal.com/market'
11
+ VALID_EXCHANGES = [
12
+ :BTC, :LTC
13
+ ]
14
+ VALID_COINS = [
15
+ :AUR, :BC, :BTCS, :CAGE, :CTM, :DGB, :DOGE, :DOPE, :DRK, :ECC, :EMO,
16
+ :FLT, :HVC, :KARM, :KDC, :LTC, :MINT, :MRC, :MRS, :MZC, :OLY, :PANDA,
17
+ :PENG, :PND, :POT, :Q2C, :RBBT, :RIC, :SAT, :SPA, :SUN, :TAK, :TES, :TOP,
18
+ :UNO, :USDE, :UTC, :ZED, :ZEIT
19
+ ]
20
+
21
+ class << self
22
+ def market_summary(exchange=nil)
23
+ if exchange.is_a?(Symbol) || exchange.is_a?(String)
24
+ exchange = exchange.to_sym.upcase
25
+ raise ArgumentError, "You must specify a valid exchange: #{VALID_EXCHANGES}!" if !VALID_EXCHANGES.include?(exchange)
26
+ response = JSON.parse(Mechanize.new.get("#{API_URL}/summary/#{exchange}").body)
27
+ else
28
+ response = JSON.parse(Mechanize.new.get("#{API_URL}/summary").body)
29
+ end
30
+ response.map {|c| CoinSummary.new(c) }
31
+ end
32
+
33
+ def market_stats(coin, exchange=:BTC)
34
+ exchange = exchange.to_sym.upcase
35
+ raise ArgumentError, "You must specify a valid exchange: #{VALID_EXCHANGES}!" if !VALID_EXCHANGES.include?(exchange)
36
+ coin = coin.to_sym.upcase
37
+ raise ArgumentError, "You must specify a valid coin: #{VALID_COINS}!" if !VALID_COINS.include?(coin)
38
+
39
+ response = JSON.parse(Mechanize.new.get("#{API_URL}/stats/#{coin}/#{exchange}"))
40
+ CoinSummary.new(response.first)
41
+ end
42
+
43
+ def market_trades
44
+ #
45
+ end
46
+
47
+ def market_orders
48
+ #
49
+ end
50
+
51
+ def market_chart_data
52
+ #
53
+ end
54
+ end
55
+
56
+ class CoinSummary < Hashie::Trash
57
+ property :market_id, :transform_with => lambda {|v| v.to_i rescue v }
58
+ property :code, :transform_with => lambda {|v| v.to_sym rescue v }
59
+ property :exchange, :transform_with => lambda {|v| v.to_sym rescue v }
60
+ property :last_price, :transform_with => lambda {|v| BigDecimal.new(v.to_s) rescue v }
61
+ property :yesterday_price, :transform_with => lambda {|v| BigDecimal.new(v.to_s) rescue v }
62
+ property :change, :transform_with => lambda {|v| v.to_f rescue v }
63
+ property :highest_24h, :from => '24hhigh', :with => lambda {|v| BigDecimal.new(v.to_s) rescue v }
64
+ property :lowest_24h, :from => '24hlow', :with => lambda {|v| BigDecimal.new(v.to_s) rescue v }
65
+ property :volume_24h, :from => '24hvol', :with => lambda {|v| v.to_f rescue v }
66
+ property :top_bid, :transform_with => lambda {|v| BigDecimal.new(v.to_s) rescue v }
67
+ property :top_ask, :transform_with => lambda {|v| BigDecimal.new(v.to_s) rescue v }
68
+ end
69
+
70
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mintpal_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.10
5
+ platform: ruby
6
+ authors:
7
+ - Ethan Barron
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-24 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Provides a wrapper for MintPal.com API.
14
+ email: inkybro@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/mintpal_ruby.rb
20
+ homepage:
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.2.1
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: A gem providing a wrapper around the MintPal.com API.
44
+ test_files: []