leangem 2.0.0 → 2.0.1

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pay_gateway.rb +3 -17
  3. data/lib/vcode.rb +20 -15
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 37a75ad7865736b5687ba20554ab5960ba945215
4
- data.tar.gz: 1979327502a410a08fea60040a32d072b12e1b43
3
+ metadata.gz: 8e656a56241c81e64dbef0424ed7c8713d06cb31
4
+ data.tar.gz: 8620f6b3472b0a8886999a203ab4042be0c5f840
5
5
  SHA512:
6
- metadata.gz: 1206d253c2dd8167d4363d94c7453ff7ee73792d846812ef6803f0f9061fee1db3e98162092824b0644762cf5fc3bb0ced0fc601e2aa87c192f4c19e1b3b1962
7
- data.tar.gz: 0ab9ff2d866aa38710278113da5417c6d0b8500618bd3cc83409b0dcfc35c998393b148282ea89b5db79eb523ad649173c483e419978457777978ebdd8d1c45f
6
+ metadata.gz: f3246c0e8ea550155a970863300e4216efb6ee48193c8e9e91dd716535058df6d3f8914915620ea4a909e02d21b03f36eda54219bdabf4796376f60bc7475172
7
+ data.tar.gz: ab69246f53f12522d1b4f39e9a3f96744687b6eef08b372aed2fc935f6c2859ca0ef8c9d4cc3b87e766605e9a9935849af88f2667ab8e91f55e0b8744680d177
@@ -1,5 +1,5 @@
1
+ #gemfile中加入 gem 'iconv'
1
2
  class PayGateway
2
- #gemfile中加入 gem 'iconv'
3
3
  require 'net/https'
4
4
  require 'uri'
5
5
  # 支付接口地址
@@ -16,8 +16,7 @@ class PayGateway
16
16
  # v_amount:订单金额
17
17
  # v_moneytype:支付货币类型
18
18
  def self.pay(v_mid, key, v_url, remark2, v_oid, v_amount, v_moneytype = "CNY")
19
- v_md5info = PayGateway.md5info(v_mid, key, v_url, v_oid, v_amount, v_moneytype)
20
- # {'v_mid'=>v_mid,'v_oid'=>v_oid,'v_amount'=>v_amount,'v_moneytype'=>v_moneytype,'v_url'=>v_url,'v_md5info'=>v_md5info,'pmode_id'=>pmode_id,'remark2'=>remark2}
19
+ v_md5info = Digest::MD5.hexdigest(v_amount.to_s + v_moneytype + v_oid + v_mid + v_url + key).upcase
21
20
  response = Func.post(URL_UTF8,{'v_mid'=>v_mid,'v_oid'=>v_oid,'v_amount'=>v_amount,'v_moneytype'=>v_moneytype,'v_url'=>v_url,'v_md5info'=>v_md5info,'remark2'=>remark2})
22
21
  html = Iconv.iconv('utf-8', 'gbk', response.body).first
23
22
  html.scan(/[href|src]=("[^"]*.[css|js|gif|jpg]")/).each do |h|
@@ -26,19 +25,6 @@ class PayGateway
26
25
  html
27
26
  end
28
27
 
29
- # 功能:获取md5info信息
30
- # 参数:
31
- # v_mid:商户编号
32
- # key:商户md5密钥
33
- # v_url:支付成功后跳转的页面
34
- # v_oid:订单编号
35
- # v_amount:订单金额
36
- # v_moneytype:支付货币类型
37
- def self.md5info(v_mid, key, v_url, v_oid, v_amount, v_moneytype = "CNY")
38
- Digest::MD5.hexdigest(v_amount.to_s + v_moneytype + v_oid + v_mid + v_url + key).upcase
39
- end
40
-
41
- # string str = v_oid + v_pstatus + v_amount + v_moneytype + key;
42
28
  # 功能:自动验证结果
43
29
  # 参数:
44
30
  # params参数
@@ -67,4 +53,4 @@ class PayGateway
67
53
  return nil
68
54
  end
69
55
  end
70
- end
56
+ end
@@ -1,30 +1,38 @@
1
1
  class Vcode
2
- def initialize(w=90,h=40,fontsize=24)
3
- @w=w and @h=h and @size=fontsize
4
- end
5
- def getvcode
2
+ #控制器
3
+ #def getcode
4
+ # vcode = Vcode.getvcode
5
+ # session[:code]=vcode[:code]
6
+ # send_data vcode[:img], content_type: 'image/jpeg', disposition: 'inline'
7
+ #end
8
+ #view
9
+ # <img src="/getcode">
10
+ #Vcode.getvcode(90,40,24)
11
+ #w宽,h高,fontsize字体大小
12
+ #返回json类型
13
+ def self.getvcode(w=90,h=40,fontsize=24)
6
14
  #创建画布
7
- img = Magick::Image.new(@w, @h) {
15
+ img = Magick::Image.new(w, h) {
8
16
  self.background_color = 'white'
9
17
  self.format="JPG"
10
18
  }
11
19
  text= Magick::Draw.new
12
- text.pointsize = @size
20
+ text.pointsize = fontsize
13
21
  text.kerning = -1
14
22
  text.fill('blue')
15
23
  #随机文字
16
- @code=""
17
- 4.times{@code << (97 + rand(26)).chr}
24
+ code=""
25
+ 4.times{code << (97 + rand(26)).chr}
18
26
  #设置文字
19
- text.text(rand(@w/2-5),@h/2-5+ rand(@h/2), @code)
27
+ text.text(rand(w/2-5),h/2-5+ rand(h/2), code)
20
28
  #随机直线
21
29
  for i in 1..rand(4)
22
- text.line(rand(@w), rand(@h), rand(@w), rand(@h)) #直线
30
+ text.line(rand(w), rand(h), rand(w), rand(h)) #直线
23
31
  end
24
32
  text.fill('blue')
25
33
  #燥点
26
34
  for i in 1..280
27
- text.point(rand(@w), rand(@h))
35
+ text.point(rand(w), rand(h))
28
36
  end
29
37
  text.draw(img)
30
38
  #模糊
@@ -32,9 +40,6 @@ class Vcode
32
40
  #扭曲
33
41
  img = img.wave(5.5, 50)
34
42
  #返回图片数据流
35
- img.to_blob
36
- end
37
- def code
38
- @code
43
+ {img: img.to_blob,code: code}
39
44
  end
40
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leangem
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lean
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-12 00:00:00.000000000 Z
11
+ date: 2015-05-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: vcode,fileupload,pager,imageupload,func,pay_gateway
14
14
  email: leanv@sina.com
@@ -42,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
42
42
  version: '0'
43
43
  requirements: []
44
44
  rubyforge_project:
45
- rubygems_version: 2.4.3
45
+ rubygems_version: 2.4.6
46
46
  signing_key:
47
47
  specification_version: 4
48
48
  summary: leangem!