Sha256: 4394f160709d432cd3b39cb61d3ff8d11f3997ec797ebf8911cb640c331fe915

Contents?: true

Size: 1.05 KB

Versions: 12

Compression:

Stored size: 1.05 KB

Contents

# encoding: utf-8

require 'fileutils'
require 'multi_json'

require_relative 'global_helpers'

module GoodData
  module Helpers
    module AuthHelper
      class << self
        # Get path of .gooddata config
        def credentials_file
          "#{Helpers.home_directory}/.gooddata"
        end

        # Read credentials
        def read_credentials(credentials_file_path = credentials_file)
          if File.exist?(credentials_file_path)
            config = File.read(credentials_file_path)
            MultiJson.load(config, :symbolize_keys => true)
          else
            {}
          end
        end

        # Writes credentials
        def write_credentials(credentials, credentials_file_path = credentials_file)
          File.open(credentials_file_path, 'w', 0600) do |f|
            f.puts MultiJson.encode(credentials, :pretty => true)
          end
          credentials
        end

        def remove_credentials_file(credentials_file_path = credentials_file)
          FileUtils.rm_f(credentials_file_path)
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
gooddata-0.6.19 lib/gooddata/helpers/auth_helpers.rb
gooddata-0.6.18 lib/gooddata/helpers/auth_helpers.rb
gooddata-0.6.17 lib/gooddata/helpers/auth_helpers.rb
gooddata-0.6.16 lib/gooddata/helpers/auth_helpers.rb
gooddata-0.6.15 lib/gooddata/helpers/auth_helpers.rb
gooddata-0.6.14 lib/gooddata/helpers/auth_helpers.rb
gooddata-0.6.13 lib/gooddata/helpers/auth_helpers.rb
gooddata-0.6.12 lib/gooddata/helpers/auth_helpers.rb
gooddata-0.6.11 lib/gooddata/helpers/auth_helpers.rb
gooddata-0.6.10 lib/gooddata/helpers/auth_helpers.rb
gooddata-0.6.9 lib/gooddata/helpers/auth_helpers.rb
gooddata-0.6.8 lib/gooddata/helpers/auth_helpers.rb