Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 86 lines (74 sloc) 2.704 kB
11771c5 @ddollar initial copy from slugc
ddollar authored
1 require "language_pack"
2 require "language_pack/rails2"
3
b6b0971 @hone inital comment pass
hone authored
4 # Rails 3 Language Pack. This is for all Rails 3.x apps.
11771c5 @ddollar initial copy from slugc
ddollar authored
5 class LanguagePack::Rails3 < LanguagePack::Rails2
b6b0971 @hone inital comment pass
hone authored
6 # detects if this is a Rails 3.x app
7 # @return [Boolean] true if it's a Rails 3.x app
11771c5 @ddollar initial copy from slugc
ddollar authored
8 def self.use?
9 super &&
10 File.exists?("config/application.rb") &&
11 File.read("config/application.rb") =~ /Rails::Application/
12 end
13
14 def name
719ee84 @ddollar name packs as language/framework
ddollar authored
15 "Ruby/Rails"
11771c5 @ddollar initial copy from slugc
ddollar authored
16 end
17
18 def default_process_types
b6b0971 @hone inital comment pass
hone authored
19 # let's special case thin here
11771c5 @ddollar initial copy from slugc
ddollar authored
20 web_process = gem_is_bundled?("thin") ?
21 "bundle exec thin start -R config.ru -e $RAILS_ENV -p $PORT" :
22 "bundle exec rails server -p $PORT"
23
24 super.merge({
25 "web" => web_process,
26 "console" => "bundle exec rails console"
27 })
28 end
29
30 private
31
32 def plugins
33 super.concat(%w( rails3_serve_static_assets )).uniq
34 end
35
b6b0971 @hone inital comment pass
hone authored
36 # runs the tasks for the Rails 3.1 asset pipeline
de96ed1 @hone run assets:precompile across the whole ruby lp
hone authored
37 def run_assets_precompile_rake_task
42a6043 @ddollar add basic logging
ddollar authored
38 log("assets_precompile") do
c622da1 @hone setup DATABASE_URL env before detecting rake task since it breaks som…
hone authored
39 setup_database_url_env
40
42a6043 @ddollar add basic logging
ddollar authored
41 if rake_task_defined?("assets:precompile")
42 topic("Preparing app for Rails asset pipeline")
43 if File.exists?("public/assets/manifest.yml")
44 puts "Detected manifest.yml, assuming assets were compiled locally"
45 else
46 ENV["RAILS_GROUPS"] ||= "assets"
47 ENV["RAILS_ENV"] ||= "production"
7bbb5ee @ddollar allow user env to take precedence
ddollar authored
48
42a6043 @ddollar add basic logging
ddollar authored
49 puts "Running: rake assets:precompile"
6a359c4 @hone apply success message to rails3
hone authored
50 require 'benchmark'
51 time = Benchmark.realtime { pipe("env PATH=$PATH:bin bundle exec rake assets:precompile 2>&1") }
5f467e4 @hone Revert "Revert "pick a database_url based on gems""
hone authored
52
b899418 @hone fix assets precompile plugin detection
hone authored
53 if $?.success?
54 log "assets_precompile", :status => "success"
89334e2 @hone format time to 2 floating digits
hone authored
55 puts "Asset precompilation completed (#{"%.2f" % time}s)"
b899418 @hone fix assets precompile plugin detection
hone authored
56 else
c350395 @ddollar consistency and ease of splunking
ddollar authored
57 log "assets_precompile", :status => "failure"
42a6043 @ddollar add basic logging
ddollar authored
58 puts "Precompiling assets failed, enabling runtime asset compilation"
59 install_plugin("rails31_enable_runtime_asset_compilation")
60 puts "Please see this article for troubleshooting help:"
61 puts "http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting"
62 end
0e104d9 @hone setup asset pipeline for rails 3.1.0
hone authored
63 end
bc90eeb @hone execute assets:precompile on rails 3 apps
hone authored
64 end
65 end
66 end
67
27d59ec @knewter Fix typo in comment in rails3 buildpack
knewter authored
68 # setup the database url as an environment variable
efd873f @hone move DATABASE_URL env setup into a method
hone authored
69 def setup_database_url_env
70 ENV["DATABASE_URL"] ||= begin
71 # need to use a dummy DATABASE_URL here, so rails can load the environment
72 scheme =
73 if gem_is_bundled?("pg")
74 "postgres"
75 elsif gem_is_bundled?("mysql")
76 "mysql"
77 elsif gem_is_bundled?("mysql2")
78 "mysql2"
79 elsif gem_is_bundled?("sqlite3") || gem_is_bundled?("sqlite3-ruby")
80 "sqlite3"
81 end
82 "#{scheme}://user:pass@127.0.0.1/dbname"
83 end
84 end
11771c5 @ddollar initial copy from slugc
ddollar authored
85 end
Something went wrong with that request. Please try again.