aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rwxr-xr-xrailties/bin/about4
-rwxr-xr-xrailties/bin/console2
-rwxr-xr-xrailties/bin/dbconsole2
-rwxr-xr-xrailties/bin/destroy2
-rwxr-xr-xrailties/bin/generate2
-rwxr-xr-xrailties/bin/performance/benchmarker2
-rwxr-xr-xrailties/bin/performance/profiler2
-rwxr-xr-xrailties/bin/plugin2
-rwxr-xr-xrailties/bin/runner2
-rwxr-xr-xrailties/bin/server2
-rw-r--r--railties/html/404.html33
-rw-r--r--railties/html/422.html33
-rw-r--r--railties/html/500.html31
-rw-r--r--railties/html/index.html61
-rw-r--r--railties/lib/initializer.rb4
-rw-r--r--railties/lib/rails/configuration.rb40
-rw-r--r--railties/lib/rails/paths.rb40
-rw-r--r--railties/lib/rails/rack/metal.rb8
-rw-r--r--railties/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb8
-rw-r--r--railties/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb3
-rw-r--r--railties/lib/vendor/bundler/LICENSE20
-rw-r--r--railties/lib/vendor/bundler/Rakefile52
-rwxr-xr-xrailties/lib/vendor/bundler/bin/gem_bundler40
-rw-r--r--railties/lib/vendor/bundler/lib/bundler.rb24
-rw-r--r--railties/lib/vendor/bundler/lib/bundler/cli.rb24
-rw-r--r--railties/lib/vendor/bundler/lib/bundler/dependency.rb35
-rw-r--r--railties/lib/vendor/bundler/lib/bundler/finder.rb42
-rw-r--r--railties/lib/vendor/bundler/lib/bundler/gem_bundle.rb23
-rw-r--r--railties/lib/vendor/bundler/lib/bundler/gem_specification.rb10
-rw-r--r--railties/lib/vendor/bundler/lib/bundler/installer.rb44
-rw-r--r--railties/lib/vendor/bundler/lib/bundler/manifest.rb130
-rw-r--r--railties/lib/vendor/bundler/lib/bundler/resolver.rb19
-rw-r--r--railties/lib/vendor/bundler/lib/bundler/resolver/builders.rb61
-rw-r--r--railties/lib/vendor/bundler/lib/bundler/resolver/engine.rb38
-rw-r--r--railties/lib/vendor/bundler/lib/bundler/resolver/inspect.rb24
-rw-r--r--railties/lib/vendor/bundler/lib/bundler/resolver/search.rb71
-rw-r--r--railties/lib/vendor/bundler/lib/bundler/resolver/stack.rb72
-rw-r--r--railties/lib/vendor/bundler/lib/bundler/resolver/state.rb172
-rw-r--r--railties/lib/vendor/bundler/lib/bundler/runtime.rb39
-rw-r--r--railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb4
-rw-r--r--railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb4
-rw-r--r--railties/test/initializer/check_ruby_version_test.rb2
-rw-r--r--railties/test/initializer/install_gem_spec_stubs_test.rb29
-rw-r--r--railties/test/initializer/path_test.rb2
-rw-r--r--railties/test/initializer/test_helper.rb48
-rw-r--r--railties/test/metal_test.rb30
-rw-r--r--railties/test/paths_test.rb92
47 files changed, 1255 insertions, 179 deletions
diff --git a/railties/bin/about b/railties/bin/about
index ed8deb0dfc..1eeb6eb915 100755
--- a/railties/bin/about
+++ b/railties/bin/about
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
+require File.expand_path('../../config/boot', __FILE__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
-require 'commands/about' \ No newline at end of file
+require 'commands/about'
diff --git a/railties/bin/console b/railties/bin/console
index 498077ab33..235a1f2780 100755
--- a/railties/bin/console
+++ b/railties/bin/console
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
+require File.expand_path('../../config/boot', __FILE__)
require 'commands/console'
diff --git a/railties/bin/dbconsole b/railties/bin/dbconsole
index caa60ce829..83c8436a9d 100755
--- a/railties/bin/dbconsole
+++ b/railties/bin/dbconsole
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
+require File.expand_path('../../config/boot', __FILE__)
require 'commands/dbconsole'
diff --git a/railties/bin/destroy b/railties/bin/destroy
index a4df765a39..88d295f7aa 100755
--- a/railties/bin/destroy
+++ b/railties/bin/destroy
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
+require File.expand_path('../../config/boot', __FILE__)
require 'commands/destroy'
diff --git a/railties/bin/generate b/railties/bin/generate
index 173a9f147d..62a8a4c0c5 100755
--- a/railties/bin/generate
+++ b/railties/bin/generate
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
+require File.expand_path('../../config/boot', __FILE__)
require 'commands/generate'
diff --git a/railties/bin/performance/benchmarker b/railties/bin/performance/benchmarker
index c842d35d33..3bff809fb3 100755
--- a/railties/bin/performance/benchmarker
+++ b/railties/bin/performance/benchmarker
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../config/boot'
+require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/benchmarker'
diff --git a/railties/bin/performance/profiler b/railties/bin/performance/profiler
index d855ac8b13..07640575cd 100755
--- a/railties/bin/performance/profiler
+++ b/railties/bin/performance/profiler
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../config/boot'
+require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/profiler'
diff --git a/railties/bin/plugin b/railties/bin/plugin
index 87cd2070fe..b82201fa83 100755
--- a/railties/bin/plugin
+++ b/railties/bin/plugin
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
+require File.expand_path('../../config/boot', __FILE__)
require 'commands/plugin'
diff --git a/railties/bin/runner b/railties/bin/runner
index a4a7cb25ba..be4c5d4572 100755
--- a/railties/bin/runner
+++ b/railties/bin/runner
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
+require File.expand_path('../../config/boot', __FILE__)
require 'commands/runner'
diff --git a/railties/bin/server b/railties/bin/server
index 3c67f39b69..b9fcb71793 100755
--- a/railties/bin/server
+++ b/railties/bin/server
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
+require File.expand_path('../../config/boot', __FILE__)
require 'commands/server'
diff --git a/railties/html/404.html b/railties/html/404.html
index eff660b90c..88ee108e90 100644
--- a/railties/html/404.html
+++ b/railties/html/404.html
@@ -1,23 +1,20 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
+<!DOCTYPE html>
+<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>The page you were looking for doesn't exist (404)</title>
- <style type="text/css">
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
- div.dialog {
- width: 25em;
- padding: 0 4em;
- margin: 4em auto 0 auto;
- border: 1px solid #ccc;
- border-right-color: #999;
- border-bottom-color: #999;
- }
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
- </style>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
</head>
<body>
@@ -27,4 +24,4 @@
<p>You may have mistyped the address or the page may have moved.</p>
</div>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/railties/html/422.html b/railties/html/422.html
index b54e4a3cad..9c3c96670b 100644
--- a/railties/html/422.html
+++ b/railties/html/422.html
@@ -1,23 +1,20 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
+<!DOCTYPE html>
+<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>The change you wanted was rejected (422)</title>
- <style type="text/css">
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
- div.dialog {
- width: 25em;
- padding: 0 4em;
- margin: 4em auto 0 auto;
- border: 1px solid #ccc;
- border-right-color: #999;
- border-bottom-color: #999;
- }
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
- </style>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
</head>
<body>
@@ -27,4 +24,4 @@
<p>Maybe you tried to change something you didn't have access to.</p>
</div>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/railties/html/500.html b/railties/html/500.html
index ec3bbf02c4..f71c86e652 100644
--- a/railties/html/500.html
+++ b/railties/html/500.html
@@ -1,23 +1,20 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
+<!DOCTYPE html>
+<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>We're sorry, but something went wrong (500)</title>
- <style type="text/css">
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
- div.dialog {
- width: 25em;
- padding: 0 4em;
- margin: 4em auto 0 auto;
- border: 1px solid #ccc;
- border-right-color: #999;
- border-bottom-color: #999;
- }
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
- </style>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
</head>
<body>
diff --git a/railties/html/index.html b/railties/html/index.html
index cd337dc74c..ff2dfd3193 100644
--- a/railties/html/index.html
+++ b/railties/html/index.html
@@ -1,5 +1,4 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
@@ -14,20 +13,20 @@
font-size: 13px;
color: #333;
}
-
+
h1 {
font-size: 28px;
color: #000;
}
-
+
a {color: #03c}
a:hover {
background-color: #03c;
color: white;
text-decoration: none;
}
-
-
+
+
#page {
background-color: #f0f0f0;
width: 750px;
@@ -35,7 +34,7 @@
margin-left: auto;
margin-right: auto;
}
-
+
#content {
float: left;
background-color: white;
@@ -44,7 +43,7 @@
padding: 25px;
width: 500px;
}
-
+
#sidebar {
float: right;
width: 175px;
@@ -53,7 +52,7 @@
#footer {
clear: both;
}
-
+
#header, #about, #getting-started {
padding-left: 75px;
@@ -73,14 +72,14 @@
font-weight: normal;
font-size: 16px;
}
-
-
+
+
#about h3 {
margin: 0;
margin-bottom: 10px;
font-size: 14px;
}
-
+
#about-content {
background-color: #ffd;
border: 1px solid #fc0;
@@ -113,8 +112,8 @@
margin: 0;
padding: 10px;
}
-
-
+
+
#getting-started {
border-top: 1px solid #ccc;
margin-top: 25px;
@@ -150,8 +149,8 @@
color: #555;
font-size: 13px;
}
-
-
+
+
#search {
margin: 0;
padding-top: 10px;
@@ -163,8 +162,8 @@
margin: 2px;
}
#search-text {width: 170px}
-
-
+
+
#sidebar ul {
margin-left: 0;
padding-left: 0;
@@ -181,7 +180,7 @@
#sidebar ul.links li {
margin-bottom: 5px;
}
-
+
</style>
<script type="text/javascript" src="javascripts/prototype.js"></script>
<script type="text/javascript" src="javascripts/effects.js"></script>
@@ -194,11 +193,11 @@
onComplete: function() {new Effect.BlindDown('about-content', {duration: 0.25})}
});
} else {
- new Effect[Element.visible('about-content') ?
+ new Effect[Element.visible('about-content') ?
'BlindUp' : 'BlindDown']('about-content', {duration: 0.25});
}
}
-
+
window.onload = function() {
$('search-text').value = '';
$('search').onsubmit = function() {
@@ -218,7 +217,7 @@
<input type="submit" value="Search" /> the Rails site
</form>
</li>
-
+
<li>
<h3>Join the community</h3>
<ul class="links">
@@ -227,7 +226,7 @@
<li><a href="http://wiki.rubyonrails.org/">Wiki</a></li>
</ul>
</li>
-
+
<li>
<h3>Browse the documentation</h3>
<ul class="links">
@@ -250,17 +249,17 @@
<h3><a href="rails/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
<div id="about-content" style="display: none"></div>
</div>
-
+
<div id="getting-started">
<h1>Getting started</h1>
<h2>Here&rsquo;s how to get rolling:</h2>
-
- <ol>
+
+ <ol>
<li>
- <h2>Use <tt>script/generate</tt> to create your models and controllers</h2>
+ <h2>Use <code>script/generate</code> to create your models and controllers</h2>
<p>To see all available options, run it without parameters.</p>
</li>
-
+
<li>
<h2>Set up a default route and remove or rename this file</h2>
<p>Routes are set up in config/routes.rb.</p>
@@ -268,13 +267,13 @@
<li>
<h2>Create your database</h2>
- <p>Run <tt>rake db:migrate</tt> to create your database. If you're not using SQLite (the default), edit <tt>config/database.yml</tt> with your username and password.</p>
+ <p>Run <code>rake db:migrate</code> to create your database. If you're not using SQLite (the default), edit <code>config/database.yml</code> with your username and password.</p>
</li>
</ol>
</div>
</div>
-
+
<div id="footer">&nbsp;</div>
</div>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index 560105670f..f0fb78c8f4 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -12,6 +12,10 @@ require 'rails/configuration'
RAILS_ENV = (ENV['RAILS_ENV'] || 'development').dup unless defined?(RAILS_ENV)
module Rails
+ # Sanity check to make sure this file is only loaded once
+ # TODO: Get to the point where this can be removed.
+ raise "It looks like initializer.rb was required twice" if defined?(Initializer)
+
class Initializer
class Error < StandardError ; end
diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb
index d877915460..1a2f217d20 100644
--- a/railties/lib/rails/configuration.rb
+++ b/railties/lib/rails/configuration.rb
@@ -62,33 +62,19 @@ module Rails
end
@paths = Rails::Application::Root.new(root_path)
- @paths.app = "app"
- @paths.app.metals = "app/metal"
- @paths.app.models = "app/models"
- @paths.app.controllers = "app/controllers"
- @paths.app.helpers = "app/helpers"
- @paths.app.services = "app/services"
- @paths.lib = "lib"
- @paths.vendor = "vendor"
- @paths.vendor.plugins = "vendor/plugins"
- @paths.cache = "tmp/cache"
- @paths.config = "config"
- @paths.config.locales = "config/locales"
- @paths.config.environments = "config/environments"
-
- @paths.app.controllers.concat builtin_directories
-
- @paths.app.load_path!
- @paths.app.metals.load_path!
- @paths.app.models.eager_load!
- @paths.app.controllers.eager_load!
- @paths.app.helpers.eager_load!
- @paths.app.services.load_path!
- @paths.app.metals.eager_load!
- @paths.lib.load_path!
- @paths.vendor.load_path!
-
- @paths.config.environments.glob = "#{RAILS_ENV}.rb"
+ @paths.app "app", :load_path => true
+ @paths.app.metals "app/metal", :eager_load => true
+ @paths.app.models "app/models", :eager_load => true
+ @paths.app.controllers "app/controllers", builtin_directories, :eager_load => true
+ @paths.app.helpers "app/helpers", :eager_load => true
+ @paths.app.services "app/services", :load_path => true
+ @paths.lib "lib", :load_path => true
+ @paths.vendor "vendor", :load_path => true
+ @paths.vendor.plugins "vendor/plugins"
+ @paths.cache "tmp/cache"
+ @paths.config "config"
+ @paths.config.locales "config/locales"
+ @paths.config.environments "config/environments", :glob => "#{RAILS_ENV}.rb"
RAILS_ROOT.replace root_path
end
diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb
index d2f6d83659..3899b744b0 100644
--- a/railties/lib/rails/paths.rb
+++ b/railties/lib/rails/paths.rb
@@ -6,8 +6,8 @@ module Rails
def method_missing(id, *args)
name = id.to_s
- if name =~ /^(.*)=$/
- @children[$1] = Path.new(args.first, @root)
+ if name =~ /^(.*)=$/ || args.any?
+ @children[$1 || name] = Path.new(@root, *args)
elsif path = @children[name]
path
else
@@ -28,17 +28,15 @@ module Rails
# TODO: Move logic from set_root_path initializer
@path = File.expand_path(path)
@root = self
- @load_once, @eager_load, @all_paths = [], [], []
+ @all_paths = []
end
def load_once
- @load_once.uniq!
- @load_once
+ all_paths.map { |path| path.paths if path.load_once? }.compact.flatten.uniq
end
def eager_load
- @eager_load.uniq!
- @eager_load
+ all_paths.map { |path| path.paths if path.eager_load? }.compact.flatten.uniq
end
def all_paths
@@ -47,7 +45,7 @@ module Rails
end
def load_paths
- all_paths.map { |path| path.paths }.flatten
+ all_paths.map { |path| path.paths if path.load_path? }.compact.flatten.uniq
end
def add_to_load_path
@@ -55,6 +53,14 @@ module Rails
$LOAD_PATH.unshift(path) if File.directory?(path)
end
end
+
+ def push(*)
+ raise "Application root can only have one physical path"
+ end
+
+ alias unshift push
+ alias << push
+ alias concat push
end
class Path
@@ -63,11 +69,18 @@ module Rails
attr_reader :path
attr_accessor :glob
- def initialize(path, root)
+ def initialize(root, *paths)
+ @options = paths.last.is_a?(::Hash) ? paths.pop : {}
@children = {}
@root = root
- @paths = [path].flatten
- @glob = "**/*.rb"
+ @paths = paths.flatten
+ @glob = @options[:glob] || "**/*.rb"
+
+ @load_once = @options[:load_once]
+ @eager_load = @options[:eager_load]
+ @load_path = @options[:load_path] || @eager_load
+
+ @root.all_paths << self
end
def push(path)
@@ -86,7 +99,6 @@ module Rails
def load_once!
@load_once = true
- @root.load_once.push *self.paths
end
def load_once?
@@ -95,8 +107,7 @@ module Rails
def eager_load!
@eager_load = true
- @root.all_paths << self
- @root.eager_load.push *self.paths
+ @load_path = true
end
def eager_load?
@@ -105,7 +116,6 @@ module Rails
def load_path!
@load_path = true
- @root.all_paths << self
end
def load_path?
diff --git a/railties/lib/rails/rack/metal.rb b/railties/lib/rails/rack/metal.rb
index b031be29af..6c0732f732 100644
--- a/railties/lib/rails/rack/metal.rb
+++ b/railties/lib/rails/rack/metal.rb
@@ -11,6 +11,9 @@ module Rails
cattr_accessor :metal_paths
self.metal_paths = ["#{Rails.root}/app/metal"]
cattr_accessor :requested_metals
+
+ cattr_accessor :pass_through_on
+ self.pass_through_on = 404
def self.metals
matcher = /#{Regexp.escape('/app/metal/')}(.*)\.rb\Z/
@@ -36,6 +39,9 @@ module Rails
def initialize(app)
@app = app
+ @pass_through_on = {}
+ [*self.class.pass_through_on].each { |status| @pass_through_on[status] = true }
+
@metals = ActiveSupport::OrderedHash.new
self.class.metals.each { |app| @metals[app] = true }
freeze
@@ -44,7 +50,7 @@ module Rails
def call(env)
@metals.keys.each do |app|
result = app.call(env)
- return result unless result[0].to_i == 404
+ return result unless @pass_through_on.include?(result[0].to_i)
end
@app.call(env)
end
diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb b/railties/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb
index ebc97f8130..aacfbe4a8f 100644
--- a/railties/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb
+++ b/railties/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb
@@ -1,9 +1,7 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!DOCTYPE html>
+<html>
<head>
- <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title><%= controller_class_name %>: <%%= controller.action_name %></title>
<%%= stylesheet_link_tag 'scaffold' %>
</head>
diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb b/railties/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb
index 2e603d5b4a..69beb388db 100644
--- a/railties/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb
+++ b/railties/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb
@@ -5,6 +5,9 @@
<% for attribute in attributes -%>
<th><%= attribute.column.human_name %></th>
<% end -%>
+ <th></th>
+ <th></th>
+ <th></th>
</tr>
<%% @<%= plural_name %>.each do |<%= singular_name %>| %>
diff --git a/railties/lib/vendor/bundler/LICENSE b/railties/lib/vendor/bundler/LICENSE
new file mode 100644
index 0000000000..41decca113
--- /dev/null
+++ b/railties/lib/vendor/bundler/LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2009 Engine Yard
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/Rakefile b/railties/lib/vendor/bundler/Rakefile
new file mode 100644
index 0000000000..fd39fbff77
--- /dev/null
+++ b/railties/lib/vendor/bundler/Rakefile
@@ -0,0 +1,52 @@
+require 'rubygems' unless ENV['NO_RUBYGEMS']
+require 'rake/gempackagetask'
+require 'rubygems/specification'
+require 'date'
+require 'spec/rake/spectask'
+
+spec = Gem::Specification.new do |s|
+ s.name = "bundler"
+ s.version = "0.0.1"
+ s.author = "Your Name"
+ s.email = "Your Email"
+ s.homepage = "http://example.com"
+ s.description = s.summary = "A gem that provides..."
+
+ s.platform = Gem::Platform::RUBY
+ s.has_rdoc = true
+ s.extra_rdoc_files = ["README", "LICENSE"]
+ s.summary = ""
+
+ # Uncomment this to add a dependency
+ # s.add_dependency "foo"
+
+ s.bindir = "bin"
+ s.executables = %w( gem_bundler )
+ s.require_path = 'lib'
+ s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
+end
+
+task :default => :spec
+
+desc "Run specs"
+Spec::Rake::SpecTask.new do |t|
+ t.spec_files = FileList['spec/**/*_spec.rb']
+ t.spec_opts = %w(-fs --color)
+end
+
+
+Rake::GemPackageTask.new(spec) do |pkg|
+ pkg.gem_spec = spec
+end
+
+desc "install the gem locally"
+task :install => [:package] do
+ sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
+end
+
+desc "create a gemspec file"
+task :make_spec do
+ File.open("#{GEM}.gemspec", "w") do |file|
+ file.puts spec.to_ruby
+ end
+end \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/bin/gem_bundler b/railties/lib/vendor/bundler/bin/gem_bundler
new file mode 100755
index 0000000000..7a8771efee
--- /dev/null
+++ b/railties/lib/vendor/bundler/bin/gem_bundler
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+require "optparse"
+require "bundler"
+
+options = {}
+
+parser = OptionParser.new do |op|
+ op.banner = "Usage: gem_bundler [OPTIONS] [PATH]"
+
+ op.on("-m", "--manifest MANIFEST") do |manifest|
+ options[:manifest] = manifest
+ end
+
+ op.on_tail("-h", "--help", "Show this message") do
+ puts op
+ exit
+ end
+end
+parser.parse!
+
+options[:path] = ARGV.shift
+
+unless options[:path]
+ puts parser
+ puts %(
+ [PATH] must be specified
+ )
+ exit
+end
+
+unless options[:manifest] && File.exist?(options[:manifest])
+ puts parser
+ puts %(
+ MANIFEST must be a valid manifest file
+ )
+ exit
+end
+
+
+Bundler.run(options) \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/lib/bundler.rb b/railties/lib/vendor/bundler/lib/bundler.rb
new file mode 100644
index 0000000000..4dcab20da9
--- /dev/null
+++ b/railties/lib/vendor/bundler/lib/bundler.rb
@@ -0,0 +1,24 @@
+require 'logger'
+require 'set'
+# Required elements of rubygems
+require "rubygems/remote_fetcher"
+require "rubygems/installer"
+
+require "bundler/gem_bundle"
+require "bundler/installer"
+require "bundler/finder"
+require "bundler/gem_specification"
+require "bundler/resolver"
+require "bundler/manifest"
+require "bundler/dependency"
+require "bundler/runtime"
+require "bundler/cli"
+
+module Bundler
+ VERSION = "0.5.0"
+
+ def self.run(options = {})
+ manifest = ManifestBuilder.load(options[:path], options[:manifest])
+ manifest.install
+ end
+end \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/lib/bundler/cli.rb b/railties/lib/vendor/bundler/lib/bundler/cli.rb
new file mode 100644
index 0000000000..ed49ef88f0
--- /dev/null
+++ b/railties/lib/vendor/bundler/lib/bundler/cli.rb
@@ -0,0 +1,24 @@
+module Bundler
+ module CLI
+
+ def default_manifest
+ current = Pathname.new(Dir.pwd)
+
+ begin
+ manifest = current.join("Gemfile")
+ return manifest.to_s if File.exist?(manifest)
+ current = current.parent
+ end until current.root?
+ nil
+ end
+
+ module_function :default_manifest
+
+ def default_path
+ Pathname.new(File.dirname(default_manifest)).join("vendor").join("gems").to_s
+ end
+
+ module_function :default_path
+
+ end
+end \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/lib/bundler/dependency.rb b/railties/lib/vendor/bundler/lib/bundler/dependency.rb
new file mode 100644
index 0000000000..739a7a117d
--- /dev/null
+++ b/railties/lib/vendor/bundler/lib/bundler/dependency.rb
@@ -0,0 +1,35 @@
+module Bundler
+ class Dependency
+
+ attr_reader :name, :version, :require_as, :only, :except
+
+ def initialize(name, options = {})
+ options.each do |k, v|
+ options[k.to_s] = v
+ end
+
+ @name = name
+ @version = options["version"] || ">= 0"
+ @require_as = Array(options["require_as"] || name)
+ @only = Array(options["only"]).map {|e| e.to_s } if options["only"]
+ @except = Array(options["except"]).map {|e| e.to_s } if options["except"]
+ end
+
+ def in?(environment)
+ environment = environment.to_s
+
+ return false unless !@only || @only.include?(environment)
+ return false if @except && @except.include?(environment)
+ true
+ end
+
+ def to_s
+ to_gem_dependency.to_s
+ end
+
+ def to_gem_dependency
+ @gem_dep ||= Gem::Dependency.new(name, version)
+ end
+
+ end
+end \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/lib/bundler/finder.rb b/railties/lib/vendor/bundler/lib/bundler/finder.rb
new file mode 100644
index 0000000000..43ff370ae4
--- /dev/null
+++ b/railties/lib/vendor/bundler/lib/bundler/finder.rb
@@ -0,0 +1,42 @@
+module Bundler
+ class Finder
+ def initialize(*sources)
+ @results = {}
+ @index = Hash.new { |h,k| h[k] = {} }
+
+ sources.each { |source| fetch(source) }
+ end
+
+ def resolve(*dependencies)
+ resolved = Resolver.resolve(dependencies, self)
+ resolved && GemBundle.new(resolved.all_specs)
+ end
+
+ def fetch(source)
+ deflated = Gem::RemoteFetcher.fetcher.fetch_path("#{source}/Marshal.4.8.Z")
+ inflated = Gem.inflate deflated
+
+ append(Marshal.load(inflated), source)
+ rescue Gem::RemoteFetcher::FetchError => e
+ raise ArgumentError, "#{source} is not a valid source: #{e.message}"
+ end
+
+ def append(index, source)
+ index.gems.values.each do |spec|
+ next unless Gem::Platform.match(spec.platform)
+ spec.source = source
+ @index[spec.name][spec.version] ||= spec
+ end
+ self
+ end
+
+ def search(dependency)
+ @results[dependency.hash] ||= begin
+ possibilities = @index[dependency.name].values
+ possibilities.select do |spec|
+ dependency =~ spec
+ end.sort_by {|s| s.version }
+ end
+ end
+ end
+end \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/lib/bundler/gem_bundle.rb b/railties/lib/vendor/bundler/lib/bundler/gem_bundle.rb
new file mode 100644
index 0000000000..b749720fd9
--- /dev/null
+++ b/railties/lib/vendor/bundler/lib/bundler/gem_bundle.rb
@@ -0,0 +1,23 @@
+module Bundler
+ class GemBundle < Array
+ def download(directory)
+ FileUtils.mkdir_p(directory)
+
+ current = Dir[File.join(directory, "cache", "*.gem*")]
+
+ each do |spec|
+ cached = File.join(directory, "cache", "#{spec.full_name}.gem")
+
+ unless File.file?(cached)
+ Gem::RemoteFetcher.fetcher.download(spec, spec.source, directory)
+ end
+
+ current.delete(cached)
+ end
+
+ current.each { |file| File.delete(file) }
+
+ self
+ end
+ end
+end \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/lib/bundler/gem_specification.rb b/railties/lib/vendor/bundler/lib/bundler/gem_specification.rb
new file mode 100644
index 0000000000..680b61fd69
--- /dev/null
+++ b/railties/lib/vendor/bundler/lib/bundler/gem_specification.rb
@@ -0,0 +1,10 @@
+module Gem
+ class Specification
+ attribute :source
+
+ def source=(source)
+ @source = source.is_a?(URI) ? source : URI.parse(source)
+ raise ArgumentError, "The source must be an absolute URI" unless @source.absolute?
+ end
+ end
+end \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/lib/bundler/installer.rb b/railties/lib/vendor/bundler/lib/bundler/installer.rb
new file mode 100644
index 0000000000..581d9d3c8e
--- /dev/null
+++ b/railties/lib/vendor/bundler/lib/bundler/installer.rb
@@ -0,0 +1,44 @@
+module Bundler
+ class Installer
+ def initialize(path)
+ if !File.directory?(path)
+ raise ArgumentError, "#{path} is not a directory"
+ elsif !File.directory?(File.join(path, "cache"))
+ raise ArgumentError, "#{path} is not a valid environment (it does not contain a cache directory)"
+ end
+
+ @path = path
+ @gems = Dir[(File.join(path, "cache", "*.gem"))]
+ end
+
+ def install(options = {})
+ bin_dir = options[:bin_dir] ||= File.join(@path, "bin")
+
+ specs = Dir[File.join(@path, "specifications", "*.gemspec")]
+ gems = Dir[File.join(@path, "gems", "*")]
+
+ @gems.each do |gem|
+ name = File.basename(gem).gsub(/\.gem$/, '')
+ installed = specs.any? { |g| File.basename(g) == "#{name}.gemspec" } &&
+ gems.any? { |g| File.basename(g) == name }
+
+ unless installed
+ installer = Gem::Installer.new(gem, :install_dir => @path,
+ :ignore_dependencies => true,
+ :env_shebang => true,
+ :wrappers => true,
+ :bin_dir => bin_dir)
+ installer.install
+ end
+
+ # remove this spec
+ specs.delete_if { |g| File.basename(g) == "#{name}.gemspec"}
+ gems.delete_if { |g| File.basename(g) == name }
+ end
+
+ (specs + gems).each do |path|
+ FileUtils.rm_rf(path)
+ end
+ end
+ end
+end \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/lib/bundler/manifest.rb b/railties/lib/vendor/bundler/lib/bundler/manifest.rb
new file mode 100644
index 0000000000..847a41940d
--- /dev/null
+++ b/railties/lib/vendor/bundler/lib/bundler/manifest.rb
@@ -0,0 +1,130 @@
+require "rubygems/source_index"
+require "pathname"
+
+module Bundler
+ class VersionConflict < StandardError; end
+
+ class Manifest
+ attr_reader :sources, :dependencies, :path
+
+ def initialize(sources, dependencies, path)
+ sources.map! {|s| s.is_a?(URI) ? s : URI.parse(s) }
+ @sources, @dependencies, @path = sources, dependencies, Pathname.new(path)
+ end
+
+ def fetch
+ return if all_gems_installed?
+
+ finder = Finder.new(*sources)
+ unless bundle = finder.resolve(*gem_dependencies)
+ gems = @dependencies.map {|d| " #{d.to_s}" }.join("\n")
+ raise VersionConflict, "No compatible versions could be found for:\n#{gems}"
+ end
+
+ bundle.download(@path)
+ end
+
+ def install(options = {})
+ fetch
+ installer = Installer.new(@path)
+ installer.install # options come here
+ create_load_paths_files(File.join(@path, "environments"))
+ create_fake_rubygems(File.join(@path, "environments"))
+ end
+
+ def activate(environment = "default")
+ require File.join(@path, "environments", "#{environment}.rb")
+ end
+
+ def require_all
+ dependencies.each do |dep|
+ dep.require_as.each {|file| require file }
+ end
+ end
+
+ def gems_for(environment)
+ deps = dependencies.select { |d| d.in?(environment) }
+ deps.map! { |d| d.to_gem_dependency }
+ index = Gem::SourceIndex.from_gems_in(File.join(@path, "specifications"))
+ Resolver.resolve(deps, index).all_specs
+ end
+
+ def environments
+ envs = dependencies.map {|dep| Array(dep.only) + Array(dep.except) }.flatten
+ envs << "default"
+ end
+
+ private
+
+ def gem_dependencies
+ @gem_dependencies ||= dependencies.map { |d| d.to_gem_dependency }
+ end
+
+ def all_gems_installed?
+ gem_versions = {}
+
+ Dir[File.join(@path, "cache", "*.gem")].each do |file|
+ file =~ /\/([^\/]+)-([\d\.]+)\.gem$/
+ name, version = $1, $2
+ gem_versions[name] = Gem::Version.new(version)
+ end
+
+ gem_dependencies.all? do |dep|
+ gem_versions[dep.name] &&
+ dep.version_requirements.satisfied_by?(gem_versions[dep.name])
+ end
+ end
+
+ def create_load_paths_files(path)
+ FileUtils.mkdir_p(path)
+ environments.each do |environment|
+ gem_specs = gems_for(environment)
+ File.open(File.join(path, "#{environment}.rb"), "w") do |file|
+ file.puts <<-RUBY_EVAL
+ module Bundler
+ def self.rubygems_required
+ #{create_gem_stubs(path, gem_specs)}
+ end
+ end
+ RUBY_EVAL
+ file.puts "$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))"
+ load_paths_for_specs(gem_specs).each do |load_path|
+ file.puts "$LOAD_PATH.unshift #{load_path.inspect}"
+ end
+ end
+ end
+ end
+
+ def create_gem_stubs(path, gem_specs)
+ gem_specs.map do |spec|
+ path = File.expand_path(File.join(path, '..', 'specifications', "#{spec.full_name}.gemspec"))
+ %{
+ Gem.loaded_specs["#{spec.name}"] = eval(File.read("#{path}"))
+ }
+ end.join("\n")
+ end
+
+ def create_fake_rubygems(path)
+ File.open(File.join(path, "rubygems.rb"), "w") do |file|
+ file.puts <<-RUBY_EVAL
+ $:.delete File.expand_path(File.dirname(__FILE__))
+ load "rubygems.rb"
+ if defined?(Bundler) && Bundler.respond_to?(:rubygems_required)
+ Bundler.rubygems_required
+ end
+ RUBY_EVAL
+ end
+ end
+
+ def load_paths_for_specs(specs)
+ load_paths = []
+ specs.each do |spec|
+ load_paths << File.join(spec.full_gem_path, spec.bindir) if spec.bindir
+ spec.require_paths.each do |path|
+ load_paths << File.join(spec.full_gem_path, path)
+ end
+ end
+ load_paths
+ end
+ end
+end \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/lib/bundler/resolver.rb b/railties/lib/vendor/bundler/lib/bundler/resolver.rb
new file mode 100644
index 0000000000..1ec89e53c4
--- /dev/null
+++ b/railties/lib/vendor/bundler/lib/bundler/resolver.rb
@@ -0,0 +1,19 @@
+require 'bundler/resolver/inspect'
+require 'bundler/resolver/search'
+require 'bundler/resolver/engine'
+require 'bundler/resolver/stack'
+require 'bundler/resolver/state'
+
+module Bundler
+ module Resolver
+ def self.resolve(deps, source_index = Gem.source_index, logger = nil)
+ unless logger
+ logger = Logger.new($stderr)
+ logger.datetime_format = ""
+ logger.level = ENV["GEM_RESOLVER_DEBUG"] ? Logger::DEBUG : Logger::ERROR
+ end
+
+ Engine.resolve(deps, source_index, logger)
+ end
+ end
+end \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/lib/bundler/resolver/builders.rb b/railties/lib/vendor/bundler/lib/bundler/resolver/builders.rb
new file mode 100644
index 0000000000..2b7b48211c
--- /dev/null
+++ b/railties/lib/vendor/bundler/lib/bundler/resolver/builders.rb
@@ -0,0 +1,61 @@
+module Bundler
+ module Resolver
+ module Builders
+ def build_index(&block)
+ index = Gem::SourceIndex.new
+ IndexBuilder.run(index, &block) if block_given?
+ index
+ end
+
+ def build_spec(name, version, &block)
+ spec = Gem::Specification.new
+ spec.instance_variable_set(:@name, name)
+ spec.instance_variable_set(:@version, Gem::Version.new(version))
+ DepBuilder.run(spec, &block) if block_given?
+ spec
+ end
+
+ def build_dep(name, requirements, type = :runtime)
+ Gem::Dependency.new(name, requirements, type)
+ end
+
+ class IndexBuilder
+ include Builders
+
+ def self.run(index, &block)
+ new(index).run(&block)
+ end
+
+ def initialize(index)
+ @index = index
+ end
+
+ def run(&block)
+ instance_eval(&block)
+ end
+
+ def add_spec(*args, &block)
+ @index.add_spec(build_spec(*args, &block))
+ end
+ end
+
+ class DepBuilder
+ def self.run(spec, &block)
+ new(spec).run(&block)
+ end
+
+ def initialize(spec)
+ @spec = spec
+ end
+
+ def run(&block)
+ instance_eval(&block)
+ end
+
+ def runtime(name, requirements)
+ @spec.add_runtime_dependency(name, requirements)
+ end
+ end
+ end
+ end
+end \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/lib/bundler/resolver/engine.rb b/railties/lib/vendor/bundler/lib/bundler/resolver/engine.rb
new file mode 100644
index 0000000000..475ba516ff
--- /dev/null
+++ b/railties/lib/vendor/bundler/lib/bundler/resolver/engine.rb
@@ -0,0 +1,38 @@
+module Bundler
+ module Resolver
+ class ClosedSet < Set
+ end
+
+ class Engine
+ include Search, Inspect
+
+ def self.resolve(deps, source_index, logger)
+ new(deps, source_index, logger).resolve
+ end
+
+ def initialize(deps, source_index, logger)
+ @deps, @source_index, @logger = deps, source_index, logger
+ logger.debug "searching for #{gem_resolver_inspect(@deps)}"
+ end
+ attr_reader :deps, :source_index, :logger, :solution
+
+ def resolve
+ state = State.initial(self, [], Stack.new, Stack.new([[[], @deps.dup]]))
+ if solution = search(state)
+ logger.info "got the solution with #{solution.all_specs.size} specs"
+ solution.dump(Logger::INFO)
+ solution
+ end
+ end
+
+ def open
+ @open ||= []
+ end
+
+ def closed
+ @closed ||= ClosedSet.new
+ end
+ end
+ end
+
+end \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/lib/bundler/resolver/inspect.rb b/railties/lib/vendor/bundler/lib/bundler/resolver/inspect.rb
new file mode 100644
index 0000000000..59640aa5f3
--- /dev/null
+++ b/railties/lib/vendor/bundler/lib/bundler/resolver/inspect.rb
@@ -0,0 +1,24 @@
+module Bundler
+ module Resolver
+ module Inspect
+ def gem_resolver_inspect(o)
+ case o
+ when Gem::Specification
+ "#<Spec: #{o.full_name}>"
+ when Array
+ '[' + o.map {|x| gem_resolver_inspect(x)}.join(", ") + ']'
+ when Set
+ gem_resolver_inspect(o.to_a)
+ when Hash
+ '{' + o.map {|k,v| "#{gem_resolver_inspect(k)} => #{gem_resolver_inspect(v)}"}.join(", ") + '}'
+ when Stack
+ o.gem_resolver_inspect
+ else
+ o.inspect
+ end
+ end
+
+ module_function :gem_resolver_inspect
+ end
+ end
+end \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/lib/bundler/resolver/search.rb b/railties/lib/vendor/bundler/lib/bundler/resolver/search.rb
new file mode 100644
index 0000000000..34102ff04c
--- /dev/null
+++ b/railties/lib/vendor/bundler/lib/bundler/resolver/search.rb
@@ -0,0 +1,71 @@
+module Bundler
+ module Resolver
+ module Search
+ def search(initial, max_depth = (1.0 / 0.0))
+ if initial.goal_met?
+ return initial
+ end
+
+ open << initial
+
+ while open.any?
+ current = open.pop
+ closed << current
+
+ new = []
+ current.each_possibility do |attempt|
+ unless closed.include?(attempt)
+ if attempt.goal_met?
+ return attempt
+ elsif attempt.depth < max_depth
+ new << attempt
+ end
+ end
+ end
+ new.reverse.each do |state|
+ open << state
+ end
+ end
+
+ nil
+ end
+
+ def open
+ raise "implement #open in #{self.class}"
+ end
+
+ def closed
+ raise "implement #closed in #{self.class}"
+ end
+
+ module Node
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+
+ module ClassMethods
+ def initial(*data)
+ new(0, *data)
+ end
+ end
+
+ def initialize(depth)
+ @depth = depth
+ end
+ attr_reader :depth
+
+ def child(*data)
+ self.class.new(@depth + 1, *data)
+ end
+
+ def each_possibility
+ raise "implement #each_possibility on #{self.class}"
+ end
+
+ def goal_met?
+ raise "implement #goal_met? on #{self.class}"
+ end
+ end
+ end
+ end
+end \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/lib/bundler/resolver/stack.rb b/railties/lib/vendor/bundler/lib/bundler/resolver/stack.rb
new file mode 100644
index 0000000000..6e1ac67e1f
--- /dev/null
+++ b/railties/lib/vendor/bundler/lib/bundler/resolver/stack.rb
@@ -0,0 +1,72 @@
+module Bundler
+ module Resolver
+ class Stack
+ def initialize(initial = [])
+ @data = []
+ initial.each do |(path,value)|
+ self[path] = value
+ end
+ end
+
+ def last
+ @data.last
+ end
+
+ def []=(path, value)
+ raise ArgumentError, "#{path.inspect} already has a value" if key?(path)
+ @data << [path.dup, value]
+ end
+
+ def [](path)
+ if key?(path)
+ _, value = @data.find do |(k,v)|
+ k == path
+ end
+ value
+ else
+ raise "No value for #{path.inspect}"
+ end
+ end
+
+ def key?(path)
+ @data.any? do |(k,v)|
+ k == path
+ end
+ end
+
+ def each
+ @data.each do |(k,v)|
+ yield k, v
+ end
+ end
+
+ def map
+ @data.map do |(k,v)|
+ yield k, v
+ end
+ end
+
+ def each_value
+ @data.each do |(k,v)|
+ yield v
+ end
+ end
+
+ def dup
+ self.class.new(@data.dup)
+ end
+
+ def to_s
+ @data.to_s
+ end
+
+ def inspect
+ @data.inspect
+ end
+
+ def gem_resolver_inspect
+ Inspect.gem_resolver_inspect(@data)
+ end
+ end
+ end
+end \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/lib/bundler/resolver/state.rb b/railties/lib/vendor/bundler/lib/bundler/resolver/state.rb
new file mode 100644
index 0000000000..f13ecbbee7
--- /dev/null
+++ b/railties/lib/vendor/bundler/lib/bundler/resolver/state.rb
@@ -0,0 +1,172 @@
+module Bundler
+ module Resolver
+ class State
+ include Search::Node, Inspect
+
+ def initialize(depth, engine, path, spec_stack, dep_stack)
+ super(depth)
+ @engine, @path, @spec_stack, @dep_stack = engine, path, spec_stack, dep_stack
+ end
+ attr_reader :path
+
+ def logger
+ @engine.logger
+ end
+
+ def goal_met?
+ logger.info "checking if goal is met"
+ dump
+ no_duplicates?
+ all_deps.all? do |dep|
+ dependency_satisfied?(dep)
+ end
+ end
+
+ def no_duplicates?
+ names = []
+ all_specs.each do |s|
+ if names.include?(s.name)
+ raise "somehow got duplicates for #{s.name}"
+ end
+ names << s.name
+ end
+ end
+
+ def dependency_satisfied?(dep)
+ all_specs.any? do |spec|
+ spec.satisfies_requirement?(dep)
+ end
+ end
+
+ def each_possibility(&block)
+ index, dep = remaining_deps.first
+ if dep
+ logger.warn "working on #{dep} for #{spec_name}"
+ handle_dep(index, dep, &block)
+ else
+ logger.warn "no dependencies left for #{spec_name}"
+ jump_to_parent(&block)
+ end
+ end
+
+ def handle_dep(index, dep)
+ specs = @engine.source_index.search(dep)
+
+ specs.reverse.each do |s|
+ logger.info "attempting with spec: #{s.full_name}"
+ new_path = @path + [index]
+ new_spec_stack = @spec_stack.dup
+ new_dep_stack = @dep_stack.dup
+
+ new_spec_stack[new_path] = s
+ new_dep_stack[new_path] = s.runtime_dependencies.sort_by do |dep|
+ @engine.source_index.search(dep).size
+ end
+ yield child(@engine, new_path, new_spec_stack, new_dep_stack)
+ end
+ end
+
+ def jump_to_parent
+ if @path.empty?
+ dump
+ logger.warn "at the end"
+ return
+ end
+
+ logger.info "jumping to parent for #{spec_name}"
+ new_path = @path[0..-2]
+ new_spec_stack = @spec_stack.dup
+ new_dep_stack = @dep_stack.dup
+
+ yield child(@engine, new_path, new_spec_stack, new_dep_stack)
+ end
+
+ def remaining_deps
+ remaining_deps_for(@path)
+ end
+
+ def remaining_deps_for(path)
+ no_duplicates?
+ remaining = []
+ @dep_stack[path].each_with_index do |dep,i|
+ remaining << [i, dep] unless all_specs.find {|s| s.name == dep.name}
+ end
+ remaining
+ end
+
+ def deps
+ @dep_stack[@path]
+ end
+
+ def spec
+ @spec_stack[@path]
+ end
+
+ def spec_name
+ @path.empty? ? "<top>" : spec.full_name
+ end
+
+ def all_deps
+ all_deps = Set.new
+ @dep_stack.each_value do |deps|
+ all_deps.merge(deps)
+ end
+ all_deps.to_a
+ end
+
+ def all_specs
+ @spec_stack.map do |path,spec|
+ spec
+ end
+ end
+
+ def dump(level = Logger::DEBUG)
+ logger.add level, "v" * 80
+ logger.add level, "path: #{@path.inspect}"
+ logger.add level, "deps: (#{deps.size})"
+ deps.map do |dep|
+ logger.add level, gem_resolver_inspect(dep)
+ end
+ logger.add level, "remaining_deps: (#{remaining_deps.size})"
+ remaining_deps.each do |dep|
+ logger.add level, gem_resolver_inspect(dep)
+ end
+ logger.add level, "dep_stack: "
+ @dep_stack.each do |path,deps|
+ logger.add level, "#{path.inspect} (#{deps.size})"
+ deps.each do |dep|
+ logger.add level, "-> #{gem_resolver_inspect(dep)}"
+ end
+ end
+ logger.add level, "spec_stack: "
+ @spec_stack.each do |path,spec|
+ logger.add level, "#{path.inspect}: #{gem_resolver_inspect(spec)}"
+ end
+ logger.add level, "^" * 80
+ end
+
+ def to_dot
+ io = StringIO.new
+ io.puts 'digraph deps {'
+ io.puts ' fontname = "Courier";'
+ io.puts ' mincross = 4.0;'
+ io.puts ' ratio = "auto";'
+ dump_to_dot(io, "<top>", [])
+ io.puts '}'
+ io.string
+ end
+
+ def dump_to_dot(io, name, path)
+ @dep_stack[path].each_with_index do |dep,i|
+ new_path = path + [i]
+ spec_name = all_specs.find {|x| x.name == dep.name}.full_name
+ io.puts ' "%s" -> "%s";' % [name, dep.to_s]
+ io.puts ' "%s" -> "%s";' % [dep.to_s, spec_name]
+ if @spec_stack.key?(new_path)
+ dump_to_dot(io, spec_name, new_path)
+ end
+ end
+ end
+ end
+ end
+end \ No newline at end of file
diff --git a/railties/lib/vendor/bundler/lib/bundler/runtime.rb b/railties/lib/vendor/bundler/lib/bundler/runtime.rb
new file mode 100644
index 0000000000..2376deef28
--- /dev/null
+++ b/railties/lib/vendor/bundler/lib/bundler/runtime.rb
@@ -0,0 +1,39 @@
+module Bundler
+ class ManifestBuilder
+
+ attr_reader :sources
+
+ def self.build(path, string)
+ builder = new(path)
+ builder.instance_eval(string)
+ builder.to_manifest
+ end
+
+ def self.load(path, file)
+ string = File.read(file)
+ build(path, string)
+ end
+
+ def initialize(path)
+ @path = path
+ @sources = %w(http://gems.rubyforge.org)
+ @dependencies = []
+ end
+
+ def to_manifest
+ Manifest.new(@sources, @dependencies, @path)
+ end
+
+ def source(source)
+ @sources << source
+ end
+
+ def gem(name, *args)
+ options = args.last.is_a?(Hash) ? args.pop : {}
+ version = args.last
+
+ @dependencies << Dependency.new(name, options.merge(:version => version))
+ end
+
+ end
+end \ No newline at end of file
diff --git a/railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb b/railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb
index 2d373ce422..4ca4ddd447 100644
--- a/railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb
+++ b/railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb
@@ -1,5 +1,5 @@
-class MetalA < Rails::Rack::Metal
+class MetalA
def self.call(env)
- [200, { "Content-Type" => "text/html"}, ["Hi"]]
+ [404, { "Content-Type" => "text/html"}, ["Metal A"]]
end
end
diff --git a/railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb b/railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb
index a8bbf3fd60..80e69fe0b0 100644
--- a/railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb
+++ b/railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb
@@ -1,5 +1,5 @@
-class MetalB < Rails::Rack::Metal
+class MetalB
def self.call(env)
- [200, { "Content-Type" => "text/html"}, ["Hi"]]
+ [200, { "Content-Type" => "text/html"}, ["Metal B"]]
end
end
diff --git a/railties/test/initializer/check_ruby_version_test.rb b/railties/test/initializer/check_ruby_version_test.rb
index 33de653906..68feba058e 100644
--- a/railties/test/initializer/check_ruby_version_test.rb
+++ b/railties/test/initializer/check_ruby_version_test.rb
@@ -1,7 +1,7 @@
require "initializer/test_helper"
module InitializerTests
- class PathsTest < ActiveSupport::TestCase
+ class PathsTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
test "rails does not initialize with ruby version 1.8.1" do
diff --git a/railties/test/initializer/install_gem_spec_stubs_test.rb b/railties/test/initializer/install_gem_spec_stubs_test.rb
index 2e94c9968f..cfb12d7405 100644
--- a/railties/test/initializer/install_gem_spec_stubs_test.rb
+++ b/railties/test/initializer/install_gem_spec_stubs_test.rb
@@ -1,7 +1,7 @@
require "initializer/test_helper"
module InitializerTests
- class GemSpecStubsTest < ActiveSupport::TestCase
+ class GemSpecStubsTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
def setup
@@ -34,19 +34,20 @@ module InitializerTests
assert $rubygems_required
end
- test "does not fail if rubygems does not exist" do
- Kernel.module_eval do
- alias old_require require
- def require(name)
- raise LoadError if name == "rubygems"
- old_require(name)
- end
- end
-
- assert_nothing_raised do
- Rails::Initializer.run { |c| c.frameworks = [] }
- end
- end
+ # Pending until we're further along
+ # test "does not fail if rubygems does not exist" do
+ # Kernel.module_eval do
+ # alias old_require require
+ # def require(name)
+ # raise LoadError if name == "rubygems"
+ # old_require(name)
+ # end
+ # end
+ #
+ # assert_nothing_raised do
+ # Rails::Initializer.run { |c| c.frameworks = [] }
+ # end
+ # end
test "adds fake Rubygems stubs if a framework is not loaded in Rubygems and we've vendored" do
Rails.vendor_rails = true
diff --git a/railties/test/initializer/path_test.rb b/railties/test/initializer/path_test.rb
index 26f796f93d..1b73cdc73e 100644
--- a/railties/test/initializer/path_test.rb
+++ b/railties/test/initializer/path_test.rb
@@ -1,6 +1,6 @@
require "initializer/test_helper"
-class PathsTest < ActiveSupport::TestCase
+class PathsTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
def self.setup
diff --git a/railties/test/initializer/test_helper.rb b/railties/test/initializer/test_helper.rb
index ddb03397ab..9d7dfff1c0 100644
--- a/railties/test/initializer/test_helper.rb
+++ b/railties/test/initializer/test_helper.rb
@@ -1,17 +1,18 @@
-require 'abstract_unit'
-require 'active_support/ruby/shim'
-require 'initializer'
+# This is a test helper file that simulates a rails application being
+# boot from scratch in vendored mode. This file should really only be
+# required in test cases that use the isolation helper so that requires
+# can be reset correctly.
+RAILS_ROOT = File.join(File.dirname(__FILE__), "root")
+RAILS_FRAMEWORK_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..'))
-RAILS_ROOT.replace File.join(File.dirname(__FILE__), "root")
+require "test/unit"
+# We are purposely avoiding adding things to the load path to catch bugs that only happen in the genuine article
+require File.join(RAILS_FRAMEWORK_ROOT, 'activesupport', 'lib', 'active_support', 'testing', 'isolation')
+require File.join(RAILS_FRAMEWORK_ROOT, 'activesupport', 'lib', 'active_support', 'testing', 'declarative')
-module Rails
- class << self
- attr_accessor :vendor_rails
- def vendor_rails?() @vendor_rails end
- end
-end
+class Test::Unit::TestCase
+ extend ActiveSupport::Testing::Declarative
-class ActiveSupport::TestCase
def assert_stderr(match)
$stderr = StringIO.new
yield
@@ -21,4 +22,27 @@ class ActiveSupport::TestCase
ensure
$stderr = STDERR
end
-end \ No newline at end of file
+end
+
+# Fake boot.rb
+module Rails
+ class << self
+ attr_accessor :vendor_rails
+
+ def vendor_rails?
+ @vendor_rails
+ end
+
+ def boot!
+ # Require the initializer
+ require File.join(RAILS_FRAMEWORK_ROOT, 'railties', 'lib', 'initializer')
+ # Run the initializer the same way boot.rb does it
+ Rails::Initializer.run(:install_gem_spec_stubs)
+ Rails::GemDependency.add_frozen_gem_path
+ Rails::Initializer.run(:set_load_path)
+ end
+ end
+end
+
+# All that for this:
+Rails.boot! \ No newline at end of file
diff --git a/railties/test/metal_test.rb b/railties/test/metal_test.rb
index d3d231132b..c79a819a76 100644
--- a/railties/test/metal_test.rb
+++ b/railties/test/metal_test.rb
@@ -55,8 +55,38 @@ class MetalTest < Test::Unit::TestCase
assert_equal(["FooMetal", "EngineMetal"], found_metals_as_string_array)
end
end
+
+ def test_metal_default_pass_through_on_404
+ use_appdir("multiplemetals") do
+ result = Rails::Rack::Metal.new(app).call({})
+ assert_equal 200, result.first
+ assert_equal ["Metal B"], result.last
+ end
+ end
+
+ def test_metal_pass_through_on_417
+ use_appdir("multiplemetals") do
+ Rails::Rack::Metal.pass_through_on = 417
+ result = Rails::Rack::Metal.new(app).call({})
+ assert_equal 404, result.first
+ assert_equal ["Metal A"], result.last
+ end
+ end
+
+ def test_metal_pass_through_on_404_and_200
+ use_appdir("multiplemetals") do
+ Rails::Rack::Metal.pass_through_on = [404, 200]
+ result = Rails::Rack::Metal.new(app).call({})
+ assert_equal 402, result.first
+ assert_equal ["End of the Line"], result.last
+ end
+ end
private
+
+ def app
+ lambda{[402,{},["End of the Line"]]}
+ end
def use_appdir(root)
dir = "#{File.dirname(__FILE__)}/fixtures/metal/#{root}"
diff --git a/railties/test/paths_test.rb b/railties/test/paths_test.rb
index fa2f6ceee2..d50882110f 100644
--- a/railties/test/paths_test.rb
+++ b/railties/test/paths_test.rb
@@ -17,17 +17,37 @@ class PathsTest < ActiveSupport::TestCase
assert_equal ["/foo/bar"], @root.app.to_a
end
+ test "creating a root level path without assignment" do
+ @root.app "/foo/bar"
+ assert_equal ["/foo/bar"], @root.app.to_a
+ end
+
+ test "trying to access a path that does not exist raises NoMethodError" do
+ assert_raises(NoMethodError) { @root.app }
+ end
+
test "relative paths are relative to the paths root" do
@root.app = "app"
assert_equal ["/foo/bar/app"], @root.app.to_a
end
+ test "relative paths are relative to the paths root without assignment" do
+ @root.app "app"
+ assert_equal ["/foo/bar/app"], @root.app.to_a
+ end
+
test "creating a child level path" do
@root.app = "/foo/bar"
@root.app.models = "/foo/bar/baz"
assert_equal ["/foo/bar/baz"], @root.app.models.to_a
end
+ test "creating a child level path without assignment" do
+ @root.app = "/foo/bar"
+ @root.app.models "/foo/bar/baz"
+ assert_equal ["/foo/bar/baz"], @root.app.models.to_a
+ end
+
test "child level paths are relative from the root" do
@root.app = "/app"
@root.app.models = "baz"
@@ -40,6 +60,11 @@ class PathsTest < ActiveSupport::TestCase
assert_equal ["/app", "/app2"], @root.app.to_a
end
+ test "adding multiple physical paths as an array without assignment" do
+ @root.app "/app", "/app2"
+ assert_equal ["/app", "/app2"], @root.app.to_a
+ end
+
test "adding multiple physical paths using #push" do
@root.app = "/app"
@root.app.push "/app2"
@@ -66,10 +91,10 @@ class PathsTest < ActiveSupport::TestCase
test "the root can only have one physical path" do
assert_raise(RuntimeError) { Rails::Application::Root.new(["/fiz", "/biz"]) }
- assert_raise(NoMethodError) { @root.push "/biz" }
- assert_raise(NoMethodError) { @root.unshift "/biz" }
- assert_raise(NoMethodError) { @root.concat ["/biz"]}
- assert_raise(NoMethodError) { @root << "/biz" }
+ assert_raise(RuntimeError) { @root.push "/biz" }
+ assert_raise(RuntimeError) { @root.unshift "/biz" }
+ assert_raise(RuntimeError) { @root.concat ["/biz"]}
+ assert_raise(RuntimeError) { @root << "/biz" }
end
test "it is possible to add a path that should be loaded only once" do
@@ -79,6 +104,19 @@ class PathsTest < ActiveSupport::TestCase
assert @root.load_once.include?(@root.app.paths.first)
end
+ test "it is possible to add a path without assignment and specify it should be loaded only once" do
+ @root.app "/app", :load_once => true
+ assert @root.app.load_once?
+ assert @root.load_once.include?("/app")
+ end
+
+ test "it is possible to add multiple paths without assignment and specify it should be loaded only once" do
+ @root.app "/app", "/app2", :load_once => true
+ assert @root.app.load_once?
+ assert @root.load_once.include?("/app")
+ assert @root.load_once.include?("/app2")
+ end
+
test "making a path load_once more than once only includes it once in @root.load_once" do
@root.app = "/app"
@root.app.load_once!
@@ -86,6 +124,13 @@ class PathsTest < ActiveSupport::TestCase
assert_equal 1, @root.load_once.select {|p| p == @root.app.paths.first }.size
end
+ test "paths added to a load_once path should be added to the load_once collection" do
+ @root.app = "/app"
+ @root.app.load_once!
+ @root.app << "/app2"
+ assert_equal 2, @root.load_once.size
+ end
+
test "it is possible to mark a path as eager" do
@root.app = "/app"
@root.app.eager_load!
@@ -93,6 +138,27 @@ class PathsTest < ActiveSupport::TestCase
assert @root.eager_load.include?(@root.app.paths.first)
end
+ test "it is possible to add a path without assignment and mark it as eager" do
+ @root.app "/app", :eager_load => true
+ assert @root.app.eager_load?
+ assert @root.eager_load.include?("/app")
+ end
+
+ test "it is possible to add multiple paths without assignment and mark them as eager" do
+ @root.app "/app", "/app2", :eager_load => true
+ assert @root.app.eager_load?
+ assert @root.eager_load.include?("/app")
+ assert @root.eager_load.include?("/app2")
+ end
+
+ test "it is possible to create a path without assignment and mark it both as eager and load once" do
+ @root.app "/app", :eager_load => true, :load_once => true
+ assert @root.app.eager_load?
+ assert @root.app.load_once?
+ assert @root.eager_load.include?("/app")
+ assert @root.load_once.include?("/app")
+ end
+
test "making a path eager more than once only includes it once in @root.eager_paths" do
@root.app = "/app"
@root.app.eager_load!
@@ -100,6 +166,13 @@ class PathsTest < ActiveSupport::TestCase
assert_equal 1, @root.eager_load.select {|p| p == @root.app.paths.first }.size
end
+ test "paths added to a eager_load path should be added to the eager_load collection" do
+ @root.app = "/app"
+ @root.app.eager_load!
+ @root.app << "/app2"
+ assert_equal 2, @root.eager_load.size
+ end
+
test "a path should have a glob that defaults to **/*.rb" do
@root.app = "/app"
assert_equal "**/*.rb", @root.app.glob
@@ -111,6 +184,11 @@ class PathsTest < ActiveSupport::TestCase
assert_equal "*.rb", @root.app.glob
end
+ test "it should be possible to override a path's default glob without assignment" do
+ @root.app "/app", :glob => "*.rb"
+ assert_equal "*.rb", @root.app.glob
+ end
+
test "a path can be added to the load path" do
@root.app = "app"
@root.app.load_path!
@@ -118,6 +196,12 @@ class PathsTest < ActiveSupport::TestCase
assert_equal ["/foo/bar/app"], @root.load_paths
end
+ test "a path can be added to the load path on creation" do
+ @root.app "/app", :load_path => true
+ assert @root.app.load_path?
+ assert_equal ["/app"], @root.load_paths
+ end
+
test "adding a path to the eager paths also adds it to the load path" do
@root.app = "app"
@root.app.eager_load!