aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/mcuadros/go-version/constraint.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2017-02-09 19:48:13 -0500
committerUnknwon <u@gogs.io>2017-02-09 19:48:13 -0500
commit2fd69f13d9599a6c58b47225565163fd7d87889f (patch)
treefd19e868e1c2e95a5fb83a268f6e393669d6ee79 /vendor/github.com/mcuadros/go-version/constraint.go
parenteb66060cd7b9bce996b1d75ae80ce1ef31d5ce62 (diff)
vendor: check in vendors
Bye bye glide...
Diffstat (limited to 'vendor/github.com/mcuadros/go-version/constraint.go')
-rw-r--r--vendor/github.com/mcuadros/go-version/constraint.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/vendor/github.com/mcuadros/go-version/constraint.go b/vendor/github.com/mcuadros/go-version/constraint.go
new file mode 100644
index 00000000..8dc2cfcc
--- /dev/null
+++ b/vendor/github.com/mcuadros/go-version/constraint.go
@@ -0,0 +1,49 @@
+package version
+
+import (
+ "strings"
+)
+
+type Constraint struct {
+ operator string
+ version string
+}
+
+// Return a new Constrain and sets operator and version to compare
+func NewConstrain(operator, version string) *Constraint {
+ constraint := new(Constraint)
+ constraint.SetOperator(operator)
+ constraint.SetVersion(version)
+
+ return constraint
+}
+
+// Sets operator to compare
+func (self *Constraint) SetOperator(operator string) {
+ self.operator = operator
+}
+
+// Get operator to compare
+func (self *Constraint) GetOperator() string {
+ return self.operator
+}
+
+// Sets version to compare
+func (self *Constraint) SetVersion(version string) {
+ self.version = version
+}
+
+// Get version to compare
+func (self *Constraint) GetVersion() string {
+ return self.version
+}
+
+// Match a given version againts the constraint
+func (self *Constraint) Match(version string) bool {
+ return Compare(version, self.version, self.operator)
+}
+
+// Return a string representation
+func (self *Constraint) String() string {
+ return strings.Trim(self.operator+" "+self.version, " ")
+}