eric_tools 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/Gemfile +6 -1
- data/lib/eric_tools.rb +4 -0
- data/lib/eric_tools/barby_tools.rb +34 -0
- data/lib/eric_tools/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaa95e8c3d4abf793490a33ccc35cc3361b21254
|
4
|
+
data.tar.gz: ad3f71f95ff2d5da11dc78b7a7a8d98308320a27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dc1defd2ce7a33c04570ef2d21215bedc615a6b641721def74bc922e71ae39385c8bbe542864a101c444d3684794fa73c126d9c07f962fdc8fd53f9e230e6e9
|
7
|
+
data.tar.gz: 06dcc58e2468ceb10ad913998bf7434dafe30da9386b84a9c54c45c097a30cb8eb52a61069dd1b4ebcdf24fa05c615834387b18c5e1437ad6a80590929072a19
|
data/.DS_Store
ADDED
Binary file
|
data/Gemfile
CHANGED
data/lib/eric_tools.rb
CHANGED
@@ -2,6 +2,9 @@ require 'nokogiri'
|
|
2
2
|
require 'rest_client'
|
3
3
|
require "eric_tools/version"
|
4
4
|
require 'json'
|
5
|
+
require 'barby/barcode/code_128'
|
6
|
+
require 'barby/outputter/png_outputter'
|
7
|
+
require 'barby/barcode/qr_code'
|
5
8
|
|
6
9
|
require File.dirname(__FILE__) + '/eric_tools/array.rb'
|
7
10
|
require File.dirname(__FILE__) + '/eric_tools/business_exception.rb'
|
@@ -13,6 +16,7 @@ require File.dirname(__FILE__) + '/eric_tools/string.rb'
|
|
13
16
|
require File.dirname(__FILE__) + '/eric_tools/symbol.rb'
|
14
17
|
require File.dirname(__FILE__) + '/eric_tools/time.rb'
|
15
18
|
require File.dirname(__FILE__) + '/eric_tools/version.rb'
|
19
|
+
require File.dirname(__FILE__) + '/eric_tools/barby_tools.rb'
|
16
20
|
|
17
21
|
module EricTools
|
18
22
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module BarbyTools
|
2
|
+
|
3
|
+
#生成的图片都比较小,官方的对png控制似乎无效
|
4
|
+
# ------会生成png文件, 一般每个大小不超过1kb, 但是文件需要自己去清除--------
|
5
|
+
|
6
|
+
# 生成条码, 不支持utf-8, 比如中文.
|
7
|
+
# 支持参数:
|
8
|
+
# content, 要转换的字符串
|
9
|
+
# file_path, 要保存的文件路径(png)
|
10
|
+
def self.create_barcode options
|
11
|
+
barcode = Barby::Code128B.new(options[:content])
|
12
|
+
blob = Barby::PngOutputter.new(barcode).to_png(:height => 20, :margin => 5)
|
13
|
+
unless File.exist? options[:file_path]
|
14
|
+
File.open(options[:file_path], 'wb'){|f|
|
15
|
+
f.write blob.force_encoding("ISO-8859-1") #在rails环境中,如果不encode,会报错
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# 生成二维码. 支持中文
|
21
|
+
# 支持参数:
|
22
|
+
# content, 要转换的字符串
|
23
|
+
# file_path, 要保存的文件路径(png)
|
24
|
+
def self.create_qrcode options
|
25
|
+
qrcode = Barby::QrCode.new(options[:content])
|
26
|
+
blob = Barby::PngOutputter.new(qrcode).to_png(:height => 20, :margin => 5)
|
27
|
+
unless File.exist? options[:file_path]
|
28
|
+
File.open(options[:file_path], 'wb'){|f|
|
29
|
+
f.write blob.force_encoding("ISO-8859-1")
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/lib/eric_tools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eric_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 刘晓琦
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -45,6 +45,7 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- .DS_Store
|
48
49
|
- .gitignore
|
49
50
|
- .rvmrc
|
50
51
|
- Gemfile
|
@@ -54,6 +55,7 @@ files:
|
|
54
55
|
- eric_tools.gemspec
|
55
56
|
- lib/eric_tools.rb
|
56
57
|
- lib/eric_tools/array.rb
|
58
|
+
- lib/eric_tools/barby_tools.rb
|
57
59
|
- lib/eric_tools/business_exception.rb
|
58
60
|
- lib/eric_tools/date.rb
|
59
61
|
- lib/eric_tools/date_time.rb
|