Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 82 lines (70 sloc) 2.608 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
39 if rake_task_defined?("assets:precompile")
40 topic("Preparing app for Rails asset pipeline")
41 if File.exists?("public/assets/manifest.yml")
42 puts "Detected manifest.yml, assuming assets were compiled locally"
43 else
44 ENV["DATABASE_URL"] ||= begin
45 # need to use a dummy DATABASE_URL here, so rails can load the environment
46 scheme =
47 if gem_is_bundled?("pg")
48 "postgres"
49 elsif gem_is_bundled?("mysql")
50 "mysql"
51 elsif gem_is_bundled?("mysql2")
52 "mysql2"
53 elsif gem_is_bundled?("sqlite3") || gem_is_bundled?("sqlite3-ruby")
54 "sqlite3"
55 end
56 "#{scheme}://user:pass@127.0.0.1/dbname"
57 end
58
59 ENV["RAILS_GROUPS"] ||= "assets"
60 ENV["RAILS_ENV"] ||= "production"
7bbb5ee @ddollar allow user env to take precedence
ddollar authored
61
42a6043 @ddollar add basic logging
ddollar authored
62 puts "Running: rake assets:precompile"
63 rake_output = ""
64 rake_output << run("env PATH=$PATH:bin bundle exec rake assets:precompile 2>&1")
65 puts rake_output
5f467e4 @hone Revert "Revert "pick a database_url based on gems""
hone authored
66
b899418 @hone fix assets precompile plugin detection
hone authored
67 if $?.success?
68 log "assets_precompile", :status => "success"
69 else
c350395 @ddollar consistency and ease of splunking
ddollar authored
70 log "assets_precompile", :status => "failure"
42a6043 @ddollar add basic logging
ddollar authored
71 puts "Precompiling assets failed, enabling runtime asset compilation"
72 install_plugin("rails31_enable_runtime_asset_compilation")
73 puts "Please see this article for troubleshooting help:"
74 puts "http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting"
75 end
0e104d9 @hone setup asset pipeline for rails 3.1.0
hone authored
76 end
bc90eeb @hone execute assets:precompile on rails 3 apps
hone authored
77 end
78 end
79 end
80
11771c5 @ddollar initial copy from slugc
ddollar authored
81 end
Something went wrong with that request. Please try again.