• Stars
    star
    145
  • Rank 254,144 (Top 6 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 12 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ruby Semantic Version class

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.

More Repositories

1

ApkDownloader

APK downloader for Ruby
Ruby
21
star
2

grunt-external-daemon

Grunt.js task for launching external background processes
JavaScript
9
star
3

rutty

A DSH (Distributed Shell) implementation in Ruby
Ruby
8
star
4

NSCollectionView-Example

An example of an NSCollectionView with all the bindings.
Objective-C
7
star
5

scapeshift

Magic: The Gathering Oracle web scraper
Ruby
7
star
6

dot-vim

My .vim and .vimrc files
Vim Script
4
star
7

hcl2

Rust HCL2 parser
Rust
4
star
8

gobot

Golang Slack chat bot
Go
3
star
9

mcserv

Minecraft Server Wrapper
Go
2
star
10

blink_watcher

Chrome Extension to watch SOMER.blink for promos
CoffeeScript
2
star
11

cookbooks

Custom chef cookbooks
Ruby
2
star
12

HTML5-Offline-Page-Demo

2
star
13

leach

Let's Encrypt Automated Certificate Handler
Go
2
star
14

pastie_chrome

Chrome Pastie Extension
2
star
15

NSURLConnection-Example

An example of asynchronous connectivity with Cocoa
Objective-C
2
star
16

screencat

Screenshot sharing with Sendcat
Rust
2
star
17

grunt-reconfigure

Grunt.js task for overriding configurations
JavaScript
2
star
18

log_test_example

Example of using StringIO to test log ouput
Ruby
2
star
19

ClownReader

RSS Reader in clojure
Clojure
1
star
20

crypt-keeper

Simple redis-backed secret management.
Python
1
star
21

rubybase-docker

Docker Ruby Base Image
Shell
1
star
22

screenbase

Simple keybase.io screenshot sharing tool
Python
1
star
23

libcart

Rust
1
star
24

blog

My weblorg
Ruby
1
star
25

herpaderp

Hello
Ruby
1
star
26

userchat

Live embeddable user chat system
Ruby
1
star
27

sqs_tools

Some basic CLI tools for interacting with Amazon SQS
1
star
28

every

Ruby
1
star
29

consulator

JSON to Consul KV tree
Rust
1
star
30

git-pm

Git Project Management
Python
1
star