class GradesFirst::CodeTalkCommand
Public Class Methods
description()
click to toggle source
Description of the “gf codetalk” command that will be used for the commandline help.
# File lib/gradesfirst/code_talk_command.rb, line 7 def self.description 'Show the next dates for code talks.' end
long_description()
click to toggle source
Description of the “gf codetalk” command that will be used in the commandline help to provide a complete description.
# File lib/gradesfirst/code_talk_command.rb, line 13 def self.long_description <<-LONG_DESCRIPTION Code talk dates are calculated based on a zero day date and the list of people who can give code talks. The dates are based on a simple rotation. In order for this command to work correctly, the environment variables GF_DAY_ZERO and GF_CODE_TALKERS need to be properly defined. These can be actual environment variables, a .env file, or .env.master file. The .env file can be in the current directory or the home directory. The .env.master file must be in the current directory. The precedence order is environment variables, .env in the current directory, .env in the home directory, and .env.master in the current directory. It is recommended that .env.master be committed to source control and the other options used to override .env.master. GF_DAY_ZERO is a date in a valid Ruby date string format. GF_CODE_TALKERS is a pipe (|) delimited list of names. Examples: GF_DAY_ZERO="2014-3-10 00:00:00" GF_CODE_TALKERS="Anthony Crumley|Tom Miller|Andrew Sellers" LONG_DESCRIPTION end
Public Instance Methods
execute()
click to toggle source
Performs the gf codetalk command with show the code talk assignments for the next round of talks.
# File lib/gradesfirst/code_talk_command.rb, line 43 def execute @assignments = {} code_talkers.count.times { |index| @assignments[index] = next_talk_date } end
response()
click to toggle source
Generates the command line output response. The output of the codetalk command will be the name and next date for each code talker.
# File lib/gradesfirst/code_talk_command.rb, line 50 def response @assignments. map { |talker_index, date| assignment(talker_index, date) }. join("\n"). concat("\n") end
Private Instance Methods
assignment(talker_index, date)
click to toggle source
# File lib/gradesfirst/code_talk_command.rb, line 59 def assignment(talker_index, date) "#{date.strftime("%m/%d/%Y %a")} - #{next_code_talkers[talker_index]}" end
code_talkers()
click to toggle source
# File lib/gradesfirst/code_talk_command.rb, line 63 def code_talkers config.code_talkers.sort end
next_code_talkers()
click to toggle source
# File lib/gradesfirst/code_talk_command.rb, line 67 def next_code_talkers @next_code_talkers ||= code_talkers.rotate(talk_count % code_talkers.count) end
next_talk_date()
click to toggle source
# File lib/gradesfirst/code_talk_command.rb, line 71 def next_talk_date if @next_talk_date @next_talk_date = @next_talk_date.next_day else @next_talk_date = today end until @next_talk_date.thursday? @next_talk_date = @next_talk_date.next_day end @next_talk_date end
talk_count()
click to toggle source
# File lib/gradesfirst/code_talk_command.rb, line 85 def talk_count talk_range.reduce(0) do |count, date| count += 1 if date.thursday? count end end
talk_range()
click to toggle source
# File lib/gradesfirst/code_talk_command.rb, line 92 def talk_range day_zero.to_date..today.prev_day end
today()
click to toggle source
# File lib/gradesfirst/code_talk_command.rb, line 96 def today Date.today end