Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 120 lines (97 sloc) 2.609 kB
02c5137 @josevalim Add view paths to Engine setup.
josevalim authored
1 require 'fileutils'
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
2 require 'rails/railties_path'
3 require 'rails/plugin'
2fde9d7 @josevalim Solve some pendencies.
josevalim authored
4 require 'rails/engine'
dc677f7 tests pass with requiring the frameworks in rails.rb
Carlhuda authored
5
accd9b4 @josh Restore "Start Rails::Application object
josh authored
6 module Rails
7fcf859 @josevalim Massive cleanup in Railties and load stack.
josevalim authored
7 class Application < Engine
4f03603 @josevalim Break application.rb file in smaller chunks.
josevalim authored
8 autoload :Bootstrap, 'rails/application/bootstrap'
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
9 autoload :Configuration, 'rails/application/configuration'
4f03603 @josevalim Break application.rb file in smaller chunks.
josevalim authored
10 autoload :Finisher, 'rails/application/finisher'
13d66cd @josevalim Extract Railtie load from application.
josevalim authored
11 autoload :Railties, 'rails/application/railties'
80130d1 @josevalim Extract routes reloading responsibilities from application and load t…
josevalim authored
12 autoload :RoutesReloader, 'rails/application/routes_reloader'
13
e4d7e50 Moving more initializers into the application object
Carl Lerche authored
14 class << self
94bb331 @jeremy Shift more responsibility from application class to its singleton ins…
jeremy authored
15 private :new
80130d1 @josevalim Extract routes reloading responsibilities from application and load t…
josevalim authored
16 alias :configure :class_eval
17
94bb331 @jeremy Shift more responsibility from application class to its singleton ins…
jeremy authored
18 def instance
9212652 @josh Add Rails::Application pointer to the default app to add symmetry to …
josh authored
19 if instance_of?(Rails::Application)
20 Rails.application.instance
21 else
22 @instance ||= new
23 end
897164d Conceptually unify instance & global initializers
Yehuda Katz + Carl Lerche authored
24 end
25
7fcf859 @josevalim Massive cleanup in Railties and load stack.
josevalim authored
26 def inherited(base)
2fde9d7 @josevalim Solve some pendencies.
josevalim authored
27 raise "You cannot have more than one Rails::Application" if Rails.application
7fcf859 @josevalim Massive cleanup in Railties and load stack.
josevalim authored
28 super
788fce2 @josevalim Create configurable modules and ensure that they are added only on di…
josevalim authored
29 Rails.application = base.instance
e4d7e50 Moving more initializers into the application object
Carl Lerche authored
30 end
6f6a589 Create the application object from config/environment.rb
Yehuda Katz + Carl Lerche authored
31
80130d1 @josevalim Extract routes reloading responsibilities from application and load t…
josevalim authored
32 protected
33
34 def method_missing(*args, &block)
35 instance.send(*args, &block)
426348b @josh Update routes.rb template to use App name
josh authored
36 end
897164d Conceptually unify instance & global initializers
Yehuda Katz + Carl Lerche authored
37 end
6f6a589 Create the application object from config/environment.rb
Yehuda Katz + Carl Lerche authored
38
788fce2 @josevalim Create configurable modules and ensure that they are added only on di…
josevalim authored
39 def require_environment!
13d66cd @josevalim Extract Railtie load from application.
josevalim authored
40 environment = config.paths.config.environment.to_a.first
41 require environment if environment
d982fe2 Replace reopening the class with App.configure as an alias to class_eval
Carlhuda authored
42 end
43
788fce2 @josevalim Create configurable modules and ensure that they are added only on di…
josevalim authored
44 def config
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
45 @config ||= Application::Configuration.new(self.class.find_root_with_flag("config.ru", Dir.pwd))
788fce2 @josevalim Create configurable modules and ensure that they are added only on di…
josevalim authored
46 end
47
80130d1 @josevalim Extract routes reloading responsibilities from application and load t…
josevalim authored
48 def routes
13d66cd @josevalim Extract Railtie load from application.
josevalim authored
49 ::ActionController::Routing::Routes
50 end
51
52 def railties
53 @railties ||= Railties.new(config)
897164d Conceptually unify instance & global initializers
Yehuda Katz + Carl Lerche authored
54 end
5f8e48c @josh Move route reloading into railties
josh authored
55
80130d1 @josevalim Extract routes reloading responsibilities from application and load t…
josevalim authored
56 def routes_reloader
57 @routes_reloader ||= RoutesReloader.new(config)
5f8e48c @josh Move route reloading into railties
josh authored
58 end
59
60 def reload_routes!
80130d1 @josevalim Extract routes reloading responsibilities from application and load t…
josevalim authored
61 routes_reloader.reload!
62 end
5f8e48c @josh Move route reloading into railties
josh authored
63
80130d1 @josevalim Extract routes reloading responsibilities from application and load t…
josevalim authored
64 def initialize!
65 run_initializers(self)
66 self
5f8e48c @josh Move route reloading into railties
josh authored
67 end
68
94bb331 @jeremy Shift more responsibility from application class to its singleton ins…
jeremy authored
69 def load_tasks
788fce2 @josevalim Create configurable modules and ensure that they are added only on di…
josevalim authored
70 initialize_tasks
13d66cd @josevalim Extract Railtie load from application.
josevalim authored
71 super
72 railties.all { |r| r.load_tasks }
73 self
94bb331 @jeremy Shift more responsibility from application class to its singleton ins…
jeremy authored
74 end
75
4ca9765 @josevalim Allow railties to specify generators paths.
josevalim authored
76 def load_generators
788fce2 @josevalim Create configurable modules and ensure that they are added only on di…
josevalim authored
77 initialize_generators
13d66cd @josevalim Extract Railtie load from application.
josevalim authored
78 super
79 railties.all { |r| r.load_generators }
80 self
82b9b15 Refactor plugins
Yehuda Katz + Carl Lerche authored
81 end
82
603d4fb @josh Build middleware stack and reload routes after app initializers run
josh authored
83 def app
80130d1 @josevalim Extract routes reloading responsibilities from application and load t…
josevalim authored
84 @app ||= middleware.build(routes)
603d4fb @josh Build middleware stack and reload routes after app initializers run
josh authored
85 end
86
897164d Conceptually unify instance & global initializers
Yehuda Katz + Carl Lerche authored
87 def call(env)
fc4f237 @josevalim Make filter parameters based on request, so they can be modified for …
josevalim authored
88 env["action_dispatch.parameter_filter"] = config.filter_parameters
603d4fb @josh Build middleware stack and reload routes after app initializers run
josh authored
89 app.call(env)
6d6ae08 Start moving the initializers into the application object
Carl Lerche authored
90 end
91
98240c4 @josevalim Get rid of initializers global and create i18n railtie.
josevalim authored
92 def initializers
4eab3aa @josevalim Ensure user set load paths have higher preference and move Bootstrap …
josevalim authored
93 initializers = Bootstrap.initializers
13d66cd @josevalim Extract Railtie load from application.
josevalim authored
94 railties.all { |r| initializers += r.initializers }
2d1f9fb @josh Plugins need to load before app initializers
josh authored
95 initializers += super
4eab3aa @josevalim Ensure user set load paths have higher preference and move Bootstrap …
josevalim authored
96 initializers += Finisher.initializers
98240c4 @josevalim Get rid of initializers global and create i18n railtie.
josevalim authored
97 initializers
98 end
788fce2 @josevalim Create configurable modules and ensure that they are added only on di…
josevalim authored
99
100 protected
101
102 def initialize_tasks
103 require "rails/tasks"
104 task :environment do
105 $rails_rake_task = true
106 initialize!
107 end
108 end
109
110 def initialize_generators
111 require "rails/generators"
112 end
113
114 # Application is always reloadable when config.cache_classes is false.
115 def reloadable?(app)
116 true
117 end
accd9b4 @josh Restore "Start Rails::Application object
josh authored
118 end
119 end
Something went wrong with that request. Please try again.