1122 lines
46 KiB
HTML
1122 lines
46 KiB
HTML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
|
|
|
<title>Class: Thor::Shell::Basic</title>
|
|
|
|
<link rel="stylesheet" href="../../rdoc.css" type="text/css" media="screen" />
|
|
|
|
<script src="../../js/jquery.js" type="text/javascript"
|
|
charset="utf-8"></script>
|
|
<script src="../../js/thickbox-compressed.js" type="text/javascript"
|
|
charset="utf-8"></script>
|
|
<script src="../../js/quicksearch.js" type="text/javascript"
|
|
charset="utf-8"></script>
|
|
<script src="../../js/darkfish.js" type="text/javascript"
|
|
charset="utf-8"></script>
|
|
|
|
</head>
|
|
<body class="class">
|
|
|
|
<div id="metadata">
|
|
<div id="home-metadata">
|
|
<div id="home-section" class="section">
|
|
<h3 class="section-header">
|
|
<a href="../../index.html">Home</a>
|
|
<a href="../../index.html#classes">Classes</a>
|
|
<a href="../../index.html#methods">Methods</a>
|
|
</h3>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="file-metadata">
|
|
<div id="file-list-section" class="section">
|
|
<h3 class="section-header">In Files</h3>
|
|
<div class="section-body">
|
|
<ul>
|
|
|
|
<li><a href="../../lib/bundler/vendor/thor/shell/basic_rb.html?TB_iframe=true&height=550&width=785"
|
|
class="thickbox" title="lib/bundler/vendor/thor/shell/basic.rb">lib/bundler/vendor/thor/shell/basic.rb</a></li>
|
|
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
<div id="class-metadata">
|
|
|
|
<!-- Parent Class -->
|
|
|
|
<div id="parent-class-section" class="section">
|
|
<h3 class="section-header">Parent</h3>
|
|
|
|
<p class="link">Object</p>
|
|
|
|
</div>
|
|
|
|
|
|
<!-- Namespace Contents -->
|
|
|
|
|
|
<!-- Method Quickref -->
|
|
|
|
<div id="method-list-section" class="section">
|
|
<h3 class="section-header">Methods</h3>
|
|
<ul class="link-list">
|
|
|
|
<li><a href="#method-i-ask">#ask</a></li>
|
|
|
|
<li><a href="#method-i-dynamic_width">#dynamic_width</a></li>
|
|
|
|
<li><a href="#method-i-dynamic_width_stty">#dynamic_width_stty</a></li>
|
|
|
|
<li><a href="#method-i-dynamic_width_tput">#dynamic_width_tput</a></li>
|
|
|
|
<li><a href="#method-i-error">#error</a></li>
|
|
|
|
<li><a href="#method-i-file_collision">#file_collision</a></li>
|
|
|
|
<li><a href="#method-i-no%3F">#no?</a></li>
|
|
|
|
<li><a href="#method-i-padding%3D">#padding=</a></li>
|
|
|
|
<li><a href="#method-i-print_table">#print_table</a></li>
|
|
|
|
<li><a href="#method-i-print_wrapped">#print_wrapped</a></li>
|
|
|
|
<li><a href="#method-i-say">#say</a></li>
|
|
|
|
<li><a href="#method-i-say_status">#say_status</a></li>
|
|
|
|
<li><a href="#method-i-terminal_width">#terminal_width</a></li>
|
|
|
|
<li><a href="#method-i-truncate">#truncate</a></li>
|
|
|
|
<li><a href="#method-i-unix%3F">#unix?</a></li>
|
|
|
|
<li><a href="#method-i-yes%3F">#yes?</a></li>
|
|
|
|
</ul>
|
|
</div>
|
|
|
|
|
|
<!-- Included Modules -->
|
|
|
|
</div>
|
|
|
|
<div id="project-metadata">
|
|
|
|
|
|
<div id="fileindex-section" class="section project-section">
|
|
<h3 class="section-header">Files</h3>
|
|
<ul>
|
|
|
|
<li class="file"><a href="../../lib/bundler/man/bundle.html">bundle</a></li>
|
|
|
|
<li class="file"><a href="../../lib/bundler/man/bundle-config.html">bundle-config</a></li>
|
|
|
|
<li class="file"><a href="../../lib/bundler/man/bundle-config_txt.html">bundle-config.txt</a></li>
|
|
|
|
<li class="file"><a href="../../lib/bundler/man/bundle-exec.html">bundle-exec</a></li>
|
|
|
|
<li class="file"><a href="../../lib/bundler/man/bundle-exec_txt.html">bundle-exec.txt</a></li>
|
|
|
|
<li class="file"><a href="../../lib/bundler/man/bundle-install.html">bundle-install</a></li>
|
|
|
|
<li class="file"><a href="../../lib/bundler/man/bundle-install_txt.html">bundle-install.txt</a></li>
|
|
|
|
<li class="file"><a href="../../lib/bundler/man/bundle-package.html">bundle-package</a></li>
|
|
|
|
<li class="file"><a href="../../lib/bundler/man/bundle-package_txt.html">bundle-package.txt</a></li>
|
|
|
|
<li class="file"><a href="../../lib/bundler/man/bundle-update.html">bundle-update</a></li>
|
|
|
|
<li class="file"><a href="../../lib/bundler/man/bundle-update_txt.html">bundle-update.txt</a></li>
|
|
|
|
<li class="file"><a href="../../lib/bundler/man/bundle_txt.html">bundle.txt</a></li>
|
|
|
|
<li class="file"><a href="../../lib/bundler/man/gemfile_5_txt.html">gemfile.5.txt</a></li>
|
|
|
|
<li class="file"><a href="../../lib/bundler/templates/Gemfile.html">Gemfile</a></li>
|
|
|
|
</ul>
|
|
</div>
|
|
|
|
|
|
<div id="classindex-section" class="section project-section">
|
|
<h3 class="section-header">Class Index
|
|
<span class="search-toggle"><img src="../../images/find.png"
|
|
height="16" width="16" alt="[+]"
|
|
title="show/hide quicksearch" /></span></h3>
|
|
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
|
<fieldset>
|
|
<legend>Quicksearch</legend>
|
|
<input type="text" name="quicksearch" value=""
|
|
class="quicksearch-field" />
|
|
</fieldset>
|
|
</form>
|
|
|
|
<ul class="link-list">
|
|
|
|
<li><a href="../../Bundler.html">Bundler</a></li>
|
|
|
|
<li><a href="../../Bundler/BundlerError.html">Bundler::BundlerError</a></li>
|
|
|
|
<li><a href="../../Bundler/CLI.html">Bundler::CLI</a></li>
|
|
|
|
<li><a href="../../Bundler/Definition.html">Bundler::Definition</a></li>
|
|
|
|
<li><a href="../../Bundler/DepProxy.html">Bundler::DepProxy</a></li>
|
|
|
|
<li><a href="../../Bundler/Dependency.html">Bundler::Dependency</a></li>
|
|
|
|
<li><a href="../../Bundler/DeprecatedError.html">Bundler::DeprecatedError</a></li>
|
|
|
|
<li><a href="../../Bundler/Dsl.html">Bundler::Dsl</a></li>
|
|
|
|
<li><a href="../../Bundler/DslError.html">Bundler::DslError</a></li>
|
|
|
|
<li><a href="../../Bundler/Environment.html">Bundler::Environment</a></li>
|
|
|
|
<li><a href="../../Bundler/GemHelper.html">Bundler::GemHelper</a></li>
|
|
|
|
<li><a href="../../Bundler/GemHelpers.html">Bundler::GemHelpers</a></li>
|
|
|
|
<li><a href="../../Bundler/GemNotFound.html">Bundler::GemNotFound</a></li>
|
|
|
|
<li><a href="../../Bundler/GemfileError.html">Bundler::GemfileError</a></li>
|
|
|
|
<li><a href="../../Bundler/GemfileNotFound.html">Bundler::GemfileNotFound</a></li>
|
|
|
|
<li><a href="../../Bundler/GemspecError.html">Bundler::GemspecError</a></li>
|
|
|
|
<li><a href="../../Bundler/GitError.html">Bundler::GitError</a></li>
|
|
|
|
<li><a href="../../Bundler/Graph.html">Bundler::Graph</a></li>
|
|
|
|
<li><a href="../../Bundler/GraphNode.html">Bundler::GraphNode</a></li>
|
|
|
|
<li><a href="../../Bundler/Index.html">Bundler::Index</a></li>
|
|
|
|
<li><a href="../../Bundler/Installer.html">Bundler::Installer</a></li>
|
|
|
|
<li><a href="../../Bundler/InvalidOption.html">Bundler::InvalidOption</a></li>
|
|
|
|
<li><a href="../../Bundler/InvalidSpecSet.html">Bundler::InvalidSpecSet</a></li>
|
|
|
|
<li><a href="../../Bundler/LazySpecification.html">Bundler::LazySpecification</a></li>
|
|
|
|
<li><a href="../../Bundler/LockfileParser.html">Bundler::LockfileParser</a></li>
|
|
|
|
<li><a href="../../Bundler/MatchPlatform.html">Bundler::MatchPlatform</a></li>
|
|
|
|
<li><a href="../../Bundler/PathError.html">Bundler::PathError</a></li>
|
|
|
|
<li><a href="../../Bundler/ProductionError.html">Bundler::ProductionError</a></li>
|
|
|
|
<li><a href="../../Bundler/RemoteSpecification.html">Bundler::RemoteSpecification</a></li>
|
|
|
|
<li><a href="../../Bundler/Resolver.html">Bundler::Resolver</a></li>
|
|
|
|
<li><a href="../../Bundler/Resolver/SpecGroup.html">Bundler::Resolver::SpecGroup</a></li>
|
|
|
|
<li><a href="../../Bundler/Runtime.html">Bundler::Runtime</a></li>
|
|
|
|
<li><a href="../../Bundler/Settings.html">Bundler::Settings</a></li>
|
|
|
|
<li><a href="../../Bundler/SharedHelpers.html">Bundler::SharedHelpers</a></li>
|
|
|
|
<li><a href="../../Bundler/SharedHelpers/Gem.html">Bundler::SharedHelpers::Gem</a></li>
|
|
|
|
<li><a href="../../Bundler/SharedHelpers/Gem/SourceIndex.html">Bundler::SharedHelpers::Gem::SourceIndex</a></li>
|
|
|
|
<li><a href="../../Bundler/Source.html">Bundler::Source</a></li>
|
|
|
|
<li><a href="../../Bundler/Source/Git.html">Bundler::Source::Git</a></li>
|
|
|
|
<li><a href="../../Bundler/Source/Path.html">Bundler::Source::Path</a></li>
|
|
|
|
<li><a href="../../Bundler/Source/Path/Installer.html">Bundler::Source::Path::Installer</a></li>
|
|
|
|
<li><a href="../../Bundler/Source/Rubygems.html">Bundler::Source::Rubygems</a></li>
|
|
|
|
<li><a href="../../Bundler/SpecSet.html">Bundler::SpecSet</a></li>
|
|
|
|
<li><a href="../../Bundler/UI.html">Bundler::UI</a></li>
|
|
|
|
<li><a href="../../Bundler/UI/RGProxy.html">Bundler::UI::RGProxy</a></li>
|
|
|
|
<li><a href="../../Bundler/UI/Shell.html">Bundler::UI::Shell</a></li>
|
|
|
|
<li><a href="../../Bundler/VersionConflict.html">Bundler::VersionConflict</a></li>
|
|
|
|
<li><a href="../../Thor.html">Thor</a></li>
|
|
|
|
<li><a href="../../Thor/Actions.html">Thor::Actions</a></li>
|
|
|
|
<li><a href="../../Thor/Actions/ClassMethods.html">Thor::Actions::ClassMethods</a></li>
|
|
|
|
<li><a href="../../Thor/Base.html">Thor::Base</a></li>
|
|
|
|
<li><a href="../../Thor/Base/ClassMethods.html">Thor::Base::ClassMethods</a></li>
|
|
|
|
<li><a href="../../Thor/DynamicTask.html">Thor::DynamicTask</a></li>
|
|
|
|
<li><a href="../../Thor/Error.html">Thor::Error</a></li>
|
|
|
|
<li><a href="../../Thor/HiddenTask.html">Thor::HiddenTask</a></li>
|
|
|
|
<li><a href="../../Thor/Invocation.html">Thor::Invocation</a></li>
|
|
|
|
<li><a href="../../Thor/Invocation/ClassMethods.html">Thor::Invocation::ClassMethods</a></li>
|
|
|
|
<li><a href="../../Thor/InvocationError.html">Thor::InvocationError</a></li>
|
|
|
|
<li><a href="../../Thor/MalformattedArgumentError.html">Thor::MalformattedArgumentError</a></li>
|
|
|
|
<li><a href="../../Thor/RequiredArgumentMissingError.html">Thor::RequiredArgumentMissingError</a></li>
|
|
|
|
<li><a href="../../Thor/Shell.html">Thor::Shell</a></li>
|
|
|
|
<li><a href="../../Thor/Shell/Basic.html">Thor::Shell::Basic</a></li>
|
|
|
|
<li><a href="../../Thor/Shell/Color.html">Thor::Shell::Color</a></li>
|
|
|
|
<li><a href="../../Thor/Shell/HTML.html">Thor::Shell::HTML</a></li>
|
|
|
|
<li><a href="../../Thor/Task.html">Thor::Task</a></li>
|
|
|
|
<li><a href="../../Thor/UndefinedTaskError.html">Thor::UndefinedTaskError</a></li>
|
|
|
|
<li><a href="../../Thor/UnknownArgumentError.html">Thor::UnknownArgumentError</a></li>
|
|
|
|
<li><a href="../../Thor/Util.html">Thor::Util</a></li>
|
|
|
|
<li><a href="../../Gem.html">Gem</a></li>
|
|
|
|
<li><a href="../../Gem/Dependency.html">Gem::Dependency</a></li>
|
|
|
|
<li><a href="../../Gem/Platform.html">Gem::Platform</a></li>
|
|
|
|
<li><a href="../../Gem/Specification.html">Gem::Specification</a></li>
|
|
|
|
</ul>
|
|
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="documentation">
|
|
<h1 class="class">Thor::Shell::Basic</h1>
|
|
|
|
<div id="description">
|
|
|
|
</div>
|
|
|
|
<!-- Constants -->
|
|
|
|
|
|
<!-- Attributes -->
|
|
|
|
<div id="attribute-method-details" class="method-section section">
|
|
<h3 class="section-header">Attributes</h3>
|
|
|
|
|
|
<div id="base-attribute-method" class="method-detail">
|
|
<a name="base"></a>
|
|
|
|
<a name="base="></a>
|
|
|
|
<div class="method-heading attribute-method-heading">
|
|
<span class="method-name">base</span><span
|
|
class="attribute-access-type">[RW]</span>
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="padding-attribute-method" class="method-detail">
|
|
<a name="padding"></a>
|
|
|
|
<a name="padding="></a>
|
|
|
|
<div class="method-heading attribute-method-heading">
|
|
<span class="method-name">padding</span><span
|
|
class="attribute-access-type">[RW]</span>
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
<!-- Methods -->
|
|
|
|
<div id="public-instance-method-details" class="method-section section">
|
|
<h3 class="section-header">Public Instance Methods</h3>
|
|
|
|
|
|
<div id="ask-method" class="method-detail ">
|
|
<a name="method-i-ask"></a>
|
|
|
|
<div class="method-heading">
|
|
|
|
<span class="method-name">ask</span><span
|
|
class="method-args">(statement, color=nil)</span>
|
|
<span class="method-click-advice">click to toggle source</span>
|
|
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
<p>
|
|
Ask something to the user and receives a response.
|
|
</p>
|
|
<h4>Example</h4>
|
|
<p>
|
|
ask(“What is your name?”)
|
|
</p>
|
|
|
|
|
|
|
|
<div class="method-source-code"
|
|
id="ask-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/bundler/vendor/thor/shell/basic.rb, line 25</span>
|
|
25: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ask</span>(<span class="ruby-identifier">statement</span>, <span class="ruby-identifier">color</span>=<span class="ruby-keyword kw">nil</span>)
|
|
26: <span class="ruby-identifier">say</span>(<span class="ruby-node">"#{statement} "</span>, <span class="ruby-identifier">color</span>)
|
|
27: <span class="ruby-identifier">$stdin</span>.<span class="ruby-identifier">gets</span>.<span class="ruby-identifier">strip</span>
|
|
28: <span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div id="error-method" class="method-detail ">
|
|
<a name="method-i-error"></a>
|
|
|
|
<div class="method-heading">
|
|
|
|
<span class="method-name">error</span><span
|
|
class="method-args">(statement)</span>
|
|
<span class="method-click-advice">click to toggle source</span>
|
|
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
<p>
|
|
Called if something goes wrong during the execution. This is used by <a
|
|
href="../../Thor.html">Thor</a> internally and should not be used inside
|
|
your scripts. If someone went wrong, you can always raise an exception. If
|
|
you raise a <a href="../Error.html">Thor::Error</a>, it will be rescued and
|
|
wrapped in the method below.
|
|
</p>
|
|
|
|
|
|
|
|
<div class="method-source-code"
|
|
id="error-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/bundler/vendor/thor/shell/basic.rb, line 187</span>
|
|
187: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">error</span>(<span class="ruby-identifier">statement</span>)
|
|
188: <span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">statement</span>
|
|
189: <span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div id="file-collision-method" class="method-detail ">
|
|
<a name="method-i-file_collision"></a>
|
|
|
|
<div class="method-heading">
|
|
|
|
<span class="method-name">file_collision</span><span
|
|
class="method-args">(destination)</span>
|
|
<span class="method-click-advice">click to toggle source</span>
|
|
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
<p>
|
|
Deals with file collision and returns true if the file should be overwriten
|
|
and false otherwise. If a block is given, it uses the block response as the
|
|
content for the diff.
|
|
</p>
|
|
<h4>Parameters</h4>
|
|
<table>
|
|
<tr><td valign="top">destination<String></td><td><p>
|
|
the destination file to solve conflicts
|
|
</p>
|
|
</td></tr>
|
|
<tr><td valign="top">block<Proc></td><td><p>
|
|
an optional block that returns the value to be used in diff
|
|
</p>
|
|
</td></tr>
|
|
</table>
|
|
|
|
|
|
|
|
<div class="method-source-code"
|
|
id="file-collision-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/bundler/vendor/thor/shell/basic.rb, line 156</span>
|
|
156: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">file_collision</span>(<span class="ruby-identifier">destination</span>)
|
|
157: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@always_force</span>
|
|
158: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">block_given?</span> <span class="ruby-operator">?</span> <span class="ruby-value str">"[Ynaqdh]"</span> <span class="ruby-operator">:</span> <span class="ruby-value str">"[Ynaqh]"</span>
|
|
159:
|
|
160: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
|
|
161: <span class="ruby-identifier">answer</span> = <span class="ruby-identifier">ask</span> <span class="ruby-node">%[Overwrite #{destination}? (enter "h" for help) #{options}]</span>
|
|
162:
|
|
163: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">answer</span>
|
|
164: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">is?</span>(<span class="ruby-value">:yes</span>), <span class="ruby-identifier">is?</span>(<span class="ruby-value">:force</span>), <span class="ruby-value str">""</span>
|
|
165: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
|
|
166: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">is?</span>(<span class="ruby-value">:no</span>), <span class="ruby-identifier">is?</span>(<span class="ruby-value">:skip</span>)
|
|
167: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
|
168: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">is?</span>(<span class="ruby-value">:always</span>)
|
|
169: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@always_force</span> = <span class="ruby-keyword kw">true</span>
|
|
170: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">is?</span>(<span class="ruby-value">:quit</span>)
|
|
171: <span class="ruby-identifier">say</span> <span class="ruby-value str">'Aborting...'</span>
|
|
172: <span class="ruby-identifier">raise</span> <span class="ruby-constant">SystemExit</span>
|
|
173: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">is?</span>(<span class="ruby-value">:diff</span>)
|
|
174: <span class="ruby-identifier">show_diff</span>(<span class="ruby-identifier">destination</span>, <span class="ruby-keyword kw">yield</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
|
175: <span class="ruby-identifier">say</span> <span class="ruby-value str">'Retrying...'</span>
|
|
176: <span class="ruby-keyword kw">else</span>
|
|
177: <span class="ruby-identifier">say</span> <span class="ruby-identifier">file_collision_help</span>
|
|
178: <span class="ruby-keyword kw">end</span>
|
|
179: <span class="ruby-keyword kw">end</span>
|
|
180: <span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div id="no--method" class="method-detail ">
|
|
<a name="method-i-no%3F"></a>
|
|
|
|
<div class="method-heading">
|
|
|
|
<span class="method-name">no?</span><span
|
|
class="method-args">(statement, color=nil)</span>
|
|
<span class="method-click-advice">click to toggle source</span>
|
|
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
<p>
|
|
Make a question the to user and returns true if the user replies
|
|
“n” or “no”.
|
|
</p>
|
|
|
|
|
|
|
|
<div class="method-source-code"
|
|
id="no--source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/bundler/vendor/thor/shell/basic.rb, line 78</span>
|
|
78: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">no?</span>(<span class="ruby-identifier">statement</span>, <span class="ruby-identifier">color</span>=<span class="ruby-keyword kw">nil</span>)
|
|
79: <span class="ruby-operator">!</span><span class="ruby-identifier">yes?</span>(<span class="ruby-identifier">statement</span>, <span class="ruby-identifier">color</span>)
|
|
80: <span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div id="padding--method" class="method-detail ">
|
|
<a name="method-i-padding%3D"></a>
|
|
|
|
<div class="method-heading">
|
|
|
|
<span class="method-name">padding=</span><span
|
|
class="method-args">(value)</span>
|
|
<span class="method-click-advice">click to toggle source</span>
|
|
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
<p>
|
|
Sets the output padding, not allowing less than zero values.
|
|
</p>
|
|
|
|
|
|
|
|
<div class="method-source-code"
|
|
id="padding--source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/bundler/vendor/thor/shell/basic.rb, line 16</span>
|
|
16: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">padding=</span>(<span class="ruby-identifier">value</span>)
|
|
17: <span class="ruby-ivar">@padding</span> = [<span class="ruby-value">0</span>, <span class="ruby-identifier">value</span>].<span class="ruby-identifier">max</span>
|
|
18: <span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div id="print-table-method" class="method-detail ">
|
|
<a name="method-i-print_table"></a>
|
|
|
|
<div class="method-heading">
|
|
|
|
<span class="method-name">print_table</span><span
|
|
class="method-args">(table, options={})</span>
|
|
<span class="method-click-advice">click to toggle source</span>
|
|
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
<p>
|
|
Prints a table.
|
|
</p>
|
|
<h4>Parameters</h4>
|
|
<p>
|
|
Array[Array[String, String, …]]
|
|
</p>
|
|
<h4>Options</h4>
|
|
<table>
|
|
<tr><td valign="top">ident<Integer></td><td><p>
|
|
Indent the first column by ident value.
|
|
</p>
|
|
</td></tr>
|
|
<tr><td valign="top">colwidth<Integer></td><td><p>
|
|
Force the first column to colwidth spaces wide.
|
|
</p>
|
|
</td></tr>
|
|
</table>
|
|
|
|
|
|
|
|
<div class="method-source-code"
|
|
id="print-table-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/bundler/vendor/thor/shell/basic.rb, line 91</span>
|
|
91: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">print_table</span>(<span class="ruby-identifier">table</span>, <span class="ruby-identifier">options</span>={})
|
|
92: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">table</span>.<span class="ruby-identifier">empty?</span>
|
|
93:
|
|
94: <span class="ruby-identifier">formats</span>, <span class="ruby-identifier">ident</span>, <span class="ruby-identifier">colwidth</span> = [], <span class="ruby-identifier">options</span>[<span class="ruby-value">:ident</span>].<span class="ruby-identifier">to_i</span>, <span class="ruby-identifier">options</span>[<span class="ruby-value">:colwidth</span>]
|
|
95: <span class="ruby-identifier">options</span>[<span class="ruby-value">:truncate</span>] = <span class="ruby-identifier">terminal_width</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:truncate</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
|
|
96:
|
|
97: <span class="ruby-identifier">formats</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"%-#{colwidth + 2}s"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">colwidth</span>
|
|
98: <span class="ruby-identifier">start</span> = <span class="ruby-identifier">colwidth</span> <span class="ruby-operator">?</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>
|
|
99:
|
|
100: <span class="ruby-identifier">start</span>.<span class="ruby-identifier">upto</span>(<span class="ruby-identifier">table</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-value">2</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
|
|
101: <span class="ruby-identifier">maxima</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">table</span>.<span class="ruby-identifier">max</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">a</span>,<span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>[<span class="ruby-identifier">i</span>].<span class="ruby-identifier">size</span> <span class="ruby-operator"><=></span> <span class="ruby-identifier">b</span>[<span class="ruby-identifier">i</span>].<span class="ruby-identifier">size</span> }[<span class="ruby-identifier">i</span>].<span class="ruby-identifier">size</span>
|
|
102: <span class="ruby-identifier">formats</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"%-#{maxima + 2}s"</span>
|
|
103: <span class="ruby-keyword kw">end</span>
|
|
104:
|
|
105: <span class="ruby-identifier">formats</span>[<span class="ruby-value">0</span>] = <span class="ruby-identifier">formats</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-value str">" "</span> * <span class="ruby-identifier">ident</span>)
|
|
106: <span class="ruby-identifier">formats</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"%s"</span>
|
|
107:
|
|
108: <span class="ruby-identifier">table</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">row</span><span class="ruby-operator">|</span>
|
|
109: <span class="ruby-identifier">sentence</span> = <span class="ruby-value str">""</span>
|
|
110:
|
|
111: <span class="ruby-identifier">row</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">column</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
|
|
112: <span class="ruby-identifier">sentence</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">formats</span>[<span class="ruby-identifier">i</span>] <span class="ruby-operator">%</span> <span class="ruby-identifier">column</span>.<span class="ruby-identifier">to_s</span>
|
|
113: <span class="ruby-keyword kw">end</span>
|
|
114:
|
|
115: <span class="ruby-identifier">sentence</span> = <span class="ruby-identifier">truncate</span>(<span class="ruby-identifier">sentence</span>, <span class="ruby-identifier">options</span>[<span class="ruby-value">:truncate</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:truncate</span>]
|
|
116: <span class="ruby-identifier">$stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">sentence</span>
|
|
117: <span class="ruby-keyword kw">end</span>
|
|
118: <span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div id="print-wrapped-method" class="method-detail ">
|
|
<a name="method-i-print_wrapped"></a>
|
|
|
|
<div class="method-heading">
|
|
|
|
<span class="method-name">print_wrapped</span><span
|
|
class="method-args">(message, options={})</span>
|
|
<span class="method-click-advice">click to toggle source</span>
|
|
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
<p>
|
|
Prints a long string, word-wrapping the text to the current width of the
|
|
terminal display. Ideal for printing heredocs.
|
|
</p>
|
|
<h4>Parameters</h4>
|
|
<p>
|
|
String
|
|
</p>
|
|
<h4>Options</h4>
|
|
<table>
|
|
<tr><td valign="top">ident<Integer></td><td><p>
|
|
Indent each line of the printed paragraph by ident value.
|
|
</p>
|
|
</td></tr>
|
|
</table>
|
|
|
|
|
|
|
|
<div class="method-source-code"
|
|
id="print-wrapped-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/bundler/vendor/thor/shell/basic.rb, line 129</span>
|
|
129: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">print_wrapped</span>(<span class="ruby-identifier">message</span>, <span class="ruby-identifier">options</span>={})
|
|
130: <span class="ruby-identifier">ident</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:ident</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>
|
|
131: <span class="ruby-identifier">width</span> = <span class="ruby-identifier">terminal_width</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">ident</span>
|
|
132: <span class="ruby-identifier">paras</span> = <span class="ruby-identifier">message</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">"\n\n"</span>)
|
|
133:
|
|
134: <span class="ruby-identifier">paras</span>.<span class="ruby-identifier">map!</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">unwrapped</span><span class="ruby-operator">|</span>
|
|
135: <span class="ruby-identifier">unwrapped</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\n/</span>, <span class="ruby-value str">" "</span>).<span class="ruby-identifier">squeeze</span>(<span class="ruby-value str">" "</span>).
|
|
136: <span class="ruby-identifier">gsub</span>(<span class="ruby-node">/.{1,#{width}}(?:\s|\Z)/</span>){(<span class="ruby-node">$&</span> <span class="ruby-operator">+</span> <span class="ruby-value">5</span>.<span class="ruby-identifier">chr</span>).
|
|
137: <span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\n\0005/</span>,<span class="ruby-value str">"\n"</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\0005/</span>,<span class="ruby-value str">"\n"</span>)}
|
|
138: <span class="ruby-keyword kw">end</span>
|
|
139:
|
|
140: <span class="ruby-identifier">paras</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">para</span><span class="ruby-operator">|</span>
|
|
141: <span class="ruby-identifier">para</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">"\n"</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
|
|
142: <span class="ruby-identifier">$stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-value str">" "</span> * <span class="ruby-identifier">ident</span>)
|
|
143: <span class="ruby-keyword kw">end</span>
|
|
144: <span class="ruby-identifier">$stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">para</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">paras</span>.<span class="ruby-identifier">last</span>
|
|
145: <span class="ruby-keyword kw">end</span>
|
|
146: <span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div id="say-method" class="method-detail ">
|
|
<a name="method-i-say"></a>
|
|
|
|
<div class="method-heading">
|
|
|
|
<span class="method-name">say</span><span
|
|
class="method-args">(message="", color=nil, force_new_line=(message.to_s !~ /( |\t)$/))</span>
|
|
<span class="method-click-advice">click to toggle source</span>
|
|
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
<p>
|
|
Say (print) something to the user. If the sentence ends with a whitespace
|
|
or tab character, a new line is not appended (print + flush). Otherwise are
|
|
passed straight to puts (behavior got from Highline).
|
|
</p>
|
|
<h4>Example</h4>
|
|
<p>
|
|
say(“I know you knew that.”)
|
|
</p>
|
|
|
|
|
|
|
|
<div class="method-source-code"
|
|
id="say-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/bundler/vendor/thor/shell/basic.rb, line 37</span>
|
|
37: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">say</span>(<span class="ruby-identifier">message</span>=<span class="ruby-value str">""</span>, <span class="ruby-identifier">color</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">force_new_line</span>=(<span class="ruby-identifier">message</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">!~</span> <span class="ruby-regexp re">/( |\t)$/</span>))
|
|
38: <span class="ruby-identifier">message</span> = <span class="ruby-identifier">message</span>.<span class="ruby-identifier">to_s</span>
|
|
39: <span class="ruby-identifier">message</span> = <span class="ruby-identifier">set_color</span>(<span class="ruby-identifier">message</span>, <span class="ruby-identifier">color</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">color</span>
|
|
40:
|
|
41: <span class="ruby-identifier">spaces</span> = <span class="ruby-value str">" "</span> * <span class="ruby-identifier">padding</span>
|
|
42:
|
|
43: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">force_new_line</span>
|
|
44: <span class="ruby-identifier">$stdout</span>.<span class="ruby-identifier">puts</span>(<span class="ruby-identifier">spaces</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">message</span>)
|
|
45: <span class="ruby-keyword kw">else</span>
|
|
46: <span class="ruby-identifier">$stdout</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">spaces</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">message</span>)
|
|
47: <span class="ruby-keyword kw">end</span>
|
|
48: <span class="ruby-identifier">$stdout</span>.<span class="ruby-identifier">flush</span>
|
|
49: <span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div id="say-status-method" class="method-detail ">
|
|
<a name="method-i-say_status"></a>
|
|
|
|
<div class="method-heading">
|
|
|
|
<span class="method-name">say_status</span><span
|
|
class="method-args">(status, message, log_status=true)</span>
|
|
<span class="method-click-advice">click to toggle source</span>
|
|
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
<p>
|
|
Say a status with the given color and appends the message. Since this
|
|
method is used frequently by actions, it allows nil or false to be given in
|
|
log_status, avoiding the message from being shown. If a Symbol is given in
|
|
log_status, it’s used as the color.
|
|
</p>
|
|
|
|
|
|
|
|
<div class="method-source-code"
|
|
id="say-status-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/bundler/vendor/thor/shell/basic.rb, line 56</span>
|
|
56: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">say_status</span>(<span class="ruby-identifier">status</span>, <span class="ruby-identifier">message</span>, <span class="ruby-identifier">log_status</span>=<span class="ruby-keyword kw">true</span>)
|
|
57: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">quiet?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">log_status</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">false</span>
|
|
58: <span class="ruby-identifier">spaces</span> = <span class="ruby-value str">" "</span> * (<span class="ruby-identifier">padding</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>)
|
|
59: <span class="ruby-identifier">color</span> = <span class="ruby-identifier">log_status</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">log_status</span> <span class="ruby-operator">:</span> <span class="ruby-value">:green</span>
|
|
60:
|
|
61: <span class="ruby-identifier">status</span> = <span class="ruby-identifier">status</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">rjust</span>(<span class="ruby-value">12</span>)
|
|
62: <span class="ruby-identifier">status</span> = <span class="ruby-identifier">set_color</span> <span class="ruby-identifier">status</span>, <span class="ruby-identifier">color</span>, <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">color</span>
|
|
63:
|
|
64: <span class="ruby-identifier">$stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{status}#{spaces}#{message}"</span>
|
|
65: <span class="ruby-identifier">$stdout</span>.<span class="ruby-identifier">flush</span>
|
|
66: <span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div id="yes--method" class="method-detail ">
|
|
<a name="method-i-yes%3F"></a>
|
|
|
|
<div class="method-heading">
|
|
|
|
<span class="method-name">yes?</span><span
|
|
class="method-args">(statement, color=nil)</span>
|
|
<span class="method-click-advice">click to toggle source</span>
|
|
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
<p>
|
|
Make a question the to user and returns true if the user replies
|
|
“y” or “yes”.
|
|
</p>
|
|
|
|
|
|
|
|
<div class="method-source-code"
|
|
id="yes--source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/bundler/vendor/thor/shell/basic.rb, line 71</span>
|
|
71: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">yes?</span>(<span class="ruby-identifier">statement</span>, <span class="ruby-identifier">color</span>=<span class="ruby-keyword kw">nil</span>)
|
|
72: <span class="ruby-identifier">ask</span>(<span class="ruby-identifier">statement</span>, <span class="ruby-identifier">color</span>) <span class="ruby-operator">=~</span> <span class="ruby-identifier">is?</span>(<span class="ruby-value">:yes</span>)
|
|
73: <span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
<div id="protected-instance-method-details" class="method-section section">
|
|
<h3 class="section-header">Protected Instance Methods</h3>
|
|
|
|
|
|
<div id="dynamic-width-method" class="method-detail ">
|
|
<a name="method-i-dynamic_width"></a>
|
|
|
|
<div class="method-heading">
|
|
|
|
<span class="method-name">dynamic_width</span><span
|
|
class="method-args">()</span>
|
|
<span class="method-click-advice">click to toggle source</span>
|
|
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
<p>
|
|
Calculate the dynamic width of the terminal
|
|
</p>
|
|
|
|
|
|
|
|
<div class="method-source-code"
|
|
id="dynamic-width-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/bundler/vendor/thor/shell/basic.rb, line 249</span>
|
|
249: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dynamic_width</span>
|
|
250: <span class="ruby-ivar">@dynamic_width</span> <span class="ruby-operator">||=</span> (<span class="ruby-identifier">dynamic_width_stty</span>.<span class="ruby-identifier">nonzero?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">dynamic_width_tput</span>)
|
|
251: <span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div id="dynamic-width-stty-method" class="method-detail ">
|
|
<a name="method-i-dynamic_width_stty"></a>
|
|
|
|
<div class="method-heading">
|
|
|
|
<span class="method-name">dynamic_width_stty</span><span
|
|
class="method-args">()</span>
|
|
<span class="method-click-advice">click to toggle source</span>
|
|
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
|
|
|
|
|
|
|
|
<div class="method-source-code"
|
|
id="dynamic-width-stty-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/bundler/vendor/thor/shell/basic.rb, line 253</span>
|
|
253: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dynamic_width_stty</span>
|
|
254: <span class="ruby-value">%{stty size 2>/dev/null}</span>.<span class="ruby-identifier">split</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">to_i</span>
|
|
255: <span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div id="dynamic-width-tput-method" class="method-detail ">
|
|
<a name="method-i-dynamic_width_tput"></a>
|
|
|
|
<div class="method-heading">
|
|
|
|
<span class="method-name">dynamic_width_tput</span><span
|
|
class="method-args">()</span>
|
|
<span class="method-click-advice">click to toggle source</span>
|
|
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
|
|
|
|
|
|
|
|
<div class="method-source-code"
|
|
id="dynamic-width-tput-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/bundler/vendor/thor/shell/basic.rb, line 257</span>
|
|
257: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dynamic_width_tput</span>
|
|
258: <span class="ruby-value">%{tput cols 2>/dev/null}</span>.<span class="ruby-identifier">to_i</span>
|
|
259: <span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div id="terminal-width-method" class="method-detail ">
|
|
<a name="method-i-terminal_width"></a>
|
|
|
|
<div class="method-heading">
|
|
|
|
<span class="method-name">terminal_width</span><span
|
|
class="method-args">()</span>
|
|
<span class="method-click-advice">click to toggle source</span>
|
|
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
<p>
|
|
This code was copied from Rake, available under MIT-LICENSE Copyright
|
|
© 2003, 2004 Jim Weirich
|
|
</p>
|
|
|
|
|
|
|
|
<div class="method-source-code"
|
|
id="terminal-width-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/bundler/vendor/thor/shell/basic.rb, line 237</span>
|
|
237: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">terminal_width</span>
|
|
238: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'THOR_COLUMNS'</span>]
|
|
239: <span class="ruby-identifier">result</span> = <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'THOR_COLUMNS'</span>].<span class="ruby-identifier">to_i</span>
|
|
240: <span class="ruby-keyword kw">else</span>
|
|
241: <span class="ruby-identifier">result</span> = <span class="ruby-identifier">unix?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">dynamic_width</span> <span class="ruby-operator">:</span> <span class="ruby-value">80</span>
|
|
242: <span class="ruby-keyword kw">end</span>
|
|
243: (<span class="ruby-identifier">result</span> <span class="ruby-operator"><</span> <span class="ruby-value">10</span>) <span class="ruby-operator">?</span> <span class="ruby-value">80</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">result</span>
|
|
244: <span class="ruby-keyword kw">rescue</span>
|
|
245: <span class="ruby-value">80</span>
|
|
246: <span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div id="truncate-method" class="method-detail ">
|
|
<a name="method-i-truncate"></a>
|
|
|
|
<div class="method-heading">
|
|
|
|
<span class="method-name">truncate</span><span
|
|
class="method-args">(string, width)</span>
|
|
<span class="method-click-advice">click to toggle source</span>
|
|
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
|
|
|
|
|
|
|
|
<div class="method-source-code"
|
|
id="truncate-source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/bundler/vendor/thor/shell/basic.rb, line 265</span>
|
|
265: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">truncate</span>(<span class="ruby-identifier">string</span>, <span class="ruby-identifier">width</span>)
|
|
266: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">string</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">width</span>
|
|
267: <span class="ruby-identifier">string</span>
|
|
268: <span class="ruby-keyword kw">else</span>
|
|
269: ( <span class="ruby-identifier">string</span>[<span class="ruby-value">0</span>, <span class="ruby-identifier">width</span><span class="ruby-operator">-</span><span class="ruby-value">3</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">""</span> ) <span class="ruby-operator">+</span> <span class="ruby-value str">"..."</span>
|
|
270: <span class="ruby-keyword kw">end</span>
|
|
271: <span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div id="unix--method" class="method-detail ">
|
|
<a name="method-i-unix%3F"></a>
|
|
|
|
<div class="method-heading">
|
|
|
|
<span class="method-name">unix?</span><span
|
|
class="method-args">()</span>
|
|
<span class="method-click-advice">click to toggle source</span>
|
|
|
|
</div>
|
|
|
|
<div class="method-description">
|
|
|
|
|
|
|
|
|
|
|
|
<div class="method-source-code"
|
|
id="unix--source">
|
|
<pre>
|
|
<span class="ruby-comment cmt"># File lib/bundler/vendor/thor/shell/basic.rb, line 261</span>
|
|
261: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unix?</span>
|
|
262: <span class="ruby-constant">RUBY_PLATFORM</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/</span>
|
|
263: <span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div id="rdoc-debugging-section-dump" class="debugging-section">
|
|
|
|
<p>Disabled; run with --debug to generate this.</p>
|
|
|
|
</div>
|
|
|
|
<div id="validator-badges">
|
|
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
|
Rdoc Generator</a> 1.1.6</small>.</p>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|
|
|