Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #31 from ddollar/profiled

set up .profile.d/ruby.sh
  • Loading branch information...
commit 4fabf5c04cdbc0bc902bb6699a7e99341cb84290 2 parents 839e7a2 + fbb10ee
@hone hone authored
View
15 lib/language_pack/base.rb
@@ -96,6 +96,21 @@ def log(*args)
def setup_language_pack_environment
end
+ def add_to_profiled(string)
+ FileUtils.mkdir_p "#{build_path}/.profile.d"
+ File.open("#{build_path}/.profile.d/ruby.sh", "a") do |file|
+ file.puts string
+ end
+ end
+
+ def set_env_default(key, val)
+ add_to_profiled "export #{key}=${#{key}:-#{val}}"
+ end
+
+ def set_env_override(key, val)
+ add_to_profiled %{export #{key}="#{val.gsub('"','\"')}"}
+ end
+
def log_internal(*args)
message = build_log_message(args)
%x{ logger -p user.notice -t "slugc[$$]" "buildpack-ruby #{message}" }
View
8 lib/language_pack/rack.rb
@@ -31,5 +31,13 @@ def default_process_types
})
end
+private
+
+ # sets up the profile.d script for this buildpack
+ def setup_profiled
+ super
+ set_env_default "RACK_ENV", "production"
+ end
+
end
View
9 lib/language_pack/rails2.rb
@@ -71,11 +71,18 @@ def install_plugin(name)
end
end
-
# most rails apps need a database
# @return [Array] shared database addon
def add_shared_database_addon
['shared-database:5mb']
end
+
+ # sets up the profile.d script for this buildpack
+ def setup_profiled
+ super
+ set_env_default "RACK_ENV", "production"
+ set_env_default "RAILS_ENV", "production"
+ end
+
end
View
14 lib/language_pack/ruby.rb
@@ -51,6 +51,7 @@ def compile
install_ruby
install_jvm
setup_language_pack_environment
+ setup_profiled
allow_git do
install_language_pack_gems
build_bundler
@@ -181,6 +182,17 @@ def setup_language_pack_environment
ENV["PATH"] = "#{ruby_install_binstub_path}:#{config_vars["PATH"]}"
end
+ # sets up the profile.d script for this buildpack
+ def setup_profiled
+ set_env_default "GEM_PATH", "$HOME/#{slug_vendor_base}"
+ set_env_default "LANG", "en_US.UTF-8"
+ set_env_override "PATH", "$HOME/bin:$HOME/#{slug_vendor_base}/bin:$PATH"
+
+ if ruby_version_jruby?
+ set_env_default "JAVA_OPTS", default_java_opts
+ end
+ end
+
# determines if a build ruby is required
# @return [Boolean] true if a build ruby is required
def build_ruby?
@@ -270,7 +282,7 @@ def setup_ruby_install_env
end
# list of default gems to vendor into the slug
- # @return [Array] resluting list of gems
+ # @return [Array] resulting list of gems
def gems
[BUNDLER_GEM_PATH]
end
Please sign in to comment.
Something went wrong with that request. Please try again.