In Files

Parent

Object

Public Instance Methods

init_pool() click to toggle source

(Not documented)

    # File bin/pool, line 23
23:   def init_pool
24:     @pool = Tournament::Pool.ncaa_2008
25:     @pool.scoring_strategy = Tournament::ScoringStrategy.strategy_for_name(params['scoring'].value)
26:   end
label_for(team, round = 1, game = 1) click to toggle source

(Not documented)

    # File bin/gui.rb, line 64
64:   def label_for(team, round = 1, game = 1)
65:     label = if Tournament::Bracket::UNKNOWN_TEAM == team
66:       "r:%d g:%d" % [round, game]
67:     else
68:       if round == 1 || round > 4
69:         "%2d %s (%s)" % [team.seed, team.name, team.short_name]
70:       else
71:         "%4s" % team.short_name
72:       end
73:     end
74:   end
load_data() click to toggle source

(Not documented)

    # File bin/gui.rb, line 14
14:   def load_data
15:     @entry  = YAML::load_file(@save_file)
16:   end
load_pool() click to toggle source

Loads the pool from the save file. If the save file does not exist, creates a default pool

    # File bin/pool, line 15
15:   def load_pool
16:     @pool = YAML::load_file(save_file_name)
17:   end
make_pick(region_idx, round, team_num, real_game) click to toggle source

(Not documented)

     # File bin/gui.rb, line 99
 99:   def make_pick(region_idx, round, team_num, real_game)
100:     team = @teams[region_idx][round-1][team_num]
101:     return if team == Tournament::Bracket::UNKNOWN_TEAM
102: 
103:     matchup = @entry.picks.matchup(round,real_game).reject{|t| t == team}[0]
104: 
105:     if round == 4
106:       @champ[region_idx].replace label_for(team, 6, 1)
107:       #@labels[0][4][region_idx].replace label_for(team, 6, 1)
108:     end
109: 
110:     if round == 6
111:       @overall_champ.replace label_for(team, 6, 1)
112:     end
113: 
114:     forward_round = round
115:     forward_idx = team_num / 2
116:     forward_team = @teams[region_idx][forward_round][forward_idx] rescue nil
117:     while forward_team == matchup
118:       ri = forward_round > 4 ? 0 : region_idx
119:       @labels[ri][forward_round][forward_idx].replace BLANK_LABEL
120:       forward_round += 1
121:       forward_idx /= 2
122:       if forward_round == 4
123:         @champ[region_idx].replace 'Regional Champ'
124:       end
125:       if forward_round == 6
126:         @overall_champ.replace 'NCAA Champion'
127:       end
128:       ri = forward_round > 4 ? 0 : region_idx
129:       fi = forward_round == 5 ? region_idx : forward_idx
130:       forward_team = @teams[ri][forward_round][fi] rescue nil
131:     end
132: 
133:     ri = round >= 4 ? 0 : region_idx
134:     ti = team_num / 2
135:     if round == 4
136:       ti = region_idx
137:     end
138:     @entry.picks.set_winner(round, real_game, team)
139:     return if round >= 6
140:     begin
141:       @labels[ri][round][ti].replace label_for(team, round+1, real_game)
142:       @teams[ri][round][ti] = team
143:     rescue Exception => e
144:       alert "got error for ri #{ri} round #{round} team_num #{team_num}: #{e}"
145:     end
146:   end
matchup_flow(region_idx, round, game, real_game, bc, gap) click to toggle source

(Not documented)

    # File bin/gui.rb, line 76
76:   def matchup_flow(region_idx, round, game, real_game, bc, gap)
77:     @entry.picks.matchup(round,real_game).each_with_index do |team, idx|
78:       flow do
79:         background bc
80:         flow_idx = (game-1)*2 + idx
81:         @teams[region_idx][round-1][flow_idx] = team
82:         stack :width => (width - 26) do
83:           @labels[region_idx][round-1][flow_idx] = para label_for(team, round, game), :height => 26, :width => 175, :font => "Monospace 10px"
84:         end
85:         stack :width => 26 do
86:           @buttons[region_idx][round-1][flow_idx] = button ">", :width => 26, :height => 26, :font => "Monospace 6px", :margin => 1 do
87:             make_pick(region_idx, round, flow_idx, real_game)
88:           end
89:         end
90:       end
91:       if gap > 0 && idx == 0
92:         stack :height => gap, :width => width do
93:           background bc
94:         end
95:       end
96:     end
97:   end
round_stack(region_idx, round, games_per_round, gap, top, width) click to toggle source

(Not documented)

    # File bin/gui.rb, line 44
44:   def round_stack(region_idx, round, games_per_round, gap, top, width)
45:     stack :width => width do
46:       if top > 0
47:         stack :height => top, :width => 26 do
48:           background white
49:         end
50:       end
51:       1.upto(games_per_round) do |game|
52:         bc = game % 2 == 0 || round > 1 ? lightgreen : white
53:         real_game = game + region_idx * games_per_round
54:         matchup_flow(region_idx, round, game, real_game, bc, gap)
55:         if gap > 0
56:           stack :height => gap, :width => width do
57:             background white
58:           end
59:         end
60:       end
61:     end
62:   end
run() click to toggle source

