Sha256: 6c053c1544315852afa547521550f0daaac3c7c431a0db434aa765225b3d7e9a

Contents?: true

Size: 963 Bytes

Versions: 14

Compression:

Stored size: 963 Bytes

Contents

require "trello_flow/config_store"
require "trello_flow/api/base"

module TrelloFlow
  class GlobalConfig
    PATH = ENV["HOME"] + "/.trello_flow"

    def initialize(store = nil)
      @store = store || ConfigStore.new(PATH)
    end

    def key
      @_key ||= store[:key] || configure_key
    end

    def token
      @_token ||= store[:token] || configure_token
    end

    private

      attr_reader :store

      def configure_key
        Cli.ask "Press enter to setup Trello for this project (will open public key url)"
        Cli.open_url "https://trello.com/app-key"
        store.save :key, Cli.ask("Input Developer API key")
      end

      def configure_token
        Cli.open_url authorize_url(key)
        store.save :token, Cli.ask("Input member token")
      end

      def authorize_url(key)
        "https://trello.com/1/authorize?key=#{key}&name=Trello-Flow&scope=read,write,account&expiration=never&response_type=token"
      end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
trello_flow-3.8.0 lib/trello_flow/global_config.rb
trello_flow-3.7.1 lib/trello_flow/global_config.rb
trello_flow-3.7.0 lib/trello_flow/global_config.rb
trello_flow-3.6.0 lib/trello_flow/global_config.rb
trello_flow-3.5.0 lib/trello_flow/global_config.rb
trello_flow-3.4.0 lib/trello_flow/global_config.rb
trello_flow-3.3.0 lib/trello_flow/global_config.rb
trello_flow-3.1.0 lib/trello_flow/global_config.rb
trello_flow-3.0.0 lib/trello_flow/global_config.rb
trello_flow-2.3.1 lib/trello_flow/global_config.rb
trello_flow-2.3.0 lib/trello_flow/global_config.rb
trello_flow-2.2.1 lib/trello_flow/global_config.rb
trello_flow-2.2.0 lib/trello_flow/global_config.rb
trello_flow-2.1.0 lib/trello_flow/global_config.rb