doge_papi 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/doge/api.rb +46 -0
- data/lib/doge/chain.rb +33 -0
- data/lib/doge_papi.rb +6 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: ae56e771f8060634b5f6a994006ef8b6c84b2c71
|
4
|
+
data.tar.gz: 6d124d02e6921b232a7897aedb482ea86ad777a4
|
5
|
+
!binary "U0hBNTEy":
|
6
|
+
metadata.gz: 1844d6eda5b3d2d1eec102bb4dd363d6378ef7349191cf8c5df62375cd7a19c7e328b20471e687dd524a06dfed629c5a36bf2f8caf52cbd5636b9e6e69143351
|
7
|
+
data.tar.gz: 67980ecc8535e6ae1eda436f32f263432af3737009f9dc9c25d55878eee5d96e4471427782f885296e83688569c51099d775eb4fcdc7b5f76797823e4e65770b
|
data/lib/doge/api.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
module DogePapi
|
2
|
+
class DogeApi
|
3
|
+
attr_accessor :api_key
|
4
|
+
|
5
|
+
BASE_URI = URI.parse 'https://www.dogeapi.com/wow'
|
6
|
+
|
7
|
+
CALLS_RETURNING_INTEGER = [:get_current_block]
|
8
|
+
CALLS_RETURNING_FLOAT = [
|
9
|
+
:get_balance ,
|
10
|
+
:get_address_received ,
|
11
|
+
:get_difficulty ,
|
12
|
+
:get_current_price
|
13
|
+
]
|
14
|
+
CALLS_RETURNING_JSON = [:get_my_addresses]
|
15
|
+
|
16
|
+
def initialize api_key
|
17
|
+
@api_key = api_key
|
18
|
+
end
|
19
|
+
|
20
|
+
def build_uri m, args
|
21
|
+
uri = @base_uri
|
22
|
+
params = args.merge a: m, api_key: @api_key
|
23
|
+
uri.query = URI.encode_www_form params
|
24
|
+
uri
|
25
|
+
end
|
26
|
+
|
27
|
+
def fetch_uri uri
|
28
|
+
uri.open.read
|
29
|
+
end
|
30
|
+
|
31
|
+
def method_missing m, args = {}, &block
|
32
|
+
output = fetch_uri build_uri(m, args)
|
33
|
+
if CALLS_RETURNING_JSON.include? m
|
34
|
+
output = JSON.parse output
|
35
|
+
else
|
36
|
+
# Doge API wraps everything in double quotes,
|
37
|
+
# so we need to get rid of them first.
|
38
|
+
#
|
39
|
+
output.tr! '"', ''
|
40
|
+
output = output.to_i if CALLS_RETURNING_INTEGER.include? m
|
41
|
+
output = output.to_f if CALLS_RETURNING_FLOAT.include? m
|
42
|
+
end
|
43
|
+
output
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/doge/chain.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module DogePapi
|
2
|
+
class DogeChain
|
3
|
+
|
4
|
+
BASE_URI = 'http://dogechain.info/chain/Dogecoin/q'
|
5
|
+
|
6
|
+
CALLS_RETURNING_INTEGER = [:getblockcount]
|
7
|
+
CALLS_RETURNING_FLOAT = [
|
8
|
+
:addressbalance ,
|
9
|
+
:getdifficulty ,
|
10
|
+
:getreceivedbyaddress ,
|
11
|
+
:getsentbyaddress ,
|
12
|
+
:totalbc
|
13
|
+
]
|
14
|
+
CALLS_RETURNING_JSON = [:transactions]
|
15
|
+
|
16
|
+
def build_uri m, params
|
17
|
+
list = params.join '/'
|
18
|
+
URI.parse "#{BASE_URI}/#{m}/#{list}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def fetch_uri uri
|
22
|
+
uri.open.read
|
23
|
+
end
|
24
|
+
|
25
|
+
def method_missing m, *args, &block
|
26
|
+
output = fetch_uri build_uri(m, args)
|
27
|
+
output = output.to_i if CALLS_RETURNING_INTEGER.include? m
|
28
|
+
output = output.to_f if CALLS_RETURNING_FLOAT.include? m
|
29
|
+
output = JSON.parse(output) if CALLS_RETURNING_JSON.include? m
|
30
|
+
output
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/doge_papi.rb
ADDED
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: doge_papi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Maxwell Bernstein
|
8
|
+
- Mariusz Pruszynski
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-02-02 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description:
|
15
|
+
email: mpruszynski@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/doge_papi.rb
|
21
|
+
- lib/doge/api.rb
|
22
|
+
- lib/doge/chain.rb
|
23
|
+
homepage: http://github.com/snicky/doge_papi
|
24
|
+
licenses:
|
25
|
+
- MIT
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 2.0.3
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: Ruby wrapper for DogeAPI.com and DogeChain.info
|
47
|
+
test_files: []
|