Class: GradesFirst::CodeTalkCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/gradesfirst/code_talk_command.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.descriptionObject

Description of the “gf codetalk” command that will be used for the commandline help.



7
8
9
# File 'lib/gradesfirst/code_talk_command.rb', line 7

def self.description
  'Show the next dates for code talks.'
end

.long_descriptionObject

Description of the “gf codetalk” command that will be used in the commandline help to provide a complete description.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 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

Instance Method Details

#executeObject

Performs the gf codetalk command with show the code talk assignments for the next round of talks.



43
44
45
46
# File 'lib/gradesfirst/code_talk_command.rb', line 43

def execute
  @assignments = {}
  code_talkers.count.times { |index| @assignments[index] = next_talk_date }
end

#responseObject

Generates the command line output response. The output of the codetalk command will be the name and next date for each code talker.



50
51
52
53
54
55
# 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