Sha256: a62a53d33d698976b8891a8169198f7beb98426d02b99dc3d09ff4631c21b6a8

Contents?: true

Size: 605 Bytes

Versions: 4

Compression:

Stored size: 605 Bytes

Contents

# frozen_string_literal: true

require 'pathname'

module Cased
  module CLI
    class Authentication
      attr_reader :directory, :credentials_path
      attr_writer :token

      def initialize(token: nil)
        @token = token || Cased.config.guard_user_token
        @directory = Pathname.new(File.expand_path('~/.cguard'))
        @credentials_path = @directory.join('credentials')
      end

      def exists?
        !token.nil?
      end

      def token
        @token ||= begin
          credentials_path.read
        rescue Errno::ENOENT
          nil
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cased-ruby-0.8.0 lib/cased/cli/authentication.rb
cased-ruby-0.7.1 lib/cased/cli/authentication.rb
cased-ruby-0.7.0 lib/cased/cli/authentication.rb
cased-ruby-0.6.1 lib/cased/cli/authentication.rb