diff --git a/plugins/ruby/flake.lock b/plugins/ruby/flake.lock new file mode 100644 index 0000000..d8f8a63 --- /dev/null +++ b/plugins/ruby/flake.lock @@ -0,0 +1,96 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1689503327, + "narHash": "sha256-qVwzYLA8oT2oWNDXO0A3bZHOhoPOihIB9T677+Hor1E=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f64b9738da8e86195766147e9752c67fccee006c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-ruby": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1699940389, + "narHash": "sha256-nyeaGnrToe2g86kj1elImJ9gga3VOZzd4n+lYoHOQQs=", + "owner": "bobvanderlinden", + "repo": "nixpkgs-ruby", + "rev": "065106dbb7eb33514478157868ad1069f26115b2", + "type": "github" + }, + "original": { + "owner": "bobvanderlinden", + "repo": "nixpkgs-ruby", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs-ruby": "nixpkgs-ruby" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/plugins/ruby/flake.nix b/plugins/ruby/flake.nix new file mode 100644 index 0000000..c3e2ea2 --- /dev/null +++ b/plugins/ruby/flake.nix @@ -0,0 +1,12 @@ +{ + inputs.nixpkgs-ruby.url = "github:bobvanderlinden/nixpkgs-ruby"; + + outputs = { self, nixpkgs-ruby }: { + lib = { + hasVersion = { version, system ? builtins.currentSystem }: + builtins.hasAttr "ruby-${version}" nixpkgs-ruby.packages.${system}; + packageFromVersion = { version, system ? builtins.currentSystem }: + nixpkgs-ruby.packages.${system}."ruby-${version}"; + }; + }; +} diff --git a/tests/plugins/python/lib_test.nix b/tests/plugins/python/lib_test.nix index 6dfc56e..2b594a4 100644 --- a/tests/plugins/python/lib_test.nix +++ b/tests/plugins/python/lib_test.nix @@ -3,8 +3,18 @@ let in [ { - name = "When the version exists"; - actual = (lib.packageFromVersion { version = "3.12.0"; }).version; - expected = "3.12.0"; + name = "When the version exists returns true"; + actual = lib.hasVersion { version = "3.12.0"; }; + expected = true; + } + { + name = "When the version does not exist returns false"; + actual = lib.hasVersion { version = "0.0.0"; }; + expected = false; + } + { + name = "When the version exists returns a package"; + actual = (lib.packageFromVersion { version = "3.12.0"; }).name; + expected = "python3-3.12.0"; } ] diff --git a/tests/plugins/ruby/lib_test.nix b/tests/plugins/ruby/lib_test.nix new file mode 100644 index 0000000..43c8e1a --- /dev/null +++ b/tests/plugins/ruby/lib_test.nix @@ -0,0 +1,20 @@ +let + lib = (builtins.getFlake (builtins.toString ./../../../plugins/ruby)).lib; +in +[ + { + name = "When the version exists returns true"; + actual = lib.hasVersion { version = "3.2.2"; }; + expected = true; + } + { + name = "When the version does not exist returns false"; + actual = lib.hasVersion { version = "0.0.0"; }; + expected = false; + } + { + name = "When the version exists returns a package"; + actual = (lib.packageFromVersion { version = "3.2.2"; }).name; + expected = "ruby-3.2.2"; + } +]