class Troo::Commands::RefreshAll

Public Class Methods

dispatch() click to toggle source

@return [String]

# File lib/troo/cli/commands/refresh/all.rb, line 5
def self.dispatch
  new.refresh_all
end

Public Instance Methods

refresh_all() click to toggle source

@return [String]

# File lib/troo/cli/commands/refresh/all.rb, line 10
def refresh_all
  return success if refreshed?
  failure
end

Private Instance Methods

all_boards() click to toggle source
# File lib/troo/cli/commands/refresh/all.rb, line 43
def all_boards
  @boards ||= Retrieval::Remote
    .fetch(Remote::Board, nil, options)
end
external_ids() click to toggle source
# File lib/troo/cli/commands/refresh/all.rb, line 39
def external_ids
  all_boards.map(&:id)
end
failure() click to toggle source
# File lib/troo/cli/commands/refresh/all.rb, line 21
def failure
  'Cannot refresh all local data.'
end
options() click to toggle source
# File lib/troo/cli/commands/refresh/all.rb, line 48
def options
  {
    mode:    :all,
    persist: false
  }
end
refreshed?() click to toggle source
# File lib/troo/cli/commands/refresh/all.rb, line 25
def refreshed?
  return false if resources.none?
  Troo::Refresh.completed!
  true
end
resources() click to toggle source
# File lib/troo/cli/commands/refresh/all.rb, line 31
def resources
  @resources ||= external_ids.inject([]) do |acc, id|
    acc << Retrieval::Remote.fetch(Remote::Board, id, mode: :board)
    acc << Retrieval::Remote.fetch(Remote::Comment, id, mode: :board)
    acc
  end
end
success() click to toggle source
# File lib/troo/cli/commands/refresh/all.rb, line 17
def success
  'All local data refreshed.'
end