mtgox 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ require 'faraday'
2
+
3
+ module Faraday
4
+ class Response::RaiseMtGoxError < Response::Middleware
5
+ def on_complete(env)
6
+ if 200 == env[:status] && 'MySQL error, please retry later' == env[:body]
7
+ raise MtGox::MysqlError, "MySQL error, please retry later"
8
+ end
9
+ end
10
+ end
11
+ end
12
+
data/lib/mtgox.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'mtgox/client'
2
+ require 'mtgox/error'
2
3
 
3
4
  module MtGox
4
5
  class << self
@@ -1,3 +1,5 @@
1
+ require 'faraday'
2
+ require 'faraday/response/raise_mtgox_error'
1
3
  require 'faraday_middleware'
2
4
  require 'mtgox/version'
3
5
 
@@ -20,6 +22,7 @@ module MtGox
20
22
  connection.use Faraday::Response::RaiseError
21
23
  connection.use Faraday::Response::Rashify
22
24
  connection.use Faraday::Response::ParseJson
25
+ connection.use Faraday::Response::RaiseMtGoxError
23
26
  connection.adapter(Faraday.default_adapter)
24
27
  end
25
28
  end
@@ -0,0 +1,7 @@
1
+ module MtGox
2
+ # Custom error class for rescuing from all MtGox errors
3
+ class Error < StandardError; end
4
+
5
+ class MysqlError < Error; end
6
+ end
7
+
data/lib/mtgox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module MtGox
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -0,0 +1,14 @@
1
+ require 'helper'
2
+
3
+ describe Faraday::Response do
4
+ before do
5
+ stub_get('/code/data/getTrades.php').
6
+ to_return(:status => 200, :body => fixture('mysql_error'))
7
+ end
8
+
9
+ it "should raise MtGox::MysqlError" do
10
+ lambda do
11
+ MtGox.trades
12
+ end.should raise_error(MtGox::MysqlError)
13
+ end
14
+ end
@@ -0,0 +1 @@
1
+ MySQL error, please retry later
metadata CHANGED
@@ -1,227 +1,227 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mtgox
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
4
5
  prerelease:
5
- version: 0.3.0
6
6
  platform: ruby
