Sha256: c72169f58bbe501e43aed496752ca2e5221fb43552cccfad0d219191b8955e54
Contents?: true
Size: 1.06 KB
Versions: 4
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true # Ruby internal require 'csv' # Pass Station module module PassStation # Password database handling class DB # Register CSV converters for parsing def csv_config strip_converter = proc { |field| field.strip } CSV::Converters[:strip] = strip_converter # https://github.com/ruby/csv/issues/208 # @config[:strip] = true # @config[:liberal_parsing] = true @config[:headers] = true @config[:converters] = :strip @config[:header_converters] = :symbol @config[:empty_value] = '<blank>' @config[:nil_value] = '<blank>' end # Parse, sort and sanitize the password database # @param sort [Symbol] column name to sort by: +:productvendor+, +:username+, +:password+ # @return [Array<CSV::Row>] table of +CSV::Row+, each row contains three # attributes: :productvendor, :username, :password def parse(sort = :productvendor) @data = CSV.table(@database_path, **@config).sort_by do |s| s[sort].downcase end end protected :csv_config end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
pass-station-1.2.2 | lib/pass_station/parse.rb |
pass-station-1.2.1 | lib/pass_station/parse.rb |
pass-station-1.2.0 | lib/pass_station/parse.rb |
pass-station-1.1.0 | lib/pass_station/parse.rb |