aio_elin 0.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 (134) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +675 -0
  3. data/README.md +9 -0
  4. data/config.rb +39 -0
  5. data/lib/aio/base/debug.rb +30 -0
  6. data/lib/aio/base/toolkit/array.rb +24 -0
  7. data/lib/aio/base/toolkit/date.rb +46 -0
  8. data/lib/aio/base/toolkit/deep_clone.rb +10 -0
  9. data/lib/aio/base/toolkit/diff.rb +104 -0
  10. data/lib/aio/base/toolkit/excel_office.rb +421 -0
  11. data/lib/aio/base/toolkit/excel_wps.rb +437 -0
  12. data/lib/aio/base/toolkit/excel_wps.rb.bak +299 -0
  13. data/lib/aio/base/toolkit/ipaddr.rb +28 -0
  14. data/lib/aio/base/toolkit/os.rb +26 -0
  15. data/lib/aio/base/toolkit/regexp.rb +32 -0
  16. data/lib/aio/base/toolkit/string.rb +28 -0
  17. data/lib/aio/base/toolkit/table.rb +441 -0
  18. data/lib/aio/base/toolkit/test_diff.rb +9 -0
  19. data/lib/aio/base/toolkit/test_excel.rb +118 -0
  20. data/lib/aio/base/toolkit/test_word.rb +58 -0
  21. data/lib/aio/base/toolkit/word_wps.rb +492 -0
  22. data/lib/aio/base/toolkit.rb +18 -0
  23. data/lib/aio/base.rb +10 -0
  24. data/lib/aio/core/device/cisco.rb +13 -0
  25. data/lib/aio/core/device/cmd_switch.rb +113 -0
  26. data/lib/aio/core/device/h3c.rb +12 -0
  27. data/lib/aio/core/device/huawei.rb +10 -0
  28. data/lib/aio/core/device/juniper.rb +10 -0
  29. data/lib/aio/core/device/maipu.rb +11 -0
  30. data/lib/aio/core/device/methods.rb +233 -0
  31. data/lib/aio/core/device/methods.rb.bak +199 -0
  32. data/lib/aio/core/device/parent_device.rb +275 -0
  33. data/lib/aio/core/device.rb +15 -0
  34. data/lib/aio/core/device_manager.rb +207 -0
  35. data/lib/aio/core/module/cmd.rb +160 -0
  36. data/lib/aio/core/module/description.rb +67 -0
  37. data/lib/aio/core/module/input_style.rb +98 -0
  38. data/lib/aio/core/module/output_style.rb +80 -0
  39. data/lib/aio/core/module/platform.rb +30 -0
  40. data/lib/aio/core/module/ranking.rb +24 -0
  41. data/lib/aio/core/module/special_style.rb +30 -0
  42. data/lib/aio/core/module/template.rb +13 -0
  43. data/lib/aio/core/module.rb +15 -0
  44. data/lib/aio/core/module_loader.rb +161 -0
  45. data/lib/aio/core/module_loader.rb.bak +148 -0
  46. data/lib/aio/core/module_manager.rb +112 -0
  47. data/lib/aio/core/module_manager.rb.bak +78 -0
  48. data/lib/aio/core/parse/file.rb +19 -0
  49. data/lib/aio/core/parse/parser.rb +91 -0
  50. data/lib/aio/core/parse/parser_machine/bak/has_cmd_state.rb +14 -0
  51. data/lib/aio/core/parse/parser_machine/bak/has_context_state.rb +11 -0
  52. data/lib/aio/core/parse/parser_machine/bak/no_cmd_state.rb +11 -0
  53. data/lib/aio/core/parse/parser_machine/bak/no_context_state.rb +11 -0
  54. data/lib/aio/core/parse/parser_machine/full_state.rb +12 -0
  55. data/lib/aio/core/parse/parser_machine/has_device_state.rb +44 -0
  56. data/lib/aio/core/parse/parser_machine/no_device_state.rb +12 -0
  57. data/lib/aio/core/parse/parser_machine/parent_state.rb +26 -0
  58. data/lib/aio/core/parse/parser_machine.rb +47 -0
  59. data/lib/aio/core/parse.rb +6 -0
  60. data/lib/aio/core/text/context.rb +211 -0
  61. data/lib/aio/core/text/line_string.rb +74 -0
  62. data/lib/aio/core/text/warning.rb +179 -0
  63. data/lib/aio/core/text.rb +7 -0
  64. data/lib/aio/core/warning/description.rb +47 -0
  65. data/lib/aio/core/warning/warning_summarize.rb +232 -0
  66. data/lib/aio/core/warning.rb +6 -0
  67. data/lib/aio/core.rb +32 -0
  68. data/lib/aio/license.rb +687 -0
  69. data/lib/aio/resource/cover_picture.png +0 -0
  70. data/lib/aio/resource/line.png +0 -0
  71. data/lib/aio/resource/logo.png +0 -0
  72. data/lib/aio/ui/banner.rb +85 -0
  73. data/lib/aio/ui/readable_text.rb +75 -0
  74. data/lib/aio/ui/verbose.rb +29 -0
  75. data/lib/aio/ui/version.rb +9 -0
  76. data/lib/aio/ui.rb +138 -0
  77. data/lib/aio.rb +13 -0
  78. data/lib/modules/cmd/cisco/show_clock.rb +32 -0
  79. data/lib/modules/cmd/cisco/show_cpu.rb +32 -0
  80. data/lib/modules/cmd/cisco/show_env.rb +71 -0
  81. data/lib/modules/cmd/cisco/show_failover.rb +39 -0
  82. data/lib/modules/cmd/cisco/show_interface_ip_brief.rb +24 -0
  83. data/lib/modules/cmd/cisco/show_interfaces.rb +177 -0
  84. data/lib/modules/cmd/cisco/show_inv.rb +43 -0
  85. data/lib/modules/cmd/cisco/show_ip_interface_brief.rb +42 -0
  86. data/lib/modules/cmd/cisco/show_ip_ospf_nei.rb +38 -0
  87. data/lib/modules/cmd/cisco/show_ip_route_summary.rb +81 -0
  88. data/lib/modules/cmd/cisco/show_memory.rb +27 -0
  89. data/lib/modules/cmd/cisco/show_process_cpu.rb +35 -0
  90. data/lib/modules/cmd/cisco/show_process_memory.rb +63 -0
  91. data/lib/modules/cmd/cisco/show_version.rb +97 -0
  92. data/lib/modules/cmd/h3c/display_clock.rb +32 -0
  93. data/lib/modules/cmd/h3c/display_cpu.rb +51 -0
  94. data/lib/modules/cmd/h3c/display_device_manuinfo.rb +45 -0
  95. data/lib/modules/cmd/h3c/display_fan.rb +91 -0
  96. data/lib/modules/cmd/h3c/display_interface.rb +203 -0
  97. data/lib/modules/cmd/h3c/display_ip_interface_brief.rb +34 -0
  98. data/lib/modules/cmd/h3c/display_ip_routing.rb +68 -0
  99. data/lib/modules/cmd/h3c/display_ip_routing_stat.rb +90 -0
  100. data/lib/modules/cmd/h3c/display_memory.rb +35 -0
  101. data/lib/modules/cmd/h3c/display_ospf_peer.rb +38 -0
  102. data/lib/modules/cmd/h3c/display_power.rb +90 -0
  103. data/lib/modules/cmd/h3c/display_version.rb +54 -0
  104. data/lib/modules/cmd/h3c/display_vrrp_verbose.rb +86 -0
  105. data/lib/modules/cmd/maipu/show_env.rb +34 -0
  106. data/lib/modules/cmd/maipu/show_ip_route.rb +74 -0
  107. data/lib/modules/cmd/maipu/show_ip_route_statistic.rb +36 -0
  108. data/lib/modules/cmd/maipu/show_memory.rb +31 -0
  109. data/lib/modules/cmd/maipu/show_system_fan.rb +66 -0
  110. data/lib/modules/cmd/maipu/show_system_power.rb +66 -0
  111. data/lib/modules/cmd/maipu/show_version.rb +50 -0
  112. data/lib/modules/description/style/crc.rb +22 -0
  113. data/lib/modules/description/style/input_errors.rb +22 -0
  114. data/lib/modules/description/style/overrun.rb +22 -0
  115. data/lib/modules/description/style/proc_ratio.rb +22 -0
  116. data/lib/modules/description/style/protocol.rb +22 -0
  117. data/lib/modules/description/style/register.rb +22 -0
  118. data/lib/modules/description/style/runts.rb +22 -0
  119. data/lib/modules/description/style/template.rb +22 -0
  120. data/lib/modules/description/style/total_output_drops.rb +22 -0
  121. data/lib/modules/input/style/compare_xml.rb +89 -0
  122. data/lib/modules/input/style/console.rb +222 -0
  123. data/lib/modules/input/style/console.rb.bak +114 -0
  124. data/lib/modules/input/style/xinhua_nat.rb +70 -0
  125. data/lib/modules/output/style/boc_day.rb +223 -0
  126. data/lib/modules/output/style/cmds.rb +77 -0
  127. data/lib/modules/output/style/compare_json.rb +26 -0
  128. data/lib/modules/output/style/compare_report.rb +31 -0
  129. data/lib/modules/output/style/compare_xml.rb +86 -0
  130. data/lib/modules/output/style/excel_table_office.rb +407 -0
  131. data/lib/modules/output/style/excel_table_wps.rb +400 -0
  132. data/lib/modules/output/style/summary_report.rb +563 -0
  133. data/lib/modules/special/style/compare.rb +110 -0
  134. metadata +176 -0
