Sha256: 98c264cf0f447911e20617f5921fcf08417e57251cea2c9349775b86d3df632c

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

# Project internal
require 'pass_station/source'
require 'pass_station/parse'
require 'pass_station/search'
require 'pass_station/version'

# Pass Station module
module PassStation
  # Constants
  include Version

  # Password database handling
  class DB
    # Get / set storage location, where will be stored the password database.
    # @return [String] database storage location. Default to +data/+.
    attr_accessor :storage_location

    # Get / set the password database name
    # @return [String] password database filename. Default to
    #   +DefaultCreds-Cheat-Sheet.csv+.
    attr_accessor :database_name

    # Get the password database in +Array<CSV::Row>+ format
    # @return [Array<CSV::Row>] pasword database
    attr_reader :data

    # A new instance of Pass Station
    def initialize
      @storage_location = 'data/'
      @database_name = 'DefaultCreds-Cheat-Sheet.csv'
      @database_path = @storage_location + @database_name
      database_exists?
      @config = {}
      csv_config
      @data = nil
      @search_result = []
    end

    # Check if the password database exists
    # @return [Boolean] +true+ if the file exists
    def database_exists?
      exists = File.file?(@database_path)
      raise "Database does not exist: #{@database_path}" unless exists

      exists
    end

    protected :database_exists?
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pass-station-1.1.0 lib/pass_station.rb