tournament 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +15 -0
- data/Manifest.txt +241 -2
- data/README.txt +152 -12
- data/Rakefile +9 -6
- data/bin/benchmark_pool +0 -0
- data/bin/gui.rb +3 -1
- data/bin/picker +0 -0
- data/bin/pool +139 -15
- data/lib/tournament/bracket.rb +33 -50
- data/lib/tournament/entry.rb +3 -0
- data/lib/tournament/pool.rb +144 -93
- data/lib/tournament/scoring_strategy.rb +69 -0
- data/lib/tournament/webgui_installer.rb +109 -0
- data/tasks/ann.rake +19 -14
- data/tasks/bones.rake +6 -25
- data/tasks/gem.rake +46 -36
- data/tasks/git.rake +41 -0
- data/tasks/jamis.rb +589 -0
- data/tasks/notes.rake +28 -0
- data/tasks/post_load.rake +18 -11
- data/tasks/{doc.rake → rdoc.rake} +12 -9
- data/tasks/rubyforge.rake +12 -12
- data/tasks/setup.rb +121 -80
- data/tasks/spec.rake +12 -13
- data/tasks/svn.rake +15 -11
- data/tasks/test.rake +6 -6
- data/test/test_tournament.rb +8 -0
- data/test/test_webgui_installer.rb +64 -0
- data/webgui/README +256 -0
- data/webgui/Rakefile +10 -0
- data/webgui/app/controllers/admin_controller.rb +61 -0
- data/webgui/app/controllers/application.rb +25 -0
- data/webgui/app/controllers/entry_controller.rb +97 -0
- data/webgui/app/controllers/pool_controller.rb +4 -0
- data/webgui/app/controllers/reports_controller.rb +7 -0
- data/webgui/app/controllers/sessions_controller.rb +43 -0
- data/webgui/app/controllers/teams_controller.rb +75 -0
- data/webgui/app/controllers/users_controller.rb +57 -0
- data/webgui/app/helpers/admin_helper.rb +2 -0
- data/webgui/app/helpers/application_helper.rb +3 -0
- data/webgui/app/helpers/entry_helper.rb +2 -0
- data/webgui/app/helpers/pool_helper.rb +2 -0
- data/webgui/app/helpers/reports_helper.rb +2 -0
- data/webgui/app/helpers/sessions_helper.rb +2 -0
- data/webgui/app/helpers/teams_helper.rb +2 -0
- data/webgui/app/helpers/users_helper.rb +93 -0
- data/webgui/app/models/entry.rb +42 -0
- data/webgui/app/models/pool.rb +141 -0
- data/webgui/app/models/region.rb +3 -0
- data/webgui/app/models/role.rb +4 -0
- data/webgui/app/models/seeding.rb +4 -0
- data/webgui/app/models/team.rb +6 -0
- data/webgui/app/models/user.rb +98 -0
- data/webgui/app/models/user_mailer.rb +25 -0
- data/webgui/app/views/admin/bracket.html.erb +3 -0
- data/webgui/app/views/admin/entries.html.erb +25 -0
- data/webgui/app/views/admin/index.html.erb +17 -0
- data/webgui/app/views/admin/pool.html.erb +53 -0
- data/webgui/app/views/entry/index.html.erb +16 -0
- data/webgui/app/views/entry/print.erb +1 -0
- data/webgui/app/views/entry/print.html.erb +1 -0
- data/webgui/app/views/entry/show.html.erb +1 -0
- data/webgui/app/views/layouts/bracket.html.erb +37 -0
- data/webgui/app/views/layouts/default.html.erb +62 -0
- data/webgui/app/views/layouts/print.html.erb +12 -0
- data/webgui/app/views/layouts/report.html.erb +38 -0
- data/webgui/app/views/pool/index.html.erb +36 -0
- data/webgui/app/views/reports/_report.html.erb +11 -0
- data/webgui/app/views/reports/show.html.erb +12 -0
- data/webgui/app/views/sessions/new.html.erb +21 -0
- data/webgui/app/views/shared/_admins.html.erb +8 -0
- data/webgui/app/views/shared/_bracket.html.erb +1296 -0
- data/webgui/app/views/teams/choose.html.erb +57 -0
- data/webgui/app/views/user_mailer/activation.erb +3 -0
- data/webgui/app/views/user_mailer/signup_notification.erb +8 -0
- data/webgui/app/views/users/_user_bar.html.erb +8 -0
- data/webgui/app/views/users/new.html.erb +19 -0
- data/webgui/config/boot.rb +109 -0
- data/webgui/config/database.yml +22 -0
- data/webgui/config/environment.rb +78 -0
- data/webgui/config/environments/development.rb +29 -0
- data/webgui/config/environments/production.rb +24 -0
- data/webgui/config/environments/test.rb +22 -0
- data/webgui/config/initializers/inflections.rb +10 -0
- data/webgui/config/initializers/mime_types.rb +5 -0
- data/webgui/config/initializers/new_rails_defaults.rb +17 -0
- data/webgui/config/initializers/pool.rb +33 -0
- data/webgui/config/initializers/site_keys.rb +38 -0
- data/webgui/config/locales/en.yml +5 -0
- data/webgui/config/routes.rb +56 -0
- data/webgui/db/development.sqlite3 +0 -0
- data/webgui/db/migrate/20090216015836_create_entries.rb +13 -0
- data/webgui/db/migrate/20090217001611_add_tie_break_to_entry.rb +9 -0
- data/webgui/db/migrate/20090217004039_create_users.rb +23 -0
- data/webgui/db/migrate/20090217014940_relate_entry_and_user.rb +10 -0
- data/webgui/db/migrate/20090218024350_create_roles.rb +17 -0
- data/webgui/db/migrate/20090218024657_add_postition_to_roles.rb +9 -0
- data/webgui/db/migrate/20090218025240_add_admin_role.rb +10 -0
- data/webgui/db/migrate/20090225022928_create_pools.rb +16 -0
- data/webgui/db/migrate/20090225030346_associate_pool_and_entry.rb +9 -0
- data/webgui/db/migrate/20090225072358_change_pool_data_column.rb +9 -0
- data/webgui/db/migrate/20090225072849_add_completed_to_entries.rb +9 -0
- data/webgui/db/migrate/20090225074149_add_pool_id_index_to_entries.rb +9 -0
- data/webgui/db/migrate/20090225084414_add_user_id_to_pool.rb +9 -0
- data/webgui/db/migrate/20090226021913_add_active_to_pools.rb +9 -0
- data/webgui/db/migrate/20090226142240_rename_bracket_column_to_data.rb +9 -0
- data/webgui/db/migrate/20090301014710_create_teams.rb +84 -0
- data/webgui/db/migrate/20090301025902_add_more_teams.rb +16 -0
- data/webgui/db/migrate/20090301041526_create_seedings.rb +16 -0
- data/webgui/db/migrate/20090301090511_create_regions.rb +14 -0
- data/webgui/db/migrate/teams.txt +347 -0
- data/webgui/db/pool.yml +408 -0
- data/webgui/db/schema.rb +91 -0
- data/webgui/db/test.sqlite3 +0 -0
- data/webgui/doc/README_FOR_APP +5 -0
- data/webgui/lib/authenticated_system.rb +189 -0
- data/webgui/lib/authenticated_test_helper.rb +11 -0
- data/webgui/lib/form_object.rb +70 -0
- data/webgui/lib/pdf_helper.rb +47 -0
- data/webgui/lib/prince.rb +74 -0
- data/webgui/lib/saves_picks.rb +23 -0
- data/webgui/lib/tasks/admin.rake +10 -0
- data/webgui/public/404.html +30 -0
- data/webgui/public/422.html +30 -0
- data/webgui/public/500.html +33 -0
- data/webgui/public/dispatch.cgi +10 -0
- data/webgui/public/dispatch.fcgi +24 -0
- data/webgui/public/dispatch.rb +10 -0
- data/webgui/public/favicon.ico +0 -0
- data/webgui/public/images/2009FinalFour.png +0 -0
- data/webgui/public/images/rails.png +0 -0
- data/webgui/public/javascripts/application.js +2 -0
- data/webgui/public/javascripts/bracket.js +73 -0
- data/webgui/public/javascripts/controls.js +963 -0
- data/webgui/public/javascripts/dragdrop.js +973 -0
- data/webgui/public/javascripts/effects.js +1128 -0
- data/webgui/public/javascripts/prototype.js +4320 -0
- data/webgui/public/robots.txt +5 -0
- data/webgui/public/stylesheets/bracket-print.css +39 -0
- data/webgui/public/stylesheets/bracket.css +125 -0
- data/webgui/public/stylesheets/main.css +144 -0
- data/webgui/public/stylesheets/prince.css +6 -0
- data/webgui/public/stylesheets/prince_landscape.css +1 -0
- data/webgui/script/about +4 -0
- data/webgui/script/console +3 -0
- data/webgui/script/dbconsole +3 -0
- data/webgui/script/destroy +3 -0
- data/webgui/script/generate +3 -0
- data/webgui/script/performance/benchmarker +3 -0
- data/webgui/script/performance/profiler +3 -0
- data/webgui/script/performance/request +3 -0
- data/webgui/script/plugin +3 -0
- data/webgui/script/process/inspector +3 -0
- data/webgui/script/process/reaper +3 -0
- data/webgui/script/process/spawner +3 -0
- data/webgui/script/runner +3 -0
- data/webgui/script/server +3 -0
- data/webgui/test/fixtures/entries.yml +10 -0
- data/webgui/test/fixtures/pools.yml +14 -0
- data/webgui/test/fixtures/regions.yml +11 -0
- data/webgui/test/fixtures/roles.yml +11 -0
- data/webgui/test/fixtures/roles_users.yml +3 -0
- data/webgui/test/fixtures/seedings.yml +12 -0
- data/webgui/test/fixtures/teams.yml +3051 -0
- data/webgui/test/fixtures/users.yml +44 -0
- data/webgui/test/functional/admin_controller_test.rb +8 -0
- data/webgui/test/functional/entry_controller_test.rb +27 -0
- data/webgui/test/functional/pool_controller_test.rb +8 -0
- data/webgui/test/functional/reports_controller_test.rb +8 -0
- data/webgui/test/functional/sessions_controller_test.rb +82 -0
- data/webgui/test/functional/teams_controller_test.rb +216 -0
- data/webgui/test/functional/users_controller_test.rb +88 -0
- data/webgui/test/performance/browsing_test.rb +9 -0
- data/webgui/test/test_helper.rb +38 -0
- data/webgui/test/unit/entry_test.rb +8 -0
- data/webgui/test/unit/pool_test.rb +8 -0
- data/webgui/test/unit/region_test.rb +8 -0
- data/webgui/test/unit/role_test.rb +8 -0
- data/webgui/test/unit/seeding_test.rb +8 -0
- data/webgui/test/unit/team_test.rb +10 -0
- data/webgui/test/unit/user_mailer_test.rb +31 -0
- data/webgui/test/unit/user_test.rb +109 -0
- data/webgui/vendor/plugins/auto_complete/README +23 -0
- data/webgui/vendor/plugins/auto_complete/Rakefile +22 -0
- data/webgui/vendor/plugins/auto_complete/init.rb +2 -0
- data/webgui/vendor/plugins/auto_complete/lib/auto_complete.rb +47 -0
- data/webgui/vendor/plugins/auto_complete/lib/auto_complete_macros_helper.rb +143 -0
- data/webgui/vendor/plugins/auto_complete/test/auto_complete_test.rb +67 -0
- data/webgui/vendor/plugins/enumerations_mixin/ATTENTION +15 -0
- data/webgui/vendor/plugins/enumerations_mixin/LICENSE +20 -0
- data/webgui/vendor/plugins/enumerations_mixin/README_ENUMERATIONS +163 -0
- data/webgui/vendor/plugins/enumerations_mixin/init.rb +21 -0
- data/webgui/vendor/plugins/enumerations_mixin/lib/active_record/acts/enumerated.rb +177 -0
- data/webgui/vendor/plugins/enumerations_mixin/lib/active_record/aggregations/has_enumerated.rb +60 -0
- data/webgui/vendor/plugins/enumerations_mixin/lib/active_record/virtual_enumerations.rb +68 -0
- data/webgui/vendor/plugins/enumerations_mixin/virtual_enumerations_sample.rb +76 -0
- data/webgui/vendor/plugins/restful_authentication/.gitignore +21 -0
- data/webgui/vendor/plugins/restful_authentication/CHANGELOG +68 -0
- data/webgui/vendor/plugins/restful_authentication/README.textile +224 -0
- data/webgui/vendor/plugins/restful_authentication/Rakefile +32 -0
- data/webgui/vendor/plugins/restful_authentication/TODO +15 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/USAGE +1 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/authenticated_generator.rb +478 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/lib/insert_routes.rb +54 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/_model_partial.html.erb +8 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/activation.erb +3 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_system.rb +189 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb +22 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb +43 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/helper.rb +2 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/login.html.erb +16 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/mailer.rb +25 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/migration.rb +26 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/model.rb +83 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/model_controller.rb +85 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/model_helper.rb +93 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/model_helper_spec.rb +158 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/observer.rb +11 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/signup.html.erb +19 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/signup_notification.erb +8 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/site_keys.rb +38 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/controllers/access_control_spec.rb +90 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/controllers/authenticated_system_spec.rb +102 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/controllers/sessions_controller_spec.rb +139 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/controllers/users_controller_spec.rb +198 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/fixtures/users.yml +60 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/helpers/users_helper_spec.rb +141 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/spec/models/user_spec.rb +290 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/rest_auth_stories.rb +22 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/rest_auth_stories_helper.rb +81 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb +49 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_resource_steps.rb +179 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_response_steps.rb +171 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/user_steps.rb +153 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/users/accounts.story +186 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/users/sessions.story +134 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/test/functional_test.rb +82 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/test/mailer_test.rb +31 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/test/model_functional_test.rb +93 -0
- data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/test/unit_test.rb +164 -0
- data/webgui/vendor/plugins/restful_authentication/init.rb +1 -0
- data/webgui/vendor/plugins/restful_authentication/install.rb +1 -0
- data/webgui/vendor/plugins/restful_authentication/lib/authentication/by_cookie_token.rb +82 -0
- data/webgui/vendor/plugins/restful_authentication/lib/authentication/by_password.rb +64 -0
- data/webgui/vendor/plugins/restful_authentication/lib/authentication.rb +40 -0
- data/webgui/vendor/plugins/restful_authentication/lib/authorization/aasm_roles.rb +63 -0
- data/webgui/vendor/plugins/restful_authentication/lib/authorization/stateful_roles.rb +62 -0
- data/webgui/vendor/plugins/restful_authentication/lib/authorization.rb +14 -0
- data/webgui/vendor/plugins/restful_authentication/lib/trustification/email_validation.rb +20 -0
- data/webgui/vendor/plugins/restful_authentication/lib/trustification.rb +14 -0
- data/webgui/vendor/plugins/restful_authentication/notes/AccessControl.txt +2 -0
- data/webgui/vendor/plugins/restful_authentication/notes/Authentication.txt +5 -0
- data/webgui/vendor/plugins/restful_authentication/notes/Authorization.txt +154 -0
- data/webgui/vendor/plugins/restful_authentication/notes/RailsPlugins.txt +78 -0
- data/webgui/vendor/plugins/restful_authentication/notes/SecurityFramework.graffle +0 -0
- data/webgui/vendor/plugins/restful_authentication/notes/SecurityFramework.png +0 -0
- data/webgui/vendor/plugins/restful_authentication/notes/SecurityPatterns.txt +163 -0
- data/webgui/vendor/plugins/restful_authentication/notes/Tradeoffs.txt +126 -0
- data/webgui/vendor/plugins/restful_authentication/notes/Trustification.txt +49 -0
- data/webgui/vendor/plugins/restful_authentication/rails/init.rb +3 -0
- data/webgui/vendor/plugins/restful_authentication/restful-authentication.gemspec +33 -0
- data/webgui/vendor/plugins/restful_authentication/tasks/auth.rake +33 -0
- metadata +288 -8
- data/tasks/annotations.rake +0 -22
data/bin/pool
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require File.expand_path(
|
3
|
-
File.join(File.dirname(__FILE__), '..', 'lib', 'tournament'))
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'tournament'))
|
4
3
|
|
5
4
|
require 'rubygems'
|
6
5
|
require 'main'
|
7
6
|
require 'yaml'
|
7
|
+
require 'fileutils'
|
8
|
+
require 'net/http'
|
9
|
+
require 'uri'
|
8
10
|
|
9
11
|
Main do
|
10
12
|
|
@@ -20,7 +22,7 @@ Main do
|
|
20
22
|
|
21
23
|
def init_pool
|
22
24
|
@pool = Tournament::Pool.ncaa_2008
|
23
|
-
@pool.
|
25
|
+
@pool.scoring_strategy = Tournament::ScoringStrategy.strategy_for_name(params['scoring'].value)
|
24
26
|
end
|
25
27
|
|
26
28
|
def save_pool
|
@@ -31,34 +33,152 @@ Main do
|
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
mode('install_webgui') do
|
37
|
+
description 'Installs the Rails webgui.'
|
38
|
+
option('web-dir', 'W') do
|
39
|
+
required
|
40
|
+
argument :required
|
41
|
+
arity 1
|
42
|
+
description "Installation directory for the Rails application."
|
43
|
+
error(:after) { puts usage.to_s }
|
44
|
+
end
|
45
|
+
option('site-name', 'S') do
|
46
|
+
optional
|
47
|
+
argument :required
|
48
|
+
default 'Tournament'
|
49
|
+
arity 1
|
50
|
+
description "Web site name used in <title> tags an email subject lines."
|
51
|
+
end
|
52
|
+
option('relative-root', 'R') do
|
53
|
+
optional
|
54
|
+
argument :required
|
55
|
+
arity 1
|
56
|
+
description "Relative URL root if you are installing the web application as a subdirectory in an existing website."
|
57
|
+
end
|
58
|
+
option('admin-email') do
|
59
|
+
required
|
60
|
+
argument :required
|
61
|
+
arity 1
|
62
|
+
description "Email address of the admin account."
|
63
|
+
error(:after) { puts usage.to_s }
|
64
|
+
end
|
65
|
+
option('email-server') do
|
66
|
+
optional
|
67
|
+
argument :required
|
68
|
+
arity 1
|
69
|
+
description "SMTP email server name."
|
70
|
+
end
|
71
|
+
option('email-port') do
|
72
|
+
cast :int
|
73
|
+
optional
|
74
|
+
argument :required
|
75
|
+
default 25
|
76
|
+
arity 1
|
77
|
+
description "SMTP email server port."
|
78
|
+
end
|
79
|
+
option('email-domain') do
|
80
|
+
optional
|
81
|
+
argument :required
|
82
|
+
arity 1
|
83
|
+
description "SMTP email server HELO domain."
|
84
|
+
end
|
85
|
+
option('email-user') do
|
86
|
+
optional
|
87
|
+
argument :required
|
88
|
+
arity 1
|
89
|
+
description "SMTP email server user name."
|
90
|
+
end
|
91
|
+
option('email-password') do
|
92
|
+
optional
|
93
|
+
argument :required
|
94
|
+
arity 1
|
95
|
+
description "SMTP email server user name."
|
96
|
+
end
|
97
|
+
option('email-auth') do
|
98
|
+
optional
|
99
|
+
argument :required
|
100
|
+
default 'login'
|
101
|
+
arity 1
|
102
|
+
validate {|ea| ['login', 'plain', 'cram_md5'].include?(ea)}
|
103
|
+
description "SMTP email server authentication type."
|
104
|
+
end
|
105
|
+
option('use-princexml', 'X') do
|
106
|
+
optional
|
107
|
+
argument :required
|
108
|
+
arity 1
|
109
|
+
description "Location of prince xml command line program, or directory into which the program will be installed after being downloaded from the Prince XML website."
|
110
|
+
end
|
111
|
+
option('tmp-dir', 't') do
|
112
|
+
optional
|
113
|
+
argument :required
|
114
|
+
default '/tmp'
|
115
|
+
arity 1
|
116
|
+
description "Temp directory location."
|
117
|
+
end
|
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 " 2. RAILS_ENV=production rake \"admin:create[admin,#{params['admin-email'].value},Joe Admin,password]\""
|
146
|
+
puts " You should substitute your desired admin user login, name and password."
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
mixin :savefile do
|
151
|
+
option('save-file', 's') do
|
152
|
+
optional
|
153
|
+
argument :required
|
154
|
+
default 'pool.yml'
|
155
|
+
arity 1
|
156
|
+
description "Save file for the pool."
|
157
|
+
end
|
40
158
|
end
|
41
159
|
|
42
160
|
mode('setup') do
|
43
161
|
description "Sets up the pool the first time"
|
162
|
+
mixin :savefile
|
44
163
|
option('scoring', 'S') do
|
45
164
|
optional
|
46
165
|
argument :required
|
47
166
|
arity 1
|
48
167
|
default 'basic_scoring_strategy'
|
49
|
-
validate {|s| Tournament::
|
50
|
-
description "Sets the scoring strategy, should be one of #{Tournament::
|
168
|
+
validate {|s| Tournament::ScoringStrategy.available_strategies.include?(s)}
|
169
|
+
description "Sets the scoring strategy, should be one of #{Tournament::ScoringStrategy.available_strategies.join(', ')}"
|
51
170
|
end
|
52
171
|
def run
|
53
172
|
init_pool
|
54
173
|
puts "Initialized new pool"
|
55
174
|
puts "Scoring:"
|
56
|
-
puts @pool.
|
175
|
+
puts @pool.scoring_strategy.description
|
57
176
|
save_pool
|
58
177
|
end
|
59
178
|
end
|
60
179
|
|
61
180
|
mode('update') do
|
181
|
+
mixin :savefile
|
62
182
|
option('entry', 'e') do
|
63
183
|
optional
|
64
184
|
argument :required
|
@@ -69,12 +189,13 @@ Main do
|
|
69
189
|
def run
|
70
190
|
load_pool
|
71
191
|
tournament = YAML::load_file(params['entry'].value)
|
72
|
-
@pool.
|
192
|
+
@pool.tournament_entry = tournament
|
73
193
|
save_pool
|
74
194
|
end
|
75
195
|
end
|
76
196
|
|
77
197
|
mode('fee') do
|
198
|
+
mixin :savefile
|
78
199
|
argument('amount') do
|
79
200
|
required
|
80
201
|
cast :integer
|
@@ -89,6 +210,7 @@ Main do
|
|
89
210
|
end
|
90
211
|
|
91
212
|
mode('payout') do
|
213
|
+
mixin :savefile
|
92
214
|
option('constant-amount', 'C') do
|
93
215
|
optional
|
94
216
|
arity 1
|
@@ -122,6 +244,7 @@ Main do
|
|
122
244
|
end
|
123
245
|
|
124
246
|
mode('entry') do
|
247
|
+
mixin :savefile
|
125
248
|
option('add', 'a') do
|
126
249
|
optional
|
127
250
|
argument :required
|
@@ -151,6 +274,7 @@ Main do
|
|
151
274
|
end
|
152
275
|
|
153
276
|
mode('dump') do
|
277
|
+
mixin :savefile
|
154
278
|
option('entry', 'e') do
|
155
279
|
optional
|
156
280
|
argument :required
|
@@ -159,14 +283,14 @@ Main do
|
|
159
283
|
end
|
160
284
|
def run
|
161
285
|
load_pool
|
162
|
-
tournament = Tournament::Entry.new('Tournament', @pool.bracket, 0)
|
163
286
|
File.open(params['entry'].value, "w") do |f|
|
164
|
-
YAML::dump(
|
287
|
+
YAML::dump(@pool.tournament_entry, f)
|
165
288
|
end
|
166
289
|
end
|
167
290
|
end
|
168
291
|
|
169
292
|
mode('report') do
|
293
|
+
mixin :savefile
|
170
294
|
available_reports = Tournament::Pool.instance_methods(false).map do |name|
|
171
295
|
if idx = name.index("_report")
|
172
296
|
name[0,idx]
|
data/lib/tournament/bracket.rb
CHANGED
@@ -4,46 +4,7 @@ class Tournament::Bracket
|
|
4
4
|
attr_reader :teams # The teams in the bracket
|
5
5
|
attr_reader :rounds # The number of rounds in the bracket
|
6
6
|
attr_reader :winners # The winners of each game in the bracket
|
7
|
-
attr_accessor :scoring_strategy # The strategy used to assign points to correct picks
|
8
7
|
|
9
|
-
# Class representing a scoring strategy where correct picks
|
10
|
-
# are worth 2 X the round number
|
11
|
-
class BasicScoringStrategy
|
12
|
-
def score(pick, winner, loser, round)
|
13
|
-
winner != UNKNOWN_TEAM && pick == winner ? round * 2 : 0
|
14
|
-
end
|
15
|
-
def description
|
16
|
-
"Each game is worth 2 times the round number."
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# Class representing a scoring strategy where correct picks
|
21
|
-
# are worth a base amount per round (3, 5, 11, 19, 30 and 40)
|
22
|
-
# plus the seed number of the winner.
|
23
|
-
class UpsetScoringStrategy
|
24
|
-
PER_ROUND = [3, 5, 11, 19, 30, 40]
|
25
|
-
def score(pick, winner, loser, round)
|
26
|
-
if winner != UNKNOWN_TEAM && pick == winner
|
27
|
-
return PER_ROUND[round-1] + winner.seed
|
28
|
-
end
|
29
|
-
return 0
|
30
|
-
end
|
31
|
-
def description
|
32
|
-
"Games are worth #{PER_ROUND.join(', ')} per round plus the seed number of the winning team."
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# Returns names of available strategies. The names returned are suitable
|
37
|
-
# for use in the strategy_for_name method
|
38
|
-
def self.available_strategies
|
39
|
-
return ['basic_scoring_strategy', 'upset_scoring_strategy']
|
40
|
-
end
|
41
|
-
|
42
|
-
# Returns an instantiated strategy class for the named strategy.
|
43
|
-
def self.strategy_for_name(name)
|
44
|
-
clazz = Tournament::Bracket.const_get(name.capitalize.gsub(/_([a-zA-Z])/) {|m| $1.upcase})
|
45
|
-
return clazz.new
|
46
|
-
end
|
47
8
|
|
48
9
|
UNKNOWN_TEAM = :unk unless defined?(UNKNOWN_TEAM)
|
49
10
|
|
@@ -54,11 +15,11 @@ class Tournament::Bracket
|
|
54
15
|
@winners = [@teams] + (1..@rounds).map do |r|
|
55
16
|
[UNKNOWN_TEAM] * games_in_round(r)
|
56
17
|
end
|
57
|
-
@scoring_strategy = BasicScoringStrategy.new
|
58
18
|
end
|
59
19
|
|
60
20
|
# Returns true if the provided team has not lost
|
61
21
|
def still_alive?(team)
|
22
|
+
return false if team == UNKNOWN_TEAM
|
62
23
|
team_index = @winners[0].index(team)
|
63
24
|
game = team_index/2
|
64
25
|
round = 1
|
@@ -96,6 +57,16 @@ class Tournament::Bracket
|
|
96
57
|
return round
|
97
58
|
end
|
98
59
|
|
60
|
+
# Returns true if all games have been decided
|
61
|
+
def complete?
|
62
|
+
round = 0
|
63
|
+
while round < self.rounds
|
64
|
+
return false if @winners[round+1].any? {|t| t == UNKNOWN_TEAM}
|
65
|
+
round += 1
|
66
|
+
end
|
67
|
+
return true
|
68
|
+
end
|
69
|
+
|
99
70
|
# Returns the number of teams left in the bracket.
|
100
71
|
def teams_left
|
101
72
|
return 1 + @winners.inject(0) { |memo, arr| arr.inject(memo) {|memo, team| memo += (team == UNKNOWN_TEAM ? 1 : 0)} }
|
@@ -196,7 +167,6 @@ class Tournament::Bracket
|
|
196
167
|
# that would result.
|
197
168
|
def bracket_for(possibility)
|
198
169
|
pick_bracket = Tournament::Bracket.new(self.teams)
|
199
|
-
pick_bracket.scoring_strategy = self.scoring_strategy
|
200
170
|
round = 1
|
201
171
|
while round <= pick_bracket.rounds
|
202
172
|
gir = pick_bracket.games_in_round(round)
|
@@ -216,7 +186,7 @@ class Tournament::Bracket
|
|
216
186
|
return pick_bracket
|
217
187
|
end
|
218
188
|
|
219
|
-
# Returns a two element array containing the
|
189
|
+
# Returns a two element array containing the Teams in the
|
220
190
|
# matchup for the given round and game
|
221
191
|
def matchup(round, game)
|
222
192
|
return @winners[round-1][(game-1)*2..(game-1)*2+1]
|
@@ -253,6 +223,17 @@ class Tournament::Bracket
|
|
253
223
|
end
|
254
224
|
end
|
255
225
|
|
226
|
+
# Given a overall game number, return the round and round game number
|
227
|
+
def round_and_game(overall_game)
|
228
|
+
1.upto(rounds) do |r|
|
229
|
+
if overall_game <= games_in_round(r)
|
230
|
+
return [r, overall_game]
|
231
|
+
else
|
232
|
+
overall_game -= games_in_round(r)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
256
237
|
# Sets the winner of the given round and game to the provided team
|
257
238
|
def set_winner(round, game, team)
|
258
239
|
if UNKNOWN_TEAM == team || matchup(round, game).include?(team)
|
@@ -277,8 +258,8 @@ class Tournament::Bracket
|
|
277
258
|
end
|
278
259
|
|
279
260
|
# Compute the maximum possible score if all remaining picks in this
|
280
|
-
# bracket turn out to be correct.
|
281
|
-
def maximum_score(other_bracket)
|
261
|
+
# bracket turn out to be correct using the given scoring strategy.
|
262
|
+
def maximum_score(other_bracket, scoring_strategy)
|
282
263
|
score = 0
|
283
264
|
round = 1
|
284
265
|
while round <= self.rounds
|
@@ -288,7 +269,7 @@ class Tournament::Bracket
|
|
288
269
|
winner, loser = other_bracket.winner_and_loser(round, game)
|
289
270
|
pick = self.winner(round, game)
|
290
271
|
winner = pick if winner == UNKNOWN_TEAM && other_bracket.still_alive?(pick)
|
291
|
-
score +=
|
272
|
+
score += scoring_strategy.score(pick, winner, loser, round)
|
292
273
|
game += 1
|
293
274
|
end
|
294
275
|
round += 1
|
@@ -297,8 +278,9 @@ class Tournament::Bracket
|
|
297
278
|
end
|
298
279
|
|
299
280
|
# Computes the total score of this bracket using other_bracket
|
300
|
-
#
|
301
|
-
|
281
|
+
# to determine correct picks. Use the provided scoring strategy
|
282
|
+
# to compute the score.
|
283
|
+
def score_against(other_bracket, scoring_strategy)
|
302
284
|
score = 0
|
303
285
|
round = 1
|
304
286
|
while round <= self.rounds
|
@@ -306,7 +288,7 @@ class Tournament::Bracket
|
|
306
288
|
game = 1
|
307
289
|
while game <= games_in_round
|
308
290
|
winner, loser = other_bracket.winner_and_loser(round, game)
|
309
|
-
score +=
|
291
|
+
score += scoring_strategy.score(self.winner(round, game), winner, loser, round)
|
310
292
|
#puts "round #{round} game #{game} winner #{winner} loser #{loser} pick #{self.winner(round,game)}"
|
311
293
|
game += 1
|
312
294
|
end
|
@@ -316,19 +298,20 @@ class Tournament::Bracket
|
|
316
298
|
end
|
317
299
|
|
318
300
|
# Compute the score for a particular round against the other_bracket
|
301
|
+
# using the provided scoring strategy.
|
319
302
|
# Returns an array of two element arrays, one for each game in the
|
320
303
|
# round. The first element of the subarray is the score and the
|
321
304
|
# second element is the team that was picked. If the winner of the
|
322
305
|
# game is unknown (because it has not been played), the score element
|
323
306
|
# will be nil.
|
324
|
-
def scores_for_round(round, other_bracket)
|
307
|
+
def scores_for_round(round, other_bracket, scoring_strategy)
|
325
308
|
games_in_round = self.games_in_round(round)
|
326
309
|
return (1..games_in_round).to_a.map do |g|
|
327
310
|
winner, loser = other_bracket.winner_and_loser(round, g)
|
328
311
|
pick = self.winner(round, g)
|
329
312
|
score = nil
|
330
313
|
if winner != UNKNOWN_TEAM || !other_bracket.still_alive?(pick)
|
331
|
-
score =
|
314
|
+
score = scoring_strategy.score(pick, winner, loser, round)
|
332
315
|
end
|
333
316
|
[score, pick]
|
334
317
|
end
|