Class: Hyrb::Tasks::Hipchat::ArchiveOldRooms

Inherits:
Hyrb::Task
  • Object
show all
Defined in:
lib/hyrb/tasks/hipchat.rb

Instance Attribute Summary

Attributes inherited from Hyrb::Task

#env, #pipeline

Instance Method Summary collapse

Methods inherited from Hyrb::Task

depends, #initialize, prompt, prompts, #run_before

Constructor Details

This class inherits a constructor from Hyrb::Task

Instance Method Details

#run(env) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/hyrb/tasks/hipchat.rb', line 57

def run(env)
  floor = Time.now - 3.months
  say "Listing all unarchived room last active before #{floor}"
  say "CTRL+C to exit"
  old_rooms = env.hipchat_rooms.select do |room|
    room["is_archived"] == false && room["last_active"] < floor.to_i
  end

  old_rooms.each do |room|
    if yes? "Archive #{room["name"]}? (last active at #{Time.at(room["last_active"])})"
      say "Hipchat does not support archiving rooms via the API :(", :red
    else
      say "Spared #{room["name"]}", :yellow
    end
  end
end