Skip to content
This repository
Browse code

Combined the script/environment.rb used for gems and regular files ve…

…rsion. If vendor/rails/* has all the frameworks, then files version is used, otherwise gems #878 [Nicholas Seckar]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@946 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 20e3cfe52d294893ad46307440e4acf1f02165ea 1 parent a613606
David Heinemeier Hansson authored March 20, 2005
2  railties/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* Combined the script/environment.rb used for gems and regular files version. If vendor/rails/* has all the frameworks, then files version is used, otherwise gems #878 [Nicholas Seckar]
  4
+
3 5
 * Changed .htaccess to allow dispatch.* to be called from a sub-directory as part of the push with Action Pack to make Rails work on non-vhost setups #826 [Nicholas Seckar/Tobias Luetke]
4 6
 
5 7
 * Added script/runner which can be used to run code inside the environment by eval'ing the first parameter. Examples:
13  railties/Rakefile
@@ -90,16 +90,15 @@ end
90 90
 
91 91
 desc "Copy in all the Rails packages to vendor"
92 92
 task :copy_vendor_libraries do
  93
+  mkdir File.join(PKG_DESTINATION, 'vendor', 'rails')
93 94
   cp_r VENDOR_LIBS.map { |dir| File.join('..', dir) },
94  
-       File.join(PKG_DESTINATION, 'vendor')
  95
+       File.join(PKG_DESTINATION, 'vendor', 'rails')
95 96
 end
96 97
 
97 98
 desc "Link in all the Rails packages to vendor"
98 99
 task :link_vendor_libraries do
99  
-  return_dir = File.dirname(File.expand_path(__FILE__))
100  
-  cd File.join(PKG_DESTINATION, 'vendor')
101  
-  VENDOR_LIBS.each { |dir| ln_s File.dirname(__FILE__) + "/../../#{dir}", "." }
102  
-  cd return_dir
  100
+  branch_root = File.dirname(File.dirname(File.expand_path(__FILE__)))
  101
+  ln_s branch_root, File.join(PKG_DESTINATION, 'vendor', 'rails')
103 102
 end
104 103
 
105 104
 
@@ -138,7 +137,7 @@ task :copy_configs do
138 137
 
139 138
   cp "configs/apache.conf", "#{PKG_DESTINATION}/public/.htaccess"
140 139
 
141  
-  cp "environments/shared.rb", "#{PKG_DESTINATION}/config/environment.rb"
  140
+  cp "environments/environment.rb", "#{PKG_DESTINATION}/config/environment.rb"
142 141
   cp "environments/production.rb", "#{PKG_DESTINATION}/config/environments/production.rb"
143 142
   cp "environments/development.rb", "#{PKG_DESTINATION}/config/environments/development.rb"
144 143
   cp "environments/test.rb", "#{PKG_DESTINATION}/config/environments/test.rb"
@@ -207,7 +206,7 @@ end
207 206
 # Generate GEM ----------------------------------------------------------------------------
208 207
 
209 208
 task :copy_gem_environment do
210  
-  cp "environments/shared_for_gem.rb", "#{PKG_DESTINATION}/config/environment.rb"
  209
+  cp "environments/environment.rb", "#{PKG_DESTINATION}/config/environment.rb"
211 210
   dest_file = File.join(PKG_DESTINATION, 'script', 'breakpointer')
212 211
   copy_with_rewritten_ruby_path(File.join('bin', 'breakpointer_for_gem'), dest_file)
213 212
   chmod 0755, dest_file
39  railties/environments/shared.rb → railties/environments/environment.rb
@@ -11,35 +11,28 @@
11 11
 
12 12
 # Followed by the standard includes.
13 13
 ADDITIONAL_LOAD_PATHS.concat %w(
14  
-  app
15  
-  app/models
16  
-  app/controllers
17  
-  app/helpers
18  
-  app/apis
19  
-  config
20  
-  components
21  
-  lib
22  
-  vendor
23  
-  vendor/railties
24  
-  vendor/railties/lib
25  
-  vendor/activesupport/lib
26  
-  vendor/activerecord/lib
27  
-  vendor/actionpack/lib
28  
-  vendor/actionmailer/lib
29  
-  vendor/actionwebservice/lib
30  
-).map { |dir| "#{RAILS_ROOT}/#{dir}" }
  14
+  app app/models app/controllers app/helpers app/apis config components lib vendor
  15
+).map { |dir| "#{RAILS_ROOT}/#{dir}" }.select { |dir| File.directory?(dir) }
31 16
 
32 17
 # Prepend to $LOAD_PATH
33 18
 ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
34 19
 
35  
-
36 20
 # Require Rails libraries.
37  
-require 'active_support'
38  
-require 'active_record'
39  
-require 'action_controller'
40  
-require 'action_mailer'
41  
-require 'action_web_service'
  21
+rails_files = %w(
  22
+  actionpack/lib/action_controller
  23
+  actionpack/lib/action_view
  24
+  activesupport/lib/active_support
  25
+  activerecord/lib/active_record
  26
+  actionmailer/lib/action_mailer
  27
+  actionwebservice/lib/action_web_service
  28
+).collect { |p| File.join(RAILS_ROOT, 'vendor', 'rails', "#{p}.rb") }
42 29
 
  30
+if rails_files.all? { |f| File.file?(f) }
  31
+  rails_files.each { |f| require f }
  32
+else
  33
+  require 'rubygems'
  34
+  %w( activesupport activerecord actionpack actionmailer actionwebservice rails ).each { |gem| require_gem(gem) }
  35
+end
43 36
 
44 37
 # Environment-specific configuration.
45 38
 require_dependency "environments/#{RAILS_ENV}"
66  railties/environments/shared_for_gem.rb
... ...
@@ -1,66 +0,0 @@
1  
-RAILS_ROOT = File.dirname(__FILE__) + "/../"
2  
-RAILS_ENV  = ENV['RAILS_ENV'] || 'development'
3  
-
4  
-
5  
-# Mocks first.
6  
-ADDITIONAL_LOAD_PATHS = ["#{RAILS_ROOT}/test/mocks/#{RAILS_ENV}"]
7  
-
8  
-# Then model subdirectories.
9  
-ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/app/models/[_a-z]*"])
10  
-ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/components/[_a-z]*"])
11  
-
12  
-# Followed by the standard includes.
13  
-ADDITIONAL_LOAD_PATHS.concat %w(
14  
-  app
15  
-  app/models
16  
-  app/controllers
17  
-  app/helpers
18  
-  app/apis
19  
-  config
20  
-  components
21  
-  lib
22  
-  vendor
23  
-).map { |dir| "#{RAILS_ROOT}/#{dir}" }
24  
-
25  
-# Prepend to $LOAD_PATH
26  
-ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
27  
-
28  
-
29  
-# Require Rails gems.
30  
-require 'rubygems'
31  
-require_gem 'activesupport'
32  
-require_gem 'activerecord'
33  
-require_gem 'actionpack'
34  
-require_gem 'actionmailer'
35  
-require_gem 'actionwebservice'
36  
-require_gem 'rails'
37  
-
38  
-
39  
-# Environment-specific configuration.
40  
-require_dependency "environments/#{RAILS_ENV}"
41  
-ActiveRecord::Base.configurations = File.open("#{RAILS_ROOT}/config/database.yml") { |f| YAML::load(f) }
42  
-ActiveRecord::Base.establish_connection
43  
-
44  
-
45  
-# Configure defaults if the included environment did not.
46  
-begin
47  
-  RAILS_DEFAULT_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log")
48  
-rescue StandardError
49  
-  RAILS_DEFAULT_LOGGER = Logger.new(STDERR)
50  
-  RAILS_DEFAULT_LOGGER.level = Logger::WARN
51  
-  RAILS_DEFAULT_LOGGER.warn(
52  
-    "Rails Error: Unable to access log file. Please ensure that log/#{RAILS_ENV}.log exists and is chmod 0666. " +
53  
-    "The log level has been raised to WARN and the output directed to STDERR until the problem is fixed."
54  
-  )
55  
-end
56  
-
57  
-[ActiveRecord, ActionController, ActionMailer].each { |mod| mod::Base.logger ||= RAILS_DEFAULT_LOGGER }
58  
-[ActionController, ActionMailer].each { |mod| mod::Base.template_root ||= "#{RAILS_ROOT}/app/views/" }
59  
-ActionController::Routing::Routes.reload
60  
-
61  
-Controllers = Dependencies::LoadingModule.root(
62  
-  File.join(RAILS_ROOT, 'app', 'controllers'),
63  
-  File.join(RAILS_ROOT, 'components')
64  
-)
65  
-
66  
-# Include your app's configuration here:
6  railties/lib/rails_generator/generators/applications/app/app_generator.rb
@@ -37,11 +37,7 @@ def manifest
37 37
       m.template "configs/apache.conf", "public/.htaccess"
38 38
 
39 39
       # Environments
40  
-      if options[:gem]
41  
-        m.file "environments/shared_for_gem.rb", "config/environment.rb"
42  
-      else
43  
-        m.file "environments/shared.rb", "config/environment.rb"
44  
-      end
  40
+      m.file "environments/environment.rb", "config/environment.rb"
45 41
       m.file "environments/production.rb", "config/environments/production.rb"
46 42
       m.file "environments/development.rb", "config/environments/development.rb"
47 43
       m.file "environments/test.rb", "config/environments/test.rb"

0 notes on commit 20e3cfe

Please sign in to comment.
Something went wrong with that request. Please try again.