@@ -0,0 +1,58 @@
1
+ FileDir = File.expand_path(File.dirname(__FILE__))
2
+ load "#{FileDir}/word.rb"
3
+ load "#{FileDir}/excel.rb"
4
+
5
+ word = Word.new
6
+ word.show
7
+ word.display_alerts = false
8
+ doc = word.init_document
9
+ text = doc.add_text
10
+
11
+ # 测试文本
12
+ text.section("Cover 1") do
13
+ "数据通信网络高级巡检报告\n巡检时间:2017-04-12"
14
+ end
15
+
16
+ # 测试表格
17
+ text.style("正文")
18
+ text.add_table(2,2) do |tbl|
19
+ tbl.merge_row
20
+ tbl << ["1", "2", "3"]
21
+ end
22
+ text.entry
23
+
24
+ # 测试图片
25
+ text.add_head_image(File.join(FileDir, "..", "picture.png"))
26
+ text.page_break
27
+ path = File.join(FileDir, "..", "line.png")
28
+
29
+ text.add_image(path)
30
+
31
+ # 测试图表
32
+ tbl = [
33
+ ["a", "1"],
34
+ ["b", "2"],
35
+ ["c", "3"],
36
+ ["d", "4"],
37
+ ]
38
+ text.chart(tbl) do |chart|
39
+ chart.title = "Name"
40
+ chart.type = 5
41
+ #chart.axes_x = "year"
42
+ #chart.axes_y = "value"
43
+ chart.style = 251
44
+ end
45
+
46
+ # 测试目录
47
+ doc.create_catalog
48
+
49
+ text.section("标题 1") do
50
+ "a"
51
+ end
52
+ text.entry
53
+ text.section("标题 1") do
54
+ "b"
55
+ end
56
+ text.entry
57
+
58
+ doc.update_catalog
@@ -0,0 +1,492 @@
1
+ module Aio::Base::Toolkit
2
+ module WordWps
3
+ class Word
4
+
5
+ include Aio::Ui::Verbose
6
+
7
+ def initialize(encoding = "utf-8")
8
+
9
+ if Aio::Base::Toolkit::OS.windows?
10
+ require "win32ole"
11
+ else
12
+ print_error "只有Windows系统才能使用Excel模块"
13
+ exit 0
14
+ end
15
+
16
+
17
+ @word = WIN32OLE.new("Word.Application")
18
+ @word.visible = false
19
+ @encoding = encoding
20
+ end
21
+
22
+ # 警告提示开关
23
+ def display_alerts=(bool)
24
+ @word.DisplayAlerts = bool
25
+ end
26
+
27
+ def init_document
28
+ @document = @word.Documents.add
29
+ return Document.new(@document, @word)
30
+ end
31
+
32
+
33
+ def show
34
+ @word.visible = true
35
+ end
36
+
37
+ def save(path)
38
+ @document.saveas(path)
39
+ end
40
+
41
+ def close
42
+ @document.close
43
+ @word.quit
44
+ end
45
+ end
46
+
47
+ # 对文本控件的调用
48
+ class Document
49
+
50
+ def initialize(document, word)
51
+ @doc_work = document
52
+ @word = word
53
+ #@text = Text.new(@word.Selection, self)
54
+ create_style
55
+ end
56
+
57
+ # ActiveDocument
58
+ def doc_work
59
+ @doc_work
60
+ end
61
+
62
+ # 自动化对象
63
+ def word_basic
64
+ doc_work.Application.WordBasic
65
+ end
66
+
67
+ # 创建样式
68
+ def create_style
69
+
70
+ # 正文 楷体五号
71
+ sty = @doc_work.styles("正文")
72
+ sty.font.size = 10
73
+ sty.font.NameFarEast = "宋体"
74
+ sty.font.NameAscii = "Times New Roman"
75
+ sty.font.NameOther = "Times New Roman"
76
+ sty.ParagraphFormat.Alignment = 3
77
+ sty.ParagraphFormat.LineSpacingRule = 1
78
+ sty.NextParagraphStyle = "正文"
79
+
80
+ # 楷体3号字体
81
+ sty = @doc_work.styles.add("Cover 1", 1)
82
+ sty.font.size = 16
83
+ sty.font.NameFarEast = "楷体"
84
+ sty.font.NameAscii = "Times New Roman"
85
+ sty.font.NameOther = "Times New Roman"
86
+ end
87
+
88
+ # 由实例自己创建风格
89
+ def create_style_self(name)
90
+ sty = @doc_work.styles.add(name, 1)
91
+ yield sty
92
+ end
93
+
94
+ # 返回Selection
95
+ def now
96
+ @word.Selection
97
+ end
98
+
99
+ # 返回Text类
100
+ def add_text
101
+ return Text.new(@word.Selection, self)
102
+ entry
103
+ end
104
+
105
+ # 风格设置
106
+ def styles(name)
107
+ @doc_work.Styles(name)
108
+ end
109
+
110
+ # 设置表格
111
+ def add_table(row, col)
112
+ @doc_work.tables.add(now.Range, row, col)
113
+ end
114
+
115
+ # 创建目录
116
+ def create_catalog
117
+ #range = doc_work.Range(0, 0)
118
+ range = now.range
119
+ doc_work.TablesOfContents.Add(
120
+ range, # Range
121
+ true, # UseHeadingStyles
122
+ 1, # UpperHeadingLevel
123
+ 3, # LowerHeadingLevel default: 9
124
+ false, # UseFields
125
+ nil, # TableId
126
+ true, # RightAlignPageNumbers
127
+ true, # IncludePageNumbers
128
+ "", # AddedStyles
129
+ true, # UseHyperlinks
130
+ true, # HidePageNumbersInWeb
131
+ true, # UseOutlineLevels default: false
132
+ )
133
+
134
+ # 换到下一行
135
+ move_down
136
+ end
137
+
138
+ # 更新目录
139
+ def update_catalog
140
+ word_basic.UpdateTableOfContents
141
+ end
142
+
143
+ # 回车
144
+ def entry
145
+ now.TypeParagraph
146
+ end
147
+
148
+ # 移动到行首
149
+ def home_key
150
+ now.HomeKey(5)
151
+ end
152
+
153
+ # 移动到行尾
154
+ def end_key
155
+ now.EndKey(5)
156
+ end
157
+
158
+ # 移动到下一行
159
+ def move_down
160
+ self.end_key
161
+ self.entry
162
+ end
163
+
164
+ # 右移
165
+ # count 数值, 移动距离
166
+ # ext 0or1 , 是否扩展
167
+ # unit wdCharachter
168
+ def move_right(count=nil, ext=nil, unit=nil)
169
+ now.MoveRight(unit, count, ext)
170
+ end
171
+
172
+ # 将厘米换算成磅
173
+ def cent_to_point(int)
174
+ @word.CentimetersToPoints(int)
175
+ end
176
+
177
+ end
178
+
179
+ # 只对内容服务
180
+ class Text
181
+
182
+ def initialize(selection, document)
183
+ # 现在所选项
184
+ @selection = selection
185
+
186
+ # Document 类
187
+ @document = document
188
+ end
189
+
190
+ # ActiveDocument
191
+ def doc_work
192
+ @document.doc_work
193
+ end
194
+
195
+ # ActiveDocument.Selecton
196
+ def now
197
+ @selection
198
+ end
199
+
200
+ # 调整字体
201
+ def font
202
+ now.Font
203
+ end
204
+
205
+ # 调整字体大小
206
+ def size=(int)
207
+ self.font.Size = int
208
+ end
209
+
210
+ # 文本左对齐
211
+ def left
212
+ now.ParagraphFormat.Alignment = 0
213
+ end
214
+
215
+ # 文本居中
216
+ def center
217
+ now.ParagraphFormat.Alignment = 1
218
+ end
219
+
220
+ # 文本右对齐
221
+ def right
222
+ now.ParagraphFormat.Alignment = 2
223
+ end
224
+
225
+ # 两端对其
226
+ def justify
227
+ now.ParagraphFormat.Alignment = 3
228
+ end
229
+
230
+ # 回车
231
+ def entry
232
+ @document.entry
233
+ end
234
+
235
+ # 移动到下一行
236
+ def move_down
237
+ @document.move_down
238
+ end
239
+
240
+ # 写入元数据
241
+ def print(str)
242
+ now.TypeText(str)
243
+ end
244
+
245
+ # 写入数据,抬头Tab, 并且换行
246
+ def puts(str)
247
+ now.TypeText("\t" + str)
248
+ self.entry
249
+ end
250
+
251
+ # 替换,并替换风格
252
+ def replace(find, replace, style)
253
+ rep_opt = now.Find
254
+ rep_opt.ClearFormatting
255
+ rep_opt.Replacement.ClearFormatting
256
+ rep_opt.Replacement.Style = doc_work.Styles(style)
257
+ rep_opt.Text = find
258
+ rep_opt.Replacement.Text = replace
259
+ rep_opt.Forward = true
260
+ rep_opt.wrap = 1 # 到达开头或结尾时继续搜索
261
+ rep_opt.Format = true
262
+ rep_opt.MatchCase = false
263
+ rep_opt.MatchWholeWord = false
264
+ rep_opt.MatchByte = true
265
+ rep_opt.MatchWildcards = false
266
+ rep_opt.MatchSoundsLike = false
267
+ rep_opt.MatchAllWordForms = false
268
+
269
+ rep_opt.Execute(nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,1)
270
+ end
271
+
272
+
273
+ # 设置风格
274
+ def style(name)
275
+ now.Style = @document.styles(name)
276
+ end
277
+
278
+ # 按一个段设置风格和内容
279
+ def section(style_name=nil)
280
+ self.style(style_name) unless style_name.nil?
281
+ res = yield
282
+ if res.kind_of? ::Array
283
+ res.join("\n")
284
+ end
285
+ print(res)
286
+ self.entry
287
+ end
288
+
289
+ # 插入表格,并返回Table类
290
+ def insert_table(row, col)
291
+ obj = @document.add_table(row, col)
292
+ Table.new(now, row, col, obj)
293
+ end
294
+
295
+ # 插入表格
296
+ def add_table(row, col, &block)
297
+ table = insert_table(row, col)
298
+ block.call(table)
299
+
300
+ # 跳出表格
301
+ now.MoveDown(5, 1)
302
+ end
303
+
304
+ # 通过已有的数组插入表格
305
+ def add_table_by_value(tbl, &block)
306
+ row = tbl.size
307
+ col = tbl[0].size
308
+ table = insert_table(row, col)
309
+ block.call(table)
310
+
311
+ # 保证在写入数据的时候在第一个单元格
312
+ table.top
313
+ # 一维化数组
314
+ table << tbl.flatten
315
+ # 跳出表格
316
+ now.MoveDown(5, 1)
317
+ end
318
+
319
+ # 插入头部的图片
320
+ def add_head_image(path)
321
+ self.first_line_indent = -2
322
+ add_image(path)
323
+ picture_size(1.25)
324
+ self.entry
325
+ self.first_line_indent = 0
326
+ end
327
+
328
+ # 插入图片
329
+ def add_image(path)
330
+ now.InlineShapes.AddPicture(path, false, true)
331
+ end
332
+
333
+ # 修改首行缩进(厘米)
334
+ def first_line_indent=(cent)
335
+ now.ParagraphFormat.FirstLineIndent = @document.cent_to_point(cent)
336
+ end
337
+
338
+ # 修改最近一个图片尺寸倍数
339
+ def picture_size(int)
340
+ num = doc_work.InlineShapes.Count
341
+ pic = doc_work.InlineShapes(num)
342
+ pic.width *= int
343
+ end
344
+
345
+ # 插入一条横线
346
+ def insert_line
347
+
348
+ # 通过导入图片的方法
349
+ path = File.join(BaseFile, "aio", "resource", "line.png")
350
+ self.add_image(path)
351
+ self.move_down
352
+ end
353
+
354
+ # 绘制图表
355
+ # 测试图表
356
+ #tbl = [
357
+ # ["a", "1"],
358
+ # ["b", "2"],
359
+ # ["c", "3"],
360
+ # ["d", "4"],
361
+ #]
362
+ #text.chart(tbl) do |chart|
363
+ # chart.title = "Name"
364
+ # chart.type = 5
365
+ # #chart.axes_x = "year"
366
+ # #chart.axes_y = "value"
367
+ # chart.style = 251
368
+ #end
369
+ def chart(tbl, &block)
370
+ begin
371
+ excel = ExcelWps::WorkBook.new
372
+ #excel.show
373
+ excel.display_alerts = false
374
+ worksheet = excel.add_worksheet("sheet")
375
+ tbl.each do |r|
376
+ worksheet.add_row { |row| row << r }
377
+ end
378
+
379
+ # 获取结束的单元格
380
+ col = tbl[0].size
381
+ end_cell = worksheet.current_row.cell_name(col - 1)
382
+
383
+ worksheet.add_chart do |chart|
384
+ chart.source = worksheet.range("A1:#{end_cell}")
385
+ block.call(chart)
386
+ end
387
+ ensure
388
+ excel.close
389
+ end
390
+
391
+ self.style("正文")
392
+ self.center
393
+ doc_work.Application.Selection.PasteAndFormat(13)
394
+
395
+ # 移动到下一行
396
+ self.move_down
397
+ self.left
398
+ end
399
+
400
+ # 插入分页符
401
+ def page_break
402
+ now.InsertBreak(7)
403
+ end
404
+
405
+ alias :style= :style
406
+ end
407
+
408
+ # 表格
409
+ class Table
410
+ def initialize(selection, row, col, obj)
411
+ @row = row
412
+ @col = col
413
+ @count = row * col
414
+ @selection = selection
415
+ @obj = obj
416
+ end
417
+
418
+ def now
419
+ @selection
420
+ end
421
+
422
+ # 合并列
423
+ def merge_row
424
+ now.SelectRow
425
+ now.Cells.Merge
426
+ @count = @count - @row + 1
427
+ end
428
+
429
+ # 放入数据
430
+ def puts(str)
431
+ now.SelectCell
432
+ now.TypeText(str)
433
+ @count -= 1
434
+ now.MoveRight(12) unless @count < 1
435
+ end
436
+
437
+ # 放入数据, 可以按数组放入
438
+ def <<(arr)
439
+ case arr
440
+ when ::String
441
+ puts(arr)
442
+ when ::Array
443
+ arr.each { |a| puts(a) }
444
+ end
445
+ end
446
+
447
+ # 设置行高
448
+ def height=(point)
449
+ now.Rows.Height = point
450
+ end
451
+
452
+ # 设置风格
453
+ def style=(sty)
454
+ select_all
455
+ now.Style = sty
456
+ end
457
+
458
+ # 设置列宽度
459
+ def set_columns_width(col, point)
460
+ @obj.Columns(col).SetWidth(point, 2)
461
+ end
462
+
463
+ # 移动到第一个单元格
464
+ def top
465
+ @obj.Cell(1,1).Select
466
+ end
467
+
468
+ # 居中
469
+ def center
470
+ select_all
471
+ now.ParagraphFormat.Alignment = 1
472
+ end
473
+
474
+ # 选择整个表格
475
+ def select_all
476
+ @obj.Select
477
+ end
478
+
479
+ # 网格线
480
+ def border_line
481
+ select_all
482
+ now.Borders(-1).LineStyle = 1
483
+ now.Borders(-2).LineStyle = 1
484
+ now.Borders(-3).LineStyle = 1
485
+ now.Borders(-4).LineStyle = 1
486
+ now.Borders(-5).LineStyle = 1
487
+ now.Borders(-6).LineStyle = 1
488
+ end
489
+ end
490
+
491
+ end
492
+ end
@@ -0,0 +1,18 @@
1
+ module Aio::Base
2
+ module Toolkit
3
+
4
+ require "aio/base/toolkit/os"
5
+ require "aio/base/toolkit/regexp"
6
+ require "aio/base/toolkit/array"
7
+ require "aio/base/toolkit/string"
8
+ require "aio/base/toolkit/table"
9
+ require "aio/base/toolkit/deep_clone"
10
+ require "aio/base/toolkit/excel_office"
11
+ require "aio/base/toolkit/excel_wps"
12
+ require "aio/base/toolkit/word_wps"
13
+ # require "aio/base/toolkit/word_office"
14
+ require "aio/base/toolkit/date"
15
+ require "aio/base/toolkit/ipaddr"
16
+
17
+ end
18
+ end
data/lib/aio/base.rb ADDED
@@ -0,0 +1,10 @@
1
+ #
2
+ # Base 模块用于添加基本的字符串,数组的功能,方便二次开发
3
+ #
4
+
5
+ module Base
6
+
7
+ require "aio/base/toolkit"
8
+ require "aio/base/debug"
9
+
10
+ end
@@ -0,0 +1,13 @@
1
+ module Aio::Device
2
+ class Cisco < ParentDevice
3
+
4
+ InvalidInput = /Invalid input detected/
5
+
6
+ def initialize
7
+ super
8
+ @device_type = "cisco"
9
+ end
10
+
11
+ end
12
+ end
13
+
@@ -0,0 +1,113 @@
1
+ #
2
+ # 这个模块用于转换不同设备间的命令
3
+ #
4
+ module Aio::Device
5
+ module CmdSwitch
6
+
7
+ include Aio::Module
8
+
9
+ class << self
10
+ def version(klass)
11
+ case klass
12
+ when Cisco, Maipu
13
+ "show version"
14
+ when H3C
15
+ "display version"
16
+ end
17
+ end
18
+
19
+ def cpu(klass)
20
+ case klass
21
+ when Cisco
22
+ "show process cpu"
23
+ when H3C
24
+ "display cpu-usage"
25
+ when Maipu
26
+ "show cpu"
27
+ end
28
+ end
29
+
30
+ def memory(klass)
31
+ case klass
32
+ when Cisco
33
+ "show process memory"
34
+ when H3C
35
+ "display memory"
36
+ when Maipu
37
+ "show memory"
38
+ end
39
+ end
40
+
41
+ def inventory(klass)
42
+ case klass
43
+ when Cisco
44
+ "show inventory"
45
+ when H3C
46
+ "display device manuinfo"
47
+ end
48
+ end
49
+
50
+ def clock(klass)
51
+ case klass
52
+ when Cisco
53
+ "show clock"
54
+ when H3C
55
+ "display clock"
56
+ end
57
+ end
58
+
59
+ def environment(klass)
60
+ case klass
61
+ when Cisco, Maipu
62
+ "show environment"
63
+ end
64
+ end
65
+
66
+ def power(klass)
67
+ case klass
68
+ when Cisco
69
+ "show environment"
70
+ when H3C
71
+ "display power"
72
+ when Maipu
73
+ "show system power"
74
+ end
75
+ end
76
+
77
+ def fan(klass)
78
+ case klass
79
+ when Cisco
80
+ "show environment"
81
+ when H3C
82
+ "display fan"
83
+ when Maipu
84
+ "show system fan"
85
+ end
86
+ end
87
+
88
+ def interface(klass)
89
+ case klass
90
+ when Cisco, Maipu
91
+ "show interfaces"
92
+ when H3C, Huawei
93
+ "display interface"
94
+ end
95
+ end
96
+
97
+ def interface_brief(klass)
98
+ case klass
99
+ when Cisco
100
+ # if klass.platform == FW
101
+ # "show interface ip brief"
102
+ "show ip interface brief"
103
+ when H3C
104
+ "display ip interface brief"
105
+ when Maipu
106
+ "show ip interface brief"
107
+ end
108
+ end
109
+
110
+
111
+ end # class self
112
+ end
113
+ end
@@ -0,0 +1,12 @@
1
+ module Aio::Device
2
+ class H3C < ParentDevice
3
+
4
+ InvalidInput = /Unrecognized command found/
5
+
6
+ def initialize
7
+ super
8
+ @device_type = "h3c"
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ module Aio::Device
2
+ class Huawei < ParentDevice
3
+
4
+ def initialize
5
+ super
6
+ @device_type = "huawei"
7
+ end
8
+
9
+ end
10
+ end