class Pello::Runner

Attributes

board_url[RW]
list_name[RW]
log_file_path[RW]
prompt[RW]
username[RW]

Public Class Methods

new() click to toggle source
# File lib/pello/runner.rb, line 15
def initialize
  @prompt = TTY::Prompt.new
  configure_pello
end

Public Instance Methods

run!() click to toggle source
# File lib/pello/runner.rb, line 20
def run!
  continue = true

  while continue
    case prompt.select('Choose task') do |menu|
      menu.choice name: 'Add pomodori', value: :add_pomodori
      menu.choice name: 'Move card', value: :move_card
      menu.choice name: 'Print board pomodori report', value: :report
      menu.choice name: 'Edit config', value: :edit_config
      menu.choice name: 'quit', value: :quit
    end
    when :add_pomodori
      add_pomodori_to_card
    when :move_card
      move_card
    when :report
      report
    when :edit_config
      editor = ENV['EDITOR'] || 'vim'
      system 'mkdir -p ~/.config/pello'
      system "#{editor} ~/.config/pello/pello.yaml"
    when :quit
      puts 'Ok, bye!'
      exit
    end
  end
end

Private Instance Methods

add_pomodori_to_card() click to toggle source
# File lib/pello/runner.rb, line 50
def add_pomodori_to_card
  Pello::Actions::AddPomodoriToCard.new(prompt).run(@user, board_url, list_name)
end
configure_pello() click to toggle source
# File lib/pello/runner.rb, line 62
def configure_pello
  config = Pello::Config.new
  if config.valid?
    Trello.configure do |trello_config|
      trello_config.developer_public_key = config.developer_public_key
      trello_config.member_token = config.member_token
    end

    @user          = Trello::Member.find config.username
    @board_url     = config.board_url
    @list_name     = config.list_name
  else
    puts 'No config found, opening config file...'
    Pello::Config.write_empty_config
    system "#{ENV['EDITOR']} #{Pello::Config::CONFIG_FILE_PATH}"
    exit
  end
end
move_card() click to toggle source
# File lib/pello/runner.rb, line 54
def move_card
  Pello::Actions::MoveCard.new(prompt).run(@user, board_url, list_name)
end
report() click to toggle source
# File lib/pello/runner.rb, line 58
def report
  Pello::Actions::Report.new.run(@user, board_url)
end