File: C:/Ruby27-x64/share/doc/ruby/html/Bundler/Deployment.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>class Bundler::Deployment - RDoc Documentation</title>
<script type="text/javascript">
var rdoc_rel_prefix = "../";
var index_rel_prefix = "../";
</script>
<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>
<link href="../css/fonts.css" rel="stylesheet">
<link href="../css/rdoc.css" rel="stylesheet">
<body id="top" role="document" class="class">
<nav role="navigation">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="../index.html" rel="home">Home</a>
</h2>
<div id="table-of-contents-navigation">
<a href="../table_of_contents.html#pages">Pages</a>
<a href="../table_of_contents.html#classes">Classes</a>
<a href="../table_of_contents.html#methods">Methods</a>
</div>
</div>
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search" spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>
<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>
</div>
<div id="class-metadata">
<div id="parent-class-section" class="nav-section">
<h3>Parent</h3>
<p class="link"><a href="../Object.html">Object</a>
</div>
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
<h3>Methods</h3>
<ul class="link-list" role="directory">
<li ><a href="#method-c-define_task">::define_task</a>
</ul>
</div>
</div>
</nav>
<main role="main" aria-labelledby="class-Bundler::Deployment">
<h1 id="class-Bundler::Deployment" class="class">
class Bundler::Deployment
</h1>
<section class="description">
</section>
<section id="5Buntitled-5D" class="documentation-section">
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
<header>
<h3>Public Class Methods</h3>
</header>
<div id="method-c-define_task" class="method-detail ">
<div class="method-heading">
<span class="method-name">define_task</span><span
class="method-args">(context, task_method = :task, opts = {})</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="define_task-source">
<pre><span class="ruby-comment"># File lib/bundler/deployment.rb, line 10</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">define_task</span>(<span class="ruby-identifier">context</span>, <span class="ruby-identifier">task_method</span> = <span class="ruby-value">:task</span>, <span class="ruby-identifier">opts</span> = {})
<span class="ruby-keyword">if</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-constant">Capistrano</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Capistrano</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>)
<span class="ruby-identifier">context_name</span> = <span class="ruby-string">"capistrano"</span>
<span class="ruby-identifier">role_default</span> = <span class="ruby-string">"{:except => {:no_release => true}}"</span>
<span class="ruby-identifier">error_type</span> = <span class="ruby-operator">::</span><span class="ruby-constant">Capistrano</span><span class="ruby-operator">::</span><span class="ruby-constant">CommandError</span>
<span class="ruby-keyword">else</span>
<span class="ruby-identifier">context_name</span> = <span class="ruby-string">"vlad"</span>
<span class="ruby-identifier">role_default</span> = <span class="ruby-string">"[:app]"</span>
<span class="ruby-identifier">error_type</span> = <span class="ruby-operator">::</span><span class="ruby-constant">Rake</span><span class="ruby-operator">::</span><span class="ruby-constant">CommandFailedError</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">roles</span> = <span class="ruby-identifier">context</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:bundle_roles</span>, <span class="ruby-keyword">false</span>)
<span class="ruby-identifier">opts</span>[<span class="ruby-value">:roles</span>] = <span class="ruby-identifier">roles</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">roles</span>
<span class="ruby-identifier">context</span>.<span class="ruby-identifier">send</span> <span class="ruby-value">:namespace</span>, <span class="ruby-value">:bundle</span> <span class="ruby-keyword">do</span>
<span class="ruby-identifier">send</span> <span class="ruby-value">:desc</span>, <span class="ruby-identifier"><<-DESC</span>
<span class="ruby-value"> Install the current Bundler environment. By default, gems will be \
installed to the shared/bundle path. Gems in the development and \
test group will not be installed. The install command is executed \
with the --deployment and --quiet flags. If the bundle cmd cannot \
be found then you can override the bundle_cmd variable to specify \
which one it should use. The base path to the app is fetched from \
the :latest_release variable. Set it for custom deploy layouts.
You can override any of these defaults by setting the variables shown below.
N.B. bundle_roles must be defined before you require 'bundler/#{context_name}' \
in your deploy.rb file.
set :bundle_gemfile, "Gemfile"
set :bundle_dir, File.join(fetch(:shared_path), 'bundle')
set :bundle_flags, "--deployment --quiet"
set :bundle_without, [:development, :test]
set :bundle_with, [:mysql]
set :bundle_cmd, "bundle" # e.g. "/opt/ruby/bin/bundle"
set :bundle_roles, #{role_default} # e.g. [:app, :batch]
</span><span class="ruby-identifier"> DESC</span>
<span class="ruby-identifier">send</span> <span class="ruby-identifier">task_method</span>, <span class="ruby-value">:install</span>, <span class="ruby-identifier">opts</span> <span class="ruby-keyword">do</span>
<span class="ruby-identifier">bundle_cmd</span> = <span class="ruby-identifier">context</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:bundle_cmd</span>, <span class="ruby-string">"bundle"</span>)
<span class="ruby-identifier">bundle_flags</span> = <span class="ruby-identifier">context</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:bundle_flags</span>, <span class="ruby-string">"--deployment --quiet"</span>)
<span class="ruby-identifier">bundle_dir</span> = <span class="ruby-identifier">context</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:bundle_dir</span>, <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">context</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:shared_path</span>), <span class="ruby-string">"bundle"</span>))
<span class="ruby-identifier">bundle_gemfile</span> = <span class="ruby-identifier">context</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:bundle_gemfile</span>, <span class="ruby-string">"Gemfile"</span>)
<span class="ruby-identifier">bundle_without</span> = [<span class="ruby-operator">*</span><span class="ruby-identifier">context</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:bundle_without</span>, [<span class="ruby-value">:development</span>, <span class="ruby-value">:test</span>])].<span class="ruby-identifier">compact</span>
<span class="ruby-identifier">bundle_with</span> = [<span class="ruby-operator">*</span><span class="ruby-identifier">context</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:bundle_with</span>, [])].<span class="ruby-identifier">compact</span>
<span class="ruby-identifier">app_path</span> = <span class="ruby-identifier">context</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:latest_release</span>)
<span class="ruby-keyword">if</span> <span class="ruby-identifier">app_path</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">empty?</span>
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">error_type</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">"Cannot detect current release path - make sure you have deployed at least once."</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">args</span> = [<span class="ruby-node">"--gemfile #{File.join(app_path, bundle_gemfile)}"</span>]
<span class="ruby-identifier">args</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"--path #{bundle_dir}"</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">bundle_dir</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">empty?</span>
<span class="ruby-identifier">args</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">bundle_flags</span>.<span class="ruby-identifier">to_s</span>
<span class="ruby-identifier">args</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"--without #{bundle_without.join(" ")}"</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">bundle_without</span>.<span class="ruby-identifier">empty?</span>
<span class="ruby-identifier">args</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"--with #{bundle_with.join(" ")}"</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">bundle_with</span>.<span class="ruby-identifier">empty?</span>
<span class="ruby-identifier">run</span> <span class="ruby-node">"cd #{app_path} && #{bundle_cmd} install #{args.join(" ")}"</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
</section>
</section>
</main>
<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.1.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>