(Not documented)

     # File bin/pool, line 263
263:     def run
264:       load_pool
265:       if params['add'].given?
266:         @pool.add_entry_yaml(params['add'].value)
267:         save_pool 
268:       elsif params['remove'].given?
269:         @pool.remove_by_name(params['remove'].value)
270:         save_pool 
271:       else
272:         puts "Please specify add or remove"
273:         print usage.to_s
274:         exit_warn!
275:       end
276:     end
run() click to toggle source

(Not documented)

     # File bin/pool, line 310
310:     def run
311:       load_pool
312:       @pool.send("#{params['type'].value}_report")
313:     end
run() click to toggle source

(Not documented)

     # File bin/pool, line 118
118:     def run
119:       installer = Tournament::WebguiInstaller.new(params['web-dir'].value)
120:       installer.tmp_dir = params['tmp-dir'].value
121:       options = params.to_options
122:       if params['use-princexml'].given?
123:         prince_xml = params['use-princexml'].value
124:         if File.exist?(prince_xml) && File.executable?(prince_xml) && !File.directory?(prince_xml)
125:           puts "=> USING PRINCE XML EXECUTABLE #{prince_xml}"
126:         elsif File.exist?(prince_xml) && File.executable?(prince_xml) && File.directory?(prince_xml)
127:           puts "=> INSTALLING PRINCE XML INTO #{prince_xml}"
128:           installer.install_prince(prince_xml)
129:           prince_xml = File.join(prince_xml, 'bin', 'prince')
130:         else
131:           print usage.to_s
132:           exit_warn!
133:         end
134:         options['prince-path'] = prince_xml
135:       end
136:       puts "=> INSTALLING TOURNAMENT WEB GUI INTO #{installer.install_dir}"
137:       installer.install_webgui
138:       puts "=> ADJUSTING TOURNAMENT WEB GUI CONFIGURATION"
139:       installer.adjust_configuration(options)
140: 
141:       puts "=> INSTALLATION COMPLETE."
142:       puts "You should now change to #{installer.install_dir} and"
143:       puts "perform the following steps:"
144:       puts "  1. RAILS_ENV=production rake db:migrate"
145:       puts "If this is the first time you have installed the web gui, you"
146:       puts "Should also perform these steps:"
147:       puts "  1. RAILS_ENV=production rake auth:gen:site_key"
148:       puts "  2. RAILS_ENV=production rake \"admin:create[admin,#{params['admin-email'].value},Joe Admin,password]\""
149:       puts "     You should substitute your desired admin user login, name and password."
150:     end
run() click to toggle source

(Not documented)

     # File bin/pool, line 287
287:     def run
288:       load_pool
289:       File.open(params['entry'].value, "w") do |f|
290:         YAML::dump(@pool.tournament_entry, f)
291:       end
292:     end
run() click to toggle source

(Not documented)

     # File bin/pool, line 174
174:     def run
175:       init_pool
176:       puts "Initialized new pool"
177:       puts "Scoring:"
178:       puts @pool.scoring_strategy.description
179:       save_pool
180:     end
run() click to toggle source

(Not documented)

     # File bin/pool, line 234
234:     def run
235:       load_pool
236:       rank = params['rank'].value
237:       if 'last' == rank
238:         rank = :last
239:       else
240:         rank = rank.to_i
241:       end
242:       amount = params['amount'].value
243:       amount = -amount if params['constant-amount'].value
244:       @pool.set_payout(rank, amount)
245:       save_pool
246:     end
run() click to toggle source

(Not documented)

     # File bin/pool, line 192
192:     def run
193:       load_pool
194:       tournament = YAML::load_file(params['entry'].value)
195:       @pool.tournament_entry = tournament
196:       save_pool 
197:     end
run() click to toggle source

(Not documented)

     # File bin/pool, line 208
208:     def run
209:       load_pool
210:       @pool.entry_fee = params['amount'].value
211:       save_pool
212:     end
run() click to toggle source

(Not documented)

     # File bin/pool, line 316
316:   def run
317:     print usage.to_s
318:     exit_warn!
319:   end
save_data() click to toggle source

(Not documented)

    # File bin/gui.rb, line 18
18:   def save_data
19:     @entry.name = @name.text
20:     @entry.tie_breaker = @tie_break.text.to_i
21:     File.open(@save_file, "w") do |f|
22:       YAML::dump(@entry, f)
23:     end
24:   end
save_file_name() click to toggle source

(Not documented)

    # File bin/pool, line 19
19:   def save_file_name
20:     params['save-file'].value
21:   end
save_pool() click to toggle source

(Not documented)

    # File bin/pool, line 28
28:   def save_pool
29:     if @pool
30:       File.open(save_file_name, "w") do |f|
31:         YAML::dump(@pool, f)
32:       end
33:     end
34:   end
scrub_save_file() click to toggle source

(Not documented)

     # File bin/gui.rb, line 148
148:   def scrub_save_file
149:     unless '.yml' == File.extname(@save_file)
150:       @save_file += '.yml'
151:     end
152:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.