Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 61 lines (48 sloc) 1.515 kB
11771c5 @ddollar initial copy from slugc
ddollar authored
1 require "language_pack"
2 require "language_pack/rails2"
3
4 class LanguagePack::Rails3 < LanguagePack::Rails2
d46635a @hone uninstall node.js if assets:precompile works
hone authored
5 NODE_JS_BINARY_PATH = 'node/node-0.4.7/node'
11771c5 @ddollar initial copy from slugc
ddollar authored
6
7 def self.use?
8 super &&
9 File.exists?("config/application.rb") &&
10 File.read("config/application.rb") =~ /Rails::Application/
11 end
12
13 def name
719ee84 @ddollar name packs as language/framework
ddollar authored
14 "Ruby/Rails"
11771c5 @ddollar initial copy from slugc
ddollar authored
15 end
16
17 def default_process_types
18 web_process = gem_is_bundled?("thin") ?
19 "bundle exec thin start -R config.ru -e $RAILS_ENV -p $PORT" :
20 "bundle exec rails server -p $PORT"
21
22 super.merge({
23 "web" => web_process,
24 "console" => "bundle exec rails console"
25 })
26 end
27
28 def compile
29 super
bc90eeb @hone execute assets:precompile on rails 3 apps
hone authored
30 run_assets_precompile_task
11771c5 @ddollar initial copy from slugc
ddollar authored
31 end
32
33 private
34
35 def plugins
36 super.concat(%w( rails3_serve_static_assets )).uniq
37 end
38
3da296d @hone Revert "Revert "bundle node into rails 3 slugs :{""
hone authored
39 def binaries
d46635a @hone uninstall node.js if assets:precompile works
hone authored
40 node = gem_is_bundled?('execjs') ? [NODE_JS_BINARY_PATH] : []
5a46865 @hone Revert "Revert "only bundle in node for execjs based apps""
hone authored
41 super + node
3da296d @hone Revert "Revert "bundle node into rails 3 slugs :{""
hone authored
42 end
43
bc90eeb @hone execute assets:precompile on rails 3 apps
hone authored
44 def run_assets_precompile_task
06af685 @hone remove the compile task check since it might not stay around
hone authored
45 if rake_task_defined?("assets:precompile")
bc90eeb @hone execute assets:precompile on rails 3 apps
hone authored
46 topic("Running assets:precompile task")
2dac248 @hone rails needs this to set the cache store to file
hone authored
47 run("mkdir -p tmp/cache")
abf735a @hone use dummy database_url for assets:precompile
hone authored
48 # need to use a dummy DATABASE_URL here, so rails can load the environment
3da296d @hone Revert "Revert "bundle node into rails 3 slugs :{""
hone authored
49 pipe("env RAILS_ENV=production DATABASE_URL=postgres://user:pass@127.0.0.1/dbname PATH=$PATH:bin bundle exec rake assets:precompile 2>&1")
d46635a @hone uninstall node.js if assets:precompile works
hone authored
50 if $?.success?
51 uninstall_binary(NODE_JS_BINARY_PATH)
52 else
af665ab @hone don't fail if the assets:precompile task works
hone authored
53 puts "assets:precompile task failed"
d46635a @hone uninstall node.js if assets:precompile works
hone authored
54 puts "installing node.js binary to compile assets at bootup"
bc90eeb @hone execute assets:precompile on rails 3 apps
hone authored
55 end
56 end
57 end
58
11771c5 @ddollar initial copy from slugc
ddollar authored
59 end
60
Something went wrong with that request. Please try again.