Sha256: 85cf7ff3e772c8d1e333638637bada7fda7c8e818b946de6ce2d05b8c46b9a9e

Contents?: true

Size: 622 Bytes

Versions: 11

Compression:

Stored size: 622 Bytes

Contents

# frozen_string_literal: true

require 'pathname'

module Cased
  module CLI
    class Authentication
      attr_reader :directory
      attr_reader :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

11 entries across 11 versions & 1 rubygems

Version Path
cased-ruby-0.5.2 lib/cased/cli/authentication.rb
cased-ruby-0.5.1 lib/cased/cli/authentication.rb
cased-ruby-0.5.0 lib/cased/cli/authentication.rb
cased-ruby-0.4.8 lib/cased/cli/authentication.rb
cased-ruby-0.4.7 lib/cased/cli/authentication.rb
cased-ruby-0.4.6 lib/cased/cli/authentication.rb
cased-ruby-0.4.5 lib/cased/cli/authentication.rb
cased-ruby-0.4.4 lib/cased/cli/authentication.rb
cased-ruby-0.4.3 lib/cased/cli/authentication.rb
cased-ruby-0.4.2 lib/cased/cli/authentication.rb
cased-ruby-0.4.1 lib/cased/cli/authentication.rb