bitreserve 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +31 -0
- data/LICENSE.txt +1 -1
- data/Rakefile +14 -1
- data/bitreserve.gemspec +13 -8
- data/lib/bitreserve.rb +20 -2
- data/lib/bitreserve/endpoints.rb +5 -0
- data/lib/bitreserve/request.rb +39 -0
- data/lib/bitreserve/ticker.rb +7 -0
- data/lib/bitreserve/version.rb +1 -1
- data/spec/request_spec.rb +37 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/ticker_spec.rb +15 -0
- metadata +68 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee526dc2c85b5a22331440fb4b1f294ac4e9be57
|
4
|
+
data.tar.gz: cc95b745aeeea4a0a72f5f6c0fe75cd44b1a977f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 912336aff96c4d53db4e625d16a6691cadb063523ede174e774c26f63fb36bd89099205181cf2d7f2d152547ba96dcb30d8e29bdb84ca383d10ffbd42fccec28
|
7
|
+
data.tar.gz: 5195b5fce5850ad14487085f41db61219d39a5252189278fc731d9aad6cf19a10d113a3375e061ff1ce8b9aaa4be591a663f5142fe88f821d32f004a8145c3c9
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
AllCops:
|
2
|
+
Include:
|
3
|
+
- '**/Rakefile'
|
4
|
+
- '**/config.ru'
|
5
|
+
Exclude:
|
6
|
+
- 'db/**/*'
|
7
|
+
- 'config/**/*'
|
8
|
+
- 'script/**/*'
|
9
|
+
- 'bin/**/*'
|
10
|
+
- 'vendor/**/*'
|
11
|
+
|
12
|
+
Metrics/LineLength:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Style/AlignParameters:
|
16
|
+
EnforcedStyle: with_fixed_indentation
|
17
|
+
|
18
|
+
Style/ClassAndModuleChildren:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Style/Documentation:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/DotPosition:
|
25
|
+
EnforcedStyle: trailing
|
26
|
+
|
27
|
+
Style/IfUnlessModifier:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Style/RegexpLiteral:
|
31
|
+
MaxSlashes: 0
|
data/LICENSE.txt
CHANGED
data/Rakefile
CHANGED
@@ -1,2 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rubocop/rake_task'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
RuboCop::RakeTask.new
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
2
6
|
|
7
|
+
task :console do
|
8
|
+
require 'irb'
|
9
|
+
require 'irb/completion'
|
10
|
+
require 'bitreserve'
|
11
|
+
ARGV.clear
|
12
|
+
IRB.start
|
13
|
+
end
|
14
|
+
|
15
|
+
task default: [:rubocop, :spec]
|
data/bitreserve.gemspec
CHANGED
@@ -4,19 +4,24 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'bitreserve/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'bitreserve'
|
8
8
|
spec.version = Bitreserve::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Group Buddies']
|
10
|
+
spec.email = ['zamith@groupbuddies.com', 'mpalhas@groupbuddies.com']
|
11
11
|
spec.summary = %q{A wrapper for the bitreserve API}
|
12
|
-
spec.homepage =
|
13
|
-
spec.license =
|
12
|
+
spec.homepage = 'https://github.com/groupbuddies/bitreserve'
|
13
|
+
spec.license = 'MIT'
|
14
14
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0")
|
16
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
-
spec.require_paths = [
|
18
|
+
spec.require_paths = ['lib']
|
19
19
|
|
20
|
-
spec.
|
21
|
-
|
20
|
+
spec.add_dependency 'httparty', '>= 0.13.3'
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rubocop', '~> 0.27.1'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.1.0'
|
26
|
+
spec.add_development_dependency 'webmock', '~> 1.20.4'
|
22
27
|
end
|
data/lib/bitreserve.rb
CHANGED
@@ -1,5 +1,23 @@
|
|
1
|
-
require
|
1
|
+
require 'net/https'
|
2
|
+
require 'logger'
|
3
|
+
require 'httparty'
|
4
|
+
|
5
|
+
require 'bitreserve/version'
|
6
|
+
require 'bitreserve/endpoints'
|
2
7
|
|
3
8
|
module Bitreserve
|
4
|
-
|
9
|
+
API_BASE = 'api.bitreserve.org'
|
10
|
+
ROOT_PATH = File.dirname(__FILE__)
|
11
|
+
|
12
|
+
@api_base = API_BASE
|
13
|
+
@api_port = Net::HTTP.https_default_port
|
14
|
+
@api_version = 0
|
15
|
+
@logger = Logger.new(STDOUT)
|
16
|
+
|
17
|
+
class << self
|
18
|
+
attr_accessor :api_base, :api_port, :api_version, :logger
|
19
|
+
end
|
5
20
|
end
|
21
|
+
|
22
|
+
require 'bitreserve/request'
|
23
|
+
require 'bitreserve/ticker'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Bitreserve
|
2
|
+
class Request
|
3
|
+
include ::HTTParty
|
4
|
+
base_uri "#{Bitreserve.api_base}/v#{Bitreserve.api_version}"
|
5
|
+
|
6
|
+
def self.perform(http_method, path, options = {})
|
7
|
+
new(path, options).public_send(http_method)
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(path, options)
|
11
|
+
@path = path
|
12
|
+
@options = options
|
13
|
+
end
|
14
|
+
|
15
|
+
def get
|
16
|
+
response = Request.get(path, options)
|
17
|
+
log_request_info(:get, response)
|
18
|
+
response.parsed_response
|
19
|
+
end
|
20
|
+
|
21
|
+
def post
|
22
|
+
response = Request.post(path, options)
|
23
|
+
log_request_info(:post, response)
|
24
|
+
response.parsed_response
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_reader :path, :options
|
30
|
+
|
31
|
+
def log_request_info(http_method, response)
|
32
|
+
Bitreserve.logger.info "[Bitreserve] [#{current_time}] #{http_method.to_s.upcase} #{Request.base_uri}#{path} #{options} #{response.code}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def current_time
|
36
|
+
Time.now.utc.strftime('%d/%b/%Y %H:%M:%S %Z')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/bitreserve/version.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'webmock/rspec'
|
3
|
+
WebMock.disable_net_connect!
|
4
|
+
|
5
|
+
module Bitreserve
|
6
|
+
describe Request do
|
7
|
+
let(:request) { spy('request') }
|
8
|
+
|
9
|
+
context '.perform' do
|
10
|
+
it 'makes the correct call for a GET' do
|
11
|
+
allow(Request).to receive(:new).and_return(request)
|
12
|
+
|
13
|
+
Request.perform(:get, '/some-url')
|
14
|
+
|
15
|
+
expect(request).to have_received(:get)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'makes the correct call for a POST' do
|
19
|
+
allow(Request).to receive(:new).and_return(request)
|
20
|
+
|
21
|
+
Request.perform(:post, '/some-url')
|
22
|
+
|
23
|
+
expect(request).to have_received(:post)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'makes the actual call' do
|
27
|
+
url = '/some-url'
|
28
|
+
stub_request(:get, Request.base_uri + url)
|
29
|
+
allow(Request).to receive(:get).and_call_original
|
30
|
+
|
31
|
+
Request.perform(:get, url)
|
32
|
+
|
33
|
+
expect(Request).to have_received(:get).with(url, {})
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/spec/ticker_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Bitreserve
|
4
|
+
describe Ticker do
|
5
|
+
context '.all' do
|
6
|
+
it 'gets all the tickers' do
|
7
|
+
allow(Request).to receive(:perform)
|
8
|
+
|
9
|
+
Ticker.all
|
10
|
+
|
11
|
+
expect(Request).to have_received(:perform).with(:get, Endpoints::TICKER)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitreserve
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Group Buddies
|
@@ -10,6 +10,20 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2015-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.13.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.13.3
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +52,48 @@ dependencies:
|
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.27.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.27.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.1.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.1.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.20.4
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.20.4
|
41
97
|
description:
|
42
98
|
email:
|
43
99
|
- zamith@groupbuddies.com
|
@@ -47,13 +103,20 @@ extensions: []
|
|
47
103
|
extra_rdoc_files: []
|
48
104
|
files:
|
49
105
|
- ".gitignore"
|
106
|
+
- ".rubocop.yml"
|
50
107
|
- Gemfile
|
51
108
|
- LICENSE.txt
|
52
109
|
- README.md
|
53
110
|
- Rakefile
|
54
111
|
- bitreserve.gemspec
|
55
112
|
- lib/bitreserve.rb
|
113
|
+
- lib/bitreserve/endpoints.rb
|
114
|
+
- lib/bitreserve/request.rb
|
115
|
+
- lib/bitreserve/ticker.rb
|
56
116
|
- lib/bitreserve/version.rb
|
117
|
+
- spec/request_spec.rb
|
118
|
+
- spec/spec_helper.rb
|
119
|
+
- spec/ticker_spec.rb
|
57
120
|
homepage: https://github.com/groupbuddies/bitreserve
|
58
121
|
licenses:
|
59
122
|
- MIT
|
@@ -78,4 +141,7 @@ rubygems_version: 2.2.2
|
|
78
141
|
signing_key:
|
79
142
|
specification_version: 4
|
80
143
|
summary: A wrapper for the bitreserve API
|
81
|
-
test_files:
|
144
|
+
test_files:
|
145
|
+
- spec/request_spec.rb
|
146
|
+
- spec/spec_helper.rb
|
147
|
+
- spec/ticker_spec.rb
|