doc/SidekiqUniqueJobs/VersionCheck.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Class: SidekiqUniqueJobs::VersionCheck
— Documentation by YARD 0.9.26
</title>
<link rel="stylesheet" href="../css/style.css" type="text/css" />
<link rel="stylesheet" href="../css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "SidekiqUniqueJobs::VersionCheck";
relpath = '../';
</script>
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
</head>
<body>
<div class="nav_wrap">
<iframe id="nav" src="../class_list.html?1"></iframe>
<div id="resizer"></div>
</div>
<div id="main" tabindex="-1">
<div id="header">
<div id="menu">
<a href="../_index.html">Index (V)</a> »
<span class='title'><span class='object_link'><a href="../SidekiqUniqueJobs.html" title="SidekiqUniqueJobs (module)">SidekiqUniqueJobs</a></span></span>
»
<span class="title">VersionCheck</span>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="../class_list.html">
<svg width="24" height="24">
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
</svg>
</a>
</div>
<div class="clear"></div>
</div>
<div id="content"><h1>Class: SidekiqUniqueJobs::VersionCheck
</h1>
<div class="box_info">
<dl>
<dt>Inherits:</dt>
<dd>
<span class="inheritName">Object</span>
<ul class="fullTree">
<li>Object</li>
<li class="next">SidekiqUniqueJobs::VersionCheck</li>
</ul>
<a href="#" class="inheritanceTree">show all</a>
</dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/sidekiq_unique_jobs/version_check.rb</dd>
</dl>
</div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>Handles checking if a version is compliant with given constraint</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Author:</p>
<ul class="author">
<li>
<div class='inline'><p>Mikael Henriksson <a href="mailto:mikael@mhenrixon.com">mikael@mhenrixon.com</a></p>
</div>
</li>
</ul>
</div>
<h2>
Constant Summary
<small><a href="#" class="constants_summary_toggle">collapse</a></small>
</h2>
<dl class="constants">
<dt id="PATTERN-constant" class="">PATTERN =
<div class="docstring">
<div class="discussion">
<p>rubocop:disable Layout/LineLength, Lint/MixedRegexpCaptureTypes</p>
</div>
</div>
<div class="tags">
</div>
</dt>
<dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(?<operator1>[<>=]+)?\s?(?<version1>(\d+.?)+)(\s+&&\s+)?(?<operator2>[<>=]+)?\s?(?<version2>(\d+.?)+)?</span><span class='regexp_end'>/m</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
</dl>
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#match-instance_method" title="#match (instance method)">#<strong>match</strong> ⇒ Object </a>
</span>
<span class="note title readonly">readonly</span>
<span class="summary_desc"><div class='inline'><p>Returns the value of attribute match.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#version-instance_method" title="#version (instance method)">#<strong>version</strong> ⇒ Object </a>
</span>
<span class="note title readonly">readonly</span>
<span class="summary_desc"><div class='inline'><p>Returns the value of attribute version.</p>
</div></span>
</li>
</ul>
<h2>
Class Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#satisfied%3F-class_method" title="satisfied? (class method)">.<strong>satisfied?</strong>(version, constraint) ⇒ true, false </a>
</span>
<span class="summary_desc"><div class='inline'><p>Checks if a version is constraint is satisfied.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#unfulfilled%3F-class_method" title="unfulfilled? (class method)">.<strong>unfulfilled?</strong>(version, constraint) ⇒ true, false </a>
</span>
<span class="summary_desc"><div class='inline'><p>Checks if a version is constraint is unfulfilled.</p>
</div></span>
</li>
</ul>
<h2>
Instance Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(version, constraint) ⇒ VersionCheck </a>
</span>
<span class="note title constructor">constructor</span>
<span class="summary_desc"><div class='inline'><p>Initialize a new VersionCheck instance.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#satisfied%3F-instance_method" title="#satisfied? (instance method)">#<strong>satisfied?</strong> ⇒ true, false </a>
</span>
<span class="summary_desc"><div class='inline'><p>Checks if all constraints were met.</p>
</div></span>
</li>
</ul>
<div id="constructor_details" class="method_details_list">
<h2>Constructor Details</h2>
<div class="method_details first">
<h3 class="signature first" id="initialize-instance_method">
#<strong>initialize</strong>(version, constraint) ⇒ <tt><span class='object_link'><a href="" title="SidekiqUniqueJobs::VersionCheck (class)">VersionCheck</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Initialize a new VersionCheck instance</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>version</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>a version string <code>5.0.0</code></p>
</div>
</li>
<li>
<span class='name'>constraint</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>a version constraint <code>>= 5.0.0 <= 5.1.1</code></p>
</div>
</li>
</ul>
<p class="tag_title">Raises:</p>
<ul class="raise">
<li>
<span class='type'>(<tt>ArgumentError</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
65
66
67
68
69
70
71</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/version_check.rb', line 65</span>
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_version'>version</span><span class='comma'>,</span> <span class='id identifier rubyid_constraint'>constraint</span><span class='rparen'>)</span>
<span class='ivar'>@version</span> <span class='op'>=</span> <span class='const'>Gem</span><span class='op'>::</span><span class='const'>Version</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_version'>version</span><span class='rparen'>)</span>
<span class='ivar'>@match</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="#PATTERN-constant" title="SidekiqUniqueJobs::VersionCheck::PATTERN (constant)">PATTERN</a></span></span><span class='period'>.</span><span class='id identifier rubyid_match'><span class='object_link'><a href="#match-instance_method" title="SidekiqUniqueJobs::VersionCheck#match (method)">match</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_constraint'>constraint</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>A version (eg. 5.0) is required to compare against</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='ivar'>@version</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>At least one operator and version is required (eg. >= 5.1)</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_constraint'>constraint</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="instance_attr_details" class="attr_details">
<h2>Instance Attribute Details</h2>
<span id=""></span>
<div class="method_details first">
<h3 class="signature first" id="match-instance_method">
#<strong>match</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the value of attribute match.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
57
58
59</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/version_check.rb', line 57</span>
<span class='kw'>def</span> <span class='id identifier rubyid_match'>match</span>
<span class='ivar'>@match</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<span id=""></span>
<div class="method_details ">
<h3 class="signature " id="version-instance_method">
#<strong>version</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the value of attribute version.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
53
54
55</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/version_check.rb', line 53</span>
<span class='kw'>def</span> <span class='id identifier rubyid_version'>version</span>
<span class='ivar'>@version</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="class_method_details" class="method_details_list">
<h2>Class Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="satisfied?-class_method">
.<strong>satisfied?</strong>(version, constraint) ⇒ <tt>true</tt>, <tt>false</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Checks if a version is constraint is satisfied</p>
</div>
</div>
<div class="tags">
<div class="examples">
<p class="tag_title">Examples:</p>
<p class="example_title"><div class='inline'><p>A satisfied constraint</p>
</div></p>
<pre class="example code"><code><span class='const'><span class='object_link'><a href="" title="SidekiqUniqueJobs::VersionCheck (class)">VersionCheck</a></span></span><span class='period'>.</span><span class='id identifier rubyid_satisfied?'>satisfied?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>5.0.0</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>>= 4.0.0</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='comment'>#=> true</span></code></pre>
<p class="example_title"><div class='inline'><p>An unsatisfied constraint</p>
</div></p>
<pre class="example code"><code><span class='const'><span class='object_link'><a href="" title="SidekiqUniqueJobs::VersionCheck (class)">VersionCheck</a></span></span><span class='period'>.</span><span class='id identifier rubyid_satisfied?'>satisfied?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>5.0.0</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'><= 4.0.0</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='comment'>#=> false</span></code></pre>
</div>
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>version</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>a version string <code>5.0.0</code></p>
</div>
</li>
<li>
<span class='name'>constraint</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>a version constraint <code>>= 5.0.0 <= 5.1.1</code></p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>true</tt>, <tt>false</tt>)</span>
—
<div class='inline'><p><description></p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
27
28
29</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/version_check.rb', line 27</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_satisfied?'>satisfied?</span><span class='lparen'>(</span><span class='id identifier rubyid_version'>version</span><span class='comma'>,</span> <span class='id identifier rubyid_constraint'>constraint</span><span class='rparen'>)</span>
<span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_version'>version</span><span class='comma'>,</span> <span class='id identifier rubyid_constraint'>constraint</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_satisfied?'>satisfied?</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="unfulfilled?-class_method">
.<strong>unfulfilled?</strong>(version, constraint) ⇒ <tt>true</tt>, <tt>false</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Checks if a version is constraint is unfulfilled</p>
</div>
</div>
<div class="tags">
<div class="examples">
<p class="tag_title">Examples:</p>
<p class="example_title"><div class='inline'><p>A satisfied constraint</p>
</div></p>
<pre class="example code"><code><span class='const'><span class='object_link'><a href="" title="SidekiqUniqueJobs::VersionCheck (class)">VersionCheck</a></span></span><span class='period'>.</span><span class='id identifier rubyid_unfulfilled?'>unfulfilled?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>5.0.0</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>>= 4.0.0</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='comment'>#=> false</span></code></pre>
<p class="example_title"><div class='inline'><p>An unfulfilled constraint</p>
</div></p>
<pre class="example code"><code><span class='const'><span class='object_link'><a href="" title="SidekiqUniqueJobs::VersionCheck (class)">VersionCheck</a></span></span><span class='period'>.</span><span class='id identifier rubyid_unfulfilled?'>unfulfilled?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>5.0.0</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'><= 4.0.0</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='comment'>#=> true</span></code></pre>
</div>
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>version</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>a version string <code>5.0.0</code></p>
</div>
</li>
<li>
<span class='name'>constraint</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>a version constraint <code>>= 5.0.0 <= 5.1.1</code></p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>true</tt>, <tt>false</tt>)</span>
—
<div class='inline'><p><description></p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
46
47
48</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/version_check.rb', line 46</span>
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_unfulfilled?'>unfulfilled?</span><span class='lparen'>(</span><span class='id identifier rubyid_version'>version</span><span class='comma'>,</span> <span class='id identifier rubyid_constraint'>constraint</span><span class='rparen'>)</span>
<span class='op'>!</span><span class='id identifier rubyid_satisfied?'>satisfied?</span><span class='lparen'>(</span><span class='id identifier rubyid_version'>version</span><span class='comma'>,</span> <span class='id identifier rubyid_constraint'>constraint</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="satisfied?-instance_method">
#<strong>satisfied?</strong> ⇒ <tt>true</tt>, <tt>false</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Checks if all constraints were met</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>true</tt>, <tt>false</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
79
80
81
82
83</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/sidekiq_unique_jobs/version_check.rb', line 79</span>
<span class='kw'>def</span> <span class='id identifier rubyid_satisfied?'>satisfied?</span>
<span class='id identifier rubyid_constraints'>constraints</span><span class='period'>.</span><span class='id identifier rubyid_all?'>all?</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_expected'>expected</span><span class='comma'>,</span> <span class='id identifier rubyid_operator'>operator</span><span class='op'>|</span>
<span class='id identifier rubyid_compare'>compare</span><span class='lparen'>(</span><span class='id identifier rubyid_expected'>expected</span><span class='comma'>,</span> <span class='id identifier rubyid_operator'>operator</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Mon Sep 27 15:29:08 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-3.0.2).
</div>
</div>
</body>
</html>