Skip to content

Commit

Permalink
Merge pull request #136 from RickCarlino/master
Browse files Browse the repository at this point in the history
[STABLE] Remove some abiguity from bot status messages.
  • Loading branch information
RickCarlino committed Jan 4, 2016
2 parents 9a0a5fb + d97cf37 commit 5af2bb0
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions lib/command_objects/report_bot_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,32 @@ class ReportBotStatus < Mutations::Command
def execute
# TODO: Replace everything here with just `bot.status.to_h`. Can't right
# now because it will be a breaking change to the web app.
{
busy: bot.status[:busy],
current_command: bot.status[:last],
x: bot.status[:x],
y: bot.status[:y],
z: bot.status[:z],
last_sync: bot.status_storage.fetch(:pi, :last_sync)
}.merge(pin_info)
.merge(bot.status.to_h)
.deep_symbolize_keys
{}
.merge(status_info)
.merge(pin_info)
.merge(other_info)
.deep_symbolize_keys
end

private

def other_info
bot
.status
.to_h
.except(:X, :Y, :Z, :BUSY, :LAST, :PINS, :S)
end

def status_info
{ busy: bot.status[:busy],
current_command: bot.status[:last],
x: bot.status[:x],
y: bot.status[:y],
z: bot.status[:z],
s: bot.status[:s],
last_sync: bot.status_storage.fetch(:pi, :last_sync) }
end

def pin_info
[*0..13].inject({}) do |hsh, pin|
hsh["pin#{pin}".to_sym] = bot.status.get_pin(pin)
Expand Down

0 comments on commit 5af2bb0

Please sign in to comment.