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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d38d98cbc8130f0f85ce0b4602250e7c3b8734bc
4
- data.tar.gz: 583f017fcef10da6eb67e0dc326820c349443b0d
3
+ metadata.gz: ee526dc2c85b5a22331440fb4b1f294ac4e9be57
4
+ data.tar.gz: cc95b745aeeea4a0a72f5f6c0fe75cd44b1a977f
5
5
  SHA512:
6
- metadata.gz: 9cbd3fefa0a64ca5a235cb1663639953be8a32320fc52a1195ee6e295823d6c19b14a875982fa3e5a2149d88390f37ef91d149faea520b2f0740ce271c7ae5fa
7
- data.tar.gz: 0c9e8ea04d4164770749206553c6757aaad6cfec98410a2c5a9698a676e7824ba518ee2ffcf0a4e578146ee1b473d40ddd369ac5938063b3b66b1afdcc266c05
6
+ metadata.gz: 912336aff96c4d53db4e625d16a6691cadb063523ede174e774c26f63fb36bd89099205181cf2d7f2d152547ba96dcb30d8e29bdb84ca383d10ffbd42fccec28
7
+ data.tar.gz: 5195b5fce5850ad14487085f41db61219d39a5252189278fc731d9aad6cf19a10d113a3375e061ff1ce8b9aaa4be591a663f5142fe88f821d32f004a8145c3c9
@@ -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
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015 Zamith
1
+ Copyright (c) 2015 Group Buddies
2
2
 
3
3
  MIT License
4
4
 
data/Rakefile CHANGED
@@ -1,2 +1,15 @@
1
- require "bundler/gem_tasks"
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]
@@ -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 = "bitreserve"
7
+ spec.name = 'bitreserve'
8
8
  spec.version = Bitreserve::VERSION
9
- spec.authors = ["Group Buddies"]
10
- spec.email = ["zamith@groupbuddies.com", "mpalhas@groupbuddies.com"]
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 = "https://github.com/groupbuddies/bitreserve"
13
- spec.license = "MIT"
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 = ["lib"]
18
+ spec.require_paths = ['lib']
19
19
 
20
- spec.add_development_dependency "bundler", "~> 1.7"
21
- spec.add_development_dependency "rake", "~> 10.0"
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
@@ -1,5 +1,23 @@
1
- require "bitreserve/version"
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
- # Your code goes here...
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,5 @@
1
+ module Bitreserve
2
+ module Endpoints
3
+ TICKER = '/ticker'
4
+ end
5
+ end
@@ -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
@@ -0,0 +1,7 @@
1
+ module Bitreserve
2
+ class Ticker
3
+ def self.all
4
+ Request.perform(:get, Endpoints::TICKER)
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module Bitreserve
2
- VERSION = "0.0.2"
2
+ VERSION = '0.0.3'
3
3
  end
@@ -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
@@ -0,0 +1,8 @@
1
+ require 'bitreserve'
2
+
3
+ Dir[File.join(Bitreserve::ROOT_PATH, 'spec/support/**/*.rb')].each { |f| require f }
4
+
5
+ class DummyLogger
6
+ def self.info(_message); end
7
+ end
8
+ Bitreserve.logger = DummyLogger
@@ -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.2
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