bashrw_ttt 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/play.rb +10 -0
- data/lib/ttt/ai.rb +33 -0
- data/lib/ttt/ai_easy.rb +17 -0
- data/lib/ttt/ai_hard.rb +21 -0
- data/lib/ttt/ai_medium.rb +21 -0
- data/lib/ttt/ai_medium_back.rb +58 -0
- data/lib/ttt/board.rb +37 -0
- data/lib/ttt/config_helper.rb +53 -0
- data/lib/ttt/config_options.rb +27 -0
- data/lib/ttt/context.rb +214 -0
- data/lib/ttt/four_by_four.rb +62 -0
- data/lib/ttt/game.rb +94 -0
- data/lib/ttt/game_history.rb +37 -0
- data/lib/ttt/game_interactor.rb +126 -0
- data/lib/ttt/human.rb +12 -0
- data/lib/ttt/interfaces/cli/lib/cli/board_selection.rb +34 -0
- data/lib/ttt/interfaces/cli/lib/cli/cli_game.rb +186 -0
- data/lib/ttt/interfaces/cli/lib/cli/cli_presenter.rb +216 -0
- data/lib/ttt/interfaces/cli/lib/cli/clio.rb +17 -0
- data/lib/ttt/interfaces/cli/lib/cli/play_again.rb +38 -0
- data/lib/ttt/interfaces/cli/lib/cli/player_selection.rb +43 -0
- data/lib/ttt/interfaces/cli/lib/cli/selection.rb +8 -0
- data/lib/ttt/interfaces/cli/lib/cli/walk_history.rb +48 -0
- data/lib/ttt/interfaces/cli/spec/cli/board_selection_spec.rb +29 -0
- data/lib/ttt/interfaces/cli/spec/cli/cli_game_spec.rb +376 -0
- data/lib/ttt/interfaces/cli/spec/cli/cli_presenter_spec.rb +147 -0
- data/lib/ttt/interfaces/cli/spec/cli/play_again_spec.rb +39 -0
- data/lib/ttt/interfaces/cli/spec/cli/player_selection_spec.rb +62 -0
- data/lib/ttt/interfaces/cli/spec/cli/walk_history_spec.rb +115 -0
- data/lib/ttt/interfaces/cli/spec/spec_helper.rb +14 -0
- data/lib/ttt/interfaces/limelight/four_by_four/props.rb +1 -0
- data/lib/ttt/interfaces/limelight/four_by_four/styles.rb +74 -0
- data/lib/ttt/interfaces/limelight/four_by_four_finished/props.rb +1 -0
- data/lib/ttt/interfaces/limelight/four_by_four_finished/styles.rb +74 -0
- data/lib/ttt/interfaces/limelight/game_list/players/load_button.rb +10 -0
- data/lib/ttt/interfaces/limelight/game_list/props.rb +17 -0
- data/lib/ttt/interfaces/limelight/game_list/styles.rb +8 -0
- data/lib/ttt/interfaces/limelight/main_menu/players/exit_ttt.rb +3 -0
- data/lib/ttt/interfaces/limelight/main_menu/players/load_game.rb +3 -0
- data/lib/ttt/interfaces/limelight/main_menu/players/new_game.rb +3 -0
- data/lib/ttt/interfaces/limelight/main_menu/props.rb +17 -0
- data/lib/ttt/interfaces/limelight/new_game/players/board_type.rb +1 -0
- data/lib/ttt/interfaces/limelight/new_game/players/new_game.rb +5 -0
- data/lib/ttt/interfaces/limelight/new_game/players/player_type.rb +1 -0
- data/lib/ttt/interfaces/limelight/new_game/players/setup_button.rb +21 -0
- data/lib/ttt/interfaces/limelight/new_game/props.rb +21 -0
- data/lib/ttt/interfaces/limelight/new_game/styles.rb +23 -0
- data/lib/ttt/interfaces/limelight/partials/board_partial.rb +14 -0
- data/lib/ttt/interfaces/limelight/partials/menu_button_partial.rb +5 -0
- data/lib/ttt/interfaces/limelight/partials/move_history_partial.rb +6 -0
- data/lib/ttt/interfaces/limelight/partials/title_history_partial.rb +10 -0
- data/lib/ttt/interfaces/limelight/players/board.rb +3 -0
- data/lib/ttt/interfaces/limelight/players/game.rb +4 -0
- data/lib/ttt/interfaces/limelight/players/generic_move_history.rb +5 -0
- data/lib/ttt/interfaces/limelight/players/generic_player.rb +8 -0
- data/lib/ttt/interfaces/limelight/players/left_button.rb +3 -0
- data/lib/ttt/interfaces/limelight/players/main_menu.rb +3 -0
- data/lib/ttt/interfaces/limelight/players/right_button.rb +3 -0
- data/lib/ttt/interfaces/limelight/playscripts/game_playscript.rb +169 -0
- data/lib/ttt/interfaces/limelight/production.rb +14 -0
- data/lib/ttt/interfaces/limelight/spec/game_playscript_spec.rb +218 -0
- data/lib/ttt/interfaces/limelight/spec/main_menu/main_menu_spec.rb +38 -0
- data/lib/ttt/interfaces/limelight/spec/new_game/new_game_spec.rb +45 -0
- data/lib/ttt/interfaces/limelight/spec/spec_helper.rb +8 -0
- data/lib/ttt/interfaces/limelight/stages.rb +6 -0
- data/lib/ttt/interfaces/limelight/styles.rb +119 -0
- data/lib/ttt/interfaces/limelight/three_by_three/props.rb +1 -0
- data/lib/ttt/interfaces/limelight/three_by_three/styles.rb +39 -0
- data/lib/ttt/interfaces/limelight/three_by_three_by_three/props.rb +1 -0
- data/lib/ttt/interfaces/limelight/three_by_three_by_three/styles.rb +119 -0
- data/lib/ttt/interfaces/limelight/three_by_three_by_three_finished/props.rb +1 -0
- data/lib/ttt/interfaces/limelight/three_by_three_by_three_finished/styles.rb +119 -0
- data/lib/ttt/interfaces/limelight/three_by_three_finished/props.rb +1 -0
- data/lib/ttt/interfaces/limelight/three_by_three_finished/styles.rb +39 -0
- data/lib/ttt/interfaces/rails/app/controllers/application_controller.rb +3 -0
- data/lib/ttt/interfaces/rails/app/controllers/ttt_games_controller.rb +86 -0
- data/lib/ttt/interfaces/rails/app/helpers/application_helper.rb +2 -0
- data/lib/ttt/interfaces/rails/app/models/ttt_game.rb +34 -0
- data/lib/ttt/interfaces/rails/app/presenters/web_game_presenter.rb +159 -0
- data/lib/ttt/interfaces/rails/autotest/discover.rb +1 -0
- data/lib/ttt/interfaces/rails/config/application.rb +67 -0
- data/lib/ttt/interfaces/rails/config/boot.rb +6 -0
- data/lib/ttt/interfaces/rails/config/environment.rb +5 -0
- data/lib/ttt/interfaces/rails/config/environments/development.rb +37 -0
- data/lib/ttt/interfaces/rails/config/environments/production.rb +67 -0
- data/lib/ttt/interfaces/rails/config/environments/test.rb +37 -0
- data/lib/ttt/interfaces/rails/config/initializers/backtrace_silencers.rb +7 -0
- data/lib/ttt/interfaces/rails/config/initializers/inflections.rb +15 -0
- data/lib/ttt/interfaces/rails/config/initializers/mime_types.rb +5 -0
- data/lib/ttt/interfaces/rails/config/initializers/secret_token.rb +7 -0
- data/lib/ttt/interfaces/rails/config/initializers/session_store.rb +8 -0
- data/lib/ttt/interfaces/rails/config/initializers/wrap_parameters.rb +14 -0
- data/lib/ttt/interfaces/rails/config/routes.rb +49 -0
- data/lib/ttt/interfaces/rails/db/schema.rb +28 -0
- data/lib/ttt/interfaces/rails/db/seeds.rb +7 -0
- data/lib/ttt/interfaces/rails/spec/controllers/ttt_games_controller_spec.rb +211 -0
- data/lib/ttt/interfaces/rails/spec/models/ttt_game_spec.rb +76 -0
- data/lib/ttt/interfaces/rails/spec/presenters/web_game_presenter_spec.rb +52 -0
- data/lib/ttt/interfaces/rails/spec/spec_helper.rb +13 -0
- data/lib/ttt/interfaces/web_interface/html_generator.rb +76 -0
- data/lib/ttt/interfaces/web_interface/web_game_presenter.rb +0 -0
- data/lib/ttt/minimax.rb +46 -0
- data/lib/ttt/move_history.rb +10 -0
- data/lib/ttt/move_traverser.rb +49 -0
- data/lib/ttt/player.rb +15 -0
- data/lib/ttt/riak_db.rb +53 -0
- data/lib/ttt/setup.rb +59 -0
- data/lib/ttt/three_by_three.rb +35 -0
- data/lib/ttt/three_by_three_by_three.rb +37 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/ttt/ai_easy_spec.rb +15 -0
- data/spec/ttt/ai_hard_spec.rb +76 -0
- data/spec/ttt/ai_medium_spec.rb +65 -0
- data/spec/ttt/ai_spec.rb +50 -0
- data/spec/ttt/board_spec.rb +96 -0
- data/spec/ttt/config_helper_spec.rb +54 -0
- data/spec/ttt/context_spec.rb +398 -0
- data/spec/ttt/four_by_four_spec.rb +112 -0
- data/spec/ttt/game_history_spec.rb +41 -0
- data/spec/ttt/game_interactor_spec.rb +197 -0
- data/spec/ttt/game_spec.rb +246 -0
- data/spec/ttt/human_spec.rb +18 -0
- data/spec/ttt/move_history_spec.rb +13 -0
- data/spec/ttt/move_traverser_spec.rb +75 -0
- data/spec/ttt/player_spec.rb +13 -0
- data/spec/ttt/riak_db_spec.rb +64 -0
- data/spec/ttt/setup_spec.rb +63 -0
- data/spec/ttt/three_by_three_by_three_spec.rb +130 -0
- data/spec/ttt/three_by_three_spec.rb +110 -0
- metadata +238 -0
@@ -0,0 +1,159 @@
|
|
1
|
+
module WebGamePresenter
|
2
|
+
def self.for(options)
|
3
|
+
klass = case options.fetch :board
|
4
|
+
when TTT::ThreeByThree then ThreeByThree
|
5
|
+
when TTT::FourByFour then FourByFour
|
6
|
+
when TTT::ThreeByThreeByThree then ThreeByThreeByThree
|
7
|
+
else
|
8
|
+
raise ArgumentError, "Unknown board: #{board.inspect}"
|
9
|
+
end
|
10
|
+
klass.new board: options[:board], id: options[:id]
|
11
|
+
end
|
12
|
+
|
13
|
+
class Base
|
14
|
+
|
15
|
+
def initialize(options)
|
16
|
+
self.board = options.fetch :board
|
17
|
+
self.id = options.fetch :id
|
18
|
+
end
|
19
|
+
|
20
|
+
def board
|
21
|
+
board.board[]
|
22
|
+
end
|
23
|
+
|
24
|
+
def side_class(square)
|
25
|
+
return 'x_taken_square' if square == "x"
|
26
|
+
'o_taken_square'
|
27
|
+
end
|
28
|
+
|
29
|
+
def next_player_move
|
30
|
+
if TTT::Context.instance.ai_move?(id)
|
31
|
+
"ai"
|
32
|
+
else
|
33
|
+
"human"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def generate_form(index)
|
38
|
+
%Q(<form id="#{index}" class="untaken_square" accept-charset="UTF-8" action="/ttt_games/#{id}/update_game" method="post"><input type="hidden" name="move" value="#{index}"></form>)
|
39
|
+
end
|
40
|
+
|
41
|
+
attr_accessor :board, :id
|
42
|
+
end
|
43
|
+
|
44
|
+
class ThreeByThree < Base
|
45
|
+
def show_board
|
46
|
+
html_string = "<table class='three_by_three'><tr>"
|
47
|
+
board[].each_with_index do |square, index|
|
48
|
+
html_string += "</tr><tr>" if index % 3 == 0 && index != 0
|
49
|
+
if square == " "
|
50
|
+
html_string += %Q(#{generate_form(index) unless board.finished?}<td value="#{index}" class="square #{next_player_move} #{square_class(index)}"></td>)
|
51
|
+
else
|
52
|
+
html_string += %Q(<td id="#{index}" name="move" class="square #{side_class(square)} #{square_class(index)}">#{square}</td>)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
html_string += "</tr></table>"
|
56
|
+
end
|
57
|
+
|
58
|
+
def square_class(index)
|
59
|
+
html_class = case index
|
60
|
+
when 0 then 'top_left'
|
61
|
+
when 1 then 'top_middle'
|
62
|
+
when 2 then 'top_right'
|
63
|
+
when 3 then 'middle_left'
|
64
|
+
when 4 then 'middle'
|
65
|
+
when 5 then 'middle_right'
|
66
|
+
when 6 then 'bottom_left'
|
67
|
+
when 7 then 'bottom_middle'
|
68
|
+
when 8 then 'bottom_right'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
class FourByFour < Base
|
74
|
+
def show_board
|
75
|
+
html_string = "<table class='four_by_four'><tr>"
|
76
|
+
board[].each_with_index do |square, index|
|
77
|
+
html_string += "</tr><tr>" if index % 4 == 0 && index != 0
|
78
|
+
if square == " "
|
79
|
+
html_string += %Q(#{generate_form(index) unless board.finished?}<td value="#{index}" class="square #{next_player_move} #{square_class(index)}"></td>)
|
80
|
+
else
|
81
|
+
html_string += %Q(<td id="#{index}" class="square #{side_class(square)} #{square_class(index)}">#{square}</td>)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
html_string += "</tr></table>"
|
85
|
+
end
|
86
|
+
|
87
|
+
def square_class(index)
|
88
|
+
html_class = case index
|
89
|
+
when 0 then 'top_left'
|
90
|
+
when 1 then 'top_middle'
|
91
|
+
when 2 then 'top_middle'
|
92
|
+
when 3 then 'top_right'
|
93
|
+
when 4 then 'middle_left'
|
94
|
+
when 5 then 'middle'
|
95
|
+
when 6 then 'middle'
|
96
|
+
when 7 then 'middle_right'
|
97
|
+
when 8 then 'middle_left'
|
98
|
+
when 9 then 'middle'
|
99
|
+
when 10 then 'middle'
|
100
|
+
when 11 then 'middle_right'
|
101
|
+
when 12 then 'bottom_left'
|
102
|
+
when 13 then 'bottom_middle'
|
103
|
+
when 14 then 'bottom_middle'
|
104
|
+
when 15 then 'bottom_right'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
class ThreeByThreeByThree < Base
|
110
|
+
def show_board
|
111
|
+
html_string = ""
|
112
|
+
board[].each_slice(9).with_index do |board_level, board_level_index|
|
113
|
+
html_string += "<table class='three_by_three_by_three'><tr>"
|
114
|
+
board_level.each_with_index do |square, index|
|
115
|
+
html_string += "</tr><tr>" if index % 3 == 0 && index != 0
|
116
|
+
if square == " "
|
117
|
+
html_string += %Q(#{generate_form(index + (board_level_index * 9)) unless board.finished?}<td value="#{index + (board_level_index * 9)}" class="square #{next_player_move} #{square_class(index)}"></td>)
|
118
|
+
else
|
119
|
+
html_string += %Q(<td id="#{index}" class="square #{side_class(square)} #{square_class(index)}">#{square}</td>)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
html_string += "</tr></table>"
|
123
|
+
end
|
124
|
+
html_string
|
125
|
+
end
|
126
|
+
|
127
|
+
def square_class(index)
|
128
|
+
html_class = case index
|
129
|
+
when 0 then 'top_left'
|
130
|
+
when 1 then 'top_middle'
|
131
|
+
when 2 then 'top_right'
|
132
|
+
when 3 then 'middle_left'
|
133
|
+
when 4 then 'middle'
|
134
|
+
when 5 then 'middle_right'
|
135
|
+
when 6 then 'bottom_left'
|
136
|
+
when 7 then 'bottom_middle'
|
137
|
+
when 8 then 'bottom_right'
|
138
|
+
when 9 then 'top_left'
|
139
|
+
when 10 then 'top_middle'
|
140
|
+
when 11 then 'top_right'
|
141
|
+
when 12 then 'middle_left'
|
142
|
+
when 13 then 'middle'
|
143
|
+
when 14 then 'middle_right'
|
144
|
+
when 15 then 'bottom_left'
|
145
|
+
when 16 then 'bottom_middle'
|
146
|
+
when 17 then 'bottom_right'
|
147
|
+
when 18 then 'top_left'
|
148
|
+
when 19 then 'top_middle'
|
149
|
+
when 20 then 'top_right'
|
150
|
+
when 21 then 'middle_left'
|
151
|
+
when 22 then 'middle'
|
152
|
+
when 23 then 'middle_right'
|
153
|
+
when 24 then 'bottom_left'
|
154
|
+
when 25 then 'bottom_middle'
|
155
|
+
when 26 then 'bottom_right'
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Autotest.add_discovery { "rspec2" }
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
# Pick the frameworks you want:
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_mailer/railtie"
|
7
|
+
require "active_resource/railtie"
|
8
|
+
require "sprockets/railtie"
|
9
|
+
require "rails/test_unit/railtie"
|
10
|
+
|
11
|
+
if defined?(Bundler)
|
12
|
+
# If you precompile assets before deploying to production, use this line
|
13
|
+
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
14
|
+
# If you want your assets lazily compiled in production, use this line
|
15
|
+
# Bundler.require(:default, :assets, Rails.env)
|
16
|
+
end
|
17
|
+
|
18
|
+
module Railsttt
|
19
|
+
class Application < Rails::Application
|
20
|
+
# Settings in config/environments/* take precedence over those specified here.
|
21
|
+
# Application configuration should go into files in config/initializers
|
22
|
+
# -- all .rb files in that directory are automatically loaded.
|
23
|
+
|
24
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
25
|
+
|
26
|
+
config.autoload_paths += %W(#{config.root}/../../../)
|
27
|
+
|
28
|
+
|
29
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
30
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
31
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
32
|
+
|
33
|
+
# Activate observers that should always be running.
|
34
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
35
|
+
|
36
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
37
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
38
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
39
|
+
|
40
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
41
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
42
|
+
# config.i18n.default_locale = :de
|
43
|
+
|
44
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
45
|
+
config.encoding = "utf-8"
|
46
|
+
|
47
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
48
|
+
config.filter_parameters += [:password]
|
49
|
+
|
50
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
51
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
52
|
+
# like if you have constraints or database-specific column types
|
53
|
+
# config.active_record.schema_format = :sql
|
54
|
+
|
55
|
+
# Enforce whitelist mode for mass assignment.
|
56
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
57
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
58
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
59
|
+
config.active_record.whitelist_attributes = true
|
60
|
+
|
61
|
+
# Enable the asset pipeline
|
62
|
+
config.assets.enabled = true
|
63
|
+
|
64
|
+
# Version of your assets, change this if you want to expire all your assets
|
65
|
+
config.assets.version = '1.0'
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Railsttt::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Only use best-standards-support built into browsers
|
23
|
+
config.action_dispatch.best_standards_support = :builtin
|
24
|
+
|
25
|
+
# Raise exception on mass assignment protection for Active Record models
|
26
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
27
|
+
|
28
|
+
# Log the query plan for queries taking more than this (works
|
29
|
+
# with SQLite, MySQL, and PostgreSQL)
|
30
|
+
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
31
|
+
|
32
|
+
# Do not compress assets
|
33
|
+
config.assets.compress = false
|
34
|
+
|
35
|
+
# Expands the lines which load the assets
|
36
|
+
config.assets.debug = true
|
37
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
Railsttt::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# Code is not reloaded between requests
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Full error reports are disabled and caching is turned on
|
8
|
+
config.consider_all_requests_local = false
|
9
|
+
config.action_controller.perform_caching = true
|
10
|
+
|
11
|
+
# Disable Rails's static asset server (Apache or nginx will already do this)
|
12
|
+
config.serve_static_assets = false
|
13
|
+
|
14
|
+
# Compress JavaScripts and CSS
|
15
|
+
config.assets.compress = true
|
16
|
+
|
17
|
+
# Don't fallback to assets pipeline if a precompiled asset is missed
|
18
|
+
config.assets.compile = false
|
19
|
+
|
20
|
+
# Generate digests for assets URLs
|
21
|
+
config.assets.digest = true
|
22
|
+
|
23
|
+
# Defaults to Rails.root.join("public/assets")
|
24
|
+
# config.assets.manifest = YOUR_PATH
|
25
|
+
|
26
|
+
# Specifies the header that your server uses for sending files
|
27
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
28
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
29
|
+
|
30
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
31
|
+
# config.force_ssl = true
|
32
|
+
|
33
|
+
# See everything in the log (default is :info)
|
34
|
+
# config.log_level = :debug
|
35
|
+
|
36
|
+
# Prepend all log lines with the following tags
|
37
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
38
|
+
|
39
|
+
# Use a different logger for distributed setups
|
40
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
41
|
+
|
42
|
+
# Use a different cache store in production
|
43
|
+
# config.cache_store = :mem_cache_store
|
44
|
+
|
45
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
46
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
47
|
+
|
48
|
+
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
49
|
+
# config.assets.precompile += %w( search.js )
|
50
|
+
|
51
|
+
# Disable delivery errors, bad email addresses will be ignored
|
52
|
+
# config.action_mailer.raise_delivery_errors = false
|
53
|
+
|
54
|
+
# Enable threaded mode
|
55
|
+
# config.threadsafe!
|
56
|
+
|
57
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
58
|
+
# the I18n.default_locale when a translation can not be found)
|
59
|
+
config.i18n.fallbacks = true
|
60
|
+
|
61
|
+
# Send deprecation notices to registered listeners
|
62
|
+
config.active_support.deprecation = :notify
|
63
|
+
|
64
|
+
# Log the query plan for queries taking more than this (works
|
65
|
+
# with SQLite, MySQL, and PostgreSQL)
|
66
|
+
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
67
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Railsttt::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Configure static asset server for tests with Cache-Control for performance
|
11
|
+
config.serve_static_assets = true
|
12
|
+
config.static_cache_control = "public, max-age=3600"
|
13
|
+
|
14
|
+
# Log error messages when you accidentally call methods on nil
|
15
|
+
config.whiny_nils = true
|
16
|
+
|
17
|
+
# Show full error reports and disable caching
|
18
|
+
config.consider_all_requests_local = true
|
19
|
+
config.action_controller.perform_caching = false
|
20
|
+
|
21
|
+
# Raise exceptions instead of rendering exception templates
|
22
|
+
config.action_dispatch.show_exceptions = false
|
23
|
+
|
24
|
+
# Disable request forgery protection in test environment
|
25
|
+
config.action_controller.allow_forgery_protection = false
|
26
|
+
|
27
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
28
|
+
# The :test delivery method accumulates sent emails in the
|
29
|
+
# ActionMailer::Base.deliveries array.
|
30
|
+
config.action_mailer.delivery_method = :test
|
31
|
+
|
32
|
+
# Raise exception on mass assignment protection for Active Record models
|
33
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
34
|
+
|
35
|
+
# Print deprecation notices to the stderr
|
36
|
+
config.active_support.deprecation = :stderr
|
37
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# These inflection rules are supported but not enabled by default:
|
13
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
14
|
+
# inflect.acronym 'RESTful'
|
15
|
+
# end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Railsttt::Application.config.secret_token = '144665b181071f83878ce0aa8bc8889ab456df358300978f6bcf97cebe9d51d111cdc7872e0e1b5bef02d040b2fa225bb3f5d5c8af89d24c5c7a6750d9e7060f'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Railsttt::Application.config.session_store :cookie_store, key: '_railsttt_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# Railsttt::Application.config.session_store :active_record_store
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
#
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Disable root element in JSON by default.
|
12
|
+
ActiveSupport.on_load(:active_record) do
|
13
|
+
self.include_root_in_json = false
|
14
|
+
end
|