Sha256: bba6506d3c231d17e536c9475b0ef751623a6c074c0f99cea5bc82ac50c4a5a3

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

require 'startling'
require 'highline/import'
require 'trello'
require_relative 'startling_trello/api'
require_relative 'startling_trello/commands/trello_start'

module StartlingTrello
  class << self
    def method_missing(method, *args, &block)
      Startling.send(method, *args, &block)
    end
  end

  def self.api
    @api ||= get_api
  end

  private

  def self.get_api
    developer_public_key = get_developer_public_key
    member_token = get_member_token(developer_public_key)

    Api.new(
      developer_public_key: developer_public_key,
      member_token: member_token
    )
  end

  def self.get_developer_public_key
    return developer_public_key unless developer_public_key.nil?

    Trello.open_public_key_url
    abort 'Trello developer API key is not configured. Get a developer public key and add it to the configuration file.'
  end

  def self.get_member_token(developer_public_key)
    Startling.cache.fetch('.trello_member_token') do
      Trello.open_authorization_url(key: developer_public_key)
      ask('Enter your member token: ')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
startling_trello-0.0.4 lib/startling_trello.rb
startling_trello-0.0.3 lib/startling_trello.rb
startling_trello-0.0.2 lib/startling_trello.rb
startling_trello-0.0.1 lib/startling_trello.rb