struggle 2.3.3 → 2.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 112fe0ea89b9a5f002aa3d780d3637933d4a2313
4
- data.tar.gz: ccceb9879d2754c82643f645af84742b89c50e46
3
+ metadata.gz: 749a77542911c479181cf568360ff7be79bc7d58
4
+ data.tar.gz: e4c3a65526d87b6f5d636f0982e199f138f1e16e
5
5
  SHA512:
6
- metadata.gz: 032b8457a94a02fb429930123806d725ceb7d2e9fcfd760e03b32a4a7d68c077f4a4fe42cfc46b3e0792696bdb456f0c4fe6e8c2778f0227491cd425662293b1
7
- data.tar.gz: f8bef5338fa75ff7ca93d9864ad9e1aa431056a2e5ee898df6f0a221697dda4030c68a81709ae2ac978e54a7efca4fc4aff2997040547ce6807a7cdf8f161d3d
6
+ metadata.gz: 2b56a9fce16105a8e0829f8f0536852f72831e7246d322562e59ff6db25f4b351048fc71d897d31fd6870cacb74e03a7200b25ec49ace34ead2674bee7615c05
7
+ data.tar.gz: 50709d9201c4d1183fcdd0c8518b11abfdb8eb586c2b1746120a4917865efec4b2ea307bbbf4ab1be0c952295c87437f3f37e689216fbf34ec263c4f734a9d5d
data/README.md CHANGED
@@ -1,2 +1,27 @@
1
- # tool-libs
2
- tool-libs
1
+ 功能描述:
2
+ 一、工具包
3
+ 1.AES:加密、解密、文件加密、解密等。
4
+ 2.code:验证码
5
+ 3.ftp_tool:ftp工具
6
+ 4.getui:个推,手机推送功能。
7
+ 5.http:http请求工具
8
+ 6.logistic:物流码查询插件。
9
+ 7.pager:分页插件。
10
+ 8.rsa:加密、解密、签名
11
+ 9.sms:短信平台。
12
+ 10.tfile:文件上传、压缩、格式验证、图片上传、图片剪切、目录算法等。
13
+ 11.tmagick:画图工具,图片水印、叠加等功能。
14
+ 12.zip_tool:zip压缩工具,压缩文件和目录。
15
+ 13.sql:sql导出插件,导出成insert语句的sql文件。
16
+ 二、重构
17
+ 1.decimal:钱格式重构,如果小数点后是零则舍掉。
18
+ 2.int:整数型重构,整数转换大写钱格式。
19
+ 3.string:文本型重构,判断中英文,字符串截取,html清除。
20
+ 三、支付
21
+ 1.微信支付
22
+ 2.京东支付
23
+ 四、授权登录
24
+ 1.微信授权登录。
25
+ 2.微信企业授权登录。
26
+ 升级说明:
27
+ 2.3.4:增加sql导出功能,修改验证码的字体。
@@ -0,0 +1,14 @@
1
+ require 'rails'
2
+
3
+ module Struggle
4
+ module Generators
5
+ class SqlConfigGenerator < Rails::Generators::Base
6
+ desc "create sql export config file"
7
+ def create_sql_config
8
+ libdir = File.expand_path(File.dirname(__FILE__))
9
+ sqlconfig = File.expand_path("../../templates/tsql_config.yml", libdir)
10
+ FileUtils.cp(sqlconfig, "config/tsql_config.yml")
11
+ end
12
+ end
13
+ end
14
+ end
data/lib/struggle/code.rb CHANGED
@@ -21,7 +21,9 @@ module Struggle
21
21
  text= Magick::Draw.new
22
22
  text.pointsize = fontsize
23
23
  text.kerning = -1
24
- text.font("/font/ARIALNBI.TTF")
24
+ filePath = File.expand_path(File.dirname(File.dirname(__FILE__)))
25
+ fontPath = File.expand_path("struggle/font/ARIALNBI.TTF", filePath)
26
+ text.font(fontPath)
25
27
  text.font_weight(200)
26
28
  text.fill('blue')
27
29
  # 随机文字
