mpex 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/README.md +2 -2
- data/Rakefile +3 -0
- data/lib/mpex.rb +1 -0
- data/lib/mpex/cli.rb +14 -0
- data/lib/mpex/http.rb +41 -0
- data/lib/mpex/irc.rb +20 -0
- data/lib/mpex/mpex.rb +15 -12
- data/lib/mpex/version.rb +1 -1
- data/mpex.gemspec +4 -3
- metadata +22 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75ca9aee6159266cfd7cc27d8fe3612f96a569cb
|
4
|
+
data.tar.gz: ffadf1b2a0830efc46e6977fbded6ef9759379d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7eb0911853927001842f53116f37c87c069d1f5054a02f0f4816934b3eca87d849f98fb5a8ccae06c609b36876fd31b5214d367a78aac2f5f10e1998cd337ea
|
7
|
+
data.tar.gz: 207037af4b69b56ad8cd536d1ebe06bd0cdd26e392062ce036d7ae2152a5e590ddaccd8832beba7ec4326486068b1e7a68980f6580da83cb8f561f1c5af38492
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mpex (0.4.
|
4
|
+
mpex (0.4.6)
|
5
5
|
cri (~> 2.2)
|
6
6
|
gpgme
|
7
7
|
highline
|
@@ -27,6 +27,7 @@ GEM
|
|
27
27
|
highline (1.6.15)
|
28
28
|
json (1.7.6)
|
29
29
|
net-yail (1.6.1)
|
30
|
+
rake (10.0.3)
|
30
31
|
rspec-expectations (2.12.1)
|
31
32
|
diff-lcs (~> 1.1.3)
|
32
33
|
|
@@ -36,4 +37,5 @@ PLATFORMS
|
|
36
37
|
DEPENDENCIES
|
37
38
|
cucumber
|
38
39
|
mpex!
|
40
|
+
rake
|
39
41
|
rspec-expectations
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# MPEx.rb: a commandline client for MPEx
|
2
2
|
|
3
3
|
## About
|
4
4
|
|
5
|
-
|
5
|
+
MPEx.rb is a commandline client for [MPEx](http://mpex.co), a Bitcoin security exchange. Make sure to carefully read its [FAQ](http://mpex.co/faq.html) before using it.
|
6
6
|
|
7
7
|
## Install
|
8
8
|
|
data/Rakefile
CHANGED
data/lib/mpex.rb
CHANGED
data/lib/mpex/cli.rb
CHANGED
@@ -185,6 +185,20 @@ end
|
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
188
|
+
@cmd.define_command do
|
189
|
+
name 'proxies'
|
190
|
+
usage 'proxies [options]'
|
191
|
+
summary 'list active MPEx proxies; only works when connected to IRC'
|
192
|
+
|
193
|
+
run do |opts, args|
|
194
|
+
mpex = Mpex::Mpex.new
|
195
|
+
mpex.list_proxies do |proxies|
|
196
|
+
puts proxies
|
197
|
+
puts "To use a proxy, edit ~/.mpex/config.yaml and restart mpex cli"
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
188
202
|
def self.run(args)
|
189
203
|
@cmd.run(ARGV)
|
190
204
|
end
|
data/lib/mpex/http.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'net/http'
|
3
|
+
|
4
|
+
module Mpex
|
5
|
+
class Http
|
6
|
+
|
7
|
+
def self.post_form(url, params)
|
8
|
+
begin
|
9
|
+
res = Net::HTTP.post_form(mpex_uri(url), params)
|
10
|
+
return res.body.to_s
|
11
|
+
rescue Exception => ex
|
12
|
+
suggest_proxies
|
13
|
+
raise ex
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.get(url, url_extension="")
|
18
|
+
begin
|
19
|
+
uri = mpex_uri(url).merge(url_extension)
|
20
|
+
return Net::HTTP.get(uri)
|
21
|
+
rescue Exception => ex
|
22
|
+
suggest_proxies
|
23
|
+
raise ex
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def self.suggest_proxies
|
29
|
+
puts "----------"
|
30
|
+
say("<%= color('MPEx proxy maybe not reachable.', :red) %>")
|
31
|
+
puts "Try a different one or IRC bots.\nType 'irc' to connect to IRC."
|
32
|
+
puts "When you're connected you can use mpex via irc bots or find out about alternative proxies via 'proxies'"
|
33
|
+
puts "----------"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.mpex_uri(url)
|
37
|
+
URI.parse(url).merge("/")
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
data/lib/mpex/irc.rb
CHANGED
@@ -90,6 +90,26 @@ module Mpex
|
|
90
90
|
}
|
91
91
|
end
|
92
92
|
|
93
|
+
def list_proxies(&block)
|
94
|
+
@irc.msg MPEXBOT, '$proxies'
|
95
|
+
|
96
|
+
status = Timeout::timeout(TIMEOUT) {
|
97
|
+
yield wait_for_mpexbot_plain_message
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
def wait_for_mpexbot_plain_message
|
102
|
+
while true
|
103
|
+
if @last_message
|
104
|
+
answer = @last_message[:message]
|
105
|
+
if answer
|
106
|
+
@last_message = nil
|
107
|
+
return answer
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
93
113
|
def wait_for_mpexbot_message
|
94
114
|
while true
|
95
115
|
if @last_message
|
data/lib/mpex/mpex.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
require 'fileutils'
|
2
|
-
require 'open-uri'
|
3
|
-
require 'net/http'
|
4
2
|
require 'json'
|
5
3
|
require 'yaml'
|
6
4
|
require 'highline/import'
|
@@ -68,8 +66,8 @@ module Mpex
|
|
68
66
|
end
|
69
67
|
end
|
70
68
|
else
|
71
|
-
res =
|
72
|
-
yield handle_answer(res
|
69
|
+
res = Http.post_form(opts[:url], { 'msg' => "#{encrypted_msg}" })
|
70
|
+
yield handle_answer(res, opts)
|
73
71
|
end
|
74
72
|
end
|
75
73
|
|
@@ -82,10 +80,6 @@ module Mpex
|
|
82
80
|
verified_response.to_s
|
83
81
|
end
|
84
82
|
|
85
|
-
def mpex_uri(url)
|
86
|
-
URI.parse(url).merge("/")
|
87
|
-
end
|
88
|
-
|
89
83
|
def validate_mpsic(mpsic)
|
90
84
|
if mpsic.match(/^\w\./)
|
91
85
|
return mpsic
|
@@ -126,8 +120,8 @@ module Mpex
|
|
126
120
|
vwaps = JSON.parse(resp)
|
127
121
|
end
|
128
122
|
else
|
129
|
-
|
130
|
-
vwaps = JSON.parse(
|
123
|
+
vwaps_raw = Http.get(url, "/mpex-vwap.php")
|
124
|
+
vwaps = JSON.parse(vwaps_raw)
|
131
125
|
end
|
132
126
|
yield vwaps
|
133
127
|
end
|
@@ -140,8 +134,7 @@ module Mpex
|
|
140
134
|
end
|
141
135
|
else
|
142
136
|
opts = verify_opts_present(opts, [ :url ])
|
143
|
-
|
144
|
-
orderbook_res = Net::HTTP.get(orderbook_url)
|
137
|
+
orderbook_res = Http.get(opts[:url], "/mpex-mktdepth.php")
|
145
138
|
orderbook_res = orderbook_res.start_with?("JurovP") ? orderbook_res.match(/JurovP\((.+)\)/)[1] : orderbook_res
|
146
139
|
orderbook = JSON.parse(orderbook_res)
|
147
140
|
end
|
@@ -156,6 +149,16 @@ module Mpex
|
|
156
149
|
end
|
157
150
|
end
|
158
151
|
|
152
|
+
def list_proxies(&block)
|
153
|
+
if $IRC_LEAK && $IRC_LEAK.connected?
|
154
|
+
$IRC_LEAK.list_proxies do |proxies|
|
155
|
+
yield proxies
|
156
|
+
end
|
157
|
+
else
|
158
|
+
puts "This command only works when connected to irc. Type 'irc' to connect."
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
159
162
|
def portfolio(opts, stat, &block)
|
160
163
|
|
161
164
|
return unless stat
|
data/lib/mpex/version.rb
CHANGED
data/mpex.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Fa Wuxi"]
|
9
9
|
s.email = [""]
|
10
10
|
s.homepage = "https://github.com/fawuxi/mpex"
|
11
|
-
s.summary = %q{
|
12
|
-
s.description = %q{
|
11
|
+
s.summary = %q{MPEx.rb: a commandline client for MPEx}
|
12
|
+
s.description = %q{MPEx.rb is a commandline client for "MPEx":http://mpex.co a Bitcoin security exchange. Make sure to carefully read its "FAQ":http://mpex.co/faq.html before using it.}
|
13
13
|
|
14
14
|
s.files = Dir['[A-Z]*'] + Dir['{bin,lib,tasks,test}/**/*'] + [ 'mpex.gemspec' ]
|
15
15
|
s.extra_rdoc_files = ['README.md']
|
@@ -23,11 +23,12 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_runtime_dependency "gpgme"
|
24
24
|
s.add_runtime_dependency "net-yail"
|
25
25
|
|
26
|
+
s.add_development_dependency "rake"
|
26
27
|
s.add_development_dependency "cucumber"
|
27
28
|
s.add_development_dependency "rspec-expectations"
|
28
29
|
|
29
30
|
s.post_install_message = %q{------------------------------------------------------------------------------
|
30
|
-
run "mpex help" for usage information
|
31
|
+
run "mpex help" for usage information; or "mpex -i" to start interactive
|
31
32
|
------------------------------------------------------------------------------
|
32
33
|
}
|
33
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mpex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fa Wuxi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cri
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: cucumber
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,8 +122,9 @@ dependencies:
|
|
108
122
|
- - '>='
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
|
-
description:
|
112
|
-
Make sure to carefully read its "FAQ":http://mpex.co/faq.html before using
|
125
|
+
description: MPEx.rb is a commandline client for "MPEx":http://mpex.co a Bitcoin security
|
126
|
+
exchange. Make sure to carefully read its "FAQ":http://mpex.co/faq.html before using
|
127
|
+
it.
|
113
128
|
email:
|
114
129
|
- ''
|
115
130
|
executables:
|
@@ -126,6 +141,7 @@ files:
|
|
126
141
|
- bin/mpex
|
127
142
|
- lib/mpex/cli.rb
|
128
143
|
- lib/mpex/converter.rb
|
144
|
+
- lib/mpex/http.rb
|
129
145
|
- lib/mpex/interactive.rb
|
130
146
|
- lib/mpex/irc.rb
|
131
147
|
- lib/mpex/mpex.rb
|
@@ -137,7 +153,7 @@ licenses: []
|
|
137
153
|
metadata: {}
|
138
154
|
post_install_message: |
|
139
155
|
------------------------------------------------------------------------------
|
140
|
-
run "mpex help" for usage information
|
156
|
+
run "mpex help" for usage information; or "mpex -i" to start interactive
|
141
157
|
------------------------------------------------------------------------------
|
142
158
|
rdoc_options:
|
143
159
|
- --main
|
@@ -159,5 +175,5 @@ rubyforge_project:
|
|
159
175
|
rubygems_version: 2.0.0
|
160
176
|
signing_key:
|
161
177
|
specification_version: 4
|
162
|
-
summary:
|
178
|
+
summary: 'MPEx.rb: a commandline client for MPEx'
|
163
179
|
test_files: []
|