Code Monkey home page Code Monkey logo

swfsemanticversion's Introduction

SWFSemanticVersion

Version Platform

A port of the semantic version value class from the semantic Ruby gem that implements the SemVer versioning scheme.

Usage

To run the example project; clone the repo, build and run with Xcode. The sample is an iOS app that you can type two semantic version strings into and display the comparison result.

Creating a Semantic Version

The SWFSemanticVersion class parses a string in the format defined by the standard and produces an immutable value object from it. If the version string can't be parsed it returns nil.

Instances can be compared and follow the rules defined by the standard. Specifically, major > minor > patch. Pre-release < release, but two pre-release suffixes are compared lexically and numerically. Build suffixes are ignored for comparison.

For example:

  • 1.0.0 < 2.0.0 < 2.1.0 < 2.1.1
  • 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0

Create from a string (will return a nil if the string isn't parseable):

SWFSemanticVersion *semVer = [SWFSemanticVersion semanticVersionWithString:@"0.1.0"];

Or create manually:

SWFSemanticVersion *semVer = [[SWFSemanticVersion alloc] initWithMajor:@(0) minor:@(0) patch:@(0) pre:nil build:nil];

Installation

SWFSemanticVersion is available through CocoaPods, to install it simply add the following line to your Podfile:

pod "SWFSemanticVersion"

Author

Samuel Ford, [email protected]

Acknowledgements

License

SWFSemanticVersion is available under the MIT license. See the LICENSE file for more info.

swfsemanticversion's People

Contributors

samuelwford avatar wlisac avatar jonmchan avatar mikaelbartlett avatar

Stargazers

Kvar Izunia avatar Michael Starke avatar Alex Antonyuk avatar Konstantin Pavlikhin avatar  avatar 黄巧波 avatar Alexey avatar  avatar Yin Cheng avatar bxfula avatar Wei Wang avatar Joe Nguyen avatar Nestor Lafon-Gracia avatar

Watchers

 avatar James Cloos avatar  avatar

swfsemanticversion's Issues

Semver Validation Does Not Comply With Spec

When parsing strings as semver with [SWFSemanticVersion semanticVersionWithString], the library fails to follow Paragraph 2 of the spec:

A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative integers, and MUST NOT contain leading zeroes. http://semver.org/#spec-item-2

The following should fail validation, but passes:

1  # missing minor and patch
1.0 # missing patch
1.0.003 # contain leading zeroes.

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.