rrschedule 0.1.2 → 0.1.3

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.
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ rdoc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
+ *.gemspec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
data/lib/rrschedule.rb CHANGED
@@ -1,9 +1,7 @@
1
1
  # rrschedule (Round Robin Schedule generator)
2
2
  # Auhtor: François Lamontagne
3
3
  ############################################################################################################################
4
- require 'rubygems'
5
4
  require 'active_support'
6
-
7
5
  module RRSchedule
8
6
  class Schedule
9
7
  attr_accessor :playing_surfaces, :game_times, :cycles, :wdays, :start_date, :exclude_dates, :shuffle_initial_order
@@ -13,7 +11,7 @@ module RRSchedule
13
11
  self.teams = params[:teams] || [1,2,3,4,5]
14
12
  self.playing_surfaces = params[:playing_surfaces] || ["--"]
15
13
  self.cycles = params[:cycles] || 1
16
- self.game_times = params[:game_times] || ["7:00 PM"]
14
+ self.game_times = params[:game_times] || ["Game time not specified"]
17
15
  self.shuffle_initial_order = params[:shuffle_initial_order] || true
18
16
  self.exclude_dates = params[:exclude_dates] || []
19
17
  self.start_date = params[:start_date] || Time.now.beginning_of_day
@@ -42,10 +40,16 @@ module RRSchedule
42
40
  #round completed
43
41
  current_round += 1
44
42
  @rounds ||= []
45
- @rounds << Round.new(:round => current_round, :games => games.collect {|g| Game.new(:team_a => g[:team_a], :team_b => g[:team_b])})
43
+ @rounds << Round.new(
44
+ :round => current_round,
45
+ :games => games.collect { |g| Game.new(
46
+ :team_a => g[:team_a],
47
+ :team_b => g[:team_b])
48
+ })
46
49
 
47
- games.reject! {|g| g[:team_a] == :dummy || g[:team_b] == :dummy}
48
- all_games.reject! {|g| g[:team_a] == :dummy || g[:team_b] == :dummy}
50
+ reject_dummy = lambda {|g| g[:team_a] == :dummy || g[:team_b] == :dummy}
51
+ games.reject! {|g| reject_dummy.call(g)}
52
+ all_games.reject! {|g| reject_dummy.call(g)}
49
53
 
50
54
  @teams = @teams.insert(1,@teams.delete_at(@teams.size-1))
51
55
 
@@ -67,7 +71,7 @@ module RRSchedule
67
71
  def face_to_face(team_a,team_b)
68
72
  res=[]
69
73
  self.gamedays.each do |gd,games|
70
- res << games.select{|g| (g.team_a == team_a && g.team_b == team_b) || (g.team_a == team_b && g.team_b == team_a)}
74
+ res << games.select {|g| (g.team_a == team_a && g.team_b == team_b) || (g.team_a == team_b && g.team_b == team_a)}
71
75
  end
72
76
  res.flatten
73
77
  end
@@ -76,11 +80,10 @@ module RRSchedule
76
80
  res = ""
77
81
  res << "#{@schedule.keys.size.to_s} gamedays\n"
78
82
  @schedule.sort.each do |gd,games|
79
- gd_proc = lambda {gd.strftime("%Y-%m-%d")}
80
- res << gd_proc.call + "\n"
81
- res << "=" * gd_proc.call.length + "\n"
83
+ res << gd.strftime("%Y-%m-%d") + "\n"
84
+ res << "==========\n"
82
85
  games.each do |g|
83
- res << g.team_a.to_s + " VS " + g.team_b.to_s + " on playing surface #{g.playing_surface} at #{g.game_time}\n"
86
+ res << "#{g.team_a.to_s} VS #{g.team_b.to_s} on playing surface #{g.playing_surface} at #{g.game_time}\n"
84
87
  end
85
88
  res << "\n"
86
89
  end
@@ -94,7 +97,6 @@ module RRSchedule
94
97
  def by_team(team)
95
98
  gms=[]
96
99
  self.gamedays.each do |gd,games|
97
- #games = games.each {|g| g.game_date = gd}
98
100
  gms << games.select{|g| g.team_a == team || g.team_b == team}
99
101
  end
100
102
  gms.flatten
@@ -126,7 +128,12 @@ module RRSchedule
126
128
  res[cur_date] = []
127
129
  slice.each_with_index do |g,game_index|
128
130
  cur_ps = ps_stack.shift
129
- res[cur_date] << Game.new(:team_a => g[:team_a], :team_b => g[:team_b], :playing_surface => cur_ps, :game_time => cur_gt, :game_date => cur_date)
131
+ res[cur_date] << Game.new(
132
+ :team_a => g[:team_a],
133
+ :team_b => g[:team_b],
134
+ :playing_surface => cur_ps,
135
+ :game_time => cur_gt,
136
+ :game_date => cur_date)
130
137
  cur_gt = gt_stack.shift if ps_stack.empty?
131
138
  gt_stack = self.game_times.clone if gt_stack.empty?
