middlecoin 0.0.0 → 0.0.1

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
  SHA1:
3
- metadata.gz: a987245589473f8ece1f9761ec8c195dd158a346
4
- data.tar.gz: 88e229054604cd034cc1332d0dbdf91c969abf4e
3
+ metadata.gz: aab9760328e43432963c743c2e4ac83022f423d2
4
+ data.tar.gz: be7f9504ca60609c0908b16eafd4b27dea301218
5
5
  SHA512:
6
- metadata.gz: 7b4a6091a826efa8dd2d07aa0d93ef854336a82e1815d877ff51446dba643844d1e6450ce6af24a138b2e013b94464fd1d34847952cd38bc0ff073c667fec378
7
- data.tar.gz: 256e16c11ad47cb705d711263c11ad794403b5937888ce8cb1f0f331eb0c4016d62d2d7934539b4e659983af81f6df86cf7a6452fac3491b7b1d263d2cf9ad2b
6
+ metadata.gz: 21610ec1e049d4ec0f646ca0f99a8c077ef6660103898390f18ed6b1ebf6be6a774b78208d07cc7a1c03114c2ea2ed5f07e315b7eb249a0847ed143f26fdfca5
7
+ data.tar.gz: abdf345f1380586a0792be560c320cd152de9525eb775086b60ee5f83624cf8fbf5426b6dfc9d8e2b0b2e6257c255aa43327af9ad0c11fb6ba125bac8cf95bf9
@@ -8,14 +8,21 @@ A rubygem for interacting with middlecoin.com JSON web api.
8
8
 
9
9
  # Usage
10
10
 
11
- %
11
+ % middlecoin 1Cfd5G6rJmSBrNcTHxEgE4uYgH7XZJPY7Z
12
+
13
+ % middlecoin 1Cfd5G6rJmSBrNcTHxEgE4uYgH7XZJPY7Z 1Cfd5G6rJmSBrNcTHxEgE4uYgH7XZJPY7Z
12
14
 
13
15
  # Contributing
14
- If you would like to contribute templates/bug fixes/etc to middlecoin. The easiest way is to fork the project on [github](http://github.com/hammackj/middlecoin) and make the changes in your fork and the submit a pull request to the project.
16
+
17
+ If you would like to contribute bug fixes/etc to the project. The easiest way is to fork the project on [github](http://github.com/hammackj/middlecoin) and make the changes in your fork and the submit a pull request to the project.
15
18
 
16
19
  # Issues
20
+
17
21
  If you have any problems, bugs or feature requests please use the [github issue tracker](http://github.com/hammackj/middlecoin/issues).
18
22
 
23
+ # Donations / tips
24
+ Feel free to donate or tip to BTC: 1Cfd5G6rJmSBrNcTHxEgE4uYgH7XZJPY7Z
25
+
19
26
  # Contact
20
27
  You can reach me at jacob[.]hammack[@]hammackj[.]com.
21
28
 
@@ -21,13 +21,14 @@
21
21
 
22
22
  module Middlecoin
23
23
  APP_NAME = "middlecoin"
24
- VERSION = "0.0.0"
24
+ VERSION = "0.0.1"
25
25
  GITHUB = "http://github.com/hammackj/middlecoin"
26
26
  EMAIL = "jacob.hammack@hammackj.com"
27
27
  MIDDLECOIN_URL = "http://middlecoin.com"
28
28
 
29
29
  class Error < StandardError; end
30
30
  class InvalidBitcoinAddressError < Error; end
31
+ class MiddlecoinAPIError < Error; end
31
32
  end
32
33
 
33
34
  require 'json'
@@ -84,16 +84,19 @@ module Middlecoin
84
84
  next
85
85
  end
86
86
 
87
- puts "\tAddress: #{result[:address]}"
88
- puts "\tMHs: #{result[:megahashesPerSecond]}"
89
- puts "\tRejected MHs: #{result[:rejectedMegahashesPerSecond]}"
90
- puts "\tLast hour shares: #{result[:lastHourShares]}"
91
- puts "\tLast hour rejected shares: #{result[:lastHourRejectedShares]}"
92
- puts "\tImmature Balance: #{result[:immatureBalance]}"
93
- puts "\tUnexchanged Balance: #{result[:unexchangedBalance]}"
94
- puts "\tBitcoin Balance: #{result[:bitcoinBalance]}"
95
- puts "\tTotal paid out: #{result[:paidOut]}"
96
- puts "\n"
87
+ puts "Address: #{result[:address]}"
88
+ puts "Megahash/s: #{result[:megahashesPerSecond]}"
89
+ puts "Rejected MHs: #{result[:rejectedMegahashesPerSecond]}"
90
+ puts "Last hour shares: #{result[:lastHourShares]}"
91
+ puts "Last hour rejected shares: #{result[:lastHourRejectedShares]}"
92
+ puts "Immature Balance: #{result[:immatureBalance]}"
93
+ puts "Unexchanged Balance: #{result[:unexchangedBalance]}"
94
+ puts "Bitcoin Balance: #{result[:bitcoinBalance]}"
95
+ puts "Total paid out: #{result[:paidOut]}\n"
96
+
97
+ rescue Middlecoin::MiddlecoinAPIError => a
98
+ puts "[!] Error: #{i.message}"
99
+ break
97
100
  rescue Middlecoin::InvalidBitcoinAddressError => i
98
101
  puts "[!] Error: #{i.message}"
99
102
  next
@@ -25,4 +25,4 @@ module Middlecoin
25
25
  end
26
26
 
27
27
  require 'middlecoin/core/bitcoinaddress'
28
- require 'middlecoin/core/middlecoinapi'
28
+ require 'middlecoin/core/middlecoinapi'
@@ -25,6 +25,7 @@ module Middlecoin
25
25
  # Bitcoin Address
26
26
  class BitcoinAddress
27
27
 
28
+ # Does some simple validation of a BTC address to make sure its sane
28
29
  def self.validate address
29
30
  if address[0] != "1" && address[0] != "3"
30
31
  raise Middlecoin::InvalidBitcoinAddressError, "Bitcoin addresses must start with 1 or 3"
@@ -30,6 +30,7 @@ module Middlecoin
30
30
  class MiddlecoinAPI
31
31
  attr_accessor :report
32
32
 
33
+ # Simple function for following redirects, found it on stackexchange
33
34
  def fetch(uri_str, limit = 10)
34
35
  raise ArgumentError, 'HTTP redirect too deep' if limit == 0
35
36
 
@@ -50,11 +51,18 @@ module Middlecoin
50
51
  end
51
52
  end
52
53
 
54
+ # Downloads and caches the report JSON from middlecoin.com
53
55
  def fetch_report
54
- report = fetch("#{Middlecoin::MIDDLECOIN_URL}/json")
55
- @report = JSON.parse(report.body)["report"]
56
+ begin
57
+ report = fetch("#{Middlecoin::MIDDLECOIN_URL}/json")
58
+ @report = JSON.parse(report.body)["report"]
59
+ rescue => e
60
+ raise Middlecoin::MiddlecoinAPIError, "Unable to collect JSON report from middlecoin.com"
61
+ end
56
62
  end
57
63
 
64
+ # Looks up a specific btc address in the JSON report from
65
+ # middlecoin.com
58
66
  def lookup btc_address
59
67
  @report.each do |address|
60
68
  if address[0].eql?(btc_address)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middlecoin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Hammack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-11 00:00:00.000000000 Z
11
+ date: 2014-01-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: middlecoin is a parser/status checker for middlecoin.com
14
14
  email: jacob.hammack@hammackj.com