gradesfirst 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.platform = Gem::Platform::RUBY
3
3
  s.name = "gradesfirst"
4
- s.version = "0.5.1"
4
+ s.version = "0.6.0"
5
5
  s.summary = "GradesFirst command line utility for developers."
6
6
  s.description = "This utility will help manage the various tasks developers need to do on their workstation such as database updates."
7
7
  s.license = "MIT"
@@ -3,6 +3,7 @@ require 'thor'
3
3
  require 'gradesfirst/cli_helper'
4
4
  require 'gradesfirst/command'
5
5
  require 'gradesfirst/branch_command'
6
+ require 'gradesfirst/code_talk_command'
6
7
  require 'gradesfirst/commit_message_command'
7
8
  require 'gradesfirst/pair_command'
8
9
  require 'gradesfirst/task_cli'
@@ -19,6 +20,11 @@ module GradesFirst
19
20
  execute GradesFirst::BranchCommand
20
21
  end
21
22
 
23
+ desc 'codetalk', GradesFirst::CodeTalkCommand.description
24
+ def codetalk
25
+ execute GradesFirst::CodeTalkCommand
26
+ end
27
+
22
28
  desc 'commit-message', GradesFirst::CommitMessageCommand.description
23
29
  def commit_message
24
30
  set_pivotal_tracker_api_token
@@ -0,0 +1,79 @@
1
+ require 'gradesfirst/command'
2
+
3
+ module GradesFirst
4
+ class CodeTalkCommand < GradesFirst::Command
5
+ # Description of the "gf codetalk" command that will be used for the
6
+ # commandline help.
7
+ def self.description
8
+ 'Show the next dates for code talks.'
9
+ end
10
+
11
+ # Performs the gf codetalk command with show the code talk assignments
12
+ # for the next round of talks.
13
+ def execute
14
+ @assignments = {}
15
+ code_talkers.count.times { |index| @assignments[index] = next_talk_date }
16
+ end
17
+
18
+ # Generates the command line output response. The output of the codetalk
19
+ # command will be the name and next date for each code talker.
20
+ def response
21
+ @assignments.
22
+ map { |talker_index, date| assignment(talker_index, date) }.
23
+ join("\n").
24
+ concat("\n")
25
+ end
26
+
27
+ private
28
+
29
+ def assignment(talker_index, date)
30
+ "#{date.strftime("%m/%d/%Y %a")} - #{next_code_talkers[talker_index]}"
31
+ end
32
+
33
+ def code_talkers
34
+ [
35
+ "Anthony Crumley",
36
+ "Tom Miller",
37
+ "Andrew Sellers",
38
+ "Matt Turney",
39
+ "Zac Williams",
40
+ "Ben Holley",
41
+ "Chris Collins",
42
+ "Evan Travers"
43
+ ].sort
44
+ end
45
+
46
+ def next_code_talkers
47
+ @next_code_talkers ||= code_talkers.rotate(talk_count % code_talkers.count)
48
+ end
49
+
50
+ def next_talk_date
51
+ if @next_talk_date
52
+ @next_talk_date = @next_talk_date.next_day
53
+ else
54
+ @next_talk_date = today
55
+ end
56
+
57
+ until @next_talk_date.tuesday? || @next_talk_date.thursday?
58
+ @next_talk_date = @next_talk_date.next_day
59
+ end
60
+
61
+ @next_talk_date
62
+ end
63
+
64
+ def talk_count
65
+ talk_range.reduce(0) do |count, date|
66
+ count += 1 if date.tuesday? || date.thursday?
67
+ count
68
+ end
69
+ end
70
+
71
+ def talk_range
72
+ day_zero.to_date..today.prev_day
73
+ end
74
+
75
+ def today
76
+ Date.today
77
+ end
78
+ end
79
+ end
@@ -25,5 +25,11 @@ module GradesFirst
25
25
  nil
26
26
  end
27
27
  end
28
+
29
+ # Currently hard coded to return the beginning of a GradesFirst sprint but
30
+ # could be put in a configuration file in the future.
31
+ def day_zero
32
+ Time.parse("2014-3-10 00:00:00")
33
+ end
28
34
  end
29
35
  end
@@ -44,7 +44,7 @@ module GradesFirst
44
44
  @developers
45
45
  end
46
46
 
47
- # This algorythm was written by Tom Miller based on the wikipedia article on
47
+ # This algorithm was written by Tom Miller based on the wikipedia article on
48
48
  # round robin tournaments.