7
- authors:
8
- - Erik Michaels-Ober
7
+ authors:
8
+ - Erik Michaels-Ober
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-07-03 00:00:00 -07:00
12
+ date: 2011-07-03 00:00:00.000000000 -07:00
14
13
  default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: ZenTest
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
20
- none: false
21
- requirements:
22
- - - ~>
23
- - !ruby/object:Gem::Version
24
- version: "4.5"
25
- type: :development
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: maruku
29
- prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
31
- none: false
32
- requirements:
33
- - - ~>
34
- - !ruby/object:Gem::Version
35
- version: "0.6"
36
- type: :development
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: rake
40
- prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ~>
45
- - !ruby/object:Gem::Version
46
- version: "0.9"
47
- type: :development
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: rspec
51
- prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
53
- none: false
54
- requirements:
55
- - - ~>
56
- - !ruby/object:Gem::Version
57
- version: "2.6"
58
- type: :development
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: simplecov
62
- prerelease: false
63
- requirement: &id005 !ruby/object:Gem::Requirement
64
- none: false
65
- requirements:
66
- - - ~>
67
- - !ruby/object:Gem::Version
68
- version: "0.4"
69
- type: :development
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
72
- name: webmock
73
- prerelease: false
74
- requirement: &id006 !ruby/object:Gem::Requirement
75
- none: false
76
- requirements:
77
- - - ~>
78
- - !ruby/object:Gem::Version
79
- version: "1.6"
80
- type: :development
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
83
- name: yard
84
- prerelease: false
85
- requirement: &id007 !ruby/object:Gem::Requirement
86
- none: false
87
- requirements:
88
- - - ~>
89
- - !ruby/object:Gem::Version
90
- version: "0.7"
91
- type: :development
92
- version_requirements: *id007
93
- - !ruby/object:Gem::Dependency
94
- name: faraday
95
- prerelease: false
96
- requirement: &id008 !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ~>
100
- - !ruby/object:Gem::Version
101
- version: 0.6.1
102
- type: :runtime
103
- version_requirements: *id008
104
- - !ruby/object:Gem::Dependency
105
- name: faraday_middleware
106
- prerelease: false
107
- requirement: &id009 !ruby/object:Gem::Requirement
108
- none: false
109
- requirements:
110
- - - ~>
111
- - !ruby/object:Gem::Version
112
- version: 0.6.3
113
- type: :runtime
114
- version_requirements: *id009
115
- - !ruby/object:Gem::Dependency
116
- name: hashie
117
- prerelease: false
118
- requirement: &id010 !ruby/object:Gem::Requirement
119
- none: false
120
- requirements:
121
- - - ~>
122
- - !ruby/object:Gem::Version
123
- version: 1.0.0
124
- type: :runtime
125
- version_requirements: *id010
126
- - !ruby/object:Gem::Dependency
127
- name: multi_json
128
- prerelease: false
129
- requirement: &id011 !ruby/object:Gem::Requirement
130
- none: false
131
- requirements:
132
- - - ~>
133
- - !ruby/object:Gem::Version
134
- version: 1.0.3
135
- type: :runtime
136
- version_requirements: *id011
137
- - !ruby/object:Gem::Dependency
138
- name: rash
139
- prerelease: false
140
- requirement: &id012 !ruby/object:Gem::Requirement
141
- none: false
142
- requirements:
143
- - - ~>
144
- - !ruby/object:Gem::Version
145
- version: 0.3.0
146
- type: :runtime
147
- version_requirements: *id012
148
- description: Ruby wrapper for the Mt. Gox Trade API. Mt. Gox allows you to trade US Dollars (USD) for Bitcoins (BTC) or Bitcoins for US Dollars.
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: ZenTest
17
+ requirement: &70364608964540 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '4.5'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: *70364608964540
26
+ - !ruby/object:Gem::Dependency
27
+ name: maruku
28
+ requirement: &70364608964000 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '0.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *70364608964000
37
+ - !ruby/object:Gem::Dependency
38
+ name: rake
39
+ requirement: &70364608963420 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: '0.9'
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *70364608963420
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ requirement: &70364608962220 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: '2.6'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *70364608962220
59
+ - !ruby/object:Gem::Dependency
60
+ name: simplecov
61
+ requirement: &70364608961080 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: '0.4'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *70364608961080
70
+ - !ruby/object:Gem::Dependency
71
+ name: webmock
72
+ requirement: &70364608943460 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.6'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: *70364608943460
81
+ - !ruby/object:Gem::Dependency
82
+ name: yard
83
+ requirement: &70364608942360 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ version: '0.7'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: *70364608942360
92
+ - !ruby/object:Gem::Dependency
93
+ name: faraday
94
+ requirement: &70364608941420 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ~>
98
+ - !ruby/object:Gem::Version
99
+ version: 0.6.1
100
+ type: :runtime
101
+ prerelease: false
102
+ version_requirements: *70364608941420
103
+ - !ruby/object:Gem::Dependency
104
+ name: faraday_middleware
105
+ requirement: &70364608940880 !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 0.6.3
111
+ type: :runtime
112
+ prerelease: false
113
+ version_requirements: *70364608940880
114
+ - !ruby/object:Gem::Dependency
115
+ name: hashie
116
+ requirement: &70364608940240 !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ~>
120
+ - !ruby/object:Gem::Version
121
+ version: 1.0.0
122
+ type: :runtime
123
+ prerelease: false
124
+ version_requirements: *70364608940240
125
+ - !ruby/object:Gem::Dependency
126
+ name: multi_json
127
+ requirement: &70364608939620 !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ~>
131
+ - !ruby/object:Gem::Version
132
+ version: 1.0.3
133
+ type: :runtime
134
+ prerelease: false
135
+ version_requirements: *70364608939620
136
+ - !ruby/object:Gem::Dependency
137
+ name: rash
138
+ requirement: &70364608939040 !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ~>
142
+ - !ruby/object:Gem::Version
143
+ version: 0.3.0
144
+ type: :runtime
145
+ prerelease: false
146
+ version_requirements: *70364608939040
147
+ description: Ruby wrapper for the Mt. Gox Trade API. Mt. Gox allows you to trade US
148
+ Dollars (USD) for Bitcoins (BTC) or Bitcoins for US Dollars.
149
149
  email: sferik@gmail.com
150
150
  executables: []
151
-
152
151
  extensions: []
153
-
154
152
  extra_rdoc_files: []
