bitstamp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.rspec +2 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +52 -0
- data/LICENSE.txt +20 -0
- data/README.md +58 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/bitstamp.gemspec +74 -0
- data/lib/bitstamp.rb +48 -0
- data/lib/bitstamp/collection.rb +44 -0
- data/lib/bitstamp/model.rb +27 -0
- data/lib/bitstamp/net.rb +55 -0
- data/lib/bitstamp/orders.rb +30 -0
- data/spec/bitstamp_spec.rb +27 -0
- data/spec/collection_spec.rb +24 -0
- data/spec/orders_spec.rb +19 -0
- data/spec/spec_helper.rb +41 -0
- metadata +179 -0
data/.rspec
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
ruby '1.9.3'
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
# Add dependencies required to use your gem here.
|
5
|
+
# Example:
|
6
|
+
# gem "activesupport", ">= 2.3.5"
|
7
|
+
gem "activemodel", ">= 3.1"
|
8
|
+
gem "activesupport", ">= 3.1"
|
9
|
+
|
10
|
+
gem 'curb', '> 0.8.1'
|
11
|
+
|
12
|
+
|
13
|
+
# Add dependencies to develop your gem here.
|
14
|
+
# Include everything needed to run rake, tests, features, etc.
|
15
|
+
group :development do
|
16
|
+
gem "rspec", ">= 0"
|
17
|
+
gem "rdoc", "~> 3.12"
|
18
|
+
gem "bundler", "~> 1.3.5"
|
19
|
+
gem "jeweler", "~> 1.8.4"
|
20
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activemodel (4.0.0.beta1)
|
5
|
+
activesupport (= 4.0.0.beta1)
|
6
|
+
builder (~> 3.1.0)
|
7
|
+
activesupport (4.0.0.beta1)
|
8
|
+
i18n (~> 0.6.2)
|
9
|
+
minitest (~> 4.2)
|
10
|
+
multi_json (~> 1.3)
|
11
|
+
thread_safe (~> 0.1)
|
12
|
+
tzinfo (~> 0.3.33)
|
13
|
+
atomic (1.1.7)
|
14
|
+
builder (3.1.4)
|
15
|
+
curb (0.8.3)
|
16
|
+
diff-lcs (1.2.4)
|
17
|
+
git (1.2.5)
|
18
|
+
i18n (0.6.4)
|
19
|
+
jeweler (1.8.4)
|
20
|
+
bundler (~> 1.0)
|
21
|
+
git (>= 1.2.5)
|
22
|
+
rake
|
23
|
+
rdoc
|
24
|
+
json (1.7.7)
|
25
|
+
minitest (4.7.1)
|
26
|
+
multi_json (1.7.2)
|
27
|
+
rake (10.0.4)
|
28
|
+
rdoc (3.12.2)
|
29
|
+
json (~> 1.4)
|
30
|
+
rspec (2.13.0)
|
31
|
+
rspec-core (~> 2.13.0)
|
32
|
+
rspec-expectations (~> 2.13.0)
|
33
|
+
rspec-mocks (~> 2.13.0)
|
34
|
+
rspec-core (2.13.1)
|
35
|
+
rspec-expectations (2.13.0)
|
36
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
37
|
+
rspec-mocks (2.13.1)
|
38
|
+
thread_safe (0.1.0)
|
39
|
+
atomic
|
40
|
+
tzinfo (0.3.37)
|
41
|
+
|
42
|
+
PLATFORMS
|
43
|
+
ruby
|
44
|
+
|
45
|
+
DEPENDENCIES
|
46
|
+
activemodel (>= 3.1)
|
47
|
+
activesupport (>= 3.1)
|
48
|
+
bundler (~> 1.3.5)
|
49
|
+
curb (> 0.8.1)
|
50
|
+
jeweler (~> 1.8.4)
|
51
|
+
rdoc (~> 3.12)
|
52
|
+
rspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Kojn
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Bitstamp Ruby API
|
2
|
+
|
3
|
+
Feel free to fork, modify & redistribute under the MIT license.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'kojn'
|
10
|
+
|
11
|
+
## Setup
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
Bitstamp.setup do |config|
|
15
|
+
config.key = YOUR_BITSTAMP_USERNAME
|
16
|
+
config.secret = YOUR_BITSTAMP_PASSWORD
|
17
|
+
end
|
18
|
+
```
|
19
|
+
|
20
|
+
If you fail to set your `key` or `secret` a `MissingConfigExecption`
|
21
|
+
will be raised.
|
22
|
+
|
23
|
+
## Fetch your open order
|
24
|
+
|
25
|
+
Returns an array with your open orders.
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
Bitstamp.orders.all
|
29
|
+
```
|
30
|
+
|
31
|
+
## Create a sell order
|
32
|
+
|
33
|
+
Returns an `Order` object.
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
Bitstamp.orders.sell(amount: 1.0, price: 111)
|
37
|
+
```
|
38
|
+
|
39
|
+
## Create a buy order
|
40
|
+
|
41
|
+
Returns an `Order` object.
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
Bitstamp.orders.buy(amount: 1.0, price: 111)
|
45
|
+
```
|
46
|
+
|
47
|
+
To be continued!
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
1. Fork it
|
52
|
+
2. Create your feature branch (`git checkout -b
|
53
|
+
my-new-feature`)
|
54
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
55
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
56
|
+
5. Create new Pull Request
|
57
|
+
|
58
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "bitstamp"
|
18
|
+
gem.homepage = "http://github.com/kojnapp/bitstamp"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Bitstamp Ruby API}
|
21
|
+
gem.description = %Q{Ruby API for use with bitstamp.}
|
22
|
+
gem.email = "stygeo@gmail.com"
|
23
|
+
gem.authors = ["Jeffrey Wilcke"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :test
|
36
|
+
|
37
|
+
require 'rdoc/task'
|
38
|
+
Rake::RDocTask.new do |rdoc|
|
39
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
+
|
41
|
+
rdoc.rdoc_dir = 'rdoc'
|
42
|
+
rdoc.title = "bitstamp #{version}"
|
43
|
+
rdoc.rdoc_files.include('README*')
|
44
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bitstamp.gemspec
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "bitstamp"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jeffrey Wilcke"]
|
12
|
+
s.date = "2013-05-16"
|
13
|
+
s.description = "Ruby API for use with bitstamp."
|
14
|
+
s.email = "stygeo@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".rspec",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.md",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"bitstamp.gemspec",
|
28
|
+
"lib/bitstamp.rb",
|
29
|
+
"lib/bitstamp/collection.rb",
|
30
|
+
"lib/bitstamp/model.rb",
|
31
|
+
"lib/bitstamp/net.rb",
|
32
|
+
"lib/bitstamp/orders.rb",
|
33
|
+
"spec/bitstamp_spec.rb",
|
34
|
+
"spec/collection_spec.rb",
|
35
|
+
"spec/orders_spec.rb",
|
36
|
+
"spec/spec_helper.rb"
|
37
|
+
]
|
38
|
+
s.homepage = "http://github.com/kojnapp/bitstamp"
|
39
|
+
s.licenses = ["MIT"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = "1.8.25"
|
42
|
+
s.summary = "Bitstamp Ruby API"
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
s.specification_version = 3
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_runtime_dependency(%q<activemodel>, [">= 3.1"])
|
49
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 3.1"])
|
50
|
+
s.add_runtime_dependency(%q<curb>, ["> 0.8.1"])
|
51
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
53
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.3.5"])
|
54
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<activemodel>, [">= 3.1"])
|
57
|
+
s.add_dependency(%q<activesupport>, [">= 3.1"])
|
58
|
+
s.add_dependency(%q<curb>, ["> 0.8.1"])
|
59
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
60
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
61
|
+
s.add_dependency(%q<bundler>, ["~> 1.3.5"])
|
62
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
63
|
+
end
|
64
|
+
else
|
65
|
+
s.add_dependency(%q<activemodel>, [">= 3.1"])
|
66
|
+
s.add_dependency(%q<activesupport>, [">= 3.1"])
|
67
|
+
s.add_dependency(%q<curb>, ["> 0.8.1"])
|
68
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
69
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
70
|
+
s.add_dependency(%q<bundler>, ["~> 1.3.5"])
|
71
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
data/lib/bitstamp.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'active_support/core_ext'
|
2
|
+
require 'active_support/inflector'
|
3
|
+
require 'active_model'
|
4
|
+
require 'curb'
|
5
|
+
|
6
|
+
require 'bitstamp/net'
|
7
|
+
require 'bitstamp/collection'
|
8
|
+
require 'bitstamp/model'
|
9
|
+
|
10
|
+
require 'bitstamp/orders'
|
11
|
+
|
12
|
+
String.send(:include, ActiveSupport::Inflector)
|
13
|
+
|
14
|
+
module Bitstamp
|
15
|
+
# API Key
|
16
|
+
mattr_accessor :key
|
17
|
+
|
18
|
+
# Bitstamp secret
|
19
|
+
mattr_accessor :secret
|
20
|
+
|
21
|
+
# Currency
|
22
|
+
mattr_accessor :currency
|
23
|
+
@@currency = :usd
|
24
|
+
|
25
|
+
def self.orders
|
26
|
+
self.sanity_check!
|
27
|
+
|
28
|
+
@@orders ||= Bitstamp::Orders.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.balance
|
32
|
+
self.sanity_check!
|
33
|
+
|
34
|
+
JSON.parse Bitstamp::Net.get('/balance').body_str
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.setup
|
38
|
+
yield self
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.sanity_check!
|
42
|
+
unless self.key || self.secret
|
43
|
+
raise MissingConfigExecption.new("Bitstamp Gem not properly configured")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class MissingConfigExecption<Exception;end;
|
48
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Bitstamp
|
2
|
+
class Collection
|
3
|
+
attr_accessor :access_token, :module, :name, :model, :path
|
4
|
+
|
5
|
+
def initialize(api_prefix="/api")
|
6
|
+
self.access_token = Bitstamp.key
|
7
|
+
|
8
|
+
self.module = self.class.to_s.singularize.underscore
|
9
|
+
self.name = self.module.split('/').last
|
10
|
+
self.model = self.module.camelize.constantize
|
11
|
+
self.path = "#{api_prefix}/#{self.name.pluralize}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def all(options = {})
|
15
|
+
parse_objects! Bitstamp::Net::get(self.path).body_str, self.model
|
16
|
+
end
|
17
|
+
|
18
|
+
def create(options = {})
|
19
|
+
parse_object! Bitstamp::Net::post(self.path, options).body_str, self.model
|
20
|
+
end
|
21
|
+
|
22
|
+
def find(id, options = {})
|
23
|
+
parse_object! Bistamp::Net::get("#{self.path}/#{id}").body_str, self.model
|
24
|
+
end
|
25
|
+
|
26
|
+
def update(id, options = {})
|
27
|
+
parse_object! Bitstamp::Net::patch("#{self.path}/#{id}", options).body_str, self.model
|
28
|
+
end
|
29
|
+
|
30
|
+
protected
|
31
|
+
def parse_objects!(string, klass)
|
32
|
+
objects = JSON.parse(string)
|
33
|
+
objects.collect do |t_json|
|
34
|
+
parse_object!(t_json, klass)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def parse_object!(object, klass)
|
39
|
+
object = JSON.parse(object) if object.is_a? String
|
40
|
+
|
41
|
+
klass.new(object)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Bitstamp
|
2
|
+
class Model
|
3
|
+
if ActiveModel::VERSION::MAJOR <= 3
|
4
|
+
include ActiveModel::Validations
|
5
|
+
include ActiveModel::Conversion
|
6
|
+
extend ActiveModel::Naming
|
7
|
+
|
8
|
+
def initialize(attributes = {})
|
9
|
+
self.attributes = attributes
|
10
|
+
end
|
11
|
+
else
|
12
|
+
include ActiveModel::Model
|
13
|
+
end
|
14
|
+
|
15
|
+
# Set the attributes based on the given hash
|
16
|
+
def attributes=(attributes = {})
|
17
|
+
attributes.each do |name, value|
|
18
|
+
send("#{name}=", value)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Returns a hash with the current instance variables
|
23
|
+
def attributes
|
24
|
+
Hash[instance_variables.map { |name| [name, instance_variable_get(name)] }]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/bitstamp/net.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
module Bitstamp
|
2
|
+
module Net
|
3
|
+
def self.to_uri(path)
|
4
|
+
#return "http#{Kojn.ssl ? "s" : ""}://#{Kojn.host}:#{Kojn.port}#{path}"
|
5
|
+
return "https://www.bitstamp.net/api#{path}/"
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.curl(verb, path, options={})
|
9
|
+
verb = verb.upcase.to_sym
|
10
|
+
|
11
|
+
c = Curl::Easy.new(self.to_uri(path))
|
12
|
+
|
13
|
+
options[:user] = Bitstamp.key
|
14
|
+
options[:password] = Bitstamp.secret
|
15
|
+
|
16
|
+
c.post_body = options.to_query
|
17
|
+
|
18
|
+
c.http(verb)
|
19
|
+
|
20
|
+
return c
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.get(path, options={})
|
24
|
+
request = self.curl(:GET, path, options)
|
25
|
+
|
26
|
+
request.perform
|
27
|
+
|
28
|
+
return request
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.post(path, options={})
|
32
|
+
request = self.curl(:POST, path, options)
|
33
|
+
|
34
|
+
request.perform
|
35
|
+
|
36
|
+
return request
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.patch(path, options={})
|
40
|
+
request = self.curl(:PATCH, path, options)
|
41
|
+
|
42
|
+
request.perform
|
43
|
+
|
44
|
+
return request
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.delete(path, options={})
|
48
|
+
request = self.curl(:DELETE, path, options)
|
49
|
+
|
50
|
+
request.perform
|
51
|
+
|
52
|
+
return request
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Bitstamp
|
2
|
+
class Orders < Bitstamp::Collection
|
3
|
+
def all(options = {})
|
4
|
+
parse_objects! Bitstamp::Net::post('/open_orders').body_str, self.model
|
5
|
+
end
|
6
|
+
|
7
|
+
def create(options = {})
|
8
|
+
path = (options[:type] == Bitstamp::Order::SELL ? "/sell" : "/buy")
|
9
|
+
parse_object! Bitstamp::Net::post(path, options).body_str, self.model
|
10
|
+
end
|
11
|
+
|
12
|
+
def sell(options = {})
|
13
|
+
options.merge!({type: Bitstamp::Order::SELL})
|
14
|
+
self.create options
|
15
|
+
end
|
16
|
+
|
17
|
+
def buy(options = {})
|
18
|
+
options.merge!({type: Bitstamp::Order::BUY})
|
19
|
+
self.create options
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Order < Bitstamp::Model
|
24
|
+
BUY = 0
|
25
|
+
SELL = 1
|
26
|
+
|
27
|
+
attr_accessor :type, :amount, :price, :id, :datetime
|
28
|
+
attr_accessor :error, :message
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Bitstamp do
|
4
|
+
|
5
|
+
it 'should raise if not properly configured' do
|
6
|
+
-> { Bitstamp.sanity_check! }.should raise_error
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should not raise if properly configured' do
|
10
|
+
Bitstamp.setup do |config|
|
11
|
+
config.key = 'test'
|
12
|
+
config.secret = 'test'
|
13
|
+
end
|
14
|
+
|
15
|
+
-> { Bitstamp.sanity_check! }.should_not raise_error
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have a orders helper method' do
|
19
|
+
Bitstamp.should respond_to :orders
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should list information about your balance' do
|
23
|
+
read_bitstamp_yaml
|
24
|
+
|
25
|
+
Bitstamp.balance.should be_kind_of Hash
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Bitstamp::Coin < Bitstamp::Model;end
|
4
|
+
class Bitstamp::Coins < Bitstamp::Collection;end
|
5
|
+
|
6
|
+
describe Bitstamp::Coins do
|
7
|
+
let(:kojns) { Bitstamp::Coins.new }
|
8
|
+
|
9
|
+
it 'should have a name representing the class his name but not modules' do
|
10
|
+
kojns.name.should eq 'coin'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'module should reflect a singular form' do
|
14
|
+
kojns.module.should eq "bitstamp/coin"
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have a model' do
|
18
|
+
kojns.model.should be Bitstamp::Coin
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have an api end point' do
|
22
|
+
kojns.path.should eq "/api/coins"
|
23
|
+
end
|
24
|
+
end
|
data/spec/orders_spec.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Bitstamp::Orders do
|
4
|
+
before :each do
|
5
|
+
read_bitstamp_yaml
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return an array when querying for all orders" do
|
9
|
+
Bitstamp.orders.all.should be_kind_of Array
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should sell bitcoins" do
|
13
|
+
puts Bitstamp.orders.sell(:amount => 1, :price => 1000).inspect
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should buy bitcoins" do
|
17
|
+
puts Bitstamp.orders.buy(:amount => 1, :price => 1.01).inspect
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
5
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
6
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
7
|
+
# loaded once.
|
8
|
+
|
9
|
+
require 'bitstamp'
|
10
|
+
|
11
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
14
|
+
config.run_all_when_everything_filtered = true
|
15
|
+
config.filter_run :focus
|
16
|
+
|
17
|
+
# Run specs in random order to surface order dependencies. If you find an
|
18
|
+
# order dependency and want to debug it, you can fix the order by providing
|
19
|
+
# the seed, which is printed after each run.
|
20
|
+
# --seed 1234
|
21
|
+
config.order = 'random'
|
22
|
+
|
23
|
+
config.before(:all) {}
|
24
|
+
config.before(:each) do
|
25
|
+
# The famous singleton problem
|
26
|
+
Bitstamp.setup do |config|
|
27
|
+
config.key = nil
|
28
|
+
config.secret = nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
config.after(:all) {}
|
32
|
+
config.after(:each) {}
|
33
|
+
end
|
34
|
+
|
35
|
+
def read_bitstamp_yaml
|
36
|
+
Bitstamp.setup do |config|
|
37
|
+
yaml = YAML::load( File.read('bit_stamp_details.yml') )
|
38
|
+
config.key = yaml['bitstamp']['id']
|
39
|
+
config.secret = yaml['bitstamp']['password']
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bitstamp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jeffrey Wilcke
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activemodel
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.1'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: activesupport
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3.1'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.1'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: curb
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>'
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.8.1
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>'
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.8.1
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rdoc
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '3.12'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '3.12'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: bundler
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.3.5
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.3.5
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: jeweler
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.8.4
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 1.8.4
|
126
|
+
description: Ruby API for use with bitstamp.
|
127
|
+
email: stygeo@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files:
|
131
|
+
- LICENSE.txt
|
132
|
+
- README.md
|
133
|
+
files:
|
134
|
+
- .rspec
|
135
|
+
- Gemfile
|
136
|
+
- Gemfile.lock
|
137
|
+
- LICENSE.txt
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- VERSION
|
141
|
+
- bitstamp.gemspec
|
142
|
+
- lib/bitstamp.rb
|
143
|
+
- lib/bitstamp/collection.rb
|
144
|
+
- lib/bitstamp/model.rb
|
145
|
+
- lib/bitstamp/net.rb
|
146
|
+
- lib/bitstamp/orders.rb
|
147
|
+
- spec/bitstamp_spec.rb
|
148
|
+
- spec/collection_spec.rb
|
149
|
+
- spec/orders_spec.rb
|
150
|
+
- spec/spec_helper.rb
|
151
|
+
homepage: http://github.com/kojnapp/bitstamp
|
152
|
+
licenses:
|
153
|
+
- MIT
|
154
|
+
post_install_message:
|
155
|
+
rdoc_options: []
|
156
|
+
require_paths:
|
157
|
+
- lib
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
160
|
+
requirements:
|
161
|
+
- - ! '>='
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
segments:
|
165
|
+
- 0
|
166
|
+
hash: -2003054976913405923
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
none: false
|
169
|
+
requirements:
|
170
|
+
- - ! '>='
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
requirements: []
|
174
|
+
rubyforge_project:
|
175
|
+
rubygems_version: 1.8.25
|
176
|
+
signing_key:
|
177
|
+
specification_version: 3
|
178
|
+
summary: Bitstamp Ruby API
|
179
|
+
test_files: []
|