aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2007-01-11 16:26:02 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2007-01-11 16:26:02 +0000
commit83034e2a37c52db73e4f911434c3a833205be9ad (patch)
treedcc5d1660a1e197e42d346bb822f9a52b5a8ad21
parent55617bb7616fdd51f9235153d1864de2e0ab7153 (diff)
downloadpaludis-83034e2a37c52db73e4f911434c3a833205be9ad.tar.gz
paludis-83034e2a37c52db73e4f911434c3a833205be9ad.tar.xz
Bring ruby DepList up to date.
-rw-r--r--doc/create_ruby_doc.rb2
-rw-r--r--paludis/dep_list/options.cc74
-rw-r--r--paludis/dep_list/options.hh16
-rw-r--r--paludis/mask_reasons.hh2
-rw-r--r--ruby/check_result.cc2
-rw-r--r--ruby/dep_list.cc126
-rw-r--r--ruby/dep_list_TEST.rb8
-rw-r--r--ruby/environment_TEST.rb5
-rw-r--r--ruby/mask_reasons.cc84
-rw-r--r--ruby/mask_reasons_TEST.rb11
-rw-r--r--ruby/message.cc2
-rw-r--r--ruby/paludis_ruby.cc2
-rw-r--r--ruby/paludis_ruby.hh1
13 files changed, 295 insertions, 40 deletions
diff --git a/doc/create_ruby_doc.rb b/doc/create_ruby_doc.rb
index 0231469..0ae6f85 100644
--- a/doc/create_ruby_doc.rb
+++ b/doc/create_ruby_doc.rb
@@ -61,7 +61,7 @@ module RDoc
$1.split(',').each do |line|
next if line =~/last/
const = line.sub(%r{^[^_]+_},'').capitalize #strip start
- const.gsub!(%r{_(\w)}) { |x| $1.capitalize}
+ const.gsub!(%r{[_\s](\w)}) { |x| $1.capitalize}
consts << "rb_define_const(#{in_class}, \"#{const}\", #{i});"
i+=1
end
diff --git a/paludis/dep_list/options.cc b/paludis/dep_list/options.cc
index 24bcb00..9a19852 100644
--- a/paludis/dep_list/options.cc
+++ b/paludis/dep_list/options.cc
@@ -252,6 +252,35 @@ paludis::operator<< (std::ostream & o, const DepListCircularOption & s)
}
std::ostream &
+paludis::operator<< (std::ostream & o, const DepListBlocksOption & s)
+{
+ do
+ {
+ switch (s)
+ {
+ case dl_blocks_accumulate:
+ o << "blocks_accumulate";
+ continue;
+
+ case dl_blocks_error:
+ o << "blocks_error";
+ continue;
+
+ case dl_blocks_discard:
+ o << "blocks_discard";
+ continue;
+
+ case last_dl_blocks:
+ ;
+ }
+
+ throw InternalError(PALUDIS_HERE, "Bad DepListBlocksOption");
+ } while (false);
+
+ return o;
+}
+
+std::ostream &
paludis::operator<< (std::ostream & o, const DepListEntryState & s)
{
do
@@ -280,3 +309,48 @@ paludis::operator<< (std::ostream & o, const DepListEntryState & s)
return o;
}
+std::ostream &
+paludis::operator<< (std::ostream & o, const DepListEntryKind & s)
+{
+ do
+ {
+ switch (s)
+ {
+ case dlk_package:
+ o << "package";
+ continue;
+
+ case dlk_subpackage:
+ o << "sub_package";
+ continue;
+
+ case dlk_already_installed:
+ o << "already_installed";
+ continue;
+
+ case dlk_virtual:
+ o << "virtual";
+ continue;
+
+ case dlk_provided:
+ o << "provided";
+ continue;
+
+ case dlk_block:
+ o << "block";
+ continue;
+
+ case dlk_masked:
+ o << "masked";
+ continue;
+
+ case last_dlk:
+ ;
+ }
+
+ throw InternalError(PALUDIS_HERE, "Bad DepListEntryKind");
+ } while (false);
+
+ return o;
+}
+
diff --git a/paludis/dep_list/options.hh b/paludis/dep_list/options.hh
index e2d48d5..53481b5 100644
--- a/paludis/dep_list/options.hh
+++ b/paludis/dep_list/options.hh
@@ -236,12 +236,28 @@ namespace paludis
operator<< (std::ostream &, const DepListCircularOption &) PALUDIS_VISIBLE;
/**
+ * Write a DepListCircularOption to a stream.
+ *
+ * \ingroup grpdepresolver
+ */
+ std::ostream &
+ operator<< (std::ostream &, const DepListBlocksOption &) PALUDIS_VISIBLE;
+
+ /**
* Write a DepListEntryState to a stream.
*
* \ingroup grpdepresolver
*/
std::ostream &
operator<< (std::ostream &, const DepListEntryState &) PALUDIS_VISIBLE;
+
+ /**
+ * Write a DepListEntryKind to a stream.
+ *
+ * \ingroup grpdepresolver
+ */
+ std::ostream &
+ operator<< (std::ostream &, const DepListEntryKind &) PALUDIS_VISIBLE;
}
#endif
diff --git a/paludis/mask_reasons.hh b/paludis/mask_reasons.hh
index 699fc6f..c065475 100644
--- a/paludis/mask_reasons.hh
+++ b/paludis/mask_reasons.hh
@@ -46,9 +46,9 @@ namespace paludis
mr_profile_mask, ///< profile package.mask
mr_repository_mask, ///< repository package.mask
mr_eapi, ///< unknown eapi
+ mr_by_association, ///< masked by association with another package (for virtuals)
mr_license, ///< unaccepted license
mr_licence = mr_license, ///< convenience alias for those who can spell,
- mr_by_association, ///< masked by association with another package (for virtuals)
last_mr ///< number of entries
};
diff --git a/ruby/check_result.cc b/ruby/check_result.cc
index 15d865b..5564bef 100644
--- a/ruby/check_result.cc
+++ b/ruby/check_result.cc
@@ -88,7 +88,7 @@ namespace
{
CheckResult * ptr;
Data_Get_Struct(self, CheckResult, ptr);
- return INT2NUM((ptr)->most_severe_level());
+ return INT2FIX((ptr)->most_severe_level());
}
VALUE
diff --git a/ruby/dep_list.cc b/ruby/dep_list.cc
index c63c983..3ecafa0 100644
--- a/ruby/dep_list.cc
+++ b/ruby/dep_list.cc
@@ -36,7 +36,9 @@ namespace
static VALUE c_dep_list_new_slots_option;
static VALUE c_dep_list_deps_option;
static VALUE c_dep_list_circular_option;
+ static VALUE c_dep_list_blocks_option;
static VALUE c_dep_list_entry_state;
+ static VALUE c_dep_list_entry_kind;
static VALUE c_dep_list_options;
static VALUE c_dep_list;
static VALUE c_dep_list_entry;
@@ -69,10 +71,9 @@ namespace
return self;
}
-#ifdef CIARANM_TURNED_THIS_OFF
/*
* call-seq:
- * DepListOptions.new(reinstall, reinstall_scm, target_type, upgrade, new_slots, fall_back, installed_deps_prem installed_deps_runtime, installed_deps_post, uninstalled_deps_pre, uninstalled_deps_runtime, uninstalled_deps_post, circular, dependency_tags) -> DepListOptions
+ * DepListOptions.new(reinstall, reinstall_scm, target_type, upgrade, new_slots, fall_back, installed_deps_prem installed_deps_runtime, installed_deps_post, uninstalled_deps_pre, uninstalled_deps_runtime, uninstalled_deps_post, circular, blocks, dependency_tags) -> DepListOptions
* DepListOptions.new(Hash) -> DepListOptions
*
* DepListOptions.new can either be called with all parameters in order, or with one hash parameter, where the hash keys are symbols with the names above.
@@ -96,6 +97,8 @@ namespace
int value_for_uninstalled_deps_runtime;
int value_for_uninstalled_deps_post;
int value_for_circular;
+ int value_for_blocks;
+ MaskReasons value_for_override_mask_reasons;
bool value_for_dependency_tags;
if (1 == argc && rb_obj_is_kind_of(argv[0], rb_cHash))
@@ -126,6 +129,10 @@ namespace
rb_raise(rb_eArgError, "Missing Parameter: uninstalled_deps_post");
if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("circular"))))
rb_raise(rb_eArgError, "Missing Parameter: circular");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("blocks"))))
+ rb_raise(rb_eArgError, "Missing Parameter: blocks");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("override_mask_reasons"))))
+ rb_raise(rb_eArgError, "Missing Parameter: override_mask_reasons");
if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("dependency_tags"))))
rb_raise(rb_eArgError, "Missing Parameter: dependency_tags");
value_for_reinstall =
@@ -154,10 +161,15 @@ namespace
NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("uninstalled_deps_post"))));
value_for_circular =
NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("circular"))));
+ value_for_blocks =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("blocks"))));
+ value_for_override_mask_reasons = value_to_mask_reasons(
+ rb_hash_aref(argv[0], ID2SYM(rb_intern("override_mask_reasons")))
+ );
value_for_dependency_tags =
Qtrue == (rb_hash_aref(argv[0], ID2SYM(rb_intern("dependency_tags")))) ? true : false;
}
- else if (14 == argc)
+ else if (16 == argc)
{
value_for_reinstall = NUM2INT(argv[0]);
value_for_reinstall_scm = NUM2INT(argv[1]);
@@ -172,7 +184,9 @@ namespace
value_for_uninstalled_deps_runtime = NUM2INT(argv[10]);
value_for_uninstalled_deps_post = NUM2INT(argv[11]);
value_for_circular = NUM2INT(argv[12]);
- value_for_dependency_tags = Qtrue == argv[13] ? true : false;
+ value_for_blocks = NUM2INT(argv[13]);
+ value_for_override_mask_reasons = value_to_mask_reasons(argv[14]);
+ value_for_dependency_tags = Qtrue == argv[15] ? true : false;
}
else
{
@@ -205,6 +219,8 @@ namespace
rb_raise(rb_eArgError, "uninstalled_deps_post out of range");
if (value_for_circular < 0 || value_for_circular >= last_dl_circular)
rb_raise(rb_eArgError, "circular out of range");
+ if (value_for_circular < 0 || value_for_blocks >= last_dl_blocks)
+ rb_raise(rb_eArgError, "blocks out of range");
ptr = new DepListOptions(static_cast<DepListReinstallOption>(value_for_reinstall),
static_cast<DepListReinstallScmOption>(value_for_reinstall_scm),
@@ -219,6 +235,8 @@ namespace
static_cast<DepListDepsOption>(value_for_uninstalled_deps_runtime),
static_cast<DepListDepsOption>(value_for_uninstalled_deps_post),
static_cast<DepListCircularOption>(value_for_circular),
+ static_cast<DepListBlocksOption>(value_for_blocks),
+ value_for_override_mask_reasons,
value_for_dependency_tags
);
@@ -232,7 +250,6 @@ namespace
exception_to_ruby_exception(e);
}
}
-#endif
/*
* Document-method: reinstall
@@ -346,12 +363,26 @@ namespace
{
DepListOptions * p;
Data_Get_Struct(self, DepListOptions, p);
- return INT2NUM(p->*m_);
+ return INT2FIX(p->*m_);
}
};
/*
* call-seq:
+ * override_mask_reasons -> MaskReasons
+ *
+ * Our override MaskReasons.
+ */
+ VALUE
+ dep_list_options_mask_reasons(VALUE self)
+ {
+ DepListOptions * p;
+ Data_Get_Struct(self, DepListOptions, p);
+ return mask_reasons_to_value(p->override_mask_reasons);
+ }
+
+ /*
+ * call-seq:
* dependancy_tags -> true or false
*
* Out dependency_tags
@@ -471,6 +502,27 @@ namespace
/*
* call-seq:
+ * entry_state -> DepListEntryState
+ *
+ * Our DepListEntryState.
+ */
+ VALUE
+ dep_list_entry_kind(VALUE self)
+ {
+ try
+ {
+ DepListEntry * p;
+ Data_Get_Struct(self, DepListEntry, p);
+ return INT2FIX(p->kind);
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
* package -> PackageDatabaseEntry
*
* Our PackageDatabaseEntry.
@@ -551,7 +603,7 @@ namespace
{
DepListEntry * p;
Data_Get_Struct(self, DepListEntry, p);
- return INT2NUM(p->state);
+ return INT2FIX(p->state);
}
catch (const std::exception & e)
{
@@ -572,7 +624,7 @@ namespace
l = static_cast<DepListTargetType>(static_cast<int>(l) + 1))
rb_define_const(c_dep_list_target_type, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
- // cc_enum_special<paludis/dep_list/dep_list.hh, DepListTargetType, c_dep_list_target_type>
+ // cc_enum_special<paludis/dep_list/options.hh, DepListTargetType, c_dep_list_target_type>
/*
* Document-module: Paludis::DepListReinstallOption
@@ -585,7 +637,7 @@ namespace
l = static_cast<DepListReinstallOption>(static_cast<int>(l) + 1))
rb_define_const(c_dep_list_reinstall_option, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
- // cc_enum_special<paludis/dep_list/dep_list.hh, DepListReinstallOption, c_dep_list_reinstall_option>
+ // cc_enum_special<paludis/dep_list/options.hh, DepListReinstallOption, c_dep_list_reinstall_option>
/*
* Document-module: Paludis::DepListFallBackOption
@@ -598,7 +650,7 @@ namespace
l = static_cast<DepListFallBackOption>(static_cast<int>(l) + 1))
rb_define_const(c_dep_list_fall_back_option, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
- // cc_enum_special<paludis/dep_list/dep_list.hh, DepListFallBackOption, c_dep_list_fall_back_option>
+ // cc_enum_special<paludis/dep_list/options.hh, DepListFallBackOption, c_dep_list_fall_back_option>
/*
* Document-module: Paludis::DepListReinstallScmOption
@@ -611,7 +663,7 @@ namespace
l = static_cast<DepListReinstallScmOption>(static_cast<int>(l) + 1))
rb_define_const(c_dep_list_reinstall_scm_option, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
- // cc_enum_special<paludis/dep_list/dep_list.hh, DepListReinstalScmlOption, c_dep_list_reinstall_scm_option>
+ // cc_enum_special<paludis/dep_list/options.hh, DepListReinstalScmlOption, c_dep_list_reinstall_scm_option>
/*
* Document-module: Paludis::DepListUpgradeOption
@@ -624,7 +676,7 @@ namespace
l = static_cast<DepListUpgradeOption>(static_cast<int>(l) + 1))
rb_define_const(c_dep_list_upgrade_option, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
- // cc_enum_special<paludis/dep_list/dep_list.hh, DepListUpgradeOption, c_dep_list_upgrade_option>
+ // cc_enum_special<paludis/dep_list/options.hh, DepListUpgradeOption, c_dep_list_upgrade_option>
/*
* Document-module: Paludis::DepListNewSlotsOption
@@ -637,7 +689,7 @@ namespace
l = static_cast<DepListNewSlotsOption>(static_cast<int>(l) + 1))
rb_define_const(c_dep_list_new_slots_option, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
- // cc_enum_special<paludis/dep_list/dep_list.hh, DepListNewSlotsOption, c_dep_list_new_slots_option>
+ // cc_enum_special<paludis/dep_list/options.hh, DepListNewSlotsOption, c_dep_list_new_slots_option>
/*
* Document-module: Paludis::DepListDepsOption
@@ -650,7 +702,7 @@ namespace
l = static_cast<DepListDepsOption>(static_cast<int>(l) + 1))
rb_define_const(c_dep_list_deps_option, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
- // cc_enum_special<paludis/dep_list/dep_list.hh, DepListDepsOption, c_dep_list_deps_option>
+ // cc_enum_special<paludis/dep_list/options.hh, DepListDepsOption, c_dep_list_deps_option>
/*
* Document-module: Paludis::DepListCircularOption
@@ -663,7 +715,20 @@ namespace
l = static_cast<DepListCircularOption>(static_cast<int>(l) + 1))
rb_define_const(c_dep_list_circular_option, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
- // cc_enum_special<paludis/dep_list/dep_list.hh, DepListCircularOption, c_dep_list_circular_option>
+ // cc_enum_special<paludis/dep_list/options.hh, DepListCircularOption, c_dep_list_circular_option>
+
+ /*
+ * Document-module: Paludis::DepListBlocksOption
+ *
+ * How we handle blocks.
+ *
+ */
+ c_dep_list_blocks_option = rb_define_module_under(paludis_module(), "DepListBlocksOption");
+ for (DepListBlocksOption l(static_cast<DepListBlocksOption>(0)), l_end(last_dl_blocks) ; l != l_end ;
+ l = static_cast<DepListBlocksOption>(static_cast<int>(l) + 1))
+ rb_define_const(c_dep_list_blocks_option, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
+
+ // cc_enum_special<paludis/dep_list/options.hh, DepListBlocksOption, c_dep_list_blocks_option>
/*
* Document-module: Paludis::DepListEntryState
@@ -671,12 +736,25 @@ namespace
* State of a DepListEntry.
*
*/
- c_dep_list_entry_state= rb_define_module_under(paludis_module(), "DepListEntryState");
+ c_dep_list_entry_state = rb_define_module_under(paludis_module(), "DepListEntryState");
for (DepListEntryState l(static_cast<DepListEntryState>(0)), l_end(last_dle) ; l != l_end ;
l = static_cast<DepListEntryState>(static_cast<int>(l) + 1))
rb_define_const(c_dep_list_entry_state, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
- // cc_enum_special<paludis/dep_list/dep_list.hh, DepListEntryState, c_dep_list_entry_state>
+ // cc_enum_special<paludis/dep_list/options.hh, DepListEntryState, c_dep_list_entry_state>
+
+ /*
+ * Document-module: Paludis::DepListEntryKind
+ *
+ * Kind of a DepListEntry.
+ *
+ */
+ c_dep_list_entry_kind = rb_define_module_under(paludis_module(), "DepListEntryKind");
+ for (DepListEntryKind l(static_cast<DepListEntryKind>(0)), l_end(last_dlk) ; l != l_end ;
+ l = static_cast<DepListEntryKind>(static_cast<int>(l) + 1))
+ rb_define_const(c_dep_list_entry_kind, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
+
+ // cc_enum_special<paludis/dep_list/options.hh, DepListEntryKind, c_dep_list_entry_kind>
/*
* Document-class: Paludis::DepListOptions
@@ -684,11 +762,7 @@ namespace
* Parameters for a DepList.
*/
c_dep_list_options = rb_define_class_under(paludis_module(), "DepListOptions", rb_cObject);
-#ifdef CIARANM_TURNED_THIS_OFF
rb_define_singleton_method(c_dep_list_options, "new", RUBY_FUNC_CAST(&dep_list_options_new), -1);
-#else
- rb_funcall(c_dep_list_options, rb_intern("private_class_method"), 1, rb_str_new2("new"));
-#endif
rb_define_method(c_dep_list_options, "initialize", RUBY_FUNC_CAST(&dep_list_options_init), -1);
rb_define_method(c_dep_list_options, "reinstall",
RUBY_FUNC_CAST((&OptionsMember<DepListReinstallOption, &DepListOptions::reinstall>::fetch)),0);
@@ -716,7 +790,12 @@ namespace
RUBY_FUNC_CAST((&OptionsMember<DepListDepsOption, &DepListOptions::installed_deps_post>::fetch)),0);
rb_define_method(c_dep_list_options, "circular",
RUBY_FUNC_CAST((&OptionsMember<DepListCircularOption, &DepListOptions::circular>::fetch)),0);
+ rb_define_method(c_dep_list_options, "blocks",
+ RUBY_FUNC_CAST((&OptionsMember<DepListBlocksOption, &DepListOptions::blocks>::fetch)),0);
+ rb_define_method(c_dep_list_options, "ovveride_mask_reasons",
+ RUBY_FUNC_CAST((&OptionsMember<DepListBlocksOption, &DepListOptions::blocks>::fetch)),0);
+ rb_define_method(c_dep_list_options, "override_mask_reasons", RUBY_FUNC_CAST(&dep_list_options_mask_reasons),0);
rb_define_method(c_dep_list_options, "dependency_tags", RUBY_FUNC_CAST(&dep_list_options_dependency_tags),0);
/*
@@ -726,11 +805,7 @@ namespace
* but not Comparable.
*/
c_dep_list= rb_define_class_under(paludis_module(), "DepList", rb_cObject);
-#ifdef CIARANM_TURNED_THIS_OFF
rb_define_singleton_method(c_dep_list, "new", RUBY_FUNC_CAST(&dep_list_new), -1);
-#else
- rb_funcall(c_dep_list, rb_intern("private_class_method"), 1, rb_str_new2("new"));
-#endif
rb_define_method(c_dep_list, "initialize", RUBY_FUNC_CAST(&dep_list_init), -1);
rb_define_method(c_dep_list, "add", RUBY_FUNC_CAST(&dep_list_add), 1);
rb_define_method(c_dep_list, "clear", RUBY_FUNC_CAST(&dep_list_clear), 0);
@@ -745,6 +820,7 @@ namespace
*/
c_dep_list_entry = rb_define_class_under(paludis_module(), "DepListEntry", rb_cObject);
rb_funcall(c_dep_list_entry, rb_intern("private_class_method"), 1, rb_str_new2("new"));
+ rb_define_method(c_dep_list_entry, "kind", RUBY_FUNC_CAST(&dep_list_entry_kind),0);
rb_define_method(c_dep_list_entry, "package", RUBY_FUNC_CAST(&dep_list_entry_package),0);
rb_define_method(c_dep_list_entry, "metadata", RUBY_FUNC_CAST(&dep_list_entry_metadata),0);
rb_define_method(c_dep_list_entry, "destinations", RUBY_FUNC_CAST(&dep_list_entry_destinations),0);
diff --git a/ruby/dep_list_TEST.rb b/ruby/dep_list_TEST.rb
index b1a20ec..b4bd238 100644
--- a/ruby/dep_list_TEST.rb
+++ b/ruby/dep_list_TEST.rb
@@ -18,9 +18,6 @@
# Place, Suite 330, Boston, MA 02111-1307 USA
#
-# CIARANM_TURNED_THIS_OFF
-exit 0
-
ENV['PALUDIS_HOME'] = Dir.getwd() + '/dep_list_TEST_dir/home'
require 'test/unit'
@@ -45,6 +42,8 @@ module Paludis
DepListDepsOption::DepsDiscard,
DepListDepsOption::DepsDiscard,
DepListCircularOption::CircularDiscard,
+ DepListBlocksOption::BlocksError,
+ MaskReasons.new,
false
)
end
@@ -64,6 +63,8 @@ module Paludis
:uninstalled_deps_runtime => DepListDepsOption::DepsDiscard,
:uninstalled_deps_post => DepListDepsOption::DepsDiscard,
:circular => DepListCircularOption::CircularDiscard,
+ :blocks => DepListBlocksOption::BlocksError,
+ :override_mask_reasons => MaskReasons.new,
:dependency_tags => false
}
end
@@ -102,6 +103,7 @@ module Paludis
options = dlo
options_hash.each_pair do |method, value|
assert_respond_to options, method
+# next if method == :override_mask_reasons
assert_equal value, options.send(method)
end
end
diff --git a/ruby/environment_TEST.rb b/ruby/environment_TEST.rb
index acbc28a..6ebf18a 100644
--- a/ruby/environment_TEST.rb
+++ b/ruby/environment_TEST.rb
@@ -26,7 +26,6 @@ require 'Paludis'
Paludis::Log.instance.log_level = Paludis::LogLevel::Warning
module Paludis
-
class TestCase_DefaultEnvironment < Test::Unit::TestCase
def test_instance
assert_equal DefaultEnvironment.instance.__id__, DefaultEnvironment.instance.__id__
@@ -230,8 +229,8 @@ module Paludis
m = env.mask_reasons(p)
assert ! m.empty?
- assert m.include?("keyword")
- assert_equal ["keyword"], m.to_a
+ assert m.include?(MaskReason::Keyword)
+ assert_equal([MaskReason::Keyword], m.to_a)
end
def test_mask_reasons_no_such_repo
diff --git a/ruby/mask_reasons.cc b/ruby/mask_reasons.cc
index 73c0d6c..8fa8279 100644
--- a/ruby/mask_reasons.cc
+++ b/ruby/mask_reasons.cc
@@ -30,6 +30,7 @@ using namespace paludis::ruby;
namespace
{
static VALUE c_mask_reasons;
+ static VALUE c_mask_reason;
VALUE
mask_reasons_init(VALUE self)
@@ -57,7 +58,7 @@ namespace
/*
* call-seq:
- * each {|mask_reason| block }
+ * each {|mask_reason| block } -> Nil
*
* Iterate through the mask reasons.
*/
@@ -69,8 +70,8 @@ namespace
for (MaskReason i(static_cast<MaskReason>(0)), i_end(last_mr) ; i != i_end ;
i = static_cast<MaskReason>(static_cast<int>(i) + 1))
if ((*m_ptr)[i])
- rb_yield(rb_str_new2(stringify(i).c_str()));
- return self;
+ rb_yield(INT2FIX(i));
+ return Qnil;
}
/*
@@ -87,6 +88,54 @@ namespace
return m_ptr->any() ? Qfalse : Qtrue;
}
+ /*
+ * call-seq:
+ * set(mask_reason) -> Nil
+ *
+ * Add MaskReason to collection.
+ */
+ VALUE
+ mask_reasons_set(VALUE self, VALUE mask_reason)
+ {
+ MaskReasons * m_ptr;
+ Data_Get_Struct(self, MaskReasons, m_ptr);
+ try
+ {
+ int mr = NUM2INT(mask_reason);
+ if (mr < 0 || mr >= last_mr)
+ rb_raise(rb_eArgError, "MaskReason out of range");
+ m_ptr->set(mr);
+ return Qnil;
+
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
+ * == other_mask_reason -> True or False
+ *
+ * Are two MaskReasons equal
+ */
+ VALUE
+ mask_reasons_equal(VALUE self, VALUE other)
+ {
+ MaskReasons * m_ptr;
+ Data_Get_Struct(self, MaskReasons, m_ptr);
+ try
+ {
+ MaskReasons mr = value_to_mask_reasons(other);
+ return (*m_ptr) == mr ? Qtrue : Qfalse;
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
void do_register_mask_reasons()
{
/*
@@ -102,6 +151,20 @@ namespace
rb_define_method(c_mask_reasons, "each", RUBY_FUNC_CAST(&mask_reasons_each), 0);
rb_include_module(c_mask_reasons, rb_mEnumerable);
rb_define_method(c_mask_reasons, "empty?", RUBY_FUNC_CAST(&mask_reasons_empty), 0);
+ rb_define_method(c_mask_reasons, "set", RUBY_FUNC_CAST(&mask_reasons_set), 1);
+ rb_define_method(c_mask_reasons, "==", RUBY_FUNC_CAST(&mask_reasons_equal), 1);
+
+ /*
+ * Document-module: Paludis::MaskReason
+ *
+ * Each value represents one reason for a package being masked.
+ */
+ c_mask_reason = rb_define_module_under(paludis_module(), "MaskReason");
+ for (MaskReason l(static_cast<MaskReason>(0)), l_end(last_mr) ; l != l_end ;
+ l = static_cast<MaskReason>(static_cast<int>(l) + 1))
+ rb_define_const(c_mask_reason, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
+
+ // cc_enum_special<paludis/mask_reasons.hh, MaskReason, c_mask_reason>
}
}
@@ -111,6 +174,21 @@ paludis::ruby::mask_reasons_to_value(const MaskReasons & m)
return Data_Wrap_Struct(c_mask_reasons, 0, &Common<MaskReasons>::free, new MaskReasons(m));
}
+MaskReasons
+paludis::ruby::value_to_mask_reasons(VALUE v)
+{
+ if (rb_obj_is_kind_of(v, c_mask_reasons))
+ {
+ MaskReasons * v_ptr;
+ Data_Get_Struct(v, MaskReasons, v_ptr);
+ return *v_ptr;
+ }
+ else
+ {
+ rb_raise(rb_eTypeError, "Can't convert %s into MaskReasons", rb_obj_classname(v));
+ }
+}
+
RegisterRubyClass::Register paludis_ruby_register_mask_reasons PALUDIS_ATTRIBUTE((used))
(&do_register_mask_reasons);
diff --git a/ruby/mask_reasons_TEST.rb b/ruby/mask_reasons_TEST.rb
index 748f50b..0a82998 100644
--- a/ruby/mask_reasons_TEST.rb
+++ b/ruby/mask_reasons_TEST.rb
@@ -23,7 +23,6 @@ require 'Paludis'
module Paludis
class TestCase_MaskReasons < Test::Unit::TestCase
-
def test_create
m = MaskReasons.new
end
@@ -38,6 +37,16 @@ module Paludis
assert m.empty?
end
+ def test_set
+ m = MaskReasons.new
+ m.set MaskReason::Keyword
+ m.set MaskReason::ProfileMask
+
+ assert ! m.empty?
+
+ assert m.include?(MaskReason::Keyword)
+ assert m.include?(MaskReason::ProfileMask)
+ end
end
end
diff --git a/ruby/message.cc b/ruby/message.cc
index f7dd3c6..d729b94 100644
--- a/ruby/message.cc
+++ b/ruby/message.cc
@@ -91,7 +91,7 @@ namespace
{
Message * ptr;
Data_Get_Struct(self, Message, ptr);
- return INT2NUM((ptr)->level);
+ return INT2FIX((ptr)->level);
}
void do_register_message()
{
diff --git a/ruby/paludis_ruby.cc b/ruby/paludis_ruby.cc
index e91259a..034e180 100644
--- a/ruby/paludis_ruby.cc
+++ b/ruby/paludis_ruby.cc
@@ -202,7 +202,7 @@ paludis::ruby::value_case_to_RubyCase(const std::string & s)
std::string result;
for (std::string::size_type p(0), p_end(s.length()) ; p != p_end ; ++p)
{
- if ('_' == s[p])
+ if ('_' == s[p] || ' ' == s[p])
upper_next = true;
else if (upper_next)
{
diff --git a/ruby/paludis_ruby.hh b/ruby/paludis_ruby.hh
index c1b7b4e..4a44e56 100644
--- a/ruby/paludis_ruby.hh
+++ b/ruby/paludis_ruby.hh
@@ -100,6 +100,7 @@ namespace paludis
EnvironmentData* value_to_environment_data(VALUE v);
NoConfigEnvironment* value_to_no_config_environment(VALUE v);
PortageRepositoryProfilesDescLine value_to_portage_repository_profiles_desc_line(VALUE v);
+ MaskReasons value_to_mask_reasons(VALUE v);
#ifdef ENABLE_RUBY_QA
VALUE paludis_qa_module();