aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-09-23 23:15:20 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-09-23 23:15:20 +0000
commit4bdfcd357fb28620d69443af3ce28556d15007a4 (patch)
treefa793aa13ad42fd6c094c7c518b478c32f1dc75e
parentaf29052be127eddcbd129318149965f446ffe47f (diff)
downloadpaludis-4bdfcd357fb28620d69443af3ce28556d15007a4.tar.gz
paludis-4bdfcd357fb28620d69443af3ce28556d15007a4.tar.xz
Move all Ruby classes under a new Paludis master class
-rw-r--r--ruby/default_environment.cc2
-rw-r--r--ruby/default_environment_TEST.rb179
-rw-r--r--ruby/log.cc2
-rw-r--r--ruby/log_TEST.rb40
-rw-r--r--ruby/mask_reasons.cc2
-rw-r--r--ruby/mask_reasons_TEST.rb26
-rw-r--r--ruby/name.cc8
-rw-r--r--ruby/name_TEST.rb165
-rw-r--r--ruby/package_database_entry.cc2
-rw-r--r--ruby/package_database_entry_TEST.rb26
-rw-r--r--ruby/paludis_ruby.cc12
-rw-r--r--ruby/paludis_ruby.hh1
-rw-r--r--ruby/version_spec.cc2
-rw-r--r--ruby/version_spec_TEST.rb47
14 files changed, 270 insertions, 244 deletions
diff --git a/ruby/default_environment.cc b/ruby/default_environment.cc
index 41e2877..23c2ac8 100644
--- a/ruby/default_environment.cc
+++ b/ruby/default_environment.cc
@@ -123,7 +123,7 @@ namespace
{
rb_require("singleton");
- c_default_environment = rb_define_class("DefaultEnvironment", rb_cObject);
+ c_default_environment = rb_define_class_under(master_class(), "DefaultEnvironment", rb_cObject);
rb_funcall(rb_const_get(rb_cObject, rb_intern("Singleton")), rb_intern("included"), 1, c_default_environment);
rb_define_method(c_default_environment, "query_use", RUBY_FUNC_CAST(&default_environment_query_use), -1);
rb_define_method(c_default_environment, "accept_keyword", RUBY_FUNC_CAST(&default_environment_accept_keyword), -1);
diff --git a/ruby/default_environment_TEST.rb b/ruby/default_environment_TEST.rb
index 5559d88..f1d51c0 100644
--- a/ruby/default_environment_TEST.rb
+++ b/ruby/default_environment_TEST.rb
@@ -23,125 +23,128 @@ ENV["PALUDIS_HOME"] = Dir.getwd().to_s + "/default_environment_TEST_dir/home";
require 'test/unit'
require 'Paludis'
-Log.instance.log_level = Log::LogLevel::Warning
+Paludis::Log.instance.log_level = Paludis::Log::LogLevel::Warning
-class TestCase_DefaultEnvironment < Test::Unit::TestCase
- def test_instance
- assert_equal DefaultEnvironment.instance.__id__, DefaultEnvironment.instance.__id__
- end
+class Paludis
- def test_no_create
- assert_raise NoMethodError do
- x = DefaultEnvironment.new()
+ class TestCase_DefaultEnvironment < Test::Unit::TestCase
+ def test_instance
+ assert_equal DefaultEnvironment.instance.__id__, DefaultEnvironment.instance.__id__
end
- end
-end
-class TestCase_DefaultEnvironmentUse < Test::Unit::TestCase
- def test_query_use
- assert DefaultEnvironment.instance.query_use(UseFlagName.new("enabled"))
- assert ! DefaultEnvironment.instance.query_use(UseFlagName.new("not_enabled"))
- assert ! DefaultEnvironment.instance.query_use(UseFlagName.new("sometimes_enabled"))
+ def test_no_create
+ assert_raise NoMethodError do
+ x = DefaultEnvironment.new()
+ end
+ end
+ end
- pde = PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
- VersionSpec.new("1.0"), RepositoryName.new("testrepo"))
+ class TestCase_DefaultEnvironmentUse < Test::Unit::TestCase
+ def test_query_use
+ assert DefaultEnvironment.instance.query_use(UseFlagName.new("enabled"))
+ assert ! DefaultEnvironment.instance.query_use(UseFlagName.new("not_enabled"))
+ assert ! DefaultEnvironment.instance.query_use(UseFlagName.new("sometimes_enabled"))
- assert DefaultEnvironment.instance.query_use(UseFlagName.new("enabled"), pde)
- assert ! DefaultEnvironment.instance.query_use(UseFlagName.new("not_enabled"), pde)
- assert DefaultEnvironment.instance.query_use(UseFlagName.new("sometimes_enabled"), pde)
- end
+ pde = PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
+ VersionSpec.new("1.0"), RepositoryName.new("testrepo"))
- def test_query_use_bad
- assert_raise ArgumentError do
- DefaultEnvironment.instance.query_use(1, 2, 3)
- end
- assert_raise TypeError do
- DefaultEnvironment.instance.query_use("not_enabled")
+ assert DefaultEnvironment.instance.query_use(UseFlagName.new("enabled"), pde)
+ assert ! DefaultEnvironment.instance.query_use(UseFlagName.new("not_enabled"), pde)
+ assert DefaultEnvironment.instance.query_use(UseFlagName.new("sometimes_enabled"), pde)
end
- end
-end
+ def test_query_use_bad
+ assert_raise ArgumentError do
+ DefaultEnvironment.instance.query_use(1, 2, 3)
+ end
+ assert_raise TypeError do
+ DefaultEnvironment.instance.query_use("not_enabled")
+ end
+ end
-class TestCase_DefaultEnvironmentAcceptKeyword < Test::Unit::TestCase
- def test_accept_keyword
- assert DefaultEnvironment.instance.accept_keyword(KeywordName.new("test"))
- assert ! DefaultEnvironment.instance.accept_keyword(KeywordName.new("bad"))
- assert ! DefaultEnvironment.instance.accept_keyword(KeywordName.new("~test"))
+ end
- pde = PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
- VersionSpec.new("1.0"), RepositoryName.new("testrepo"))
+ class TestCase_DefaultEnvironmentAcceptKeyword < Test::Unit::TestCase
+ def test_accept_keyword
+ assert DefaultEnvironment.instance.accept_keyword(KeywordName.new("test"))
+ assert ! DefaultEnvironment.instance.accept_keyword(KeywordName.new("bad"))
+ assert ! DefaultEnvironment.instance.accept_keyword(KeywordName.new("~test"))
- assert DefaultEnvironment.instance.accept_keyword(KeywordName.new("test"), pde)
- assert ! DefaultEnvironment.instance.accept_keyword(KeywordName.new("bad"), pde)
- assert DefaultEnvironment.instance.accept_keyword(KeywordName.new("~test"), pde)
- end
+ pde = PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
+ VersionSpec.new("1.0"), RepositoryName.new("testrepo"))
- def test_accept_keyword_bad
- assert_raise ArgumentError do
- DefaultEnvironment.instance.accept_keyword(1, 2, 3)
+ assert DefaultEnvironment.instance.accept_keyword(KeywordName.new("test"), pde)
+ assert ! DefaultEnvironment.instance.accept_keyword(KeywordName.new("bad"), pde)
+ assert DefaultEnvironment.instance.accept_keyword(KeywordName.new("~test"), pde)
end
- assert_raise TypeError do
- DefaultEnvironment.instance.accept_keyword("foo")
+
+ def test_accept_keyword_bad
+ assert_raise ArgumentError do
+ DefaultEnvironment.instance.accept_keyword(1, 2, 3)
+ end
+ assert_raise TypeError do
+ DefaultEnvironment.instance.accept_keyword("foo")
+ end
end
end
-end
-
-class TestCase_DefaultEnvironmentAcceptLicense < Test::Unit::TestCase
- def test_accept_license
- assert DefaultEnvironment.instance.accept_license("test")
- pde = PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
- VersionSpec.new("1.0"), RepositoryName.new("testrepo"))
+ class TestCase_DefaultEnvironmentAcceptLicense < Test::Unit::TestCase
+ def test_accept_license
+ assert DefaultEnvironment.instance.accept_license("test")
- assert DefaultEnvironment.instance.accept_license("test", pde)
- end
+ pde = PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
+ VersionSpec.new("1.0"), RepositoryName.new("testrepo"))
- def test_accept_license_bad
- assert_raise ArgumentError do
- DefaultEnvironment.instance.accept_license(1, 2, 3)
+ assert DefaultEnvironment.instance.accept_license("test", pde)
end
- assert_raise TypeError do
- DefaultEnvironment.instance.accept_license(123)
+
+ def test_accept_license_bad
+ assert_raise ArgumentError do
+ DefaultEnvironment.instance.accept_license(1, 2, 3)
+ end
+ assert_raise TypeError do
+ DefaultEnvironment.instance.accept_license(123)
+ end
end
end
-end
-class TestCase_DefaultEnvironmentMaskReasons < Test::Unit::TestCase
- def test_mask_reasons
- p = PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
- VersionSpec.new("1.0"), RepositoryName.new("testrepo"))
+ class TestCase_DefaultEnvironmentMaskReasons < Test::Unit::TestCase
+ def test_mask_reasons
+ p = PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
+ VersionSpec.new("1.0"), RepositoryName.new("testrepo"))
- m = DefaultEnvironment.instance.mask_reasons(p)
- assert m.empty?
- end
+ m = DefaultEnvironment.instance.mask_reasons(p)
+ assert m.empty?
+ end
- def test_mask_reasons_not_empty
- p = PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
- VersionSpec.new("2.0"), RepositoryName.new("testrepo"))
+ def test_mask_reasons_not_empty
+ p = PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
+ VersionSpec.new("2.0"), RepositoryName.new("testrepo"))
- m = DefaultEnvironment.instance.mask_reasons(p)
- assert ! m.empty?
- assert m.include?("keyword")
- assert_equal ["keyword"], m.to_a
- end
+ m = DefaultEnvironment.instance.mask_reasons(p)
+ assert ! m.empty?
+ assert m.include?("keyword")
+ assert_equal ["keyword"], m.to_a
+ end
- def test_mask_reasons_no_such_repo
- p = PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
- VersionSpec.new("1.0"), RepositoryName.new("nosuchrepo"))
+ def test_mask_reasons_no_such_repo
+ p = PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
+ VersionSpec.new("1.0"), RepositoryName.new("nosuchrepo"))
- assert_raise RuntimeError do
- DefaultEnvironment.instance.mask_reasons p
+ assert_raise RuntimeError do
+ DefaultEnvironment.instance.mask_reasons p
+ end
end
- end
- def test_mask_reasons_bad
- assert_raise ArgumentError do
- DefaultEnvironment.instance.mask_reasons(1, 2)
- end
- assert_raise TypeError do
- DefaultEnvironment.instance.accept_license(123)
+ def test_mask_reasons_bad
+ assert_raise ArgumentError do
+ DefaultEnvironment.instance.mask_reasons(1, 2)
+ end
+ assert_raise TypeError do
+ DefaultEnvironment.instance.accept_license(123)
+ end
end
end
-end
+end
diff --git a/ruby/log.cc b/ruby/log.cc
index c30e676..9595494 100644
--- a/ruby/log.cc
+++ b/ruby/log.cc
@@ -48,7 +48,7 @@ namespace
{
rb_require("singleton");
- c_log = rb_define_class("Log", rb_cObject);
+ c_log = rb_define_class_under(master_class(), "Log", rb_cObject);
rb_funcall(rb_const_get(rb_cObject, rb_intern("Singleton")), rb_intern("included"), 1, c_log);
rb_define_method(c_log, "log_level", RUBY_FUNC_CAST(&log_log_level), 0);
rb_define_method(c_log, "log_level=", RUBY_FUNC_CAST(&log_log_level_set), 1);
diff --git a/ruby/log_TEST.rb b/ruby/log_TEST.rb
index c262846..022ec29 100644
--- a/ruby/log_TEST.rb
+++ b/ruby/log_TEST.rb
@@ -23,31 +23,33 @@ ENV["PALUDIS_HOME"] = Dir.getwd().to_s + "/default_environment_TEST_dir/home";
require 'test/unit'
require 'Paludis'
-class TestCase_Log < Test::Unit::TestCase
- def test_instance
- assert_equal Log.instance.__id__, Log.instance.__id__
- end
+class Paludis
+ class TestCase_Log < Test::Unit::TestCase
+ def test_instance
+ assert_equal Log.instance.__id__, Log.instance.__id__
+ end
- def test_no_create
- assert_raise NoMethodError do
- x = Log.new()
+ def test_no_create
+ assert_raise NoMethodError do
+ x = Log.new()
+ end
end
end
-end
-class TestCase_LogLogLevel < Test::Unit::TestCase
- def test_log_level
- assert_equal Log.instance.log_level, Log.instance.log_level
- assert Log.instance.log_level >= Log::LogLevel::Debug
- assert Log.instance.log_level <= Log::LogLevel::Silent
- end
+ class TestCase_LogLogLevel < Test::Unit::TestCase
+ def test_log_level
+ assert_equal Log.instance.log_level, Log.instance.log_level
+ assert Log.instance.log_level >= Log::LogLevel::Debug
+ assert Log.instance.log_level <= Log::LogLevel::Silent
+ end
- def test_log_level_set
- Log.instance.log_level = Log::LogLevel::Debug;
- assert_equal Log::LogLevel::Debug, Log.instance.log_level
+ def test_log_level_set
+ Log.instance.log_level = Log::LogLevel::Debug;
+ assert_equal Log::LogLevel::Debug, Log.instance.log_level
- Log.instance.log_level = Log::LogLevel::Warning;
- assert_equal Log::LogLevel::Warning, Log.instance.log_level
+ Log.instance.log_level = Log::LogLevel::Warning;
+ assert_equal Log::LogLevel::Warning, Log.instance.log_level
+ end
end
end
diff --git a/ruby/mask_reasons.cc b/ruby/mask_reasons.cc
index 374d29b..1fa9f6b 100644
--- a/ruby/mask_reasons.cc
+++ b/ruby/mask_reasons.cc
@@ -78,7 +78,7 @@ namespace
void do_register_mask_reasons()
{
- c_mask_reasons = rb_define_class("MaskReasons", rb_cObject);
+ c_mask_reasons = rb_define_class_under(master_class(), "MaskReasons", rb_cObject);
rb_define_singleton_method(c_mask_reasons, "new", RUBY_FUNC_CAST(&mask_reasons_new), 0);
rb_define_method(c_mask_reasons, "initialize", RUBY_FUNC_CAST(&mask_reasons_init), 0);
rb_define_method(c_mask_reasons, "each", RUBY_FUNC_CAST(&mask_reasons_each), 0);
diff --git a/ruby/mask_reasons_TEST.rb b/ruby/mask_reasons_TEST.rb
index 7f57adc..93fc095 100644
--- a/ruby/mask_reasons_TEST.rb
+++ b/ruby/mask_reasons_TEST.rb
@@ -21,21 +21,23 @@
require 'test/unit'
require 'Paludis'
-class TestCase_MaskReasons < Test::Unit::TestCase
+class Paludis
+ class TestCase_MaskReasons < Test::Unit::TestCase
- def test_create
- m = MaskReasons.new
- end
+ def test_create
+ m = MaskReasons.new
+ end
- def test_each
- m = MaskReasons.new
- assert_equal [], m.to_a
- end
+ def test_each
+ m = MaskReasons.new
+ assert_equal [], m.to_a
+ end
- def test_empty
- m = MaskReasons.new
- assert m.empty?
- end
+ def test_empty
+ m = MaskReasons.new
+ assert m.empty?
+ end
+ end
end
diff --git a/ruby/name.cc b/ruby/name.cc
index 1c39470..b0e9b2e 100644
--- a/ruby/name.cc
+++ b/ruby/name.cc
@@ -85,14 +85,14 @@ namespace
static void do_register(const std::string & name)
{
- c_class = rb_define_class(name.c_str(), rb_cObject);
+ c_class = rb_define_class_under(master_class(), name.c_str(), rb_cObject);
rb_define_singleton_method(c_class, "new", RUBY_FUNC_CAST(&name_part_new), 1);
rb_define_method(c_class, "initialize", RUBY_FUNC_CAST(&name_part_init), 1);
rb_define_method(c_class, "<=>", RUBY_FUNC_CAST(&Common<T_>::compare), 1);
rb_include_module(c_class, rb_mComparable);
rb_define_method(c_class, "to_s", RUBY_FUNC_CAST(&Common<T_>::to_s), 0);
- c_class_except = rb_define_class((name + "Error").c_str(), rb_eRuntimeError);
+ c_class_except = rb_define_class_under(master_class(), (name + "Error").c_str(), rb_eRuntimeError);
rb_define_singleton_method(c_class_except, "new", RUBY_FUNC_CAST(&name_part_error_new), 1);
rb_define_method(c_class_except, "initialize", RUBY_FUNC_CAST(&name_part_error_init), 1);
}
@@ -181,14 +181,14 @@ namespace
rb_define_method(NameWrapper<CategoryNamePart, CategoryNamePartError>::c_class,
"+", RUBY_FUNC_CAST(&category_name_part_plus), 1);
- c_qualified_package_name = rb_define_class("QualifiedPackageName", rb_cObject);
+ c_qualified_package_name = rb_define_class_under(master_class(), "QualifiedPackageName", rb_cObject);
rb_define_singleton_method(c_qualified_package_name, "new", RUBY_FUNC_CAST(&qualified_package_name_new), -1);
rb_define_method(c_qualified_package_name, "initialize", RUBY_FUNC_CAST(&qualified_package_name_init), -1);
rb_define_method(c_qualified_package_name, "<=>", RUBY_FUNC_CAST(&Common<QualifiedPackageName>::compare), 1);
rb_include_module(c_qualified_package_name, rb_mComparable);
rb_define_method(c_qualified_package_name, "to_s", RUBY_FUNC_CAST(&Common<QualifiedPackageName>::to_s), 0);
- c_qualified_package_name_error = rb_define_class("QualifiedPackageNameError", rb_eRuntimeError);
+ c_qualified_package_name_error = rb_define_class_under(master_class(), "QualifiedPackageNameError", rb_eRuntimeError);
rb_define_singleton_method(c_qualified_package_name_error, "new", RUBY_FUNC_CAST(&qualified_package_name_error_new), 1);
rb_define_method(c_qualified_package_name_error, "initialize", RUBY_FUNC_CAST(&qualified_package_name_error_init), 1);
}
diff --git a/ruby/name_TEST.rb b/ruby/name_TEST.rb
index 69e48a1..2fd3421 100644
--- a/ruby/name_TEST.rb
+++ b/ruby/name_TEST.rb
@@ -73,124 +73,125 @@ module NameTestCaseBase
end
end
-class TestCase_PackageNamePart < Test::Unit::TestCase
- include NameTestCaseBase
+class Paludis
+ class TestCase_PackageNamePart < Test::Unit::TestCase
+ include NameTestCaseBase
- def error_type
- return PackageNamePartError
- end
+ def error_type
+ return PackageNamePartError
+ end
- def name_type
- return PackageNamePart
+ def name_type
+ return PackageNamePart
+ end
end
-end
-class TestCase_CategoryNamePart < Test::Unit::TestCase
- include NameTestCaseBase
+ class TestCase_CategoryNamePart < Test::Unit::TestCase
+ include NameTestCaseBase
- def error_type
- return CategoryNamePartError
- end
+ def error_type
+ return CategoryNamePartError
+ end
- def name_type
- return CategoryNamePart
- end
+ def name_type
+ return CategoryNamePart
+ end
- def test_plus
- q = CategoryNamePart.new("foo") + PackageNamePart.new("bar")
- assert_equal "foo/bar", q.to_s
- end
+ def test_plus
+ q = CategoryNamePart.new("foo") + PackageNamePart.new("bar")
+ assert_equal "foo/bar", q.to_s
+ end
- def test_plus_bad
- assert_raise TypeError do
- q = CategoryNamePart.new("foo") + "bar"
+ def test_plus_bad
+ assert_raise TypeError do
+ q = CategoryNamePart.new("foo") + "bar"
+ end
end
end
-end
-class TestCase_UseFlagName < Test::Unit::TestCase
- include NameTestCaseBase
+ class TestCase_UseFlagName < Test::Unit::TestCase
+ include NameTestCaseBase
- def error_type
- return UseFlagNameError
- end
+ def error_type
+ return UseFlagNameError
+ end
- def name_type
- return UseFlagName
+ def name_type
+ return UseFlagName
+ end
end
-end
-class TestCase_RepositoryName < Test::Unit::TestCase
- include NameTestCaseBase
+ class TestCase_RepositoryName < Test::Unit::TestCase
+ include NameTestCaseBase
- def error_type
- return RepositoryNameError
- end
+ def error_type
+ return RepositoryNameError
+ end
- def name_type
- return RepositoryName
+ def name_type
+ return RepositoryName
+ end
end
-end
-class TestCase_SlotName < Test::Unit::TestCase
- include NameTestCaseBase
+ class TestCase_SlotName < Test::Unit::TestCase
+ include NameTestCaseBase
- def error_type
- return SlotNameError
- end
+ def error_type
+ return SlotNameError
+ end
- def name_type
- return SlotName
+ def name_type
+ return SlotName
+ end
end
-end
-class TestCase_KeywordName < Test::Unit::TestCase
- include NameTestCaseBase
+ class TestCase_KeywordName < Test::Unit::TestCase
+ include NameTestCaseBase
- def error_type
- return KeywordNameError
- end
+ def error_type
+ return KeywordNameError
+ end
- def name_type
- return KeywordName
+ def name_type
+ return KeywordName
+ end
end
-end
-class TestCase_QualifiedPackageName < Test::Unit::TestCase
- include NameTestCaseBase
+ class TestCase_QualifiedPackageName < Test::Unit::TestCase
+ include NameTestCaseBase
- def error_type
- return QualifiedPackageNameError
- end
+ def error_type
+ return QualifiedPackageNameError
+ end
- def name_type
- return QualifiedPackageName
- end
+ def name_type
+ return QualifiedPackageName
+ end
- def valid_name_foo
- return "foo/foo"
- end
+ def valid_name_foo
+ return "foo/foo"
+ end
- def valid_name_bar
- return "bar/bar"
- end
+ def valid_name_bar
+ return "bar/bar"
+ end
- def test_two_arg_create
- x = QualifiedPackageName.new(CategoryNamePart.new("foo"), PackageNamePart.new("bar"))
- assert_equal "foo/bar", x.to_s
- end
+ def test_two_arg_create
+ x = QualifiedPackageName.new(CategoryNamePart.new("foo"), PackageNamePart.new("bar"))
+ assert_equal "foo/bar", x.to_s
+ end
- def test_bad_arg_count_create
- assert_raise ArgumentError do
- x = QualifiedPackageName.new("foo", "bar", "baz")
+ def test_bad_arg_count_create
+ assert_raise ArgumentError do
+ x = QualifiedPackageName.new("foo", "bar", "baz")
+ end
end
- end
- def test_bad_type_create
- assert_raise TypeError do
- x = QualifiedPackageName.new("foo", "bar")
+ def test_bad_type_create
+ assert_raise TypeError do
+ x = QualifiedPackageName.new("foo", "bar")
+ end
end
end
end
-
diff --git a/ruby/package_database_entry.cc b/ruby/package_database_entry.cc
index 8854fbe..9e6b01b 100644
--- a/ruby/package_database_entry.cc
+++ b/ruby/package_database_entry.cc
@@ -65,7 +65,7 @@ namespace
void do_register_package_database_entry()
{
- c_package_database_entry = rb_define_class("PackageDatabaseEntry", rb_cObject);
+ c_package_database_entry = rb_define_class_under(master_class(), "PackageDatabaseEntry", rb_cObject);
rb_define_singleton_method(c_package_database_entry, "new", RUBY_FUNC_CAST(&package_database_entry_new), 3);
rb_define_method(c_package_database_entry, "initialize", RUBY_FUNC_CAST(&package_database_entry_init), 3);
rb_define_method(c_package_database_entry, "<=>", RUBY_FUNC_CAST(&Common<PackageDatabaseEntry>::compare), 1);
diff --git a/ruby/package_database_entry_TEST.rb b/ruby/package_database_entry_TEST.rb
index e77767f..6049905 100644
--- a/ruby/package_database_entry_TEST.rb
+++ b/ruby/package_database_entry_TEST.rb
@@ -20,20 +20,22 @@
require 'test/unit'
require 'Paludis'
-class TestCase_PackageDatabaseEntry < Test::Unit::TestCase
- def test_create
- v = PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
- VersionSpec.new("0"), RepositoryName.new("moo"))
- end
+class Paludis
+ class TestCase_PackageDatabaseEntry < Test::Unit::TestCase
+ def test_create
+ v = PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
+ VersionSpec.new("0"), RepositoryName.new("moo"))
+ end
- def test_create_error
- assert_raise TypeError do
- v = PackageDatabaseEntry.new("foo/bar", "0", "moo")
+ def test_create_error
+ assert_raise TypeError do
+ v = PackageDatabaseEntry.new("foo/bar", "0", "moo")
+ end
+ end
+ def test_to_s
+ assert_equal "foo/bar-10::moo", PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
+ VersionSpec.new("10"), RepositoryName.new("moo")).to_s
end
- end
- def test_to_s
- assert_equal "foo/bar-10::moo", PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
- VersionSpec.new("10"), RepositoryName.new("moo")).to_s
end
end
diff --git a/ruby/paludis_ruby.cc b/ruby/paludis_ruby.cc
index 9e59f3b..cf7ed74 100644
--- a/ruby/paludis_ruby.cc
+++ b/ruby/paludis_ruby.cc
@@ -36,6 +36,11 @@ namespace paludis
};
}
+namespace
+{
+ static VALUE c_master_class;
+}
+
RegisterRubyClass::RegisterRubyClass() :
PrivateImplementationPattern<RegisterRubyClass>(new Implementation<RegisterRubyClass>)
{
@@ -94,10 +99,17 @@ paludis::ruby::value_case_to_RubyCase(const std::string & s)
return result;
}
+VALUE
+paludis::ruby::master_class()
+{
+ return c_master_class;
+}
+
extern "C"
{
void Init_Paludis()
{
+ c_master_class = rb_define_class("Paludis", rb_cObject);
RegisterRubyClass::get_instance()->execute();
}
}
diff --git a/ruby/paludis_ruby.hh b/ruby/paludis_ruby.hh
index 8ca62d6..93b2119 100644
--- a/ruby/paludis_ruby.hh
+++ b/ruby/paludis_ruby.hh
@@ -40,6 +40,7 @@ namespace paludis
/* constructors */
+ VALUE master_class();
VALUE create_mask_reasons(const MaskReasons &);
/* registration */
diff --git a/ruby/version_spec.cc b/ruby/version_spec.cc
index 2b3e273..6941e55 100644
--- a/ruby/version_spec.cc
+++ b/ruby/version_spec.cc
@@ -56,7 +56,7 @@ namespace
void do_register_version_spec()
{
- c_version_spec = rb_define_class("VersionSpec", rb_cObject);
+ c_version_spec = rb_define_class_under(master_class(), "VersionSpec", rb_cObject);
rb_define_singleton_method(c_version_spec, "new", RUBY_FUNC_CAST(&version_spec_new), 1);
rb_define_method(c_version_spec, "initialize", RUBY_FUNC_CAST(&version_spec_init), 1);
rb_define_method(c_version_spec, "<=>", RUBY_FUNC_CAST(&Common<VersionSpec>::compare), 1);
diff --git a/ruby/version_spec_TEST.rb b/ruby/version_spec_TEST.rb
index f7afb6e..6ca2bd8 100644
--- a/ruby/version_spec_TEST.rb
+++ b/ruby/version_spec_TEST.rb
@@ -21,33 +21,36 @@
require 'test/unit'
require 'Paludis'
-class TestCase_VersionSpec < Test::Unit::TestCase
- def test_create
- v = VersionSpec.new("0")
- end
+class Paludis
+ class TestCase_VersionSpec < Test::Unit::TestCase
+ def test_create
+ v = VersionSpec.new("0")
+ end
- def test_create_error
- assert_raise TypeError do
- v = VersionSpec.new(0)
+ def test_create_error
+ assert_raise TypeError do
+ v = VersionSpec.new(0)
+ end
end
- end
- def test_compare
- v0 = VersionSpec.new("0")
- v1 = VersionSpec.new("0.1")
- v2 = VersionSpec.new("1.0")
+ def test_compare
+ v0 = VersionSpec.new("0")
+ v1 = VersionSpec.new("0.1")
+ v2 = VersionSpec.new("1.0")
- assert_operator v0, :<, v1
- assert_operator v0, :<, v2
- assert_operator v1, :<, v2
+ assert_operator v0, :<, v1
+ assert_operator v0, :<, v2
+ assert_operator v1, :<, v2
- assert_operator v0, :<=, v0
- assert_operator v0, :<=, v1
- assert_operator v0, :<=, v2
- assert_operator v1, :<=, v2
- end
+ assert_operator v0, :<=, v0
+ assert_operator v0, :<=, v1
+ assert_operator v0, :<=, v2
+ assert_operator v1, :<=, v2
+ end
- def test_to_s
- assert_equal "0.1_alpha2", VersionSpec.new("0.1_alpha2").to_s
+ def test_to_s
+ assert_equal "0.1_alpha2", VersionSpec.new("0.1_alpha2").to_s
+ end
end
end
+