132
139
  ps_stack = self.playing_surfaces.clone if ps_stack.empty?
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rrschedule
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - flamontagne
@@ -48,9 +48,7 @@ files:
48
48
  - README.rdoc
49
49
  - Rakefile
50
50
  - VERSION
51
- - lib/example.rb
52
51
  - lib/rrschedule.rb
53
- - rrschedule.gemspec
54
52
  - test/helper.rb
55
53
  - test/test_rrschedule.rb
56
54
  has_rdoc: true
@@ -88,5 +86,5 @@ signing_key:
88
86
  specification_version: 3
89
87
  summary: Round-Robin schedule generator
90
88
  test_files:
91
- - test/helper.rb
92
89
  - test/test_rrschedule.rb
90
+ - test/helper.rb
data/lib/example.rb DELETED
@@ -1,56 +0,0 @@
1
- require 'rrschedule.rb'
2
- Time.zone = "America/New_York"
3
-
4
- teams = ["Rockets","Jetpacks","Snakes","Cobras","Wolves","Huskies","Tigers","Lions","Moose","Sprinklers","Pacers","Cyclops","Munchkins","Magicians","French Fries"]
5
- schedule=RRSchedule::Schedule.new(
6
- :teams => teams, #array of teams that will compete against each other in the season (can be any kind of object)
7
- :playing_surfaces => ["A","B","C","D"], #list of available playing surfaces (volleyball fields, curling sheets, tennis courts, etc)
8
- :wdays => [3], #day(s) of the week where games are played
9
- :start_date => Time.zone.parse("2010/10/13"), #Season will start on...
10
- :exclude_dates => [ #array of dates WITHOUT games
11
- Time.zone.parse("2010/11/24"),
12
- Time.zone.parse("2010/12/15"),
13
- Time.zone.parse("2010/12/22"),
14
- Time.zone.parse("2010/12/29")
15
- ],
16
- :cycles => 1, #1 for Round Robin, 2 for Double Round Robin and so on
17
- :shuffle_initial_order => true, #Shuffle team order before each cycle
18
- :game_times => ["10:00 AM", "1:00 PM"] #Times of the day where the games are played
19
- )
20
- res=schedule.generate
21
-
22
- #human readable schedule
23
- puts schedule.to_s
24
-
25
- schedule.rounds.each do |round|
26
- puts "Round ##{round.round}"
27
- round.games.each do |g|
28
- puts g.team_a.to_s + " Vs " + g.team_b.to_s
29
- end
30
- puts "\n"
31
- end
32
-
33
- #display a team schedule
34
- #test_team = "Sprinklers"
35
- #games=schedule.by_team(test_team)
36
- #puts "Schedule for team ##{test_team.to_s}"
37
- #games.each do |g|
38
- # puts "#{g.game_date.strftime("%Y-%m-%d")}: against #{g.team_a == test_team ? g.team_b.to_s : g.team_a.to_s} on playing surface ##{g.playing_surface} at #{g.game_time}"
39
- #end
40
-
41
- #face_to_face
42
- #games=schedule.face_to_face("Lions","Moose")
43
- #puts "FACE TO FACE: Lions Vs Moose"
44
- #games.each do |g|
45
- # puts g.game_date.to_s + " on playing surface " + g.playing_surface.to_s + " at " + g.game_time.to_s
46
- #end
47
-
48
- #How to iterate the schedule
49
- #schedule.gamedays.each do |gd,games|
50
- # puts gd
51
- # puts "===================="
52
- # games.each do |g|
53
- # puts g.team_a.to_s + " Vs " + g.team_b.to_s + " on playing surface ##{g.playing_surface} at #{g.game_time}"
54
- # end
55
- # puts "\n"
56
- #end
data/rrschedule.gemspec DELETED
@@ -1,55 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{rrschedule}
8
- s.version = "0.1.2"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["flamontagne"]
12
- s.date = %q{2010-11-08}
13
- s.description = %q{This gem automate the process of creating a round-robin sport schedule.}
14
- s.email = %q{flamontagne@azanka.ca}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "lib/example.rb",
27
- "lib/rrschedule.rb",
28
- "rrschedule.gemspec",
29
- "test/helper.rb",
30
- "test/test_rrschedule.rb"
31
- ]
32
- s.homepage = %q{http://github.com/flamontagne/rrschedule}
33
- s.rdoc_options = ["--charset=UTF-8"]
34
- s.require_paths = ["lib"]
35
- s.rubygems_version = %q{1.3.7}
36
- s.summary = %q{Round-Robin schedule generator}
37
- s.test_files = [
38
- "test/helper.rb",
39
- "test/test_rrschedule.rb"
40
- ]
41
-
42
- if s.respond_to? :specification_version then
43
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
- s.specification_version = 3
45
-
46
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
- s.add_runtime_dependency(%q<activesupport>, [">= 0"])
48
- else
49
- s.add_dependency(%q<activesupport>, [">= 0"])
50
- end
51
- else
52
- s.add_dependency(%q<activesupport>, [">= 0"])
53
- end
54
- end
55
-