Sha256: 27961c8f995a3aac682741039f698c7524c12eb91542d9927f63c506ba4a3caf

Contents?: true

Size: 1.55 KB

Versions: 3

Compression:

Stored size: 1.55 KB

Contents

module Lita
  module Standups
    module Wizards
      class ScheduleStandup < Lita::Wizard

        step :repeat,
             label: 'How often? (daily, weekly)',
             options: %w(daily weekly)

        step :day_of_week,
             label: 'What day of week? (monday ... sunday)',
             options: %w(monday tuesday wednesday thursday friday saturday sunday),
             if: ->(wizard) { value_for(:repeat) == 'weekly' }

        step :time,
             label: 'At what time? (ex 9am)',
             validate: /^([1-9]|1[0-2]|0[1-9])?(:[0-5][0-9])?\s?([aApP][mM])?$/

        step :recipients,
             label: 'Enter the standup members: ',
             multiline: true

        step :channel,
             label: 'On what channel do you want to post the results to?'

        def finish_wizard
          @schedule = Models::StandupSchedule.create(
            standup: standup,
            repeat: value_for(:repeat),
            day_of_week: value_for(:day_of_week),
            time: value_for(:time),
            recipients: value_for(:recipients).to_s.gsub("@", "").split(/[\s,\n]/m).map(&:strip).map(&:presence).compact,
            channel: value_for(:channel)
          )
          robot.schedule_standup(@schedule)
        end

        def final_message
          [
            "You're done! Below is the summary of your scheduled standup:",
            ">>>",
            @schedule.description
          ].join("\n")
        end

        def standup
          @standup ||= Models::Standup[meta['standup_id']]
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lita-standups-1.0.2 lib/lita/standups/wizards/schedule_standup.rb
lita-standups-1.0.1 lib/lita/standups/wizards/schedule_standup.rb
lita-standups-1.0.0 lib/lita/standups/wizards/schedule_standup.rb