eport 0.0.1.2 → 0.0.2

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.
@@ -6,7 +6,7 @@ class CatalogParser
6
6
  end
7
7
 
8
8
 
9
- ITEM_SEPARATOR = "\r\n"
9
+ ITEM_SEPARATOR = "\r\n"
10
10
  VALUE_SEPARATOR = "\t"
11
11
 
12
12
  VALUES = {:x => [:version, :prev_version, :form_date, :money],
@@ -17,16 +17,14 @@ class CatalogParser
17
17
 
18
18
  def new_catalog(data)
19
19
  ic = Iconv.new('UTF-8', 'WINDOWS-1251')
20
-
21
20
  strings = data.split(ITEM_SEPARATOR)
22
21
  strings[1..-1].each do |string|
23
22
  values = string.split(VALUE_SEPARATOR)
24
- type = ic.iconv(values[0])
25
- key = type[1].to_sym
26
-
23
+ type = ic.iconv(values[0]).to_s
24
+ key = type.last.to_sym
27
25
  if ["+v", "+x", "+e", "+p"].include?(type)
28
26
  hash = {}
29
- VALUES[key].each_index{|index| hash[VALUES[key][index]] = ic.iconv(values[index+1]).to_s}
27
+ VALUES[key].each_with_index{|o, index| hash[VALUES[key][index]] = ic.iconv(values[index+1]).to_s}
30
28
  @catalog[key] << hash
31
29
  end
32
30
  end
data/lib/eport.rb CHANGED
@@ -17,41 +17,44 @@ class Eport
17
17
  r.path = "/cp/dir"
18
18
  r.body = ""
19
19
  end
20
+
20
21
  data = req.confirm
21
- cp = CatalogParser.new
22
+ cp = CatalogParser.new
22
23
  cp.new_catalog(data)
23
24
  end
24
25
 
25
26
  def get_balance
26
- req = Request.new do |r|
27
- r.point = @config[:eport][:point]
28
- r.private_key_path = "#{RAILS_ROOT}/#{@config[:eport][:private_key_path]}"
29
-
30
- r.host = @config[:eport][:host]
31
- r.path = "/cp/bal"
32
- r.body = ""
33
- end
34
- ic = Iconv.new('UTF-8', 'WINDOWS-1251')
35
- ic.iconv(req.confirm)
27
+ req = Request.new do |r|
28
+ r.point = @config[:eport][:point]
29
+ r.private_key_path = "#{RAILS_ROOT}/#{@config[:eport][:private_key_path]}"
30
+ r.host = @config[:eport][:host]
31
+ r.path = "/cp/bal"
32
+ r.body = ""
36
33
  end
34
+
35
+ ic = Iconv.new('UTF-8', 'WINDOWS-1251')
36
+ ic.iconv(req.confirm)
37
+ end
37
38
 
38
39
  def refill_operation(operation_name, operation_id, product_id, value, account)
39
- req = Request.new do |r|
40
- r.point = @config[:eport][:point]
41
- r.private_key_path = "#{RAILS_ROOT}/#{@config[:eport][:private_key_path]}"
40
+ req = Request.new do |r|
41
+ r.point = @config[:eport][:point]
42
+ r.private_key_path = "#{RAILS_ROOT}/#{@config[:eport][:private_key_path]}"
42
43
 
43
- r.host = @config[:eport][:host]
44
- r.path = "/cp/fe"
44
+ r.host = @config[:eport][:host]
45
+ r.path = "/cp/fe"
46
+
47
+ req = EportRequestPlainText.new
45
48
 
46
- req = EportRequestPlainText.new
49
+ req.operation_type = operation_name.to_s.upcase if [:operation, :confirm, :check, :cancel].include?(operation_name)
50
+ req.operation_id = operation_id
51
+ req.product_id = product_id
52
+ req.value = value
53
+ req.account = account
47
54
 
48
- req.operation_type = operation_name.to_s.upcase if [:operation, :confirm, :check, :cancel].include?(operation_name)
49
- req.operation_id = operation_id
50
- req.product_id = product_id
51
- req.value = value
52
- req.account = account
53
- r.body = req.body
55
+ r.body = req.body
54
56
  end
57
+
55
58
  ic = Iconv.new('UTF-8', 'WINDOWS-1251')
56
59
  ic.iconv(req.confirm)
57
60
  end
data/lib/request.rb CHANGED
@@ -6,7 +6,7 @@ class Request
6
6
  attr_accessor :point, :private_key_path, :host, :path, :additional_headers, :body
7
7
 
8
8
  def initialize(&block)
9
- block.yield(self)
9
+ yield self
10
10
 
11
11
  @headers = {
12
12
  "Content-Type" => "text/plain; charset=Windows-1251",
metadata CHANGED
@@ -5,9 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
8
  - 2
10
- version: 0.0.1.2
9
+ version: 0.0.2
11
10
  platform: ruby
12
11
  authors:
13
12
  - Alexander Lomakin, Dmitry Andreev
@@ -15,7 +14,7 @@ autorequire: eport
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-04-29 00:00:00 +04:00
17
+ date: 2010-05-07 00:00:00 +04:00
19
18
  default_executable:
20
19
  dependencies: []
21
20