waffle_api 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +20 -0
- data/.travis.yml +6 -0
- data/Gemfile +2 -0
- data/README.md +2 -2
- data/Rakefile +7 -0
- data/lib/waffle_api/version.rb +1 -1
- data/spec/lib/waffle_api/client_spec.rb +43 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/fixtures/error.json +3 -0
- data/spec/support/fixtures/not_found.json +3 -0
- data/spec/support/fixtures/success.json +78 -0
- data/spec/support/wafflepool.rb +44 -0
- data/waffle_api.gemspec +12 -2
- metadata +92 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2b30166123afd1f59e7585120211af5da274c6e
|
4
|
+
data.tar.gz: 7a3acecf444ba8910aba86c014e9b77cd7fe618f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 536e904fbdd7d7d3b53cfd9be00dbcc6dfd525441774711874f9c9d82a07dd6936332cd66fb4ec077ce9880a1e7b37b48e469948c4d0b6e57ca230439a01d018
|
7
|
+
data.tar.gz: b9cf8fd05960c7b087870c8602f5259e31586419159c4505207765dbd7f714dc40a312e3f0e53739fcfe83cdf8cf891741bbd52102bc1fecb71ab74c75cffafa
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
CHANGED
@@ -9,7 +9,7 @@ _Waffle pool API gem_
|
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
12
|
-
### Ruby
|
12
|
+
### Ruby 2+
|
13
13
|
|
14
14
|
```ruby
|
15
15
|
gem install waffle_api
|
@@ -109,7 +109,7 @@ Will return a JSON array containing the last 10 payments
|
|
109
109
|
|
110
110
|
Released under the MIT License. See the [LICENSE](https://github.com/Calyhre/waffle_api/blob/master/LICENSE.md) file for further details.
|
111
111
|
|
112
|
-
[travis_img]: https://travis-ci.org/Calyhre/waffle_api.
|
112
|
+
[travis_img]: https://travis-ci.org/Calyhre/waffle_api.svg?branch=master
|
113
113
|
[travis_url]: https://travis-ci.org/Calyhre/waffle_api
|
114
114
|
[fury_img]: https://badge.fury.io/rb/waffle_api.png
|
115
115
|
[fury_url]: http://badge.fury.io/rb/waffle_api
|
data/Rakefile
ADDED
data/lib/waffle_api/version.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WaffleAPI::Client do
|
4
|
+
describe 'without address' do
|
5
|
+
it 'raises an WaffleAPI::Error::EmptyAddress' do
|
6
|
+
expect do
|
7
|
+
WaffleAPI::Client.new
|
8
|
+
end.to raise_error(WaffleAPI::Error::EmptyAddress)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'with a bad address' do
|
13
|
+
it 'raises an WaffleAPI::Error::BadAddress' do
|
14
|
+
expect do
|
15
|
+
WaffleAPI::Client.new address: 'some_bad_address'
|
16
|
+
end.to raise_error(WaffleAPI::Error::BadAddress)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'with a valid address' do
|
21
|
+
subject do
|
22
|
+
WaffleAPI::Client.new address: '1Ju8U9Ukfc5kiMqzQrRgQBP1JvRkeSv94V'
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'asking for a non existing key' do
|
26
|
+
it 'raises an NoMethodError' do
|
27
|
+
stub_waffle Wafflepool::Success
|
28
|
+
|
29
|
+
expect do
|
30
|
+
subject.i_hope_this_key_will_never_exist
|
31
|
+
end.to raise_error(NoMethodError)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'asking for an existing key' do
|
36
|
+
it 'just return it' do
|
37
|
+
stub_waffle Wafflepool::Success
|
38
|
+
|
39
|
+
expect(subject.hashrate).to eq 4_303_407
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
|
+
|
4
|
+
require 'webmock/rspec'
|
5
|
+
require 'waffle_api'
|
6
|
+
|
7
|
+
Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each { |f| require f }
|
8
|
+
|
9
|
+
WebMock.disable_net_connect! allow_localhost: true
|
10
|
+
|
11
|
+
URL = 'http://wafflepool.com/tmp_api?address=1Ju8U9Ukfc5kiMqzQrRgQBP1JvRkeSv94V'
|
12
|
+
|
13
|
+
def stub_waffle(response_class)
|
14
|
+
stub_request(:any, URL).to_rack(response_class)
|
15
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
{
|
2
|
+
"hash_rate": 4303407,
|
3
|
+
"hash_rate_str": "4.30 MH\/s",
|
4
|
+
"worker_hashrates": [
|
5
|
+
{
|
6
|
+
"username": "1Ju8U9Ukfc5kiMqzQrRgQBP1JvRkeSv94V_calyhrerig1",
|
7
|
+
"hashrate": 2529705,
|
8
|
+
"stalerate": 3.33,
|
9
|
+
"last_seen": 1398022030,
|
10
|
+
"str": "2.53 MH\/s"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"username": "1Ju8U9Ukfc5kiMqzQrRgQBP1JvRkeSv94V_dqmsrig1",
|
14
|
+
"hashrate": 1773702,
|
15
|
+
"stalerate": 1.61,
|
16
|
+
"last_seen": 1398022030,
|
17
|
+
"str": "1.77 MH\/s"
|
18
|
+
}
|
19
|
+
],
|
20
|
+
"balances": {
|
21
|
+
"sent": 1.61039009,
|
22
|
+
"confirmed": 0.00383488,
|
23
|
+
"unconverted": 0.011964213459441
|
24
|
+
},
|
25
|
+
"recent_payments": [
|
26
|
+
{
|
27
|
+
"amount": "0.01715311",
|
28
|
+
"time": "2014-04-20 16:03:24",
|
29
|
+
"txn": "8706e0a86042619c17fab11fc83c8ceb815bcbcf53a67863e60749050fb27660"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"amount": "0.01600557",
|
33
|
+
"time": "2014-04-20 04:36:01",
|
34
|
+
"txn": "258dda8330009d63aa78fef73cd9e079ece1f35ca7bd4d1f6426dba454a7dde1"
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"amount": "0.03763282",
|
38
|
+
"time": "2014-04-19 16:07:02",
|
39
|
+
"txn": "3502be9939ab4b5e3478cded19b20946aa73af14b29e3697e8a321b82571e604"
|
40
|
+
},
|
41
|
+
{
|
42
|
+
"amount": "0.02660132",
|
43
|
+
"time": "2014-04-18 14:50:11",
|
44
|
+
"txn": "6cb1e2712945c859ff35d29cfe7171c96ef291fbcc22f3c2923903448eea588d"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"amount": "0.01660785",
|
48
|
+
"time": "2014-04-17 15:12:19",
|
49
|
+
"txn": "98b8f2c0b8bcb37c1d0bb22699460d332e6afdf6b73ae43fb5944d8ae16e87bc"
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"amount": "0.02099343",
|
53
|
+
"time": "2014-04-16 19:59:53",
|
54
|
+
"txn": "bab1cd49c6b3e737a4c251e494bc65e524a85142f52c6e35051b1f13696527e6"
|
55
|
+
},
|
56
|
+
{
|
57
|
+
"amount": "0.02189502",
|
58
|
+
"time": "2014-04-15 20:40:48",
|
59
|
+
"txn": "8c89c55a9a3b5dc7c12cb0cad8aada7658d83fe8b3ba9a5d33f858f74afcfd03"
|
60
|
+
},
|
61
|
+
{
|
62
|
+
"amount": "0.02050877",
|
63
|
+
"time": "2014-04-14 19:19:21",
|
64
|
+
"txn": "35cbe9646810e59cd1747f380c019a6e43521c77e2f0537077be22877873dc12"
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"amount": "0.01705158",
|
68
|
+
"time": "2014-04-13 15:19:52",
|
69
|
+
"txn": "63738d931504bca8aca6db6198ada4f3a96586ed2263866de38611edc4f462c6"
|
70
|
+
},
|
71
|
+
{
|
72
|
+
"amount": "0.01287918",
|
73
|
+
"time": "2014-04-12 15:50:52",
|
74
|
+
"txn": "78747c8cf856439b6d8d2ccb4595ab773ce0b1673c344bfb97a9dd0d2795ad50"
|
75
|
+
}
|
76
|
+
],
|
77
|
+
"error": ""
|
78
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
|
3
|
+
# Stub WafflePool reponses
|
4
|
+
module Wafflepool
|
5
|
+
# Provide json_reponse for all inherited class
|
6
|
+
class Base < Sinatra::Base
|
7
|
+
protected
|
8
|
+
|
9
|
+
def json_response(response_code, file_name)
|
10
|
+
content_type :json
|
11
|
+
status response_code
|
12
|
+
File.open(File.dirname(__FILE__) + '/fixtures/' + file_name, 'rb').read
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# Stub success response from WafflePool
|
17
|
+
class Success < Base
|
18
|
+
get '/tmp_api' do
|
19
|
+
json_response 200, 'success.json'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Stub unknown error response from WafflePool
|
24
|
+
class UnknownError < Base
|
25
|
+
get '/tmp_api' do
|
26
|
+
json_response 200, 'error.json'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Stub address not found response from WafflePool
|
31
|
+
class AddressNotFound < Base
|
32
|
+
get '/tmp_api' do
|
33
|
+
json_response 200, 'not_found.json'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Stub api endpoint moved
|
38
|
+
class EndPointMoved < Base
|
39
|
+
get '/tmp_api' do
|
40
|
+
status 404
|
41
|
+
body nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/waffle_api.gemspec
CHANGED
@@ -7,8 +7,18 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.description = s.summary
|
8
8
|
s.authors = ['Calyhre']
|
9
9
|
s.email = ['contact@calyh.re']
|
10
|
-
s.files = `git ls-files`.split("\n")
|
11
10
|
s.require_path = 'lib'
|
12
|
-
s.homepage = 'http://
|
11
|
+
s.homepage = 'http://github.com/Calyhre/waffle_api'
|
13
12
|
s.license = 'MIT'
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
|
17
|
+
s.required_ruby_version = '>= 2.0.0'
|
18
|
+
|
19
|
+
s.add_development_dependency 'rake'
|
20
|
+
s.add_development_dependency 'rspec'
|
21
|
+
s.add_development_dependency 'sinatra'
|
22
|
+
s.add_development_dependency 'webmock'
|
23
|
+
s.add_development_dependency 'coveralls'
|
14
24
|
end
|
metadata
CHANGED
@@ -1,15 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waffle_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Calyhre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
12
|
-
dependencies:
|
11
|
+
date: 2014-04-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sinatra
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
13
83
|
description: Waffle pool API gem
|
14
84
|
email:
|
15
85
|
- contact@calyh.re
|
@@ -17,17 +87,27 @@ executables: []
|
|
17
87
|
extensions: []
|
18
88
|
extra_rdoc_files: []
|
19
89
|
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
20
92
|
- CONTRIBUTING.md
|
93
|
+
- Gemfile
|
21
94
|
- LICENSE.md
|
22
95
|
- README.md
|
96
|
+
- Rakefile
|
23
97
|
- lib/waffle_api.rb
|
24
98
|
- lib/waffle_api/address_validator.rb
|
25
99
|
- lib/waffle_api/client.rb
|
26
100
|
- lib/waffle_api/errors.rb
|
27
101
|
- lib/waffle_api/helpers.rb
|
28
102
|
- lib/waffle_api/version.rb
|
103
|
+
- spec/lib/waffle_api/client_spec.rb
|
104
|
+
- spec/spec_helper.rb
|
105
|
+
- spec/support/fixtures/error.json
|
106
|
+
- spec/support/fixtures/not_found.json
|
107
|
+
- spec/support/fixtures/success.json
|
108
|
+
- spec/support/wafflepool.rb
|
29
109
|
- waffle_api.gemspec
|
30
|
-
homepage: http://
|
110
|
+
homepage: http://github.com/Calyhre/waffle_api
|
31
111
|
licenses:
|
32
112
|
- MIT
|
33
113
|
metadata: {}
|
@@ -39,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
39
119
|
requirements:
|
40
120
|
- - ">="
|
41
121
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
122
|
+
version: 2.0.0
|
43
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
124
|
requirements:
|
45
125
|
- - ">="
|
@@ -51,4 +131,10 @@ rubygems_version: 2.2.0
|
|
51
131
|
signing_key:
|
52
132
|
specification_version: 4
|
53
133
|
summary: Waffle pool API gem
|
54
|
-
test_files:
|
134
|
+
test_files:
|
135
|
+
- spec/lib/waffle_api/client_spec.rb
|
136
|
+
- spec/spec_helper.rb
|
137
|
+
- spec/support/fixtures/error.json
|
138
|
+
- spec/support/fixtures/not_found.json
|
139
|
+
- spec/support/fixtures/success.json
|
140
|
+
- spec/support/wafflepool.rb
|