49
49
  #
50
50
  # https://en.wikipedia.org/wiki/Round-robin_tournament
@@ -96,12 +96,5 @@ module GradesFirst
96
96
  def now
97
97
  Time.now
98
98
  end
99
-
100
- # Currently hard coded to return the beginning of a GradesFirst sprint but
101
- # could be put in a configuration file in the future.
102
- def day_zero
103
- Time.parse("2014-3-10 00:00:00")
104
- end
105
-
106
99
  end
107
100
  end
@@ -42,6 +42,10 @@ describe GradesFirst::CLI do
42
42
  assert_command_hooked_up 'branch', GradesFirst::BranchCommand
43
43
  end
44
44
 
45
+ specify 'codetalk command is hooked up' do
46
+ assert_command_hooked_up 'codetalk', GradesFirst::CodeTalkCommand
47
+ end
48
+
45
49
  specify 'commit-message command is hooked up' do
46
50
  assert_command_hooked_up 'commit-message', GradesFirst::CommitMessageCommand
47
51
  end
@@ -0,0 +1,44 @@
1
+ require 'test_helper'
2
+ require 'gradesfirst/code_talk_command'
3
+
4
+ describe GradesFirst::CodeTalkCommand do
5
+ before do
6
+ @command = GradesFirst::CodeTalkCommand.new
7
+ @code_talkers = [
8
+ 'Mickey Mouse',
9
+ 'Cat Woman',
10
+ 'Wonder Woman',
11
+ 'Superman',
12
+ 'Minnie Mouse',
13
+ 'Ironman'
14
+ ]
15
+ end
16
+
17
+ specify '#execute schedules code talks correctly' do
18
+ @command.stub :code_talkers, @code_talkers do
19
+ @command.stub :today, Date.parse("2014-3-25") do
20
+ @command.execute
21
+ assert_equal(
22
+ fixture_file('code_talk.txt'),
23
+ @command.response,
24
+ 'Code talk schedule is not correct.'
25
+ )
26
+ end
27
+ end
28
+ end
29
+
30
+ def assert_talk_count(date, count, message)
31
+ @command.stub :today, Date.parse(date) do
32
+ assert_equal(count, @command.send(:talk_count), message)
33
+ end
34
+ end
35
+
36
+ specify '#talk_count counts talks correctly' do
37
+ assert_talk_count("2014-3-10", 0, 'Zero day should not count any talks')
38
+ assert_talk_count("2014-3-11", 0, 'Tuesday should not be counted')
39
+ assert_talk_count("2014-3-12", 1, 'Tuesday should be counted on Wednesday')
40
+ assert_talk_count("2014-3-13", 1, 'Thursday should not be counted')
41
+ assert_talk_count("2014-3-14", 2, 'Thursday should be counted on Friday')
42
+ assert_talk_count("2014-3-25", 4, 'Test date count is wrong')
43
+ end
44
+ end
@@ -0,0 +1,6 @@
1
+ 03/25/2014 Tue - Minnie Mouse
2
+ 03/27/2014 Thu - Ironman
3
+ 04/01/2014 Tue - Mickey Mouse
4
+ 04/03/2014 Thu - Cat Woman
5
+ 04/08/2014 Tue - Wonder Woman
6
+ 04/10/2014 Thu - Superman
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gradesfirst
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-07 00:00:00.000000000 Z
12
+ date: 2014-05-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -79,6 +79,7 @@ files:
79
79
  - lib/gradesfirst/branch_command.rb
80
80
  - lib/gradesfirst/cli.rb
81
81
  - lib/gradesfirst/cli_helper.rb
82
+ - lib/gradesfirst/code_talk_command.rb
82
83
  - lib/gradesfirst/command.rb
83
84
  - lib/gradesfirst/commit_message_command.rb
84
85
  - lib/gradesfirst/pair_command.rb
@@ -92,8 +93,10 @@ files:
92
93
  - lib/pivotal_tracker.rb
93
94
  - test/branch_command_test.rb
94
95
  - test/cli_test.rb
96
+ - test/code_talk_command_test.rb
95
97
  - test/command_test.rb
96
98
  - test/commit_message_command_test.rb
99
+ - test/fixtures/code_talk.txt
97
100
  - test/fixtures/commit_message.txt
98
101
  - test/fixtures/gf_branch.txt
99
102
  - test/fixtures/git_branch.txt