Binary file
@@ -0,0 +1,54 @@
1
+ # 导出sql文件,生成insert语句
2
+ module Struggle
3
+ class Sql
4
+ class << self
5
+ # 按配置文件导出sql文件。
6
+ # yaml_file 配置文件yml位置。
7
+ def dump_yaml(yaml_file = "config/tsql_config.yml")
8
+ config = YAML.load_file(yaml_file)
9
+ config.each do |k, v|
10
+ self.dump(v)
11
+ end
12
+ end
13
+
14
+ # config => {"class_name": ["Member"], "file": "1.sql","adapter": "oracle"}
15
+ # class_name is ActiveRecord; file is backup sql file
16
+ def dump(config)
17
+ sqlinsert = ""
18
+ config["class_name"].each do |class_name|
19
+ obj = eval(class_name)
20
+ obj.all.each do |o|
21
+ attrs = o.attributes
22
+ names = []
23
+ values = []
24
+ attrs.each do |k, v|
25
+ names << k
26
+ value = v
27
+ if v.class == Date
28
+ value = v.strftime("%Y-%m-%d")
29
+ value = "TO_DATE('#{value}', 'YYYY-MM-DD')" if config["adapter"] && config["adapter"].downcase == "oracle"
30
+ elsif v.class == ActiveSupport::TimeWithZone
31
+ value = v.strftime("%Y-%m-%d %H:%M:%S")
32
+ value = "TO_TIMESTAMP('#{value}', 'YYYY-MM-DD HH24:MI:SS.FF6')" if config["adapter"] && config["adapter"].downcase == "oracle"
33
+ else
34
+ value = "'#{v}'"
35
+ end
36
+ values << value
37
+ end
38
+ sqlinsert += "INSERT INTO #{obj.table_name} (#{names.join(',')}) VALUES (#{values.join(',')});\r\n"
39
+ end
40
+ end
41
+ unless sqlinsert.blank?
42
+ config["file"] = config["file"].blank? ? "db.sql" : config["file"]
43
+ begin
44
+ f = File.new(config["file"], "w+")
45
+ f.write(sqlinsert)
46
+ f.close
47
+ rescue
48
+ return "#{$!}:#{config["file"]}"
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
data/lib/struggle.rb CHANGED
@@ -21,6 +21,7 @@ require 'struggle/concerns/int_extend'
21
21
  require 'struggle/concerns/decimal_extend'
22
22
  require "struggle/ftp_tool"
23
23
  require "struggle/zip_tool"
24
+ require 'struggle/sql'
24
25
  require 'pay/jd_gateway'
25
26
  String.send :include, Struggle::StringExtend
26
27
  Integer.send :include, Struggle::IntExtend
@@ -0,0 +1,14 @@
1
+ admin:
2
+ adapter: oracle
3
+ class_name: [Function, Role, Member, Routepath, Group, Menu, RouteGroup, Organization, SystemLog]
4
+ file: admin.sql
5
+
6
+ business:
7
+ adapter: oracle
8
+ class_name: []
9
+ file: business.sql
10
+
11
+ report:
12
+ adapter: oracle
13
+ class_name: [Connect, Report, Requirement, Map, MapRequirement]
14
+ file: report.sql
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.3
4
+ version: 2.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - lean
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-18 00:00:00.000000000 Z
11
+ date: 2018-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iconv
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: code,tfile,pager,http,logistic,pay,tmagick,class_extend,aes,rsa,ftp_tool,zip_tool;
55
+ description: code,tfile,pager,http,logistic,pay,tmagick,class_extend,aes,rsa,ftp_tool,zip_tool,sql;
56
56
  email: 54850915@qq.com
57
57
  executables: []
58
58
  extensions: []
@@ -60,6 +60,7 @@ extra_rdoc_files:
60
60
  - README.md
61
61
  files:
62
62
  - README.md
63
+ - lib/generators/struggle/sql_config_generator.rb
63
64
  - lib/pay/jd_gateway.rb
64
65
  - lib/struggle.rb
65
66
  - lib/struggle/aes.rb
@@ -67,6 +68,7 @@ files:
67
68
  - lib/struggle/concerns/decimal_extend.rb
68
69
  - lib/struggle/concerns/int_extend.rb
69
70
  - lib/struggle/concerns/string_extend.rb
71
+ - lib/struggle/font/ARIALNBI.TTF
70
72
  - lib/struggle/font/font.ttf
71
73
  - lib/struggle/ftp_tool.rb
72
74
  - lib/struggle/getui.rb
@@ -75,9 +77,11 @@ files:
75
77
  - lib/struggle/pager.rb
76
78
  - lib/struggle/rsa.rb
77
79
  - lib/struggle/sms.rb
80
+ - lib/struggle/sql.rb
78
81
  - lib/struggle/tfile.rb
79
82
  - lib/struggle/tmagick.rb
80
83
  - lib/struggle/zip_tool.rb
84
+ - lib/templates/tsql_config.yml
81
85
  homepage: http://rubygems.org/gems/struggle
82
86
  licenses:
83
87
  - struggle