Sha256: e7f740c53ccd44e5ee1d9ba4545f7784da8270add14a10307ec7be2e37344ceb

Contents?: true

Size: 1009 Bytes

Versions: 1

Compression:

Stored size: 1009 Bytes

Contents

module FlightPlanCli
  module Config
    private

    YAML_FILE = '.flight_plan_cli.yml'.freeze

    attr_reader :board_id, :repo_id, :default_swimlane_ids
    attr_reader :api_url, :api_key, :api_secret

    def read_config
      @board_id = config['board_id']
      @repo_id = config['repo_id']
      @default_swimlane_ids = config['ls']['default_swimlane_ids']

      @api_url = config['api_url']
      @api_key = ENV['FLIGHT_PLAN_API_KEY']
      @api_secret = ENV['FLIGHT_PLAN_API_SECRET']
    end

    def client
      @client ||= FlightPlanCli::Api.new(
        url: api_url,
        key: api_key,
        secret: api_secret,
        board_id: board_id,
        repo_id: repo_id
      )
    end

    def git
      @git ||= Rugged::Repository.new(Dir.pwd)
    end

    def config
      @config ||=
        begin
          unless File.exist?(YAML_FILE)
            puts "Could not file #{YAML_FILE} file."
            exit 1
          end
          YAML.load_file(YAML_FILE)
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flight_plan_cli-0.2.6 lib/flight_plan_cli/config.rb