webmoney 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,5 +1,10 @@
1
1
  ChangeLog
2
2
 
3
+ Tue Arp 26 2011 16:31:00 +0400
4
+ ----------------------------
5
+ V 0.0.12
6
+ * Fix compile on gcc-4.5 under mingw (unnecessary macros removed)
7
+
3
8
  Fri Feb 18 2011 18:30:00 +0300
4
9
  ----------------------------
5
10
  V 0.0.11
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.11
1
+ 0.0.12
@@ -10,18 +10,12 @@
10
10
  #include <sys/types.h>
11
11
  #include <sys/stat.h>
12
12
  #include <errno.h>
13
- #define __open _open
14
- #define __read _read
15
- #define __close _close
16
13
  #else
17
14
  #include <sys/types.h>
18
15
  #include <sys/stat.h>
19
16
  #include <sys/uio.h>
20
17
  #include <unistd.h>
21
18
  #include <errno.h>
22
- #define __open open
23
- #define __read read
24
- #define __close close
25
19
  #endif
26
20
 
27
21
  #ifndef TRUE
@@ -115,9 +109,9 @@ int Signer::LoadKeys()
115
109
 
116
110
  if( (!isIgnoreKeyFile) && (Key64Flag == FALSE) ) {
117
111
  #ifdef O_BINARY
118
- fh = __open( m_szKeyFileName, O_RDONLY | O_BINARY);
112
+ fh = open( m_szKeyFileName, O_RDONLY | O_BINARY);
119
113
  #else
120
- fh = __open( m_szKeyFileName, O_RDONLY);
114
+ fh = open( m_szKeyFileName, O_RDONLY);
121
115
  #endif
122
116
 
123
117
  if( fh == -1 )
@@ -131,10 +125,10 @@ if( (!isIgnoreKeyFile) && (Key64Flag == FALSE) ) {
131
125
  if (st_size == lMinKeyFileSize)
132
126
  {
133
127
  // load 164 bytes from "small" keys file
134
- nReaden = __read( fh, pBufRead, nMaxBufLen );
128
+ nReaden = read( fh, pBufRead, nMaxBufLen );
135
129
  bKeysReaded = (nReaden == lMinKeyFileSize);
136
130
  }
137
- __close( fh );
131
+ close( fh );
138
132
  }
139
133
  else {
140
134
  bKeysReaded = true;
@@ -32,12 +32,12 @@ module Webmoney::RequestResult # :nodoc:all
32
32
  res = {
33
33
  :retval => doc.at('//retval').inner_html.to_i,
34
34
  :retdesc => (doc.at('//testwmpurse/retdesc').inner_html rescue nil),
35
- :orderid => (doc.at('//invoice/orderid').inner_html.to_i),
35
+ :orderid => doc.at('//invoice/orderid').inner_html.to_i
36
36
  }
37
37
  if res[:retval] == 0
38
- res[:id] = (doc.at('//invoice').attributes['id'].value.to_i)
39
- res[:ts] = (doc.at('//invoice').attributes['ts'].value.to_i)
40
- res[:state] = (doc.at('//invoice/state').inner_html.to_i)
38
+ res[:id] = doc.at('//invoice')['id'].to_i
39
+ res[:ts] = doc.at('//invoice')['ts'].to_i
40
+ res[:state] = doc.at('//invoice/state').inner_html.to_i
41
41
  res[:created_at] = Time.parse(doc.at('//invoice/datecrt').inner_html)
42
42
  end
43
43
  res
@@ -58,22 +58,21 @@ module Webmoney::RequestResult # :nodoc:all
58
58
  :retval => doc.at('//retval').inner_html.to_i,
59
59
  :retdesc => (doc.at('//testwmpurse/retdesc').inner_html rescue nil),
60
60
  }
61
- if res[:retval] == 0
62
- res[:invoices] = doc.at('//outinvoices').elements.collect do |invoice|
63
- r = {
64
- :id => invoice.attributes['id'].value.to_i,
65
- :ts => invoice.attributes['ts'].value.to_i,
66
- }
67
- invoice.elements.each do |tag|
68
- name = tag.name.to_sym
69
- value = tag.inner_html
70
- value = value.to_i if [:orderid, :tranid, :period, :expiration, :wmtranid, :state].include?(name)
71
- value = value.to_f if [:rest, :amount, :comiss].include?(name)
72
- value = Time.parse(value) if [:datecrt, :dateupd].include?(name)
73
- r[name] = value
74
- end
75
- r
61
+ res[:invoices] = doc.xpath('//outinvoices/outinvoice').map do |invoice|
62
+ r = {
63
+ :id => invoice['id'].to_i,
64
+ :ts => invoice['ts'].to_i,
65
+ }
66
+ invoice.elements.each do |tag|
67
+ name = tag.name.to_sym
68
+ value = tag.inner_html
69
+ value = value.to_i if [:orderid, :tranid, :period, :expiration, :wmtranid, :state].include?(name)
70
+ value = value.to_f if [:rest, :amount, :comiss].include?(name)
71
+ value = Time.parse(value) if [:datecrt, :dateupd].include?(name)
72
+ value = @ic_in.iconv(value) if [:desc, :address].include?(name)
73
+ r[name] = value
76
74
  end
75
+ r
77
76
  end
78
77
  res
79
78
  end
@@ -115,7 +115,7 @@ module Webmoney::RequestXML # :nodoc:all
115
115
  x.period( opt[:period] || 0 ) # protection period (0 - no protection)
116
116
  x.pcode( pcode ) if pcode # protection code
117
117
  x.desc desc_in
118
- x.wminvid( wminvid ) # invoice number (0 - without invoice)
118
+ x.wminvid( opt[:wminvid] || 0 ) # invoice number (0 - without invoice)
119
119
  }
120
120
  }
121
121
  }
@@ -86,10 +86,10 @@ module Webmoney
86
86
  # when uncovertable character in input sequence. It is default behavior.
87
87
  # With option :force_encoding Iconv initialized with //IGNORE option, and
88
88
  # uncovertable characters will be cutted.
89
+ @ic_in = Iconv.new('UTF-8', 'CP1251')
89
90
  if opt[:force_encoding]
90
91
  #Iconv.new(to, from)
91
92
  @ic_out = Iconv.new('CP1251//IGNORE', 'UTF-8')
92
- @ic_in = Iconv.new('UTF-8', 'CP1251')
93
93
  instance_eval do
94
94
  def filter_str(str)
95
95
  str_out = @ic_out.iconv(str)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 11
9
- version: 0.0.11
8
+ - 12
9
+ version: 0.0.12
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alexander Oryol
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-18 00:00:00 +03:00
17
+ date: 2011-04-26 00:00:00 +04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency