aio_elin 1.0.2 → 1.0.3
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 +4 -4
- data/lib/aio/base/toolkit/string.rb +27 -21
- data/lib/aio/core/parse/parser.rb +1 -0
- data/lib/modules/input/style/console.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c983dc7e327c673b8fc3c28129e9831d7577abad0773f99f6f5720c192eba531
|
4
|
+
data.tar.gz: d2c98d1325451c6a011acde48c2fd5d4b0abc2eeca135c008fb0df99eeb5bb33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8270e9ea0e6adca9755d6513ff90140769c383c63ad534c98872e81a2dcc65889e1df4529dc191aa6e6b79718d43b5f10b4af6ba951d5fc1a408ca3a9dc41c4
|
7
|
+
data.tar.gz: b49bff6caca4f13752c3063d9b84df26577d7f50fdb0c8a2833c9bedd229c829566a9f48a811bcacb8ba34348299fbf7cba3abbabf04b710123910b9c72dd726
|
@@ -1,28 +1,34 @@
|
|
1
1
|
module Aio::Base::Toolkit::String
|
2
|
-
|
2
|
+
class << self
|
3
3
|
|
4
|
-
|
4
|
+
# 终极解决方案
|
5
5
|
# 遇到了 invalid byte sequence in UTF-8 (ArgumentError) 问题
|
6
6
|
# 解决办法参考 https://stackoverflow.com/questions/29877310/invalid-byte-sequence-in-utf-8-argumenterror
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
7
|
+
def safe(str)
|
8
|
+
case Aio::Base::Toolkit::OS.os_family
|
9
|
+
when "unix"
|
10
|
+
if ! str.valid_encoding?
|
11
|
+
str = str.encode("UTF-16be", :invalid=>:replace, :replace=>"?").encode('UTF-8')
|
12
|
+
end
|
13
|
+
|
14
|
+
# UTF-8 编码前缀删除
|
15
|
+
# 参考: https://estl.tech/of-ruby-and-hidden-csv-characters-ef482c679b35
|
16
|
+
str.sub!("\xEF\xBB\xBF", '')
|
17
|
+
|
18
|
+
when "windows"
|
19
|
+
#str = str.force_encoding("UTF-8")
|
20
|
+
str = str.encode("UTF-16be", :invalid=>:replace, :replace=>"?").encode('UTF-8')
|
21
|
+
str.sub!("\xEF\xBB\xBF", '')
|
22
|
+
end
|
17
23
|
return str
|
18
|
-
|
24
|
+
end
|
19
25
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
# 改写成安全的Windows书写方式
|
27
|
+
def safe_path(path)
|
28
|
+
if Aio::Base::Toolkit::OS.windows?
|
29
|
+
path.gsub!("/", "\\")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
27
33
|
end
|
28
|
-
|
34
|
+
|
@@ -136,8 +136,8 @@ class Aio::Module::InputStyle::Console < Aio::Module::InputStyle
|
|
136
136
|
|
137
137
|
def parse_line(line)
|
138
138
|
# 如果这行是命令行格式,那么就代表上一个cmd内容结束
|
139
|
-
tmp_reg = ::Regexp.new "^[\\[|<]
|
140
|
-
|
139
|
+
#tmp_reg = ::Regexp.new "^[\\[|<]{0,1}#{cmd_context.device_name}[#|>|\\]]{1}"
|
140
|
+
tmp_reg = ::Regexp.new "^[\\[|<]?#{cmd_context.device_name}[#|>|\\]]{1}"
|
141
141
|
# 可能会出现UTF-8识别不出摄氏度符号的问题
|
142
142
|
# 已经通过安全字符解决
|
143
143
|
begin
|
@@ -197,6 +197,7 @@ class Aio::Module::InputStyle::Console < Aio::Module::InputStyle
|
|
197
197
|
|
198
198
|
fo.each_line do |line|
|
199
199
|
begin
|
200
|
+
debugger if line =~ /more off/
|
200
201
|
line = Aio::Base::Toolkit::String.safe(line)
|
201
202
|
line = line.strip
|
202
203
|
rescue => e
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aio_elin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 网络设备巡检工具
|
14
14
|
email: 365433079@qq.com
|