aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-14 03:22:05 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-14 03:28:55 +0100
commit8d626661eebf9e33e852dd86affc5f2fa86f611f (patch)
tree5b3a8fb51014dfd428c34f939754bf379d2ab505
parent15a3dcd00f4a927a4300326a9f1b7b39dc4e9ee7 (diff)
downloadpaludis-8d626661eebf9e33e852dd86affc5f2fa86f611f.tar.gz
paludis-8d626661eebf9e33e852dd86affc5f2fa86f611f.tar.xz
(ruby) Update Ruby for previous (continued)
-rw-r--r--ruby/dep_spec.cc29
-rw-r--r--ruby/dep_spec_TEST.rb11
-rw-r--r--ruby/generator.cc40
-rw-r--r--ruby/generator_TEST.rb12
4 files changed, 71 insertions, 21 deletions
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index 19496f9..1262a89 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.cc
@@ -665,18 +665,34 @@ namespace
/*
* call-seq:
- * repository -> String or Nil
+ * in_repository -> String or Nil
*
- * Fetch the repository name.
+ * Fetch the in-repository name.
*/
VALUE
- package_dep_spec_repository_ptr(VALUE self)
+ package_dep_spec_in_repository_ptr(VALUE self)
{
std::tr1::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, std::tr1::shared_ptr<WrappedSpecBase>, ptr);
- if (0 == std::tr1::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->repository_ptr())
+ if (0 == std::tr1::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->in_repository_ptr())
return Qnil;
- return rb_str_new2(stringify((*std::tr1::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->repository_ptr())).c_str());
+ return rb_str_new2(stringify((*std::tr1::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->in_repository_ptr())).c_str());
+ }
+
+ /*
+ * call-seq:
+ * from_repository -> String or Nil
+ *
+ * Fetch the from-repository name.
+ */
+ VALUE
+ package_dep_spec_from_repository_ptr(VALUE self)
+ {
+ std::tr1::shared_ptr<WrappedSpecBase> * ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<WrappedSpecBase>, ptr);
+ if (0 == std::tr1::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->from_repository_ptr())
+ return Qnil;
+ return rb_str_new2(stringify((*std::tr1::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->from_repository_ptr())).c_str());
}
/*
@@ -1085,7 +1101,8 @@ namespace
#ifdef CIARANM_REMOVED_THIS
rb_define_method(c_package_dep_spec, "slot", RUBY_FUNC_CAST(&package_dep_spec_slot_ptr), 0);
#endif
- rb_define_method(c_package_dep_spec, "repository", RUBY_FUNC_CAST(&package_dep_spec_repository_ptr), 0);
+ rb_define_method(c_package_dep_spec, "in_repository", RUBY_FUNC_CAST(&package_dep_spec_in_repository_ptr), 0);
+ rb_define_method(c_package_dep_spec, "from_repository", RUBY_FUNC_CAST(&package_dep_spec_from_repository_ptr), 0);
rb_define_method(c_package_dep_spec, "version_requirements", RUBY_FUNC_CAST(&package_dep_spec_version_requirements_ptr), 0);
rb_define_method(c_package_dep_spec, "version_requirements_mode", RUBY_FUNC_CAST(&package_dep_spec_version_requirements_mode), 0);
#ifdef CIARANM_REMOVED_THIS
diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb
index c9ee229..177645c 100644
--- a/ruby/dep_spec_TEST.rb
+++ b/ruby/dep_spec_TEST.rb
@@ -118,9 +118,14 @@ module Paludis
assert_nil pdb.package
end
- def test_repository
- assert_equal "testrepo", pda.repository
- assert_nil pdb.repository
+ def test_from_repository
+ assert_nil pda.from_repository
+ assert_nil pdb.from_repository
+ end
+
+ def test_in_repository
+ assert_equal "testrepo", pda.in_repository
+ assert_nil pdb.in_repository
end
def test_package_name_part
diff --git a/ruby/generator.cc b/ruby/generator.cc
index a3ae830..1c8f7ee 100644
--- a/ruby/generator.cc
+++ b/ruby/generator.cc
@@ -31,7 +31,8 @@ namespace
static VALUE c_generator_all;
static VALUE c_generator_matches;
static VALUE c_generator_package;
- static VALUE c_generator_repository;
+ static VALUE c_generator_in_repository;
+ static VALUE c_generator_from_repository;
static VALUE c_generator_category;
static VALUE c_generator_intersection;
@@ -167,13 +168,32 @@ namespace
}
VALUE
- generator_repository_new(VALUE self, VALUE name_v)
+ generator_in_repository_new(VALUE self, VALUE name_v)
{
Generator * ptr(0);
try
{
RepositoryName name(StringValuePtr(name_v));
- ptr = new generator::Repository(name);
+ ptr = new generator::InRepository(name);
+ VALUE data(Data_Wrap_Struct(self, 0, &Common<Generator>::free, ptr));
+ rb_obj_call_init(data, 1, &name_v);
+ return data;
+ }
+ catch (const std::exception & e)
+ {
+ delete ptr;
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ VALUE
+ generator_from_repository_new(VALUE self, VALUE name_v)
+ {
+ Generator * ptr(0);
+ try
+ {
+ RepositoryName name(StringValuePtr(name_v));
+ ptr = new generator::FromRepository(name);
VALUE data(Data_Wrap_Struct(self, 0, &Common<Generator>::free, ptr));
rb_obj_call_init(data, 1, &name_v);
return data;
@@ -268,12 +288,20 @@ namespace
rb_define_singleton_method(c_generator_category, "new", RUBY_FUNC_CAST(&generator_category_new), 1);
/*
- * Document-class: Paludis::Generator::Repository
+ * Document-class: Paludis::Generator::InRepository
*
* Generate all packages in a given repository.
*/
- c_generator_repository = rb_define_class_under(c_generator_module, "Repository", c_generator);
- rb_define_singleton_method(c_generator_repository, "new", RUBY_FUNC_CAST(&generator_repository_new), 1);
+ c_generator_in_repository = rb_define_class_under(c_generator_module, "InRepository", c_generator);
+ rb_define_singleton_method(c_generator_in_repository, "new", RUBY_FUNC_CAST(&generator_in_repository_new), 1);
+
+ /*
+ * Document-class: Paludis::Generator::FromRepository
+ *
+ * Generate all packages originally from a given repository.
+ */
+ c_generator_from_repository = rb_define_class_under(c_generator_module, "FromRepository", c_generator);
+ rb_define_singleton_method(c_generator_from_repository, "new", RUBY_FUNC_CAST(&generator_from_repository_new), 1);
}
}
diff --git a/ruby/generator_TEST.rb b/ruby/generator_TEST.rb
index 9f1e994..c82984d 100644
--- a/ruby/generator_TEST.rb
+++ b/ruby/generator_TEST.rb
@@ -76,12 +76,12 @@ module Paludis
class TestCase_GeneratorRepository < Test::Unit::TestCase
def test_create
assert_nothing_raised do
- Generator::Repository.new("repo")
+ Generator::InRepository.new("repo")
end
end
def test_to_s
- assert_equal Generator::Repository.new("repo").to_s, "packages with repository repo"
+ assert_equal Generator::InRepository.new("repo").to_s, "packages with repository repo"
end
end
@@ -100,12 +100,12 @@ module Paludis
class TestCase_GeneratorIntersection < Test::Unit::TestCase
def test_create
assert_nothing_raised do
- Generator::Intersection.new(Generator::All.new, Generator::Repository.new("arbor"))
+ Generator::Intersection.new(Generator::All.new, Generator::InRepository.new("arbor"))
end
end
def test_to_s
- assert_equal Generator::Intersection.new(Generator::All.new, Generator::Repository.new("arbor")).to_s,
+ assert_equal Generator::Intersection.new(Generator::All.new, Generator::InRepository.new("arbor")).to_s,
"all packages intersected with packages with repository arbor"
end
end
@@ -113,14 +113,14 @@ module Paludis
class TestCase_GeneratorAmpersand < Test::Unit::TestCase
def test_create
g1 = Generator::All.new
- g2 = Generator::Repository.new("arbor")
+ g2 = Generator::InRepository.new("arbor")
assert_nothing_raised do
g1 & g2
end
end
def test_to_s
- assert_equal (Generator::All.new & Generator::Repository.new("arbor")).to_s,
+ assert_equal (Generator::All.new & Generator::InRepository.new("arbor")).to_s,
"all packages intersected with packages with repository arbor"
end
end