Sha256: 4978b0ae3d144d43bfb0c95e8706c1196ea98bac77d072934bf06d76d440cda6

Contents?: true

Size: 967 Bytes

Versions: 17

Compression:

Stored size: 967 Bytes

Contents

module Oxidized
  class Input
    module CLI

      def initialize
        @post_login = []
        @pre_logout = []
        @username, @password, @exec = nil
      end

      def get
        connect_cli
        d = @node.model.get
        disconnect
        d
      end

      def connect_cli
        @post_login.each { |command, block| block ? block.call : (cmd command) }
      end

      def disconnect_cli
        @pre_logout.each { |command, block| block ? block.call : (cmd command, nil) }
      end

      def post_login _post_login=nil, &block
        unless @exec
          @post_login << [_post_login, block]
        end
      end

      def pre_logout _pre_logout=nil, &block
        unless @exec
          @pre_logout <<  [_pre_logout, block]
        end
      end

      def username re=/^(Username|login)/
        @username or @username = re
      end

      def password re=/^Password/
        @password or @password = re
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
oxidized-0.9.0 lib/oxidized/input/cli.rb
oxidized-0.8.1 lib/oxidized/input/cli.rb
oxidized-0.8.0 lib/oxidized/input/cli.rb
oxidized-0.7.2 lib/oxidized/input/cli.rb
oxidized-0.7.1 lib/oxidized/input/cli.rb
oxidized-0.7.0 lib/oxidized/input/cli.rb
oxidized-0.6.0 lib/oxidized/input/cli.rb
oxidized-0.5.0 lib/oxidized/input/cli.rb
oxidized-0.4.1 lib/oxidized/input/cli.rb
oxidized-0.4.0 lib/oxidized/input/cli.rb
oxidized-0.3.0 lib/oxidized/input/cli.rb
oxidized-0.2.4 lib/oxidized/input/cli.rb
oxidized-0.2.3 lib/oxidized/input/cli.rb
oxidized-0.2.2 lib/oxidized/input/cli.rb
oxidized-0.2.1 lib/oxidized/input/cli.rb
oxidized-0.2.0 lib/oxidized/input/cli.rb
oxidized-0.1.1 lib/oxidized/input/cli.rb