diff options
author | ytti <saku@ytti.fi> | 2018-04-25 16:12:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-25 16:12:44 +0300 |
commit | 583bc422448a234a215113a15f8a6976c50b2296 (patch) | |
tree | b3f757e6f37aa058a0c80e4ded3ef82553bc98c1 /lib/oxidized/model/tplink.rb | |
parent | 9a7d16c00163c421d2c9f3cb2783c76633860336 (diff) | |
parent | dffae0f76656a57da8f5473ce21955638cbe1f7f (diff) |
Merge pull request #1296 from wk/the-great-makeover
the great makeover - standardize layout, alignment, indentation
Diffstat (limited to 'lib/oxidized/model/tplink.rb')
-rw-r--r-- | lib/oxidized/model/tplink.rb | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/oxidized/model/tplink.rb b/lib/oxidized/model/tplink.rb index bf13803..2a61fa5 100644 --- a/lib/oxidized/model/tplink.rb +++ b/lib/oxidized/model/tplink.rb @@ -1,26 +1,25 @@ class TPLink < Oxidized::Model - # tp-link prompt prompt /^\r?([\w.@()-]+[#>]\s?)$/ - comment '! ' + comment '! ' # handle paging # workaround for sometimes missing whitespaces with "\s?" expect /Press\s?any\s?key\s?to\s?continue\s?\(Q\s?to\s?quit\)/ do |data, re| - send ' ' - data.sub re, '' + send ' ' + data.sub re, '' end # send carriage return because \n with the command is not enough # checks if line ends with prompt >,# or \r,\nm otherwise send \r expect /[^>#\r\n]$/ do |data, re| - send "\r" - data.sub re, '' + send "\r" + data.sub re, '' end cmd :all do |cfg| # normalize linefeeds - cfg.gsub! /(\r|\r\n|\n\r)/,"\n" + cfg.gsub! /(\r|\r\n|\n\r)/, "\n" # remove empty lines cfg.each_line.reject { |line| line.match /^[\r\n\s\u0000#]+$/ }.join end @@ -31,7 +30,7 @@ class TPLink < Oxidized::Model cfg end - cmd 'show system-info' do |cfg| + cmd 'show system-info' do |cfg| comment cfg.each_line.to_a[3..-3].join end @@ -58,8 +57,5 @@ class TPLink < Oxidized::Model send "exit\r" send "logout\r" end - end - end - |