aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2011-10-01 13:14:04 +0100
committerAvatar David Leverton <levertond@googlemail.com> 2011-10-01 17:55:11 +0100
commit269259dd03f9b096aebf8027b4e139f32e18b71d (patch)
treef43d1258e647af2ccfa55d03bf01c6dc946316d5
parentd1a2b50c7d803c8cbe4af8e06e829d6dbbf01634 (diff)
downloadpaludis-269259dd03f9b096aebf8027b4e139f32e18b71d.tar.gz
paludis-269259dd03f9b096aebf8027b4e139f32e18b71d.tar.xz
(ruby) Expose mask tokens
-rw-r--r--ruby/mask.cc11
-rw-r--r--ruby/package_id_TEST.rb12
-rwxr-xr-xruby/package_id_TEST_setup.sh41
3 files changed, 64 insertions, 0 deletions
diff --git a/ruby/mask.cc b/ruby/mask.cc
index a08a370..a60757b 100644
--- a/ruby/mask.cc
+++ b/ruby/mask.cc
@@ -130,6 +130,13 @@ namespace
* Fetch the name of the metadata key that is not accepted.
*/
/*
+ * Document-method: token
+ * call-seq:
+ * token -> String
+ *
+ * An associated token. Might be empty.
+ */
+ /*
* Document-method: mask_key
*
* call-seq:
@@ -202,6 +209,8 @@ namespace
* A UserMask is a Mask due to user configuration.
*/
c_user_mask = rb_define_class_under(paludis_module(), "UserMask", c_mask);
+ rb_define_method(c_user_mask, "token",
+ RUBY_FUNC_CAST((&MaskMetadataKey<UserMask,&UserMask::token>::fetch)), 0);
/*
* Document-class: Paludis::UnacceptedMask
@@ -219,6 +228,8 @@ namespace
* A RepositoryMask is a Mask that signifies that a PackageID has been marked as masked by a Repository.
*/
c_repository_mask = rb_define_class_under(paludis_module(), "RepositoryMask", c_mask);
+ rb_define_method(c_repository_mask, "token",
+ RUBY_FUNC_CAST((&MaskMetadataKey<RepositoryMask,&RepositoryMask::token>::fetch)), 0);
/*
* Document-class: Paludis::UnsupportedMask
diff --git a/ruby/package_id_TEST.rb b/ruby/package_id_TEST.rb
index 2ef7ab6..ebe57f3 100644
--- a/ruby/package_id_TEST.rb
+++ b/ruby/package_id_TEST.rb
@@ -42,6 +42,10 @@ module Paludis
env.fetch_repository("testrepo").package_ids("bad/pkg").first
end
+ def pid_scm
+ env.fetch_repository("exheresrepo").package_ids("scm/scm").first
+ end
+
def pid_installed
env.fetch_repository("installed").package_ids("cat-one/pkg-one").first
end
@@ -186,6 +190,14 @@ module Paludis
assert_equal MaskOverrideReason::AcceptedUnstable, mask.override_reason
end
+ def test_mask_tokens
+ masks = pid_scm.masks
+ assert_equal 1, masks.length
+ mask = masks.first
+ assert_kind_of RepositoryMask, mask
+ assert_equal "scm", mask.token
+ end
+
def test_hash
a = pid_testrepo
b = pid_testrepo
diff --git a/ruby/package_id_TEST_setup.sh b/ruby/package_id_TEST_setup.sh
index e71cda8..4f8b5d0 100755
--- a/ruby/package_id_TEST_setup.sh
+++ b/ruby/package_id_TEST_setup.sh
@@ -15,6 +15,15 @@ profiles = \${location}/profiles/testprofile
builddir = `pwd`
END
+cat <<END > home/.paludis/repositories/exheresrepo.conf
+location = `pwd`/exheresrepo
+format = e
+names_cache = /var/empty
+cache = /var/empty
+profiles = \${location}/profiles/testprofile
+builddir = `pwd`
+END
+
cat <<END > home/.paludis/repositories/installed.conf
location = `pwd`/installed
format = vdb
@@ -85,6 +94,38 @@ END
cd ..
+mkdir -p exheresrepo/{exlibs,metadata,profiles/testprofile,packages/scm/scm/files} || exit 1
+cd exheresrepo || exit 1
+echo "exheresrepo" > profiles/repo_name || exit 1
+cat <<END > metadata/categories.conf || exit 1
+scm
+END
+cat <<END > metadata/layout.conf
+layout = exheres
+eapi_when_unknown = exheres-0
+eapi_when_unspecified = exheres-0
+profile_eapi_when_unspecified = exheres-0
+END
+cat <<END > metadata/profiles_desc.conf
+test testprofile stable
+END
+cat <<END > metadata/repository_mask.conf
+scm/scm[=scm] [[ token = scm ]]
+END
+
+cat <<"END" > packages/scm/scm/scm-scm.exheres-0 || exit 1
+SUMMARY="Test package"
+HOMEPAGE="http://paludis.pioto.org/"
+DOWNLOADS=""
+SLOT="0"
+MYOPTIONS="testflag"
+LICENCES="GPL-2"
+PLATFORMS="test"
+DEPENDENCIES="build: foo/bar"
+END
+
+cd ..
+
mkdir -p installed/cat-one/pkg-{one,two}-1 || exit 1
echo "cat-one" > installed/cat-one/pkg-one-1/CATEGORY