Class: Chef::VersionConstraint
Constant Summary collapse
- DEFAULT_CONSTRAINT =
">= 0.0.0"
- STANDARD_OPS =
%w(< > <= >=)
- OPS =
%w(< > = <= >= ~>)
- PATTERN =
/^(#{OPS.join('|')}) (.+)$/
Instance Attribute Summary collapse
-
#op ⇒ Object
readonly
Returns the value of attribute op.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #eql?(o) ⇒ Boolean (also: #==)
- #include?(v) ⇒ Boolean
-
#initialize(constraint_spec = DEFAULT_CONSTRAINT) ⇒ VersionConstraint
constructor
A new instance of VersionConstraint.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(constraint_spec = DEFAULT_CONSTRAINT) ⇒ VersionConstraint
Returns a new instance of VersionConstraint.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/chef/version_constraint.rb', line 28 def initialize(constraint_spec=DEFAULT_CONSTRAINT) case constraint_spec when nil parse(DEFAULT_CONSTRAINT) when Array parse_from_array(constraint_spec) when String parse(constraint_spec) else msg = "VersionConstraint should be created from a String. You gave: #{constraint_spec.inspect}" raise Chef::Exceptions::InvalidVersionConstraint, msg end end |
Instance Attribute Details
#op ⇒ Object (readonly)
Returns the value of attribute op.
26 27 28 |
# File 'lib/chef/version_constraint.rb', line 26 def op @op end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
26 27 28 |
# File 'lib/chef/version_constraint.rb', line 26 def version @version end |
Instance Method Details
#eql?(o) ⇒ Boolean Also known as: ==
59 60 61 |
# File 'lib/chef/version_constraint.rb', line 59 def eql?(o) o.class == self.class && @op == o.op && @version == o.version end |
#include?(v) ⇒ Boolean
42 43 44 45 46 47 48 49 |
# File 'lib/chef/version_constraint.rb', line 42 def include?(v) version = if v.respond_to? :version # a CookbookVersion-like object Chef::Version.new(v.version.to_s) else Chef::Version.new(v.to_s) end do_op(version) end |
#inspect ⇒ Object
51 52 53 |
# File 'lib/chef/version_constraint.rb', line 51 def inspect "(#{@op} #{@version})" end |
#to_s ⇒ Object
55 56 57 |
# File 'lib/chef/version_constraint.rb', line 55 def to_s "#{@op} #{@version}" end |