Browse Source
* Add Semver to library, an simple non-spec implementation of semver * add a None test caseremotes/origin/add-simple-redirecting-site
![gal@spitfire.co.il](/assets/img/avatar_default.png)
![GitHub](/assets/img/avatar_default.png)
15 changed files with 333 additions and 293 deletions
@ -1,27 +0,0 @@ |
|||||||
opam-version: "2.0" |
|
||||||
maintainer: "frederic.bour@lakaban.net" |
|
||||||
authors: [ |
|
||||||
"Frédéric Bour <frederic.bour@lakaban.net>" |
|
||||||
"Alain Frisch <alain.frisch@lexifi.com>" |
|
||||||
] |
|
||||||
license: "MIT" |
|
||||||
homepage: "https://github.com/let-def/ppx_tools_versioned" |
|
||||||
bug-reports: "https://github.com/let-def/ppx_tools_versioned/issues" |
|
||||||
dev-repo: "git://github.com/let-def/ppx_tools_versioned.git" |
|
||||||
tags: [ "syntax" ] |
|
||||||
build: [ |
|
||||||
["jbuilder" "subst" "-p" name] {pinned} |
|
||||||
["jbuilder" "build" "-p" name "-j" jobs] |
|
||||||
["jbuilder" "runtest" "-p" name "-j" jobs] {with-test} |
|
||||||
] |
|
||||||
depends: [ |
|
||||||
"ocaml" {>= "4.02.0"} |
|
||||||
"jbuilder" {build & >= "1.0+beta17"} |
|
||||||
"ocaml-migrate-parsetree" {>= "1.0.10" & < "1.3.0"} |
|
||||||
] |
|
||||||
synopsis: "A variant of ppx_tools based on ocaml-migrate-parsetree" |
|
||||||
url { |
|
||||||
src: |
|
||||||
"https://github.com/ocaml-ppx/ppx_tools_versioned/archive/5.2.1.tar.gz" |
|
||||||
checksum: "md5=1ae6ae43ec161fbbf12c2b4d3a7e26f5" |
|
||||||
} |
|
@ -0,0 +1,30 @@ |
|||||||
|
opam-version: "2.0" |
||||||
|
maintainer: "frederic.bour@lakaban.net" |
||||||
|
authors: [ |
||||||
|
"Frédéric Bour <frederic.bour@lakaban.net>" |
||||||
|
"Alain Frisch <alain.frisch@lexifi.com>" |
||||||
|
] |
||||||
|
license: "MIT" |
||||||
|
homepage: "https://github.com/ocaml-ppx/ppx_tools_versioned" |
||||||
|
bug-reports: "https://github.com/ocaml-ppx/ppx_tools_versioned/issues" |
||||||
|
dev-repo: "git://github.com/ocaml-ppx/ppx_tools_versioned.git" |
||||||
|
tags: [ "syntax" ] |
||||||
|
build: [ |
||||||
|
["dune" "subst"] {pinned} |
||||||
|
["dune" "build" "-p" name "-j" jobs] |
||||||
|
["dune" "runtest" "-p" name "-j" jobs] {with-test} |
||||||
|
] |
||||||
|
depends: [ |
||||||
|
"ocaml" {>= "4.02.0"} |
||||||
|
"dune" {build & >= "1.0"} |
||||||
|
"ocaml-migrate-parsetree" {>= "1.0.10"} |
||||||
|
] |
||||||
|
synopsis: "A variant of ppx_tools based on ocaml-migrate-parsetree" |
||||||
|
url { |
||||||
|
src: |
||||||
|
"https://github.com/ocaml-ppx/ppx_tools_versioned/archive/5.2.2.tar.gz" |
||||||
|
checksum: [ |
||||||
|
"md5=f78a3c2b4cc3b92702e1f7096a6125fa" |
||||||
|
"sha512=68c168ebc01af46fe8766ad7e36cc778caabb97d8eb303db284d106450cb79974c2a640ce459e197630b9e84b02caa24b59c97c9a8d39ddadc7efc7284e42a70" |
||||||
|
] |
||||||
|
} |
@ -1,35 +0,0 @@ |
|||||||
opam-version: "2.0" |
|
||||||
maintainer: "rudi.grinberg@gmail.com" |
|
||||||
authors: [ |
|
||||||
"Tikhon Jelvis" |
|
||||||
"Rudi Grinberg" |
|
||||||
] |
|
||||||
homepage: "https://github.com/rgrinberg/ocaml-semver" |
|
||||||
bug-reports: "https://github.com/rgrinberg/ocaml-semver/issues" |
|
||||||
license: "BSD3" |
|
||||||
dev-repo: "git+https://github.com/rgrinberg/ocaml-semver.git" |
|
||||||
build: [ |
|
||||||
["ocaml" "setup.ml" "-configure"] |
|
||||||
["ocaml" "setup.ml" "-build"] |
|
||||||
["ocaml" "setup.ml" "-configure" "--enable-tests"] {with-test} |
|
||||||
["ocaml" "setup.ml" "-build"] {with-test} |
|
||||||
["ocaml" "setup.ml" "-test"] {with-test} |
|
||||||
["ocaml" "setup.ml" "-doc"] {with-doc} |
|
||||||
] |
|
||||||
install: ["ocaml" "setup.ml" "-install"] |
|
||||||
remove: ["ocamlfind" "remove" "semver"] |
|
||||||
depends: [ |
|
||||||
"ocaml" {>= "4.02.0"} |
|
||||||
"ocamlfind" {build} |
|
||||||
"ounit" {with-test} |
|
||||||
"ocamlbuild" {build} |
|
||||||
] |
|
||||||
synopsis: "Semantic versioning module" |
|
||||||
description: """ |
|
||||||
Provides a single module `Semver` that can parse, compare, and manipulate |
|
||||||
software versions of the form x.x.x. See http://semver.org/""" |
|
||||||
flags: light-uninstall |
|
||||||
url { |
|
||||||
src: "https://github.com/rgrinberg/ocaml-semver/archive/v0.1.0.tar.gz" |
|
||||||
checksum: "md5=ce6614ba2f91754028b29a12989f9da6" |
|
||||||
} |
|
@ -1,5 +1,5 @@ |
|||||||
{ |
{ |
||||||
"dependencies": { |
"dependencies": { |
||||||
"yarn-pkg-config": "esy-ocaml/yarn-pkg-config#d488cd9321cd5036bd36ec96744ce78c5d45fc49" |
"yarn-pkg-config": "esy-ocaml/yarn-pkg-config#cca65f99674ed2d954d28788edeb8c57fada5ed0" |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -0,0 +1,23 @@ |
|||||||
|
[@deriving (eq, ord, make)] |
||||||
|
type t = { |
||||||
|
major: int, |
||||||
|
minor: int, |
||||||
|
patch: int, |
||||||
|
}; |
||||||
|
|
||||||
|
let fromString = str => |
||||||
|
switch ( |
||||||
|
String.split_on_char('.', str) |
||||||
|
|> List.map(int_of_string_opt) |
||||||
|
|> Core.Option.all |
||||||
|
) { |
||||||
|
| Some([major, minor, patch]) => Some({major, minor, patch}) |
||||||
|
| _ => None |
||||||
|
}; |
||||||
|
|
||||||
|
let toString = ({major, minor, patch}) => |
||||||
|
Printf.sprintf("%d.%d.%d", major, minor, patch); |
||||||
|
|
||||||
|
let major = ({major, _}) => major; |
||||||
|
let minor = ({minor, _}) => minor; |
||||||
|
let patch = ({patch, _}) => patch; |
@ -0,0 +1,11 @@ |
|||||||
|
[@deriving (eq, ord)] |
||||||
|
type t; |
||||||
|
|
||||||
|
let make: (~major: int, ~minor: int, ~patch: int) => t; |
||||||
|
|
||||||
|
let fromString: string => option(t); |
||||||
|
let toString: t => string; |
||||||
|
|
||||||
|
let major: t => int; |
||||||
|
let minor: t => int; |
||||||
|
let patch: t => int; |
@ -1,3 +1,4 @@ |
|||||||
include SmokeTest; |
include SmokeTest; |
||||||
|
include TestSemver; |
||||||
|
|
||||||
TestFramework.cli(); |
TestFramework.cli(); |
||||||
|
@ -0,0 +1,27 @@ |
|||||||
|
open TestFramework; |
||||||
|
|
||||||
|
describe("Semver", ({test, _}) => { |
||||||
|
open Fnm; |
||||||
|
|
||||||
|
test("parses a string", ({expect, _}) => { |
||||||
|
let x = Semver.fromString("1.2.3"); |
||||||
|
expect.equal(x, Some(Semver.make(~major=1, ~minor=2, ~patch=3))); |
||||||
|
}); |
||||||
|
|
||||||
|
test("returns none on invalid semver", ({expect, _}) => { |
||||||
|
let x = Semver.fromString("x1.2.3"); |
||||||
|
expect.equal(x, None); |
||||||
|
}); |
||||||
|
|
||||||
|
test("compare versions", ({expect}) => { |
||||||
|
let semver1 = Semver.make(~major=1, ~minor=2, ~patch=0); |
||||||
|
let semver2 = Semver.make(~major=1, ~minor=2, ~patch=3); |
||||||
|
let semver3 = Semver.make(~major=1, ~minor=3, ~patch=3); |
||||||
|
let semver4 = Semver.make(~major=4, ~minor=3, ~patch=3); |
||||||
|
|
||||||
|
let sorted = |
||||||
|
List.sort(Semver.compare, [semver1, semver2, semver4, semver3]); |
||||||
|
|
||||||
|
expect.list(sorted).toEqual([semver1, semver2, semver3, semver4]); |
||||||
|
}); |
||||||
|
}); |
Loading…
Reference in new issue