Git Product home page Git Product logo

semantic's Introduction

Semantic

BuildStatus

A small Ruby utility class to aid in the storage, parsing, and comparison of SemVer-style Version strings.

See the SemVer site for more details.

Usage

This library exposes a single class โ€“ Semantic::Version. Simply pass in a valid SemVer string to the initializer.

require 'semantic'

version = Semantic::Version.new '1.6.5'
version.major             # => 1
version.minor             # => 6
version.patch             # => 5

newer_version = Semantic::Version.new '1.7.0'
version > newer_version   # => false
newer_version <=> version # => 1

complex_version = Semantic::Version.new '3.7.9-pre.1+revision.15723'
complex_version.pre       # => "pre.1"
complex_version.build     # => "revision.15623"

# semantic supports Pessimistic Operator
version.satisfies? '~> 1.5'    # => true
version.satisfies? '~> 1.6.0'  # => true

# incrementing version numbers
version = Semantic::Version.new('0.1.0')
new_version = version.increment!(:major)    # 1.1.0
new_version = version.increment!(:minor)    # 0.2.0
new_version = version.increment!(:patch)    # 0.1.1

new_version = version.major!                # 1.1.0
new_version = version.minor!                # 0.2.0
new_version = version.patch!                # 0.1.1
# (note: increment! & friends return a copy and leave the original unchanged)

There is also a set of core extensions as an optional require:

require 'semantic'
require 'semantic/core_ext'

"1.8.7-pre.123".to_version

License

Copyright (c) 2012 Josh Lindsey. See LICENSE for details.

semantic's People

Contributors

axl411 avatar calyhre avatar closer avatar fornellas avatar jleeothon avatar jlindsey avatar jondeandres avatar lalithr95 avatar mbishop-fiksu avatar mikz avatar pvdb avatar thedaniel avatar twp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.