struggle 2.3.0 → 2.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02424ee5858b52a0fb130dd9cf972d3482212d08
4
- data.tar.gz: 1eddbe2e05520e2d9fe91408f04aa3021f5d5ab8
3
+ metadata.gz: 1237cd78527e3b10ce004525a8a8728305d19b07
4
+ data.tar.gz: b139367d384edd9df7f580a32a4fa1ad52cceb64
5
5
  SHA512:
6
- metadata.gz: 9a174385cfe42e9e2d34ef15f7ff2680ff30d6d6298013af8161e2cbfe90d91483f7a7318062aaf23bddaf99672216b2999cd62bfc422efc86d396292a3772b8
7
- data.tar.gz: 512e145db165b6d2c25a0dc35566180132020a4b5e5ba8d275764a3c57c7445c5d734ee88ab3930079c6f4c57e6ce897a8d41999ed4fadab8dd4f75817b44191
6
+ metadata.gz: 0ddf3c49504e5a54cf453633f37b9cf94e7862870555c41fb61fb5acd83bb5e952f635abf929df9c825febf881f67248c446c33a71d91f96153ce64fb0a1cfb3
7
+ data.tar.gz: 330c1d554a747fe8fbbf6bb643628533b69935d0fda0481a0efa107bb287c9784c95f8eef437e682e4e57de2a456a01365212a3dc56dd6f54299eb529d579553
data/lib/struggle/code.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #first gem 'rmagick'
2
2
  module Struggle
3
- class Code
3
+ class Code1
4
4
  #controller
5
5
  #def getcode
6
6
  # code = Code.getcode
@@ -12,7 +12,7 @@ module Struggle
12
12
  #Code.getcode(90,40,24)
13
13
  #w宽,h高,fontsize字体大小
14
14
  #返回json类型
15
- def self.getcode(w=90, h=40, fontsize=24)
15
+ def self.getcode(w=90, h=40, fontsize=24, wave=5.5)
16
16
  #创建画布
17
17
  img = Magick::Image.new(w, h) {
18
18
  self.background_color = 'white'
@@ -21,30 +21,30 @@ module Struggle
21
21
  text= Magick::Draw.new
22
22
  text.pointsize = fontsize
23
23
  text.kerning = -1
24
- text.font("font/font.ttf")
25
- text.font_weight(900)
24
+ text.font("/font/ARIALNBI.TTF")
25
+ text.font_weight(200)
26
26
  text.fill('blue')
27
- #随机文字
27
+ # 随机文字
28
28
  code=""
29
29
  4.times { code << (97 + rand(26)).chr }
30
- #设置文字
31
- text.text(rand(w/2-5), h/2-5+ rand(h/2), code)
32
- #随机直线
33
- for i in 1..rand(4)
30
+ # 设置文字
31
+ text.text(rand(w/2-5), h/2 + rand(-2..2), code)
32
+ # 随机直线
33
+ for i in 1..rand(5)
34
34
  text.line(rand(w), rand(h), rand(w), rand(h)) #直线
35
35
  end
36
36
  text.fill('blue')
37
- #燥点
38
- # for i in 1..280
39
- # text.point(rand(w), rand(h))
40
- # end
37
+ # 燥点
38
+ for i in 1..20
39
+ text.point(rand(w), rand(h))
40
+ end
41
41
  text.draw(img)
42
42
  #模糊
43
43
  # img = img.sketch(0, 10, 50)
44
44
  #扭曲
45
- img = img.wave(5.5, 50)
45
+ img = img.wave(wave, 70)
46
46
  #返回图片数据流
47
47
  {img: img.to_blob, code: code}
48
48
  end
49
49
  end
50
- end
50
+ end
data/lib/struggle/http.rb CHANGED
@@ -3,7 +3,6 @@ module Struggle
3
3
  require 'net/http'
4
4
  require 'net/https'
5
5
  require 'uri'
6
-
7
6
  attr_reader :uri
8
7
  attr_reader :request
9
8
 
@@ -14,6 +13,9 @@ module Struggle
14
13
  @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
15
14
  end
16
15
 
16
+ # get请求,params为携带的参数,header为报文头数据,两个参数都是hash类型,示例
17
+ # http = Struggle::Http.new("http://xxx.com/xxx")
18
+ # result = http.post({name: 'lily', age: 18}).body
17
19
  def get(params=nil, header=nil)
18
20
  @request = Net::HTTP::Get.new(@uri.request_uri, header)
19
21
  if !params.blank?
@@ -22,14 +24,18 @@ module Struggle
22
24
  @http.request(@request)
23
25
  end
24
26
 
27
+ # post请求,params为携带的参数为json类型,header为报文头数据为hash类型,示例:
28
+ # http = Struggle::Http.new("http://xxx.com/xxx")
29
+ # data = {name: 'lily', age: 18}
30
+ # result = http.post(data.to_json, {'Content-Type' => 'application/json'}).body
31
+ # eval(result) => {status: 200, msg: 'success'}
25
32
  def post(params=nil, header=nil)
26
33
  @request = Net::HTTP::Post.new(@uri.request_uri, header)
27
34
  if !params.blank?
28
- # @request.set_form_data(params)
29
- @request.body = params
35
+ @request.body = params #post json must body
30
36
  end
31
37
  @http.request(@request)
32
38
  end
33
39
 
34
40
  end
35
- end
41
+ end
data/lib/struggle/sms.rb CHANGED
@@ -9,17 +9,4 @@ module Struggle
9
9
  return response.body=="100"
10
10
  end
11
11
  end
12
- # 云讯科技
13
- class SmsYx
14
- URL = "http://sandbox.ytx.net"
15
- require 'net/https'
16
- require 'uri'
17
-
18
- def Sms.send(accountSID, authToken, version, appid, tel, templateId, content)
19
- url = "#{URL}/#{version}/sid/#{accountSID}/sms/TemplateSMS.wx"
20
- data = {"action":"templateSms","mobile":tel,"appid":appid, "templateId":"#{templateId}","datas": content}
21
- response = Http.post(URL, data)
22
- return response.body
23
- end
24
- end
25
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: struggle
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - lean
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-23 00:00:00.000000000 Z
11
+ date: 2017-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iconv
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.6.10
101
+ rubygems_version: 2.6.7
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: struggle!