aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2007-05-13 13:34:55 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2007-05-13 13:34:55 +0000
commita6d0ff5e2ca7b255cdaeb89f545f60485f1cd4c5 (patch)
treeddd944a84ff293ebb300907c766f94fccef196b8
parent6afcbdebeedff936cbe161cdb4dea7b7f58fd827 (diff)
downloadpaludis-a6d0ff5e2ca7b255cdaeb89f545f60485f1cd4c5.tar.gz
paludis-a6d0ff5e2ca7b255cdaeb89f545f60485f1cd4c5.tar.xz
(ruby) Bring VersionMetadata up to date.
-rw-r--r--ruby/version_metadata.cc205
-rw-r--r--ruby/version_metadata_TEST.rb15
2 files changed, 80 insertions, 140 deletions
diff --git a/ruby/version_metadata.cc b/ruby/version_metadata.cc
index f524298..e7dcb2e 100644
--- a/ruby/version_metadata.cc
+++ b/ruby/version_metadata.cc
@@ -125,25 +125,6 @@ namespace
return Qnil;
}
-#ifdef CIARANM_REMOVED_THIS
- /*
- * call-seq:
- * license_string
- *
- * Fetch our license, as a string, or Nil if we don't support license_interface.
- */
- VALUE
- version_metadata_license_string(VALUE self)
- {
- std::tr1::shared_ptr<const VersionMetadata> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const VersionMetadata>, self_ptr);
- if ((*self_ptr)->license_interface)
- return rb_str_new2((*self_ptr)->license_interface->license_string.c_str());
- else
- return Qnil;
- }
-#endif
-
/*
* Document-method: slot
*
@@ -160,16 +141,6 @@ namespace
*
* Our eapi
*/
-#ifdef CIARANM_REMOVED_THIS
- /*
- * Document-method: homepage
- *
- * call-seq:
- * homepage -> String
- *
- * Our homepage
- */
-#endif
/*
* Document-method: description
*
@@ -191,6 +162,22 @@ namespace
};
/*
+ * Document-method: homepage
+ *
+ * call-seq:
+ * homepage -> DepSpec
+ *
+ * Our homepage
+ */
+ VALUE
+ version_metadata_homepage(VALUE self)
+ {
+ std::tr1::shared_ptr<const VersionMetadata> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<const VersionMetadata>, self_ptr);
+ return dep_spec_to_value((*self_ptr)->homepage());
+ }
+
+ /*
* call-seq:
* interactive? -> true or false
*
@@ -204,36 +191,50 @@ namespace
return (*self_ptr)-> interactive ? Qtrue : Qfalse;
}
-#ifdef CIARANM_REMOVED_THIS
/*
- * Document-method: provide_string
+ * Document-method: provide
*
* call-seq:
- * provide_string -> String
+ * provide -> DepSpec
*
- * Fetches the package provide_string, if ebuild_interface is not Nil.
+ * Fetches the package provide, if ebuild_interface is not Nil.
*/
/*
- * Document-method: src_uri_string
+ * Document-method: src_uri
*
* call-seq:
- * src_uri_string -> String
+ * src_uri-> DepSpec
*
* Fetches the package src_uri, if ebuild_interface is not Nil.
*/
/*
- * Document-method: restrict_string
+ * Document-method: restrictions
*
* call-seq:
- * restrict_string -> String
+ * restrictions-> DepSpec
*
- * Fetches the package restrict_string, if ebuild_interface is not Nil.
+ * Fetches the package restrict, if ebuild_interface is not Nil.
*/
+ template <std::tr1::shared_ptr<const DepSpec> (VersionMetadataEbuildInterface::* m_) () const>
+ struct EbuildValue
+ {
+ static VALUE
+ fetch(VALUE self)
+ {
+ std::tr1::shared_ptr<const VersionMetadata> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<const VersionMetadata>, self_ptr);
+ if ((*self_ptr)->ebuild_interface)
+ return dep_spec_to_value(((*self_ptr)->ebuild_interface->*m_)());
+ else
+ return Qnil;
+ }
+ };
+
/*
* Document-method: eclass_keywords
*
* call-seq:
- * eclass_keywords -> String
+ * eclass_keywords -> Array
*
* Fetches the package eclass_keywords, if ebuild_interface is not Nil.
*/
@@ -241,7 +242,7 @@ namespace
* Document-method: iuse
*
* call-seq:
- * iuse -> String
+ * iuse -> Array
*
* Fetches the package iuse, if ebuild_interface is not Nil.
*/
@@ -249,12 +250,12 @@ namespace
* Document-method: inherited
*
* call-seq:
- * inherited -> String
+ * inherited -> Array
*
* Fetches the package inherited, if ebuild_interface is not Nil.
*/
- template <typename T_, T_ VersionMetadataEbuildInterface::* m_>
- struct EbuildValue
+ template <typename T_, std::tr1::shared_ptr<const T_> (VersionMetadataEbuildInterface::* m_) () const>
+ struct EbuildValueCollection
{
static VALUE
fetch(VALUE self)
@@ -262,12 +263,17 @@ namespace
std::tr1::shared_ptr<const VersionMetadata> * self_ptr;
Data_Get_Struct(self, std::tr1::shared_ptr<const VersionMetadata>, self_ptr);
if ((*self_ptr)->ebuild_interface)
- return rb_str_new2(stringify((*self_ptr)->ebuild_interface->*m_).c_str());
+ {
+ VALUE result(rb_ary_new());
+ std::tr1::shared_ptr<const T_> c(((*self_ptr)->ebuild_interface->*m_)());
+ for (typename T_::Iterator i(c->begin()), i_end(c->end()) ; i != i_end ; ++i)
+ rb_ary_push(result, rb_str_new2(stringify(*i).c_str()));
+ return result;
+ }
else
return Qnil;
}
};
-#endif
/*
* Document-method: package
@@ -351,59 +357,6 @@ namespace
}
};
-#ifdef CIARANM_REMOVED_THIS
- /*
- * Document-method: build_depend_string
- *
- * call-seq:
- * build_depend_string -> String
- *
- * Fetches build_depend information as a String, or Nil if we have no deps
- * interface
- */
- /*
- * Document-method: run_depend_string
- *
- * call-seq:
- * run_depend_string -> String
- *
- * Fetches run_depend information as a String, or Nil if we have no deps
- * interface
- */
- /*
- * Document-method: suggested_depend_string
- *
- * call-seq:
- * suggested_depend_string -> String
- *
- * Fetches suggested_depend information as a String, or Nil if we have no
- * deps interface
- */
- /*
- * Document-method: post_depend_string
- *
- * call-seq:
- * post_depend_string -> String
- *
- * Fetches post_depend information as a String, or Nil if we have no deps
- * interface
- */
- template <std::string VersionMetadataDepsInterface::* m_>
- struct DependValueString
- {
- static VALUE
- fetch(VALUE self)
- {
- std::tr1::shared_ptr<const VersionMetadata> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const VersionMetadata>, self_ptr);
- if ((*self_ptr)->deps_interface)
- return rb_str_new2((((*self_ptr)->deps_interface)->*m_).c_str());
- else
- return Qnil;
- }
- };
-#endif
-
/*
* Document-method: origin_source
*
@@ -461,25 +414,29 @@ namespace
}
-#ifdef CIARANM_REMOVED_THIS
/*
* call-seq:
- * keywords_string -> String
+ * keywords-> Array
*
* Fetches the package keywords, if ebuild_interface or cran_interface is not Nil.
*/
- VALUE version_metadata_keywords_string(VALUE self)
+ VALUE version_metadata_keywords(VALUE self)
{
std::tr1::shared_ptr<const VersionMetadata> * self_ptr;
Data_Get_Struct(self, std::tr1::shared_ptr<const VersionMetadata>, self_ptr);
+ std::tr1::shared_ptr<const KeywordNameCollection> c;
if ((*self_ptr)->ebuild_interface)
- return rb_str_new2(((*self_ptr)->ebuild_interface->keywords_string).c_str());
- if ((*self_ptr)->cran_interface)
- return rb_str_new2(((*self_ptr)->cran_interface->keywords_string).c_str());
+ c = ((*self_ptr)->ebuild_interface->keywords());
+ else if ((*self_ptr)->cran_interface)
+ c = ((*self_ptr)->cran_interface->keywords());
else
return Qnil;
+ VALUE result(rb_ary_new());
+ for (KeywordNameCollection::Iterator i(c->begin()), i_end(c->end()) ; i != i_end ; ++i)
+ rb_ary_push(result, rb_str_new2(stringify(*i).c_str()));
+ return result;
+
}
-#endif
void do_register_version_metadata()
{
@@ -498,33 +455,23 @@ namespace
rb_define_method(c_version_metadata, "origins_interface", RUBY_FUNC_CAST(&version_metadata_origins_interface), 0);
rb_define_method(c_version_metadata, "license", RUBY_FUNC_CAST(&version_metadata_license), 0);
-#ifdef CIARANM_REMOVED_THIS
- rb_define_method(c_version_metadata, "license_string", RUBY_FUNC_CAST(&version_metadata_license_string), 0);
-#endif
rb_define_method(c_version_metadata, "slot", RUBY_FUNC_CAST((&BaseValue<SlotName, &VersionMetadataBase::slot>::fetch)), 0);
rb_define_method(c_version_metadata, "eapi", RUBY_FUNC_CAST((&BaseValue<std::string, &VersionMetadataBase::eapi>::fetch)), 0);
-#ifdef CIARANM_REMOVED_THIS
- rb_define_method(c_version_metadata, "homepage", RUBY_FUNC_CAST((&BaseValue<std::string, &VersionMetadataBase::homepage>::fetch)), 0);
-#endif
+ rb_define_method(c_version_metadata, "homepage", RUBY_FUNC_CAST(&version_metadata_homepage), 0);
rb_define_method(c_version_metadata, "description", RUBY_FUNC_CAST((&BaseValue<std::string,
&VersionMetadataBase::description>::fetch)), 0);
rb_define_method(c_version_metadata, "interactive?", RUBY_FUNC_CAST(&version_metadata_interactive), 0);
-#ifdef CIARANM_REMOVED_THIS
- rb_define_method(c_version_metadata, "provide_string", RUBY_FUNC_CAST((&EbuildValue<std::string,
- &VersionMetadataEbuildInterface::provide_string>::fetch)), 0);
- rb_define_method(c_version_metadata, "src_uri_string", RUBY_FUNC_CAST((&EbuildValue<std::string,
- &VersionMetadataEbuildInterface::src_uri_string>::fetch)), 0);
- rb_define_method(c_version_metadata, "restrict_string", RUBY_FUNC_CAST((&EbuildValue<std::string,
- &VersionMetadataEbuildInterface::restrict_string>::fetch)), 0);
- rb_define_method(c_version_metadata, "eclass_keywords", RUBY_FUNC_CAST((&EbuildValue<std::string,
+ rb_define_method(c_version_metadata, "provide", RUBY_FUNC_CAST((&EbuildValue<&VersionMetadataEbuildInterface::provide>::fetch)), 0);
+ rb_define_method(c_version_metadata, "src_uri", RUBY_FUNC_CAST((&EbuildValue<&VersionMetadataEbuildInterface::src_uri>::fetch)), 0);
+ rb_define_method(c_version_metadata, "restrictions", RUBY_FUNC_CAST((&EbuildValue<&VersionMetadataEbuildInterface::restrictions>::fetch)), 0);
+ rb_define_method(c_version_metadata, "eclass_keywords", RUBY_FUNC_CAST((&EbuildValueCollection<KeywordNameCollection,
&VersionMetadataEbuildInterface::eclass_keywords>::fetch)), 0);
- rb_define_method(c_version_metadata, "iuse", RUBY_FUNC_CAST((&EbuildValue<std::string,
+ rb_define_method(c_version_metadata, "iuse", RUBY_FUNC_CAST((&EbuildValueCollection<IUseFlagCollection,
&VersionMetadataEbuildInterface::iuse>::fetch)), 0);
- rb_define_method(c_version_metadata, "inherited", RUBY_FUNC_CAST((&EbuildValue<std::string,
+ rb_define_method(c_version_metadata, "inherited", RUBY_FUNC_CAST((&EbuildValueCollection<InheritedCollection,
&VersionMetadataEbuildInterface::inherited>::fetch)), 0);
-#endif
rb_define_method(c_version_metadata, "build_depend", RUBY_FUNC_CAST((&DependValue<
&VersionMetadataDepsInterface::build_depend>::fetch)), 0);
@@ -535,16 +482,6 @@ namespace
rb_define_method(c_version_metadata, "post_depend", RUBY_FUNC_CAST((&DependValue<
&VersionMetadataDepsInterface::post_depend>::fetch)), 0);
-#ifdef CIARANM_REMOVED_THIS
- rb_define_method(c_version_metadata, "build_depend_string", RUBY_FUNC_CAST((&DependValueString<
- &VersionMetadataDepsInterface::build_depend_string>::fetch)), 0);
- rb_define_method(c_version_metadata, "run_depend_string", RUBY_FUNC_CAST((&DependValueString<
- &VersionMetadataDepsInterface::run_depend_string>::fetch)), 0);
- rb_define_method(c_version_metadata, "suggested_depend_string", RUBY_FUNC_CAST((&DependValueString<
- &VersionMetadataDepsInterface::suggested_depend_string>::fetch)), 0);
- rb_define_method(c_version_metadata, "post_depend_string", RUBY_FUNC_CAST((&DependValueString<
- &VersionMetadataDepsInterface::post_depend_string>::fetch)), 0);
-#endif
rb_define_method(c_version_metadata, "origin_source", RUBY_FUNC_CAST((&VMOrigins<
&VersionMetadataOriginsInterface::source>::fetch)), 0);
@@ -559,9 +496,7 @@ namespace
&VersionMetadataCRANInterface::version>::fetch)), 0);
rb_define_method(c_version_metadata, "is_bundle?", RUBY_FUNC_CAST(&version_metadata_is_bundle), 0);
-#ifdef CIARANM_REMOVED_THIS
- rb_define_method(c_version_metadata, "keywords_string", RUBY_FUNC_CAST(&version_metadata_keywords_string), 0);
-#endif
+ rb_define_method(c_version_metadata, "keywords", RUBY_FUNC_CAST(&version_metadata_keywords), 0);
}
}
diff --git a/ruby/version_metadata_TEST.rb b/ruby/version_metadata_TEST.rb
index 6eca20e..7112e58 100644
--- a/ruby/version_metadata_TEST.rb
+++ b/ruby/version_metadata_TEST.rb
@@ -66,18 +66,28 @@ module Paludis
def test_members
assert_equal "Test package", vmd("1.0").description
# assert_equal "http://paludis.pioto.org/", vmd("1.0").homepage
+ assert_kind_of DepSpec, vmd('1.0').homepage
assert_equal "0", vmd("1.0").slot
assert_equal "0", vmd("1.0").eapi
# assert_equal "GPL-2", vmd("1.0").license_string
+ assert_kind_of DepSpec, vmd('1.0').license
assert !vmd('1.0').interactive?
end
def test_ebuild_members
# assert_equal "", vmd("1.0").provide_string
+ assert_kind_of DepSpec, vmd('1.0').provide
# assert_equal "http://example.com/bar-1.0.tar.bz2", vmd("1.0").src_uri_string
+ assert_kind_of DepSpec, vmd('1.0').src_uri
# assert_equal "monkey", vmd("1.0").restrict_string
+ assert_kind_of DepSpec, vmd('1.0').restrictions
# assert_equal "test", vmd("1.0").keywords_string.gsub(%r/\s/, "")
+ assert_kind_of Array, vmd('1.0').keywords
+ assert_equal 1, vmd('1.0').keywords.length
+ assert_equal 'test', vmd('1.0').keywords.first
# assert_equal "", vmd("1.0").iuse.gsub(%r/\s/, "")
+ assert_kind_of Array, vmd('1.0').iuse
+ assert vmd('1.0').iuse.empty?
end
def test_deps
@@ -90,11 +100,6 @@ module Paludis
assert vmd("1.0").run_depend.to_a.empty?
assert vmd("1.0").suggested_depend.to_a.empty?
assert vmd("1.0").post_depend.to_a.empty?
-
-# assert_equal "foo/bar", vmd("1.0").build_depend_string.gsub(/\s/, "")
-# assert_equal "", vmd("1.0").run_depend_string.gsub(/\s/, "")
-# assert_equal "", vmd("1.0").suggested_depend_string.gsub(/\s/, "")
-# assert_equal "", vmd("1.0").post_depend_string.gsub(/\s/, "")
end
def test_origin_source