Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 90 lines (76 sloc) 2.701 kb
11771c5 David Dollar initial copy from slugc
ddollar authored
1 require "language_pack"
2 require "language_pack/rails2"
3
b6b0971 Terence Lee inital comment pass
hone authored
4 # Rails 3 Language Pack. This is for all Rails 3.x apps.
11771c5 David Dollar initial copy from slugc
ddollar authored
5 class LanguagePack::Rails3 < LanguagePack::Rails2
10e58a8 Terence Lee mv node/node-0.4.7 to node-0.4.7
hone authored
6 NODE_JS_BINARY_PATH = 'node-0.4.7/node'
11771c5 David Dollar initial copy from slugc
ddollar authored
7
b6b0971 Terence Lee inital comment pass
hone authored
8 # detects if this is a Rails 3.x app
9 # @return [Boolean] true if it's a Rails 3.x app
11771c5 David Dollar initial copy from slugc
ddollar authored
10 def self.use?
11 super &&
12 File.exists?("config/application.rb") &&
13 File.read("config/application.rb") =~ /Rails::Application/
14 end
15
16 def name
719ee84 David Dollar name packs as language/framework
ddollar authored
17 "Ruby/Rails"
11771c5 David Dollar initial copy from slugc
ddollar authored
18 end
19
20 def default_process_types
b6b0971 Terence Lee inital comment pass
hone authored
21 # let's special case thin here
11771c5 David Dollar initial copy from slugc
ddollar authored
22 web_process = gem_is_bundled?("thin") ?
23 "bundle exec thin start -R config.ru -e $RAILS_ENV -p $PORT" :
24 "bundle exec rails server -p $PORT"
25
26 super.merge({
27 "web" => web_process,
28 "console" => "bundle exec rails console"
29 })
30 end
31
32 def compile
33 super
0e104d9 Terence Lee setup asset pipeline for rails 3.1.0
hone authored
34 allow_git { setup_asset_pipeline }
11771c5 David Dollar initial copy from slugc
ddollar authored
35 end
36
37 private
38
39 def plugins
40 super.concat(%w( rails3_serve_static_assets )).uniq
41 end
42
3da296d Terence Lee Revert "Revert "bundle node into rails 3 slugs :{""
hone authored
43 def binaries
b6b0971 Terence Lee inital comment pass
hone authored
44 # execjs will blow up if no JS RUNTIME is detected and is loaded.
d46635a Terence Lee uninstall node.js if assets:precompile works
hone authored
45 node = gem_is_bundled?('execjs') ? [NODE_JS_BINARY_PATH] : []
5a46865 Terence Lee Revert "Revert "only bundle in node for execjs based apps""
hone authored
46 super + node
3da296d Terence Lee Revert "Revert "bundle node into rails 3 slugs :{""
hone authored
47 end
48
b6b0971 Terence Lee inital comment pass
hone authored
49 # runs the tasks for the Rails 3.1 asset pipeline
0e104d9 Terence Lee setup asset pipeline for rails 3.1.0
hone authored
50 def setup_asset_pipeline
06af685 Terence Lee remove the compile task check since it might not stay around
hone authored
51 if rake_task_defined?("assets:precompile")
fd691b1 Terence Lee change asset pipeline copy
hone authored
52 topic("Preparing app for Rails asset pipeline")
0e104d9 Terence Lee setup asset pipeline for rails 3.1.0
hone authored
53 if File.exists?("public/assets/manifest.yml")
5cfc0b9 Terence Lee asset pipeline copy changes from David Dollar
hone authored
54 puts "Detected manifest.yml, assuming assets were compiled locally"
0e104d9 Terence Lee setup asset pipeline for rails 3.1.0
hone authored
55 else
7bbb5ee David Dollar allow user env to take precedence
ddollar authored
56 ENV["DATABASE_URL"] ||= begin
57 # need to use a dummy DATABASE_URL here, so rails can load the environment
58 scheme =
59 if gem_is_bundled?("pg")
60 "postgres"
61 elsif gem_is_bundled?("mysql")
62 "mysql"
63 elsif gem_is_bundled?("mysql2")
64 "mysql2"
65 elsif gem_is_bundled?("sqlite3") || gem_is_bundled?("sqlite3-ruby")
66 "sqlite3"
67 end
68 "#{scheme}://user:pass@127.0.0.1/dbname"
69 end
70
71 ENV["RAILS_GROUPS"] ||= "assets"
72 ENV["RAILS_ENV"] ||= "production"
5f467e4 Terence Lee Revert "Revert "pick a database_url based on gems""
hone authored
73
5cfc0b9 Terence Lee asset pipeline copy changes from David Dollar
hone authored
74 puts "Running: rake assets:precompile"
75 rake_output = ""
7bbb5ee David Dollar allow user env to take precedence
ddollar authored
76 rake_output << run("env PATH=$PATH:bin bundle exec rake assets:precompile 2>&1")
5cfc0b9 Terence Lee asset pipeline copy changes from David Dollar
hone authored
77 puts rake_output
78 unless $?.success?
79 puts "Precompiling assets failed, enabling runtime asset compilation"
0e104d9 Terence Lee setup asset pipeline for rails 3.1.0
hone authored
80 install_plugin("rails31_enable_runtime_asset_compilation")
0882151 Terence Lee link to docs on assets:precompile fail
hone authored
81 puts "Please see this article for troubleshooting help:"
82 puts "http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting"
0e104d9 Terence Lee setup asset pipeline for rails 3.1.0
hone authored
83 # uninstall_binary(NODE_JS_BINARY_PATH)
84 end
bc90eeb Terence Lee execute assets:precompile on rails 3 apps
hone authored
85 end
86 end
87 end
88
11771c5 David Dollar initial copy from slugc
ddollar authored
89 end
Something went wrong with that request. Please try again.