Starting to add tool builder. Extracting bundler file computation.
This commit is contained in:
@@ -7,10 +7,10 @@
|
||||
{
|
||||
name
|
||||
, pname ? name
|
||||
, gemdir
|
||||
, gemfile
|
||||
, lockfile
|
||||
, gemset
|
||||
, gemdir
|
||||
, ruby ? defs.ruby
|
||||
, gemConfig ? defaultGemConfig
|
||||
, postBuild ? null
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
{ lib, gemConfig, ... }:
|
||||
rec {
|
||||
bundlerFiles = {
|
||||
gemfile ? null
|
||||
, lockfile ? null
|
||||
, gemset ? null
|
||||
, gemdir ? null
|
||||
, ...
|
||||
}: {
|
||||
gemfile =
|
||||
if gemfile == null then assert gemdir != null; gemdir + "/Gemfile"
|
||||
else gemfile;
|
||||
|
||||
lockfile =
|
||||
if lockfile == null then assert gemdir != null; gemdir + "/Gemfile.lock"
|
||||
else lockfile;
|
||||
|
||||
gemset =
|
||||
if gemset == null then assert gemdir != null; gemdir + "/gemset.nix"
|
||||
else gemset;
|
||||
};
|
||||
|
||||
filterGemset = {ruby, groups,...}@env: gemset: lib.filterAttrs (name: attrs: platformMatches ruby attrs && groupMatches groups attrs) gemset;
|
||||
|
||||
platformMatches = {rubyEngine, version, ...}@ruby: attrs: (
|
||||
|
||||
@@ -7,7 +7,34 @@ let
|
||||
functions = (import ./functions.nix testConfigs);
|
||||
in
|
||||
builtins.concatLists [
|
||||
(test.run "Filter empty gemset" {} (set: functions.filterGemset {inherit ruby; groups = ["default"]; } set == {}))
|
||||
( test.run "All set, no gemdir" (functions.bundlerFiles {
|
||||
gemfile = test/Gemfile;
|
||||
lockfile = test/Gemfile.lock;
|
||||
gemset = test/gemset.nix;
|
||||
}) {
|
||||
gemfile = should.equal test/Gemfile;
|
||||
lockfile = should.equal test/Gemfile.lock;
|
||||
gemset = should.equal test/gemset.nix;
|
||||
})
|
||||
|
||||
( test.run "Just gemdir" (functions.bundlerFiles {
|
||||
gemdir = test/.;
|
||||
}) {
|
||||
gemfile = should.equal test/Gemfile;
|
||||
lockfile = should.equal test/Gemfile.lock;
|
||||
gemset = should.equal test/gemset.nix;
|
||||
})
|
||||
|
||||
( test.run "Gemset and dir" (functions.bundlerFiles {
|
||||
gemdir = test/.;
|
||||
gemset = test/extraGemset.nix;
|
||||
}) {
|
||||
gemfile = should.equal test/Gemfile;
|
||||
lockfile = should.equal test/Gemfile.lock;
|
||||
gemset = should.equal test/extraGemset.nix;
|
||||
})
|
||||
|
||||
( test.run "Filter empty gemset" {} (set: functions.filterGemset {inherit ruby; groups = ["default"]; } set == {}))
|
||||
( let gemSet = { test = { groups = ["x" "y"]; }; };
|
||||
in
|
||||
test.run "Filter matches a group" gemSet (set: functions.filterGemset {inherit ruby; groups = ["y" "z"];} set == gemSet))
|
||||
|
||||
Reference in New Issue
Block a user