Sha256: 3da2c5fee8a499598996eb0162f797fa5131d8c1417f881b3ddc7d625bb24fd8

Contents?: true

Size: 857 Bytes

Versions: 2

Compression:

Stored size: 857 Bytes

Contents

module Scoutui::Base

  class QAccounts


    attr_accessor :dut
    attr_accessor :accounts

    def initialize(f='/Users/pkim/working/nui-qa/apps/gat/data/accounts.yaml')
      @accounts = YAML.load_stream File.read(f)
    end

    def _find(id, attr)
      hit = accounts.find { |h| h['account']['loginid'] == id }
      if !hit.nil?
        id=hit['account'][attr]
      end
      id
    end

    def getUserRecord(u)
      hit=nil

      userid=getUserId(u)
      if !userid.nil?
        hit={'userid' => getUserId(u), 'password' => getPassword(u) }
      end

      hit
    end

    def getUserId(userid)
      id=nil
      hit = accounts.find { |h| h['account']['loginid'].to_s == userid.to_s }
      if !hit.nil?
        id=hit['account']['loginid']
      end
      id
    end

    def getPassword(u)
      _find(u, 'password')
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scoutui-0.1.2 lib/scoutui/base/q_accounts.rb
scoutui-0.1.1 lib/scoutui/base/q_accounts.rb