Skip to content
Newer
Older
100644 120 lines (97 sloc) 2.55 KB
02c5137 @josevalim Add view paths to Engine setup.
josevalim authored Jan 22, 2010
1 require 'fileutils'
b17e358 @josevalim Move configuration to subfolders.
josevalim authored Jan 23, 2010
2 require 'rails/railties_path'
3 require 'rails/plugin'
2fde9d7 @josevalim Solve some pendencies.
josevalim authored Jan 24, 2010
4 require 'rails/engine'
dc677f7 tests pass with requiring the frameworks in rails.rb
Carlhuda authored Dec 22, 2009
5
accd9b4 @josh Restore "Start Rails::Application object
josh authored Sep 25, 2009
6 module Rails
7fcf859 @josevalim Massive cleanup in Railties and load stack.
josevalim authored Jan 21, 2010
7 class Application < Engine
4f03603 @josevalim Break application.rb file in smaller chunks.
josevalim authored Jan 23, 2010
8 autoload :Bootstrap, 'rails/application/bootstrap'
b17e358 @josevalim Move configuration to subfolders.
josevalim authored Jan 23, 2010
9 autoload :Configuration, 'rails/application/configuration'
4f03603 @josevalim Break application.rb file in smaller chunks.
josevalim authored Jan 23, 2010
10 autoload :Finisher, 'rails/application/finisher'
13d66cd @josevalim Extract Railtie load from application.
josevalim authored Jan 23, 2010
11 autoload :Railties, 'rails/application/railties'
80130d1 @josevalim Extract routes reloading responsibilities from application and load t…
josevalim authored Jan 23, 2010
12 autoload :RoutesReloader, 'rails/application/routes_reloader'
13
e4d7e50 Moving more initializers into the application object
Carl Lerche authored Oct 8, 2009
14 class << self
94bb331 @jeremy Shift more responsibility from application class to its singleton ins…
jeremy authored Dec 23, 2009
15 private :new
80130d1 @josevalim Extract routes reloading responsibilities from application and load t…
josevalim authored Jan 23, 2010
16 alias :configure :class_eval
17
94bb331 @jeremy Shift more responsibility from application class to its singleton ins…
jeremy authored Dec 24, 2009
18 def instance
db99324 @josevalim Ensure calling a method in Rails::Application does not instantiate a …
josevalim authored Jan 26, 2010
19 if self == Rails::Application
20 Rails.application
9212652 @josh Add Rails::Application pointer to the default app to add symmetry to …
josh authored Jan 24, 2010
21 else
db99324 @josevalim Ensure calling a method in Rails::Application does not instantiate a …
josevalim authored Jan 26, 2010
22 @@instance ||= new
9212652 @josh Add Rails::Application pointer to the default app to add symmetry to …
josh authored Jan 24, 2010
23 end
897164d Conceptually unify instance & global initializers
Yehuda Katz + Carl Lerche authored Nov 2, 2009
24 end
25
7fcf859 @josevalim Massive cleanup in Railties and load stack.
josevalim authored Jan 21, 2010
26 def inherited(base)
2fde9d7 @josevalim Solve some pendencies.
josevalim authored Jan 24, 2010
27 raise "You cannot have more than one Rails::Application" if Rails.application
7fcf859 @josevalim Massive cleanup in Railties and load stack.
josevalim authored Jan 21, 2010
28 super
788fce2 @josevalim Create configurable modules and ensure that they are added only on di…
josevalim authored Jan 23, 2010
29 Rails.application = base.instance
e4d7e50 Moving more initializers into the application object
Carl Lerche authored Oct 8, 2009
30 end
6f6a589 Create the application object from config/environment.rb
Yehuda Katz + Carl Lerche authored Sep 28, 2009
31
80130d1 @josevalim Extract routes reloading responsibilities from application and load t…
josevalim authored Jan 23, 2010
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 Dec 21, 2009
36 end
897164d Conceptually unify instance & global initializers
Yehuda Katz + Carl Lerche authored Nov 3, 2009
37 end
6f6a589 Create the application object from config/environment.rb
Yehuda Katz + Carl Lerche authored Sep 29, 2009
38
788fce2 @josevalim Create configurable modules and ensure that they are added only on di…
josevalim authored Jan 23, 2010
39 def require_environment!
13d66cd @josevalim Extract Railtie load from application.
josevalim authored Jan 23, 2010
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 Dec 21, 2009
42 end
43
788fce2 @josevalim Create configurable modules and ensure that they are added only on di…
josevalim authored Jan 23, 2010
44 def config
b17e358 @josevalim Move configuration to subfolders.
josevalim authored Jan 23, 2010
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 Jan 23, 2010
46 end
47
80130d1 @josevalim Extract routes reloading responsibilities from application and load t…
josevalim authored Jan 23, 2010
48 def routes
13d66cd @josevalim Extract Railtie load from application.
josevalim authored Jan 23, 2010
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 Nov 3, 2009
54 end
5f8e48c @josh Move route reloading into railties
josh authored Dec 14, 2009
55
80130d1 @josevalim Extract routes reloading responsibilities from application and load t…
josevalim authored Jan 23, 2010
56 def routes_reloader
57 @routes_reloader ||= RoutesReloader.new(config)
5f8e48c @josh Move route reloading into railties
josh authored Dec 14, 2009
58 end
59
60 def reload_routes!
80130d1 @josevalim Extract routes reloading responsibilities from application and load t…
josevalim authored Jan 23, 2010
61 routes_reloader.reload!
62 end
5f8e48c @josh Move route reloading into railties
josh authored Dec 14, 2009
63
80130d1 @josevalim Extract routes reloading responsibilities from application and load t…
josevalim authored Jan 23, 2010
64 def initialize!
65 run_initializers(self)
66 self
5f8e48c @josh Move route reloading into railties
josh authored Dec 14, 2009
67 end
68
94bb331 @jeremy Shift more responsibility from application class to its singleton ins…
jeremy authored Dec 24, 2009
69 def load_tasks
788fce2 @josevalim Create configurable modules and ensure that they are added only on di…
josevalim authored Jan 23, 2010
70 initialize_tasks
13d66cd @josevalim Extract Railtie load from application.
josevalim authored Jan 23, 2010
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 Dec 24, 2009
74 end
75
4ca9765 @josevalim Allow railties to specify generators paths.
josevalim authored Jan 19, 2010
76 def load_generators
788fce2 @josevalim Create configurable modules and ensure that they are added only on di…
josevalim authored Jan 23, 2010
77 initialize_generators
13d66cd @josevalim Extract Railtie load from application.
josevalim authored Jan 23, 2010
78 super
79 railties.all { |r| r.load_generators }
80 self
82b9b15 Refactor plugins
Yehuda Katz + Carl Lerche authored Nov 6, 2009
81 end
82
603d4fb @josh Build middleware stack and reload routes after app initializers run
josh authored Jan 16, 2010
83 def app
80130d1 @josevalim Extract routes reloading responsibilities from application and load t…
josevalim authored Jan 23, 2010
84 @app ||= middleware.build(routes)
603d4fb @josh Build middleware stack and reload routes after app initializers run
josh authored Jan 16, 2010
85 end
86
897164d Conceptually unify instance & global initializers
Yehuda Katz + Carl Lerche authored Nov 3, 2009
87 def call(env)
fc4f237 @josevalim Make filter parameters based on request, so they can be modified for …
josevalim authored Jan 21, 2010
88 env["action_dispatch.parameter_filter"] = config.filter_parameters
603d4fb @josh Build middleware stack and reload routes after app initializers run
josh authored Jan 16, 2010
89 app.call(env)
6d6ae08 Start moving the initializers into the application object
Carl Lerche authored Oct 7, 2009
90 end
91
98240c4 @josevalim Get rid of initializers global and create i18n railtie.
josevalim authored Jan 23, 2010
92 def initializers
5d07869 @josevalim Ensure all initializers are collections.
josevalim authored Jan 26, 2010
93 initializers = Bootstrap.initializers_for(self)
13d66cd @josevalim Extract Railtie load from application.
josevalim authored Jan 23, 2010
94 railties.all { |r| initializers += r.initializers }
2d1f9fb @josh Plugins need to load before app initializers
josh authored Jan 25, 2010
95 initializers += super
5d07869 @josevalim Ensure all initializers are collections.
josevalim authored Jan 25, 2010
96 initializers += Finisher.initializers_for(self)
98240c4 @josevalim Get rid of initializers global and create i18n railtie.
josevalim authored Jan 23, 2010
97 initializers
98 end
788fce2 @josevalim Create configurable modules and ensure that they are added only on di…
josevalim authored Jan 23, 2010
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 Sep 26, 2009
118 end
119 end
Something went wrong with that request. Please try again.