155
-
156
- files:
157
- - .autotest
158
- - .gemtest
159
- - .gitignore
160
- - .rspec
161
- - .travis.yml
162
- - .yardopts
163
- - Gemfile
164
- - LICENSE.md
165
- - README.md
166
- - Rakefile
167
- - lib/mtgox.rb
168
- - lib/mtgox/client.rb
169
- - lib/mtgox/connection.rb
170
- - lib/mtgox/request.rb
171
- - lib/mtgox/version.rb
172
- - mtgox.gemspec
173
- - spec/fixtures/balance.json
174
- - spec/fixtures/buy.json
175
- - spec/fixtures/cancel.json
176
- - spec/fixtures/depth.json
177
- - spec/fixtures/error.json
178
- - spec/fixtures/orders.json
179
- - spec/fixtures/sell.json
180
- - spec/fixtures/ticker.json
181
- - spec/fixtures/trades.json
182
- - spec/fixtures/withdraw.json
183
- - spec/helper.rb
184
- - spec/mtgox/client_spec.rb
185
- - spec/mtgox_spec.rb
153
+ files:
154
+ - .autotest
155
+ - .gemtest
156
+ - .gitignore
157
+ - .rspec
158
+ - .travis.yml
159
+ - .yardopts
160
+ - Gemfile
161
+ - LICENSE.md
162
+ - README.md
163
+ - Rakefile
164
+ - lib/faraday/response/raise_mtgox_error.rb
165
+ - lib/mtgox.rb
166
+ - lib/mtgox/client.rb
167
+ - lib/mtgox/connection.rb
168
+ - lib/mtgox/error.rb
169
+ - lib/mtgox/request.rb
170
+ - lib/mtgox/version.rb
171
+ - mtgox.gemspec
172
+ - spec/faraday/response_spec.rb
173
+ - spec/fixtures/balance.json
174
+ - spec/fixtures/buy.json
175
+ - spec/fixtures/cancel.json
176
+ - spec/fixtures/depth.json
177
+ - spec/fixtures/error.json
178
+ - spec/fixtures/mysql_error
179
+ - spec/fixtures/orders.json
180
+ - spec/fixtures/sell.json
181
+ - spec/fixtures/ticker.json
182
+ - spec/fixtures/trades.json
183
+ - spec/fixtures/withdraw.json
184
+ - spec/helper.rb
185
+ - spec/mtgox/client_spec.rb
186
+ - spec/mtgox_spec.rb
186
187
  has_rdoc: true
187
188
  homepage: https://github.com/sferik/mtgox
188
189
  licenses: []
189
-
190
190
  post_install_message:
191
191
  rdoc_options: []
192
-
193
- require_paths:
194
- - lib
195
- required_ruby_version: !ruby/object:Gem::Requirement
192
+ require_paths:
193
+ - lib
194
+ required_ruby_version: !ruby/object:Gem::Requirement
196
195
  none: false
197
- requirements:
198
- - - ">="
199
- - !ruby/object:Gem::Version
200
- version: "0"
201
- required_rubygems_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ! '>='
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ required_rubygems_version: !ruby/object:Gem::Requirement
202
201
  none: false
203
- requirements:
204
- - - ">="
205
- - !ruby/object:Gem::Version
206
- version: "0"
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
207
206
  requirements: []
208
-
209
207
  rubyforge_project:
210
- rubygems_version: 1.5.1
208
+ rubygems_version: 1.6.2
211
209
  signing_key:
212
210
  specification_version: 3
213
211
  summary: Ruby wrapper for the Mt. Gox Trade API
214
- test_files:
215
- - spec/fixtures/balance.json
216
- - spec/fixtures/buy.json
217
- - spec/fixtures/cancel.json
218
- - spec/fixtures/depth.json
219
- - spec/fixtures/error.json
220
- - spec/fixtures/orders.json
221
- - spec/fixtures/sell.json
222
- - spec/fixtures/ticker.json
223
- - spec/fixtures/trades.json
224
- - spec/fixtures/withdraw.json
225
- - spec/helper.rb
226
- - spec/mtgox/client_spec.rb
227
- - spec/mtgox_spec.rb
212
+ test_files:
213
+ - spec/faraday/response_spec.rb
214
+ - spec/fixtures/balance.json
215
+ - spec/fixtures/buy.json
216
+ - spec/fixtures/cancel.json
217
+ - spec/fixtures/depth.json
218
+ - spec/fixtures/error.json
219
+ - spec/fixtures/mysql_error
220
+ - spec/fixtures/orders.json
221
+ - spec/fixtures/sell.json
222
+ - spec/fixtures/ticker.json
223
+ - spec/fixtures/trades.json
224
+ - spec/fixtures/withdraw.json
225
+ - spec/helper.rb
226
+ - spec/mtgox/client_spec.rb
227
+ - spec/mtgox_spec.rb