webmoney 0.0.4.8 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/ChangeLog +8 -0
- data/README +10 -2
- data/RUNNING_TESTS +12 -0
- data/VERSION +1 -0
- data/lib/passport.rb +72 -7
- data/lib/request_result.rb +11 -7
- data/lib/request_xml.rb +87 -67
- data/lib/webmoney.rb +64 -35
- data/rakefile +31 -35
- data/spec/spec +4 -0
- data/spec/spec_helper.rb +0 -1
- data/spec/unit/passport_spec.rb +91 -4
- data/spec/unit/webmoney_spec.rb +25 -8
- data/webmoney.gemspec +94 -0
- metadata +39 -41
- data/tools/rakehelp.rb +0 -117
data/ChangeLog
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
ChangeLog
|
2
2
|
|
3
|
+
Fri Feb 12 2010 11:22:35 + 0400
|
4
|
+
----------------------------
|
5
|
+
V 0.0.5
|
6
|
+
* Using Nokogiri instead Hpricot+Builder, incompatible with libxml2 < 2.7.0
|
7
|
+
* Using jeweler+rake-compiler
|
8
|
+
* Complete parse attestat fields (X11)
|
9
|
+
* Add X2 -Create transaction
|
10
|
+
|
3
11
|
Sat Oct 03 2009 16:18:00 + 0400
|
4
12
|
----------------------------
|
5
13
|
V 0.0.4.8
|
data/README
CHANGED
@@ -5,6 +5,8 @@ XML-interfaces: http://www.wmtransfer.com/eng/developers/interfaces/index.shtml
|
|
5
5
|
|
6
6
|
Gem have built-in native *wmsigner*.
|
7
7
|
|
8
|
+
Reqirements: Nokogiri >= 1.4.1 built with libxml2 >= 2.7 (IMPORTANT!)
|
9
|
+
|
8
10
|
Author:: Alexander Oryol (mailto:eagle.alex@gmail.com)
|
9
11
|
License:: MIT License
|
10
12
|
|
@@ -62,11 +64,17 @@ wmid = '111222333444'
|
|
62
64
|
= Passport (X11)
|
63
65
|
|
64
66
|
Get attestat data:
|
65
|
-
passport = Passport.new(wmid)
|
66
|
-
passport.attestat # { #
|
67
|
+
passport = Webmoney::Passport.new(wmid)
|
68
|
+
passport.attestat # { # hash
|
67
69
|
# :attestat => 110, # == FORMAL attestat, as example
|
68
70
|
# :created_at => Wed Feb 25 21:54:01 +0300 2004 # Time object
|
71
|
+
# :cid => "103453"
|
72
|
+
# and etc.
|
69
73
|
# }
|
74
|
+
passport.wmids # All wmids attached to the attestat
|
75
|
+
passport.userinfo[:country] # => 'Russia' # Userinfo fields in string context
|
76
|
+
passport.userinfo[:country].checked # => true # with checked/locked attribute
|
77
|
+
passport.directory # Base dictionary
|
70
78
|
|
71
79
|
= Bussines level
|
72
80
|
|
data/RUNNING_TESTS
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
== Running tests
|
2
|
+
|
3
|
+
For run tests create ~/.wm/config.yml file:
|
4
|
+
|
5
|
+
common:
|
6
|
+
type: classic
|
7
|
+
wmid: '123456789012'
|
8
|
+
key: 'gQABAIR6... YOUR BASE64-KEY (see wmsigner readme) ...2cC8FZTyKyjBM='
|
9
|
+
password: _your_password_
|
10
|
+
ca_cert: file_or_path_to_directory # optional, all needed certs in lib
|
11
|
+
|
12
|
+
and type (RSpec required): rake spec
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.5
|
data/lib/passport.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
-
require 'hpricot'
|
2
|
-
|
3
1
|
# Class for store attestat information
|
4
2
|
module Webmoney
|
3
|
+
|
5
4
|
class Passport < Wmid
|
6
5
|
|
6
|
+
class Attribute < String
|
7
|
+
attr_accessor :checked, :locked
|
8
|
+
end
|
9
|
+
|
7
10
|
# Attestate types
|
8
11
|
ALIAS = 100
|
9
12
|
FORMAL = 110
|
@@ -18,8 +21,6 @@ module Webmoney
|
|
18
21
|
SERVICE2 = 200
|
19
22
|
OPERATOR = 300
|
20
23
|
|
21
|
-
attr_reader :attestat
|
22
|
-
|
23
24
|
def self.worker= (worker)
|
24
25
|
@@worker = worker
|
25
26
|
end
|
@@ -28,9 +29,73 @@ module Webmoney
|
|
28
29
|
@@worker
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
# memoize data
|
33
|
+
def attestat; @attestat ||= getinfo[:attestat] end
|
34
|
+
def directory; @directory ||= getinfo[:directory] end
|
35
|
+
def full_access; @full_access = getinfo[:full_access] end
|
36
|
+
def userinfo; @userinfo ||= getinfo[:userinfo] end
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
def getinfo
|
41
|
+
info = @@worker.request(:get_passport, :wmid => self)
|
42
|
+
@attestat = info[:attestat]
|
43
|
+
@full_access = info[:full_access]
|
44
|
+
@userinfo = info[:userinfo]
|
45
|
+
@directory = info[:directory]
|
46
|
+
info
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.parse_result(doc)
|
50
|
+
root = doc.at('/response')
|
51
|
+
|
52
|
+
# We use latest attestat
|
53
|
+
att_elm = root.at('certinfo/attestat/row')
|
54
|
+
|
55
|
+
tid = att_elm['tid'].to_i
|
56
|
+
recalled = att_elm['recalled'].to_i
|
57
|
+
locked = root.at('certinfo/userinfo/value/row')['locked'].to_i
|
58
|
+
|
59
|
+
attestat = {
|
60
|
+
:attestat => (recalled + locked > 0) ? ALIAS : tid,
|
61
|
+
:created_at => Time.xmlschema(att_elm['datecrt'])
|
62
|
+
}
|
63
|
+
attestat.merge!( att_elm.attributes.inject({}) do |memo, a|
|
64
|
+
a[1].value.empty? ? memo : memo.merge!(a[0].to_sym => a[1].value)
|
65
|
+
end )
|
66
|
+
|
67
|
+
userinfo = root.at('certinfo/userinfo/value/row').attributes.inject({}) { |memo, a|
|
68
|
+
memo.merge!(a[0].to_sym => Attribute.new(a[1].value.strip))
|
69
|
+
}
|
70
|
+
root.at('certinfo/userinfo/check-lock/row').attributes.each_pair do |k,v|
|
71
|
+
attr = userinfo[k.to_sym]
|
72
|
+
attr.checked = v.to_s[0,1] == '1'
|
73
|
+
attr.locked = v.to_s[1,2] == '1'
|
74
|
+
end
|
75
|
+
|
76
|
+
wmids = root.xpath('certinfo/wmids/row').inject({}) do |memo, elm|
|
77
|
+
attrs = {:created_at => Time.xmlschema(elm['datereg'])}
|
78
|
+
attrs.merge!(:nickname => elm['nickname']) unless elm['nickname'].empty?
|
79
|
+
attrs.merge!(:info => elm['info']) unless elm['info'].empty?
|
80
|
+
memo.merge!(elm['wmid'] => attrs)
|
81
|
+
end
|
82
|
+
|
83
|
+
if dir = root.at('directory')
|
84
|
+
directory = {
|
85
|
+
:ctype => dir.xpath('ctype').inject({}){|memo, node| memo.merge!(node['id'].to_i => node.text)},
|
86
|
+
:jstatus => dir.xpath('jstatus').inject({}){|memo, node| memo.merge!(node['id'].to_i => node.text)},
|
87
|
+
:types => dir.xpath('tid').inject({}){|memo, node| memo.merge!(node['id'].to_i => node.text)}
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
result = {
|
92
|
+
:full_access => root.at('fullaccess').text == '1',
|
93
|
+
:attestat => attestat,
|
94
|
+
:wmids => wmids,
|
95
|
+
:userinfo => userinfo
|
96
|
+
}
|
97
|
+
result.merge!(:directory => directory) if dir
|
98
|
+
result
|
34
99
|
end
|
35
100
|
|
36
101
|
end
|
data/lib/request_result.rb
CHANGED
@@ -5,13 +5,7 @@ module Webmoney::RequestResult # :nodoc:all
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def result_get_passport(doc)
|
8
|
-
|
9
|
-
recalled = doc.at('/response/certinfo/attestat/row')['recalled'].to_i
|
10
|
-
locked = doc.at('/response/certinfo/userinfo/value/row')['locked'].to_i
|
11
|
-
{ # TODO more attestat fields...
|
12
|
-
:attestat => ( recalled + locked > 0) ? Webmoney::Passport::ALIAS : tid,
|
13
|
-
:created_at => Time.xmlschema(doc.at('/response/certinfo/attestat/row')['datecrt'])
|
14
|
-
}
|
8
|
+
Webmoney::Passport.parse_result(doc)
|
15
9
|
end
|
16
10
|
|
17
11
|
def result_bussines_level(doc)
|
@@ -33,4 +27,14 @@ module Webmoney::RequestResult # :nodoc:all
|
|
33
27
|
}
|
34
28
|
end
|
35
29
|
|
30
|
+
def result_create_transaction(doc)
|
31
|
+
op = doc.at('//operation')
|
32
|
+
{
|
33
|
+
:operation_id => op['id'],
|
34
|
+
:operation_ts => op['ts']
|
35
|
+
}.merge( op.children.inject({}) do |memo, elm|
|
36
|
+
memo.merge!(elm.name.to_sym => elm.text)
|
37
|
+
end )
|
38
|
+
end
|
39
|
+
|
36
40
|
end
|
data/lib/request_xml.rb
CHANGED
@@ -1,87 +1,107 @@
|
|
1
1
|
module Webmoney::RequestXML # :nodoc:all
|
2
2
|
|
3
|
-
def envelope(utf = true)
|
4
|
-
x = Builder::XmlMarkup.new(:indent => 1)
|
5
|
-
encoding = utf ? "utf-8" : "windows-1251"
|
6
|
-
x.instruct!(:xml, :version => "1.0", :encoding => encoding)
|
7
|
-
x
|
8
|
-
end
|
9
|
-
|
10
3
|
def xml_get_passport(opt)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
4
|
+
Nokogiri::XML::Builder.new { |x|
|
5
|
+
x.request {
|
6
|
+
x.wmid @wmid
|
7
|
+
x.passportwmid opt[:wmid]
|
8
|
+
x.params {
|
9
|
+
x.dict opt[:dict] || 0
|
10
|
+
x.info opt[:info] || 1
|
11
|
+
x.mode opt[:mode] || 0
|
12
|
+
}
|
13
|
+
# unless mode == 1, signed data need'nt
|
14
|
+
x.sign( (classic? && opt[:mode]) ? sign(@wmid + opt[:wmid]) : nil )
|
15
|
+
}
|
16
|
+
}
|
19
17
|
end
|
20
18
|
|
21
19
|
def xml_bussines_level(opt)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
Nokogiri::XML::Builder.new { |x|
|
21
|
+
x.send('WMIDLevel.request') {
|
22
|
+
x.signerwmid @wmid
|
23
|
+
x.wmid opt[:wmid]
|
24
|
+
}
|
25
|
+
}
|
28
26
|
end
|
29
27
|
|
30
28
|
def xml_check_sign(opt)
|
31
|
-
|
32
|
-
|
33
|
-
x.
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
29
|
+
plan_out = @ic_out.iconv(opt[:plan])
|
30
|
+
Nokogiri::XML::Builder.new( :encoding => 'windows-1251' ) { |x|
|
31
|
+
x.send('w3s.request') {
|
32
|
+
x.wmid @wmid
|
33
|
+
x.testsign {
|
34
|
+
x.wmid opt[:wmid]
|
35
|
+
x.plan { x.cdata opt[:plan] }
|
36
|
+
x.sign opt[:sign]
|
37
|
+
}
|
38
|
+
if classic?
|
39
|
+
plan = @wmid + opt[:wmid] + plan_out + opt[:sign]
|
40
|
+
x.sign sign(plan)
|
41
|
+
end
|
42
|
+
}
|
43
|
+
}
|
46
44
|
end
|
47
45
|
|
48
46
|
def xml_send_message(opt)
|
49
|
-
x = envelope(false)
|
50
47
|
req = reqn()
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
x.
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
48
|
+
msgsubj = @ic_out.iconv(opt[:subj])
|
49
|
+
msgtext = @ic_out.iconv(opt[:text])
|
50
|
+
Nokogiri::XML::Builder.new( :encoding => 'windows-1251' ) { |x|
|
51
|
+
x.send('w3s.request') {
|
52
|
+
x.wmid @wmid
|
53
|
+
x.reqn req
|
54
|
+
x.message do
|
55
|
+
x.receiverwmid opt[:wmid]
|
56
|
+
x.msgsubj { x.cdata opt[:subj] }
|
57
|
+
x.msgtext { x.cdata opt[:text] }
|
58
|
+
end
|
59
|
+
if classic?
|
60
|
+
@plan = opt[:wmid] + req + msgtext + msgsubj
|
61
|
+
x.sign sign(@plan)
|
62
|
+
end
|
63
|
+
}
|
64
|
+
}
|
67
65
|
end
|
68
66
|
|
69
67
|
def xml_find_wm(opt)
|
70
|
-
x = envelope(false)
|
71
68
|
req = reqn()
|
72
|
-
|
73
|
-
x.
|
74
|
-
|
75
|
-
|
76
|
-
x.
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
69
|
+
Nokogiri::XML::Builder.new { |x|
|
70
|
+
x.send('w3s.request') {
|
71
|
+
x.wmid @wmid
|
72
|
+
x.reqn req
|
73
|
+
x.testwmpurse do
|
74
|
+
x.wmid( opt[:wmid] || '' )
|
75
|
+
x.purse( opt[:purse] || '' )
|
76
|
+
end
|
77
|
+
if classic?
|
78
|
+
@plan = "#{opt[:wmid]}#{opt[:purse]}"
|
79
|
+
x.sign sign(@plan)
|
80
|
+
end
|
81
|
+
}
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
def xml_create_transaction(opt)
|
86
|
+
req = reqn()
|
87
|
+
desc = @ic_out.iconv(opt[:desc]) # description
|
88
|
+
Nokogiri::XML::Builder.new( :encoding => 'windows-1251' ) { |x|
|
89
|
+
x.send('w3s.request') {
|
90
|
+
x.reqn req
|
91
|
+
x.wmid(@wmid) if classic?
|
92
|
+
x.sign sign(@plan) if classic?
|
93
|
+
x.trans {
|
94
|
+
x.tranid opt[:transid] # transaction id - unique
|
95
|
+
x.pursesrc opt[:pursesrc] # sender purse
|
96
|
+
x.pursedest opt[:pursedest] # recipient purse
|
97
|
+
x.amount opt[:amount]
|
98
|
+
x.period( opt[:period] || 0 ) # protection period (0 - no protection)
|
99
|
+
x.pcode( opt[:pcode].strip ) if opt[:period] > 0 && opt[:pcode] # protection code
|
100
|
+
x.desc desc
|
101
|
+
x.wminvid( opt[:wminvid] || 0 ) # invoice number (0 - without invoice)
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
85
105
|
end
|
86
106
|
|
87
107
|
end
|
data/lib/webmoney.rb
CHANGED
@@ -7,8 +7,7 @@ require 'net/http'
|
|
7
7
|
require 'net/https'
|
8
8
|
require 'rubygems'
|
9
9
|
require 'iconv'
|
10
|
-
require '
|
11
|
-
require 'hpricot'
|
10
|
+
require 'nokogiri'
|
12
11
|
|
13
12
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
14
13
|
%w(wmsigner wmid passport purse request_xml request_retval request_result messenger).each { |lib| require lib }
|
@@ -31,8 +30,40 @@ module Webmoney
|
|
31
30
|
class NonExistentWmidError < WebmoneyError; end
|
32
31
|
class CaCertificateError < WebmoneyError; end
|
33
32
|
|
34
|
-
attr_reader :wmid, :error, :errormsg, :last_request
|
35
|
-
attr_accessor :
|
33
|
+
attr_reader :wmid, :error, :errormsg, :last_request, :last_response, :interfaces
|
34
|
+
attr_accessor :messenger
|
35
|
+
|
36
|
+
|
37
|
+
# Preset for W3S
|
38
|
+
def w3s_url
|
39
|
+
'https://w3s.wmtransfer.com/asp/'
|
40
|
+
end
|
41
|
+
|
42
|
+
# Presets for interfaces
|
43
|
+
def interface_urls
|
44
|
+
{
|
45
|
+
:create_invoice => w3s_url + 'XMLInvoice.asp', # x1
|
46
|
+
:create_transaction => w3s_url + 'XMLTrans.asp', # x2
|
47
|
+
:operation_history => w3s_url + 'XMLOperations.asp', # x3
|
48
|
+
:outgoing_invoices => w3s_url + 'XMLOutInvoices.asp', # x4
|
49
|
+
:finish_protect => w3s_url + 'XMLFinishProtect.asp', # x5
|
50
|
+
:send_message => w3s_url + 'XMLSendMsg.asp', # x6
|
51
|
+
:check_sign => w3s_url + 'XMLClassicAuth.asp', # x7
|
52
|
+
:find_wm => w3s_url + 'XMLFindWMPurse.asp', # x8
|
53
|
+
:balance => w3s_url + 'XMLPurses.asp', # x9
|
54
|
+
:incoming_invoices => w3s_url + 'XMLInInvoices.asp', # x10
|
55
|
+
:get_passport => 'https://passport.webmoney.ru/asp/XMLGetWMPassport.asp', # x11
|
56
|
+
:reject_protection => w3s_url + 'XMLRejectProtect.asp', # x13
|
57
|
+
:transaction_moneyback => w3s_url + 'XMLTransMoneyback.asp', # x14
|
58
|
+
:i_trust => w3s_url + 'XMLTrustList.asp', # x15
|
59
|
+
:trust_me => w3s_url + 'XMLTrustList2.asp', # x15
|
60
|
+
:trust_save => w3s_url + 'XMLTrustSave2.asp', # x15
|
61
|
+
:create_purse => w3s_url + 'XMLCreatePurse.asp', # x16
|
62
|
+
:create_contract => 'https://arbitrage.webmoney.ru/xml/X17_CreateContract.aspx', # x17
|
63
|
+
:transaction_get => 'https://merchant.webmoney.ru/conf/xml/XMLTransGet.asp', # x18
|
64
|
+
:bussines_level => 'https://stats.wmtransfer.com/levels/XMLWMIDLevel.aspx'
|
65
|
+
}
|
66
|
+
end
|
36
67
|
|
37
68
|
|
38
69
|
# Required options:
|
@@ -52,6 +83,10 @@ module Webmoney
|
|
52
83
|
|
53
84
|
def initialize(opt = {})
|
54
85
|
|
86
|
+
unless check_libxml_version
|
87
|
+
$stderr.puts "WARNING: webmoney lib will not work correctly with nokogori compiled with libxml2 version < 2.7.0"
|
88
|
+
end
|
89
|
+
|
55
90
|
@wmid = Wmid.new(opt[:wmid])
|
56
91
|
|
57
92
|
# classic or light
|
@@ -72,34 +107,12 @@ module Webmoney
|
|
72
107
|
opt[:ca_cert]
|
73
108
|
end
|
74
109
|
|
75
|
-
w3s = 'https://w3s.wmtransfer.com/asp/'
|
76
|
-
|
77
|
-
@interfaces = {
|
78
|
-
'create_invoice' => URI.parse( w3s + 'XMLInvoice.asp' ), # x1
|
79
|
-
'create_transaction' => URI.parse( w3s + 'XMLTrans.asp' ), # x2
|
80
|
-
'operation_history' => URI.parse( w3s + 'XMLOperations.asp' ), # x3
|
81
|
-
'outgoing_invoices' => URI.parse( w3s + 'XMLOutInvoices.asp' ), # x4
|
82
|
-
'finish_protect' => URI.parse( w3s + 'XMLFinishProtect.asp' ), # x5
|
83
|
-
'send_message' => URI.parse( w3s + 'XMLSendMsg.asp'), # x6
|
84
|
-
'check_sign' => URI.parse( w3s + 'XMLClassicAuth.asp'), # x7
|
85
|
-
'find_wm' => URI.parse( w3s + 'XMLFindWMPurse.asp'), # x8
|
86
|
-
'balance' => URI.parse( w3s + 'XMLPurses.asp'), # x9
|
87
|
-
'incoming_invoices' => URI.parse( w3s + 'XMLInInvoices.asp'), # x10
|
88
|
-
'get_passport' => URI.parse( 'https://passport.webmoney.ru/asp/XMLGetWMPassport.asp'), # x11
|
89
|
-
'reject_protection' => URI.parse( w3s + 'XMLRejectProtect.asp'), # x13
|
90
|
-
'transaction_moneyback' => URI.parse( w3s + 'XMLTransMoneyback.asp'), # x14
|
91
|
-
'i_trust' => URI.parse( w3s + 'XMLTrustList.asp'), # x15
|
92
|
-
'trust_me' => URI.parse( w3s + 'XMLTrustList2.asp'), # x15
|
93
|
-
'trust_save' => URI.parse( w3s + 'XMLTrustSave2.asp'), # x15
|
94
|
-
'create_purse' => URI.parse( w3s + 'XMLCreatePurse.asp'), # x16
|
95
|
-
'create_contract' => URI.parse( 'https://arbitrage.webmoney.ru/xml/X17_CreateContract.aspx'), # x17
|
96
|
-
'transaction_get' => URI.parse( 'https://merchant.webmoney.ru/conf/xml/XMLTransGet.asp'), # x18
|
97
|
-
'bussines_level' => URI.parse( 'https://stats.wmtransfer.com/levels/XMLWMIDLevel.aspx')
|
98
|
-
}
|
99
110
|
# Iconv.new(to, from)
|
100
111
|
@ic_in = Iconv.new('UTF-8', 'CP1251')
|
101
112
|
@ic_out = Iconv.new('CP1251', 'UTF-8')
|
102
113
|
|
114
|
+
prepare_interface_urls
|
115
|
+
|
103
116
|
# initialize workers by self
|
104
117
|
Purse.worker = self
|
105
118
|
Passport.worker = self
|
@@ -138,7 +151,7 @@ module Webmoney
|
|
138
151
|
res = https_request(iface, make_xml(iface, opt))
|
139
152
|
|
140
153
|
# Parse response
|
141
|
-
doc =
|
154
|
+
doc = Nokogiri::XML(res)
|
142
155
|
parse_retval(iface, doc)
|
143
156
|
make_result(iface, doc)
|
144
157
|
end
|
@@ -152,15 +165,25 @@ module Webmoney
|
|
152
165
|
|
153
166
|
protected
|
154
167
|
|
168
|
+
def prepare_interface_urls
|
169
|
+
@interfaces = interface_urls.inject({}) do |m,k|
|
170
|
+
url = k[1]
|
171
|
+
url.sub!(/(\.asp)/, 'Cert.asp') if !classic? && url.match("^"+w3s_url)
|
172
|
+
m.merge!(k[0] => URI.parse(url))
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
155
176
|
# Make HTTPS request, return result body if 200 OK
|
156
177
|
|
157
178
|
def https_request(iface, xml)
|
179
|
+
@last_request = @last_response = nil
|
158
180
|
url = case iface
|
159
181
|
when Symbol
|
160
|
-
@interfaces[iface
|
182
|
+
@interfaces[iface]
|
161
183
|
when String
|
162
184
|
URI.parse(iface)
|
163
185
|
end
|
186
|
+
raise ArgumentError, iface unless url
|
164
187
|
http = Net::HTTP.new(url.host, url.port)
|
165
188
|
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
166
189
|
if File.file? @ca_cert
|
@@ -172,12 +195,10 @@ module Webmoney
|
|
172
195
|
end
|
173
196
|
http.use_ssl = true
|
174
197
|
@last_request = xml
|
175
|
-
result = http.post( url.path, xml, "Content-Type" => "text/xml" )
|
198
|
+
@last_response = result = http.post( url.path, xml, "Content-Type" => "text/xml" )
|
176
199
|
case result
|
177
200
|
when Net::HTTPSuccess
|
178
|
-
|
179
|
-
res = result.body.gsub(/(w3s\.response|WMIDLevel\.response)/,'w3s_response')
|
180
|
-
return @ic_in.iconv(res)
|
201
|
+
result.body
|
181
202
|
else
|
182
203
|
@error = result.code
|
183
204
|
@errormsg = result.body if result.class.body_permitted?()
|
@@ -195,7 +216,7 @@ module Webmoney
|
|
195
216
|
|
196
217
|
def make_xml(iface, opt) # :nodoc:
|
197
218
|
iface_func = "xml_#{iface}"
|
198
|
-
send(iface_func, opt).
|
219
|
+
send(iface_func, opt).to_xml
|
199
220
|
end
|
200
221
|
|
201
222
|
def parse_retval(iface, doc) # :nodoc:
|
@@ -212,4 +233,12 @@ module Webmoney
|
|
212
233
|
send(iface_result, doc)
|
213
234
|
end
|
214
235
|
|
236
|
+
def check_libxml_version
|
237
|
+
libxml = Nokogiri::VERSION_INFO['libxml']
|
238
|
+
[libxml['compiled'], libxml['loaded']].each do |ver|
|
239
|
+
major, minor = ver.match(/^(\d+)\.(\d+).*/).to_a[1,2].map(&:to_i)
|
240
|
+
return false if major < 2 or minor < 7
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
215
244
|
end
|
data/rakefile
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
3
|
require 'rake/clean'
|
4
|
-
|
4
|
+
begin
|
5
|
+
require 'rake/extensiontask'
|
6
|
+
rescue LoadError
|
7
|
+
puts "Rake-compiler not available. Install it with: sudo gem install rake-compiler"
|
8
|
+
exit 1
|
9
|
+
end
|
5
10
|
require 'spec/rake/spectask'
|
6
11
|
|
7
|
-
|
8
|
-
|
9
|
-
setup_extension('wmsigner', 'wmsigner')
|
12
|
+
CLEAN.include ["ext/wmsigner/*.{so,o}", "ext/wmsigner/Makefile", "lib/wmsigner.so", "pkg", "tmp"]
|
10
13
|
|
11
|
-
|
12
|
-
task :compile => [:wmsigner]
|
13
|
-
|
14
|
-
task :default => [:compile, :spec]
|
14
|
+
Rake::ExtensionTask.new('wmsigner')
|
15
15
|
|
16
16
|
Spec::Rake::SpecTask.new do |task|
|
17
17
|
task.libs << 'spec'
|
@@ -19,32 +19,28 @@ Spec::Rake::SpecTask.new do |task|
|
|
19
19
|
task.verbose = true
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
gemspec.files += []
|
43
|
-
else
|
44
|
-
gemspec.platform = Gem::Platform::RUBY
|
45
|
-
gemspec.extensions = Dir.glob( 'ext/**/extconf.rb' )
|
22
|
+
spec = begin
|
23
|
+
require 'jeweler'
|
24
|
+
Jeweler::Tasks.new do |gemspec|
|
25
|
+
gemspec.name = "webmoney"
|
26
|
+
gemspec.rubyforge_project = 'webmoney'
|
27
|
+
gemspec.authors = ["Alexander Oryol"]
|
28
|
+
gemspec.email = "eagle.alex@gmail.com"
|
29
|
+
gemspec.summary = "Webmoney interfaces and native wmsigner"
|
30
|
+
gemspec.add_dependency('nokogiri')
|
31
|
+
gemspec.files << %w( rakefile ChangeLog lib/WebMoneyCA.crt ) +
|
32
|
+
Dir.glob( 'ext/**/*.{h,cpp,rb}' ) +
|
33
|
+
Dir.glob( 'tools/*.rb' )
|
34
|
+
|
35
|
+
if RUBY_PLATFORM.match("win32")
|
36
|
+
gemspec.platform = Gem::Platform::WIN32
|
37
|
+
gemspec.files += []
|
38
|
+
else
|
39
|
+
gemspec.platform = Gem::Platform::RUBY
|
40
|
+
gemspec.extensions = Dir.glob( 'ext/**/extconf.rb' )
|
41
|
+
end
|
46
42
|
end
|
47
|
-
end
|
48
|
-
|
49
|
-
CLEAN.include ["ext/wmsigner/*.{so,o}", "ext/wmsigner/Makefile", "lib/wmsigner.so", "pkg", "*.gem"]
|
50
43
|
|
44
|
+
rescue LoadError
|
45
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler -s http://gemcutter.org"
|
46
|
+
end
|
data/spec/spec
ADDED
data/spec/spec_helper.rb
CHANGED
data/spec/unit/passport_spec.rb
CHANGED
@@ -12,16 +12,102 @@ module Webmoney
|
|
12
12
|
Passport.new(@wm.wmid).should be_instance_of(Passport)
|
13
13
|
end
|
14
14
|
|
15
|
-
it "request result get_passport should be
|
16
|
-
|
15
|
+
it "request result get_passport should be hash with data" do
|
16
|
+
wmid = '000000000007'
|
17
|
+
created_at = Time.at(1077735241.37)
|
18
|
+
res = @wm.request(:get_passport, :wmid => wmid, :dict => 1)
|
19
|
+
res[:full_access].should be_false
|
20
|
+
res[:wmids].should == {
|
21
|
+
wmid => { :created_at=>Time.at(1077733193.353) }
|
22
|
+
}
|
23
|
+
res[:attestat].should == {
|
24
|
+
:regcid=>"10",
|
25
|
+
:locked=>"1",
|
26
|
+
:recalled=>"0",
|
27
|
+
:cid=>"103453",
|
28
|
+
:admlocked=>"0",
|
29
|
+
:created_at=>created_at,
|
30
|
+
:datecrt=>"2004-02-25T21:54:01.370",
|
31
|
+
:regnickname=>"WM Passport Service /Центр аттестации/",
|
32
|
+
:regwmid=>"464889785562",
|
33
|
+
:attestat=>150,
|
34
|
+
:tid=>"150",
|
35
|
+
:datediff=>(Date.today - created_at.send(:to_date)).to_s
|
36
|
+
}
|
37
|
+
|
38
|
+
u_info = {
|
39
|
+
:locked=>"0",
|
40
|
+
:ctype=>"1",
|
41
|
+
:citid=>"12918",
|
42
|
+
:cap_owner=>"0",
|
43
|
+
:region=>"Москва",
|
44
|
+
:countryid=>"195",
|
45
|
+
:city=>"Москва",
|
46
|
+
:pasdoc=>"0",
|
47
|
+
:nickname=>"Арбитр",
|
48
|
+
:country=>"Россия",
|
49
|
+
:inndoc=>"0",
|
50
|
+
:email=>"", :pdateMMDDYYYY => "", :pday => "", :pmonth => "", :pyear => "",
|
51
|
+
:iname=>"", :inn=>"", :okonx=>"", :bik=>"", :pbywhom=>"", :phonemobile=>"", :rcountry=>"",
|
52
|
+
:bmonth=>"", :jadres=>"", :okpo=>"", :bday=>"", :pnomer=>"", :bankname=>"", :pcountry=>"", :pcountryid=>"",
|
53
|
+
:jcountryid=>"", :ks=>"", :infoopen=>"", :icq=>"", :byear=>"", :oname=>"", :osnovainfo=>"", :dirfio=>"",
|
54
|
+
:pdate=>"", :bplace=>"", :rs=>"", :rcity=>"", :adres=>"", :phone=>"", :buhfio=>"", :radres=>"", :fname=>"",
|
55
|
+
:phonehome=>"", :jcity=>"", :name=>"", :pcity=>"", :jstatus=>"", :fax=>"", :zipcode=>"", :rcountryid=>"",
|
56
|
+
:web=>"", :jzipcode=>"", :jcountry=>""
|
57
|
+
}
|
58
|
+
|
59
|
+
# a1 = res[:userinfo].keys.map(&:to_s).sort
|
60
|
+
# a2 = u_info.keys.map(&:to_s).sort
|
61
|
+
# puts ((a1|a2) - (a1 & a2)).inspect
|
62
|
+
|
63
|
+
res[:userinfo].should == u_info
|
64
|
+
|
65
|
+
res[:directory].should == {
|
66
|
+
:ctype=>{
|
67
|
+
1=>"Частное лицо",
|
68
|
+
2=>"Юридическое лицо"
|
69
|
+
},
|
70
|
+
:jstatus=>{
|
71
|
+
20=>"Директор юридического лица",
|
72
|
+
21=>"Бухгалтер юридического лица",
|
73
|
+
22=>"Представитель юридического лица",
|
74
|
+
23=>"ИП"
|
75
|
+
},
|
76
|
+
:types=>{
|
77
|
+
100=>"Аттестат псевдонима",
|
78
|
+
110=>"Формальный аттестат",
|
79
|
+
120=>"Начальный аттестат",
|
80
|
+
130=>"Персональный аттестат",
|
81
|
+
135=>"Аттестат продавца",
|
82
|
+
136=>"Аттестат Capitaller",
|
83
|
+
140=>"Аттестат разработчика",
|
84
|
+
150=>"Аттестат регистратора",
|
85
|
+
170=>"Аттестат Гаранта",
|
86
|
+
190=>"Аттестат сервиса WMT",
|
87
|
+
200=>"Аттестат сервиса WMT",
|
88
|
+
300=>"Аттестат Оператора"
|
89
|
+
}
|
90
|
+
}
|
17
91
|
end
|
18
|
-
|
19
|
-
it "should return
|
92
|
+
|
93
|
+
it "should return userinfo attributes with checked/locked" do
|
94
|
+
wmid = '000000000007'
|
95
|
+
p = Passport.new(wmid)
|
96
|
+
p.userinfo[:adres].should be_empty
|
97
|
+
p.userinfo[:adres].checked.should be_true
|
98
|
+
p.userinfo[:adres].locked.should be_true
|
99
|
+
p.userinfo[:inn].should be_empty
|
100
|
+
p.userinfo[:inn].checked.should be_false
|
101
|
+
p.userinfo[:inn].locked.should be_true
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should return correct fields" do
|
20
105
|
wmid = '000000000007'
|
21
106
|
p = Passport.new(wmid)
|
22
107
|
p.wmid.should == wmid
|
23
108
|
p.attestat[:attestat].should == Webmoney::Passport::REGISTRATOR
|
24
109
|
p.attestat[:created_at].strftime('%Y-%m-%d %H:%M:%S').should == '2004-02-25 21:54:01'
|
110
|
+
p.full_access.should be_false
|
25
111
|
|
26
112
|
wmid = '370860915669'
|
27
113
|
p = Passport.new(wmid)
|
@@ -35,6 +121,7 @@ module Webmoney
|
|
35
121
|
end
|
36
122
|
|
37
123
|
it "should raise exception on non existent WMID" do
|
124
|
+
@wm.stub!(:http_request).and_return("<?xml version='1.0' encoding='windows-1251'?><response retval='0'><fullaccess>0</fullaccess><certinfo wmid='012345678901'/><retdesc>WMID not found</retdesc></response>")
|
38
125
|
lambda {@wm.request(:get_passport, :wmid => '012345678901')}.should raise_error(Webmoney::NonExistentWmidError)
|
39
126
|
end
|
40
127
|
|
data/spec/unit/webmoney_spec.rb
CHANGED
@@ -9,7 +9,7 @@ module Webmoney
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should be classic" do
|
12
|
-
@wm.
|
12
|
+
@wm.should be_classic # @wm.classic? == true
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should return reqn" do
|
@@ -20,6 +20,16 @@ module Webmoney
|
|
20
20
|
(t2 > t1).should be_true
|
21
21
|
end
|
22
22
|
|
23
|
+
it "should correct prepare interfaces urls" do
|
24
|
+
wm = TestWM.new :wmid => WmConfig.wmid
|
25
|
+
wm.should_not be_classic
|
26
|
+
wm.interfaces[:balance].class.should == URI::HTTPS
|
27
|
+
# converted to light-auth version
|
28
|
+
wm.interfaces[:balance].to_s.should == 'https://w3s.wmtransfer.com/asp/XMLPursesCert.asp'
|
29
|
+
# non-converted to light-auth version
|
30
|
+
wm.interfaces[:get_passport].to_s.should == 'https://passport.webmoney.ru/asp/XMLGetWMPassport.asp'
|
31
|
+
end
|
32
|
+
|
23
33
|
it "should correct reqn" do
|
24
34
|
Time.stub!(:now).and_return(Time.at(1244704683.69677))
|
25
35
|
@wm.send(:reqn).should == '2009061111180369'
|
@@ -36,9 +46,8 @@ module Webmoney
|
|
36
46
|
end
|
37
47
|
|
38
48
|
it "should send request" do
|
39
|
-
|
40
|
-
doc
|
41
|
-
doc.at('w3s_response').should_not be_nil
|
49
|
+
doc = Nokogiri.XML(@wm.send(:https_request, :check_sign, '<w3s.request/>'))
|
50
|
+
doc.root.should_not be_nil
|
42
51
|
end
|
43
52
|
|
44
53
|
it"should raise error on bad response" do
|
@@ -80,9 +89,13 @@ module Webmoney
|
|
80
89
|
it "should check_sign with specials" do
|
81
90
|
plan = '<test>текст</test>'
|
82
91
|
real_plan = Iconv.conv('CP1251', 'UTF-8', plan)
|
83
|
-
|
84
|
-
|
85
|
-
|
92
|
+
begin
|
93
|
+
@wm.request(:check_sign,
|
94
|
+
:wmid => @wm.wmid,
|
95
|
+
:plan => plan,
|
96
|
+
:sign => @wm.send(:sign, real_plan )
|
97
|
+
).should be_true
|
98
|
+
end
|
86
99
|
end
|
87
100
|
|
88
101
|
it "should parse retval and raise error on broken get_passport" do
|
@@ -117,7 +130,11 @@ module Webmoney
|
|
117
130
|
result[:id].should match(/^\d*$/)
|
118
131
|
((result[:date] + 60) > Time.now).should be_true
|
119
132
|
end
|
120
|
-
|
133
|
+
|
134
|
+
it "should create transaction" do
|
135
|
+
# TODO @wm.request( :create_transaction, ...)
|
136
|
+
end
|
137
|
+
|
121
138
|
it "should raise error on undefined xml func" do
|
122
139
|
lambda { @wm.request(:unexistent_interface) }.should raise_error(::NoMethodError)
|
123
140
|
end
|
data/webmoney.gemspec
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{webmoney}
|
8
|
+
s.version = "0.0.5"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Alexander Oryol"]
|
12
|
+
s.date = %q{2010-02-12}
|
13
|
+
s.email = %q{eagle.alex@gmail.com}
|
14
|
+
s.extensions = ["ext/wmsigner/extconf.rb"]
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"ChangeLog",
|
17
|
+
"README"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".gitignore",
|
21
|
+
"ChangeLog",
|
22
|
+
"README",
|
23
|
+
"RUNNING_TESTS",
|
24
|
+
"VERSION",
|
25
|
+
"ext/wmsigner/base64.cpp",
|
26
|
+
"ext/wmsigner/base64.h",
|
27
|
+
"ext/wmsigner/cmdbase.cpp",
|
28
|
+
"ext/wmsigner/cmdbase.h",
|
29
|
+
"ext/wmsigner/crypto.cpp",
|
30
|
+
"ext/wmsigner/crypto.h",
|
31
|
+
"ext/wmsigner/extconf.rb",
|
32
|
+
"ext/wmsigner/md4.cpp",
|
33
|
+
"ext/wmsigner/md4.h",
|
34
|
+
"ext/wmsigner/rsalib1.cpp",
|
35
|
+
"ext/wmsigner/rsalib1.h",
|
36
|
+
"ext/wmsigner/signer.cpp",
|
37
|
+
"ext/wmsigner/signer.h",
|
38
|
+
"ext/wmsigner/stdafx.cpp",
|
39
|
+
"ext/wmsigner/stdafx.h",
|
40
|
+
"ext/wmsigner/wmsigner.cpp",
|
41
|
+
"lib/certs/02a6c417.0",
|
42
|
+
"lib/certs/3c58f906.0",
|
43
|
+
"lib/certs/AddTrust_External_Root.crt",
|
44
|
+
"lib/certs/WebMoneyCA.crt",
|
45
|
+
"lib/messenger.rb",
|
46
|
+
"lib/passport.rb",
|
47
|
+
"lib/purse.rb",
|
48
|
+
"lib/request_result.rb",
|
49
|
+
"lib/request_retval.rb",
|
50
|
+
"lib/request_xml.rb",
|
51
|
+
"lib/webmoney.rb",
|
52
|
+
"lib/wmid.rb",
|
53
|
+
"rakefile",
|
54
|
+
"spec/spec",
|
55
|
+
"spec/spec_helper.rb",
|
56
|
+
"spec/unit/messenger_spec.rb",
|
57
|
+
"spec/unit/passport_spec.rb",
|
58
|
+
"spec/unit/purse_spec.rb",
|
59
|
+
"spec/unit/signer_spec.rb",
|
60
|
+
"spec/unit/time_spec.rb",
|
61
|
+
"spec/unit/webmoney_spec.rb",
|
62
|
+
"spec/unit/wmid_spec.rb",
|
63
|
+
"webmoney.gemspec"
|
64
|
+
]
|
65
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
66
|
+
s.require_paths = ["lib"]
|
67
|
+
s.rubyforge_project = %q{webmoney}
|
68
|
+
s.rubygems_version = %q{1.3.5}
|
69
|
+
s.summary = %q{Webmoney interfaces and native wmsigner}
|
70
|
+
s.test_files = [
|
71
|
+
"spec/unit/time_spec.rb",
|
72
|
+
"spec/unit/purse_spec.rb",
|
73
|
+
"spec/unit/signer_spec.rb",
|
74
|
+
"spec/unit/messenger_spec.rb",
|
75
|
+
"spec/unit/passport_spec.rb",
|
76
|
+
"spec/unit/webmoney_spec.rb",
|
77
|
+
"spec/unit/wmid_spec.rb",
|
78
|
+
"spec/spec_helper.rb"
|
79
|
+
]
|
80
|
+
|
81
|
+
if s.respond_to? :specification_version then
|
82
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
83
|
+
s.specification_version = 3
|
84
|
+
|
85
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
86
|
+
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
87
|
+
else
|
88
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
89
|
+
end
|
90
|
+
else
|
91
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webmoney
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Oryol
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-02-12 00:00:00 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: nokogiri
|
17
17
|
type: :runtime
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -22,21 +22,7 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: "0"
|
24
24
|
version:
|
25
|
-
|
26
|
-
name: builder
|
27
|
-
type: :runtime
|
28
|
-
version_requirement:
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: "0"
|
34
|
-
version:
|
35
|
-
description: |
|
36
|
-
This library should help to make requests to WebMoney Transfer http://www.wmtransfer.com
|
37
|
-
XML-interfaces: http://www.wmtransfer.com/eng/developers/interfaces/index.shtml
|
38
|
-
Gem have built-in native wmsigner tool.
|
39
|
-
|
25
|
+
description:
|
40
26
|
email: eagle.alex@gmail.com
|
41
27
|
executables: []
|
42
28
|
|
@@ -46,28 +32,18 @@ extra_rdoc_files:
|
|
46
32
|
- ChangeLog
|
47
33
|
- README
|
48
34
|
files:
|
49
|
-
-
|
35
|
+
- .gitignore
|
50
36
|
- ChangeLog
|
51
37
|
- README
|
52
|
-
-
|
53
|
-
-
|
54
|
-
- lib/certs/AddTrust_External_Root.crt
|
55
|
-
- lib/certs/WebMoneyCA.crt
|
56
|
-
- lib/messenger.rb
|
57
|
-
- lib/request_result.rb
|
58
|
-
- lib/request_retval.rb
|
59
|
-
- lib/request_xml.rb
|
60
|
-
- lib/passport.rb
|
61
|
-
- lib/purse.rb
|
62
|
-
- lib/webmoney.rb
|
63
|
-
- lib/wmid.rb
|
64
|
-
- ext/wmsigner/extconf.rb
|
38
|
+
- RUNNING_TESTS
|
39
|
+
- VERSION
|
65
40
|
- ext/wmsigner/base64.cpp
|
66
41
|
- ext/wmsigner/base64.h
|
67
42
|
- ext/wmsigner/cmdbase.cpp
|
68
43
|
- ext/wmsigner/cmdbase.h
|
69
44
|
- ext/wmsigner/crypto.cpp
|
70
45
|
- ext/wmsigner/crypto.h
|
46
|
+
- ext/wmsigner/extconf.rb
|
71
47
|
- ext/wmsigner/md4.cpp
|
72
48
|
- ext/wmsigner/md4.h
|
73
49
|
- ext/wmsigner/rsalib1.cpp
|
@@ -77,14 +53,36 @@ files:
|
|
77
53
|
- ext/wmsigner/stdafx.cpp
|
78
54
|
- ext/wmsigner/stdafx.h
|
79
55
|
- ext/wmsigner/wmsigner.cpp
|
80
|
-
-
|
56
|
+
- lib/certs/02a6c417.0
|
57
|
+
- lib/certs/3c58f906.0
|
58
|
+
- lib/certs/AddTrust_External_Root.crt
|
59
|
+
- lib/certs/WebMoneyCA.crt
|
60
|
+
- lib/messenger.rb
|
61
|
+
- lib/passport.rb
|
62
|
+
- lib/purse.rb
|
63
|
+
- lib/request_result.rb
|
64
|
+
- lib/request_retval.rb
|
65
|
+
- lib/request_xml.rb
|
66
|
+
- lib/webmoney.rb
|
67
|
+
- lib/wmid.rb
|
68
|
+
- rakefile
|
69
|
+
- spec/spec
|
70
|
+
- spec/spec_helper.rb
|
71
|
+
- spec/unit/messenger_spec.rb
|
72
|
+
- spec/unit/passport_spec.rb
|
73
|
+
- spec/unit/purse_spec.rb
|
74
|
+
- spec/unit/signer_spec.rb
|
75
|
+
- spec/unit/time_spec.rb
|
76
|
+
- spec/unit/webmoney_spec.rb
|
77
|
+
- spec/unit/wmid_spec.rb
|
78
|
+
- webmoney.gemspec
|
81
79
|
has_rdoc: true
|
82
|
-
homepage:
|
80
|
+
homepage:
|
83
81
|
licenses: []
|
84
82
|
|
85
83
|
post_install_message:
|
86
|
-
rdoc_options:
|
87
|
-
|
84
|
+
rdoc_options:
|
85
|
+
- --charset=UTF-8
|
88
86
|
require_paths:
|
89
87
|
- lib
|
90
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -102,16 +100,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
100
|
requirements: []
|
103
101
|
|
104
102
|
rubyforge_project: webmoney
|
105
|
-
rubygems_version: 1.3.
|
103
|
+
rubygems_version: 1.3.5
|
106
104
|
signing_key:
|
107
105
|
specification_version: 3
|
108
106
|
summary: Webmoney interfaces and native wmsigner
|
109
107
|
test_files:
|
110
|
-
- spec/
|
111
|
-
- spec/unit/messenger_spec.rb
|
112
|
-
- spec/unit/passport_spec.rb
|
108
|
+
- spec/unit/time_spec.rb
|
113
109
|
- spec/unit/purse_spec.rb
|
114
110
|
- spec/unit/signer_spec.rb
|
115
|
-
- spec/unit/
|
111
|
+
- spec/unit/messenger_spec.rb
|
112
|
+
- spec/unit/passport_spec.rb
|
116
113
|
- spec/unit/webmoney_spec.rb
|
117
114
|
- spec/unit/wmid_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
data/tools/rakehelp.rb
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
def make(makedir)
|
2
|
-
Dir.chdir(makedir) do
|
3
|
-
sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
|
8
|
-
def extconf(dir)
|
9
|
-
Dir.chdir(dir) do ruby "extconf.rb" end
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
def setup_tests
|
14
|
-
Rake::TestTask.new do |t|
|
15
|
-
t.libs << "test"
|
16
|
-
t.test_files = FileList['test/test*.rb']
|
17
|
-
t.verbose = true
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
def setup_clean otherfiles
|
23
|
-
files = ['build/*', '**/*.o', '**/*.so', '**/*.a', 'lib/*-*', '**/*.log'] + otherfiles
|
24
|
-
CLEAN.include(files)
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
def setup_rdoc files
|
29
|
-
Rake::RDocTask.new do |rdoc|
|
30
|
-
rdoc.rdoc_dir = 'doc/rdoc'
|
31
|
-
rdoc.options << '--line-numbers'
|
32
|
-
rdoc.rdoc_files.add(files)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
def setup_extension(dir, extension)
|
38
|
-
ext = "ext/#{dir}"
|
39
|
-
ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
|
40
|
-
ext_files = FileList[
|
41
|
-
"#{ext}/*.cpp",
|
42
|
-
"#{ext}/*.h",
|
43
|
-
"#{ext}/extconf.rb",
|
44
|
-
"#{ext}/Makefile",
|
45
|
-
"lib"
|
46
|
-
]
|
47
|
-
|
48
|
-
task "lib" do
|
49
|
-
directory "lib"
|
50
|
-
end
|
51
|
-
|
52
|
-
desc "Builds just the #{extension} extension"
|
53
|
-
task extension.to_sym => ["#{ext}/Makefile", ext_so ]
|
54
|
-
|
55
|
-
file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
|
56
|
-
extconf "#{ext}"
|
57
|
-
end
|
58
|
-
|
59
|
-
file ext_so => ext_files do
|
60
|
-
make "#{ext}"
|
61
|
-
cp ext_so, "lib"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
|
-
def base_gem_spec(pkg_name, pkg_version)
|
67
|
-
rm_rf "test/coverage"
|
68
|
-
pkg_version = pkg_version
|
69
|
-
pkg_name = pkg_name
|
70
|
-
pkg_file_name = "#{pkg_name}-#{pkg_version}"
|
71
|
-
Gem::Specification.new do |s|
|
72
|
-
s.name = pkg_name
|
73
|
-
s.version = pkg_version
|
74
|
-
s.platform = Gem::Platform::RUBY
|
75
|
-
s.has_rdoc = true
|
76
|
-
s.extra_rdoc_files = [ "README" ]
|
77
|
-
|
78
|
-
s.files = %w(COPYING LICENSE README Rakefile) +
|
79
|
-
Dir.glob("{bin,doc/rdoc,test}/**/*") +
|
80
|
-
Dir.glob("ext/**/*.{h,cpp,rb,rl}") +
|
81
|
-
Dir.glob("{examples,tools,lib}/**/*.rb")
|
82
|
-
|
83
|
-
s.require_path = "lib"
|
84
|
-
s.extensions = FileList["ext/**/extconf.rb"].to_a
|
85
|
-
s.bindir = "bin"
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def setup_gem(pkg_name, pkg_version)
|
90
|
-
spec = base_gem_spec(pkg_name, pkg_version)
|
91
|
-
yield spec if block_given?
|
92
|
-
|
93
|
-
Rake::GemPackageTask.new(spec) do |p|
|
94
|
-
p.gem_spec = spec
|
95
|
-
p.need_tar = true if RUBY_PLATFORM !~ /mswin/
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def sub_project(project, *targets)
|
100
|
-
targets.each do |target|
|
101
|
-
Dir.chdir "projects/#{project}" do
|
102
|
-
sh %{rake --trace #{target.to_s} }
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
# Conditional require rcov/rcovtask if present
|
108
|
-
begin
|
109
|
-
require 'rcov/rcovtask'
|
110
|
-
|
111
|
-
Rcov::RcovTask.new do |t|
|
112
|
-
t.test_files = FileList['test/test*.rb']
|
113
|
-
t.rcov_opts << "-x /usr"
|
114
|
-
t.output_dir = "test/coverage"
|
115
|
-
end
|
116
|
-
rescue Object
|
117
|
-
end
|