aboutsummaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-08-06 22:29:05 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-08-06 22:29:05 +0100
commit690f227d9efcbd1bf4e232591faf8b3885fc3b76 (patch)
treee8eef637815980649516ef49083e26d4fb48bb28 /ruby
parenta5a402331f246c81bdd14dea34639ec2f916928c (diff)
downloadpaludis-690f227d9efcbd1bf4e232591faf8b3885fc3b76.tar.gz
paludis-690f227d9efcbd1bf4e232591faf8b3885fc3b76.tar.xz
Better tracking of choice origins
Diffstat (limited to 'ruby')
-rw-r--r--ruby/choice.cc45
-rw-r--r--ruby/choice_TEST.rb8
2 files changed, 35 insertions, 18 deletions
diff --git a/ruby/choice.cc b/ruby/choice.cc
index be9209c68..5d91379a3 100644
--- a/ruby/choice.cc
+++ b/ruby/choice.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 2011 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -30,6 +30,7 @@ namespace
static VALUE c_choice;
static VALUE c_choices;
static VALUE c_choice_value;
+ static VALUE c_choice_origin;
/*
* call-seq:
@@ -296,17 +297,6 @@ namespace
*/
FAKE_RDOC_METHOD(choice_value_locked)
- /*
- * call-seq:
- * explicitly_listed? -> true or false
- *
- * Is this flag explicitly listed?
- *
- * Use this to avoid showing things like LINGUAS values that aren't listed
- * in IUSE but that end up as a ChoiceValue anyway.
- */
- FAKE_RDOC_METHOD(choice_value_explicitly_listed)
-
template <typename R_, R_ (ChoiceValue::* r_) () const>
struct ChoiceValueBoolishMembers
{
@@ -324,6 +314,22 @@ namespace
}
};
+ /*
+ * call-seq:
+ * origin? -> ChoiceOrigin
+ *
+ * Is this flag explicitly listed?
+ *
+ * Use this to avoid showing things like LINGUAS values that aren't listed
+ * in IUSE but that end up as a ChoiceValue anyway.
+ */
+ VALUE
+ choice_value_origin(VALUE self_v)
+ {
+ std::shared_ptr<const ChoiceValue> self(value_to_choice_value(self_v));
+ return INT2FIX(self->origin());
+ }
+
void do_register_choice()
{
/*
@@ -363,6 +369,18 @@ namespace
rb_include_module(c_choice, rb_mEnumerable);
/*
+ * Document-module: Paludis::ChoiceOrigin
+ *
+ * The origin of a Choice
+ */
+ c_choice_origin = rb_define_module_under(paludis_module(), "ChoiceOrigin");
+ for (ChoiceOrigin l(static_cast<ChoiceOrigin>(0)), l_end(last_co) ; l != l_end ;
+ l = static_cast<ChoiceOrigin>(static_cast<int>(l) + 1))
+ rb_define_const(c_choice_origin, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
+
+ // cc_enum_special<paludis/choice.hh, ChoiceOrigin, c_choice_origin>
+
+ /*
* Document-class: Paludis::ChoiceValue
*
* A single ChoiceValue object for a Choice.
@@ -381,8 +399,7 @@ namespace
(&ChoiceValueBoolishMembers<bool, &ChoiceValue::locked>::fetch)), 0);
rb_define_method(c_choice_value, "description", RDOC_IS_STUPID(choice_value_description,
(&ChoiceValueStringishMembers<std::string, &ChoiceValue::description>::fetch)), 0);
- rb_define_method(c_choice_value, "explicitly_listed?", RDOC_IS_STUPID(choice_value_explicitly_listed,
- (&ChoiceValueBoolishMembers<bool, &ChoiceValue::explicitly_listed>::fetch)), 0);
+ rb_define_method(c_choice_value, "origin", RUBY_FUNC_CAST(&choice_value_origin), 0);
}
}
diff --git a/ruby/choice_TEST.rb b/ruby/choice_TEST.rb
index 782f36778..886275a21 100644
--- a/ruby/choice_TEST.rb
+++ b/ruby/choice_TEST.rb
@@ -194,10 +194,10 @@ module Paludis
assert_equal "", linguas_en.description
end
- def test_explicitly_listed
- assert use_flag1.explicitly_listed?
- assert use_flag2.explicitly_listed?
- assert linguas_en.explicitly_listed?
+ def test_choice_origin
+ assert_equal ChoiceOrigin::Explicit, use_flag1.origin
+ assert_equal ChoiceOrigin::Explicit, use_flag2.origin
+ assert_equal ChoiceOrigin::Explicit, linguas_en.origin
end
end
end