aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2007-03-16 09:41:09 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2007-03-16 09:41:09 +0000
commita912295bebcd451786281f15324169a3bce8becd (patch)
tree4b6add43cce6e6d3223e5507b5ee0a2d99afccf6
parent490c7cc94b32adbb610416379c3ca9819a6ba3b3 (diff)
downloadpaludis-a912295bebcd451786281f15324169a3bce8becd.tar.gz
paludis-a912295bebcd451786281f15324169a3bce8becd.tar.xz
ruby/version_metadata_TEST.rb: Update ruby with new PortageDepParser
and PackageDepSpec, and add Environment.accept_unstable=
-rw-r--r--ruby/dep_list_TEST.rb6
-rw-r--r--ruby/dep_spec.cc63
-rw-r--r--ruby/dep_spec_TEST.rb20
-rw-r--r--ruby/environment.cc14
-rw-r--r--ruby/environment_TEST.rb10
-rw-r--r--ruby/package_database_TEST.rb28
-rw-r--r--ruby/paludis_ruby_TEST.rb6
-rw-r--r--ruby/portage_dep_parser.cc169
-rw-r--r--ruby/portage_dep_parser_TEST.rb82
-rw-r--r--ruby/qualified_package_name_TEST.rb2
-rw-r--r--ruby/query_TEST.rb2
-rw-r--r--ruby/repository_TEST.rb2
-rw-r--r--ruby/version_metadata.cc37
-rw-r--r--ruby/version_metadata_TEST.rb5
14 files changed, 329 insertions, 117 deletions
diff --git a/ruby/dep_list_TEST.rb b/ruby/dep_list_TEST.rb
index 4baba3b..865caf4 100644
--- a/ruby/dep_list_TEST.rb
+++ b/ruby/dep_list_TEST.rb
@@ -118,7 +118,7 @@ module Paludis
end
def pda
- PackageDepSpec.new('foo/bar')
+ PackageDepSpec.new('foo/bar', PackageDepSpecParseMode::Permissive)
end
def dd
@@ -206,11 +206,11 @@ module Paludis
def test_errors
assert_raise AllMaskedError do
- dl.add(PackageDepSpec.new('foo/ba'), dd)
+ dl.add(PackageDepSpec.new('foo/ba', PackageDepSpecParseMode::Permissive), dd)
end
begin
- dl.add(PackageDepSpec.new('foo/ba'), dd)
+ dl.add(PackageDepSpec.new('foo/ba', PackageDepSpecParseMode::Permissive), dd)
rescue AllMaskedError => error
assert_equal 'foo/ba', error.query
end
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index cd626bb..dd7276a 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.cc
@@ -39,6 +39,7 @@ namespace
static VALUE c_block_dep_spec;
static VALUE c_string_dep_spec;
static VALUE c_version_requirements_mode;
+ static VALUE c_package_dep_spec_parse_mode;
VALUE
dep_spec_init_1(VALUE self, VALUE)
@@ -47,6 +48,13 @@ namespace
}
VALUE
+ package_dep_spec_init(int, VALUE *, VALUE self)
+ {
+ return self;
+ }
+
+
+ VALUE
block_dep_spec_new(VALUE self, VALUE spec)
{
std::tr1::shared_ptr<const BlockDepSpec> * ptr(0);
@@ -101,6 +109,35 @@ namespace
}
};
+ VALUE
+ package_dep_spec_new(int argc, VALUE *argv, VALUE self)
+ {
+ std::tr1::shared_ptr<const PackageDepSpec> * ptr(0);
+ try
+ {
+ PackageDepSpecParseMode p;
+ if (1 == argc)
+ {
+ rb_warn("Calling PackageDepSpec.new with one argument has been deprecated");
+ p = pds_pm_unspecific;
+ }
+ else
+ p = static_cast<PackageDepSpecParseMode>(NUM2INT(argv[1]));
+
+ ptr = new std::tr1::shared_ptr<const PackageDepSpec>(new PackageDepSpec(StringValuePtr(argv[0]), p));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<std::tr1::shared_ptr<const PackageDepSpec> >::free, ptr));
+ rb_obj_call_init(tdata, argc, argv);
+ return tdata;
+
+
+ }
+ catch (const std::exception & e)
+ {
+ delete ptr;
+ exception_to_ruby_exception(e);
+ }
+ }
+
/*
* call-seq:
* flag -> String
@@ -304,8 +341,8 @@ namespace
* possibly with associated version and SLOT restrictions.
*/
c_package_dep_spec = rb_define_class_under(paludis_module(), "PackageDepSpec", c_string_dep_spec);
- rb_define_singleton_method(c_package_dep_spec, "new", RUBY_FUNC_CAST(&DepSpecThings<PackageDepSpec>::dep_spec_new_1), 1);
- rb_define_method(c_package_dep_spec, "initialize", RUBY_FUNC_CAST(&dep_spec_init_1), 1);
+ rb_define_singleton_method(c_package_dep_spec, "new", RUBY_FUNC_CAST(&package_dep_spec_new), -1);
+ rb_define_method(c_package_dep_spec, "initialize", RUBY_FUNC_CAST(&package_dep_spec_init), -1);
rb_define_method(c_package_dep_spec, "to_s", RUBY_FUNC_CAST(&Common<std::tr1::shared_ptr<const PackageDepSpec> >::to_s_via_ptr), 0);
rb_define_method(c_package_dep_spec, "package", RUBY_FUNC_CAST(&package_dep_spec_package), 0);
rb_define_method(c_package_dep_spec, "text", RUBY_FUNC_CAST(&package_dep_spec_text), 0);
@@ -347,20 +384,36 @@ namespace
rb_define_const(c_version_requirements_mode, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
// cc_enum_special<paludis/version_requirements.hh, VersionRequirementsMode, c_version_requirements_mode>
+
+ /*
+ * Document-module: Paludis::PackageDepSpecParseMode
+ *
+ * How to parse a PackageDepSpec string.
+ *
+ */
+ c_package_dep_spec_parse_mode = rb_define_module_under(paludis_module(), "PackageDepSpecParseMode");
+ for (PackageDepSpecParseMode l(static_cast<PackageDepSpecParseMode>(0)), l_end(last_pds_pm) ; l != l_end ;
+ l = static_cast<PackageDepSpecParseMode>(static_cast<int>(l) + 1))
+ rb_define_const(c_package_dep_spec_parse_mode, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
+
+ // cc_enum_special<paludis/dep_spec-se.hh, PackageDepSpecParseMode, c_package_dep_spec_parse_mode>
}
}
std::tr1::shared_ptr<const PackageDepSpec>
paludis::ruby::value_to_package_dep_spec(VALUE v)
{
- if (T_STRING == TYPE(v))
- return std::tr1::shared_ptr<const PackageDepSpec>(new PackageDepSpec(StringValuePtr(v)));
- else if (rb_obj_is_kind_of(v, c_package_dep_spec))
+ if (rb_obj_is_kind_of(v, c_package_dep_spec))
{
std::tr1::shared_ptr<const PackageDepSpec> * v_ptr;
Data_Get_Struct(v, std::tr1::shared_ptr<const PackageDepSpec>, v_ptr);
return *v_ptr;
}
+ if (T_STRING == TYPE(v))
+ {
+ rb_warn("Calling PackageDepSpec.new with one argument has been deprecated");
+ return std::tr1::shared_ptr<const PackageDepSpec>(new PackageDepSpec(StringValuePtr(v), pds_pm_unspecific));
+ }
else
{
rb_raise(rb_eTypeError, "Can't convert %s into PackageDepSpec", rb_obj_classname(v));
diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb
index 59d8057..ed66b2e 100644
--- a/ruby/dep_spec_TEST.rb
+++ b/ruby/dep_spec_TEST.rb
@@ -21,8 +21,6 @@
require 'test/unit'
require 'Paludis'
-exit 0
-
module Paludis
class TestCase_DepSpec < Test::Unit::TestCase
def test_create_error
@@ -43,7 +41,7 @@ module Paludis
class TestCase_PackageDepSpec < Test::Unit::TestCase
def pda
- PackageDepSpec.new('>=foo/bar-1:100::testrepo')
+ PackageDepSpec.new('>=foo/bar-1:100::testrepo', PackageDepSpecParseMode::Permissive)
end
def test_create
@@ -52,10 +50,10 @@ module Paludis
def test_create_error
assert_raise TypeError do
- v = PackageDepSpec.new(0)
+ v = PackageDepSpec.new(0, PackageDepSpecParseMode::Permissive)
end
assert_raise PackageDepSpecError do
- v = PackageDepSpec.new("=sys-apps/foo")
+ v = PackageDepSpec.new("=sys-apps/foo", PackageDepSpecParseMode::Permissive)
end
end
@@ -110,31 +108,31 @@ module Paludis
class TestCase_BlockDepSpec < Test::Unit::TestCase
def test_create
- v = BlockDepSpec.new(PackageDepSpec.new(">=foo/bar-1"))
- w = BlockDepSpec.new("<=foo/bar-2")
+ v = BlockDepSpec.new(PackageDepSpec.new(">=foo/bar-1", PackageDepSpecParseMode::Permissive))
end
def test_create_error
assert_raise TypeError do
v = BlockDepSpec.new(0)
end
+
assert_raise PackageDepSpecError do
- v = BlockDepSpec.new("=foo/bar")
+ v = BlockDepSpec.new(PackageDepSpec.new("=foo/bar", PackageDepSpecParseMode::Permissive))
end
+
assert_raise TypeError do
v = BlockDepSpec.new(PlainTextDepSpec.new('foo-bar/baz'))
end
end
def test_blocked_spec
- assert_equal "foo/bar", BlockDepSpec.new("foo/bar").blocked_spec.to_s
- assert_equal "foo/baz", BlockDepSpec.new(PackageDepSpec.new("foo/baz")).blocked_spec.to_s
+ assert_equal "foo/baz", BlockDepSpec.new(PackageDepSpec.new("foo/baz", PackageDepSpecParseMode::Permissive)).blocked_spec.to_s
end
end
class TestCase_Composites < Test::Unit::TestCase
def test_composites
- spec = PortageDepParser::parse("|| ( foo/bar foo/baz ) foo/monkey")
+ spec = PortageDepParser::parse_depend("|| ( foo/bar foo/baz ) foo/monkey", PackageDepSpecParseMode::Permissive)
assert_kind_of CompositeDepSpec, spec
assert_kind_of AllDepSpec, spec
diff --git a/ruby/environment.cc b/ruby/environment.cc
index e3fe96c..144a039 100644
--- a/ruby/environment.cc
+++ b/ruby/environment.cc
@@ -429,6 +429,19 @@ namespace
}
}
+ /*
+ * call-seq:
+ * accept_unstable=(true or false)
+ *
+ * Should we accept unstable keywords?
+ */
+ VALUE
+ no_config_environment_set_accept_unstable(VALUE self, VALUE unstable)
+ {
+ value_to_no_config_environment(self)->set_accept_unstable(!(Qfalse == unstable || Qnil == unstable));
+ return Qnil;
+ }
+
VALUE
environment_maker_make_from_spec(VALUE, VALUE spec)
{
@@ -492,6 +505,7 @@ namespace
rb_define_method(c_no_config_environment, "initialize", RUBY_FUNC_CAST(&no_config_environment_init), -1);
rb_define_method(c_no_config_environment, "portage_repository", RUBY_FUNC_CAST(&no_config_environment_portage_repository), 0);
rb_define_method(c_no_config_environment, "master_repository", RUBY_FUNC_CAST(&no_config_environment_master_repository), 0);
+ rb_define_method(c_no_config_environment, "accept_unstable=", RUBY_FUNC_CAST(&no_config_environment_set_accept_unstable), 0);
c_environment_maker = rb_define_class_under(paludis_module(), "EnvironmentMaker", rb_cObject);
rb_funcall(rb_const_get(rb_cObject, rb_intern("Singleton")), rb_intern("included"), 1, c_environment_maker);
diff --git a/ruby/environment_TEST.rb b/ruby/environment_TEST.rb
index cc2572f..ece1445 100644
--- a/ruby/environment_TEST.rb
+++ b/ruby/environment_TEST.rb
@@ -419,5 +419,15 @@ module Paludis
assert_kind_of Array, env.default_destinations
end
end
+
+ class TestCase_EnvironmentSetAcceptUnstable < Test::Unit::TestCase
+ def env
+ NoConfigEnvironment.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo")
+ end
+
+ def test_set_accept_unstable
+ assert_respond_to env, :accept_unstable=
+ end
+ end
end
diff --git a/ruby/package_database_TEST.rb b/ruby/package_database_TEST.rb
index b9ded9e..ac8cb75 100644
--- a/ruby/package_database_TEST.rb
+++ b/ruby/package_database_TEST.rb
@@ -76,6 +76,14 @@ module Paludis
return env.package_database
end
+ def pda
+ PackageDepSpec.new('=foo/bar-1.0', PackageDepSpecParseMode::Permissive)
+ end
+
+ def pda2
+ PackageDepSpec.new('foo/bar', PackageDepSpecParseMode::Permissive)
+ end
+
def test_arg_count
assert_raise ArgumentError do
db.query(1);
@@ -83,15 +91,15 @@ module Paludis
#outputs a deprecation warning
assert_nothing_raised do
- db.query(PackageDepSpec.new("=foo/bar-1.0"), InstallState::Any)
+ db.query(pda, InstallState::Any)
end
assert_nothing_raised do
- db.query(PackageDepSpec.new("=foo/bar-1.0"), InstallState::Any, QueryOrder::Whatever)
+ db.query(pda, InstallState::Any, QueryOrder::Whatever)
end
assert_nothing_raised do
- db.query(Query::Matches.new(PackageDepSpec.new('=foo/bar-1.0')), QueryOrder::Whatever)
+ db.query(Query::Matches.new(pda), QueryOrder::Whatever)
end
assert_raise ArgumentError do
@@ -100,17 +108,17 @@ module Paludis
end
def test_package_database_query
- a = db.query("=foo/bar-1.0", InstallState::InstallableOnly, QueryOrder::Whatever)
+ a = db.query(pda, InstallState::InstallableOnly, QueryOrder::Whatever)
assert_equal a, [ PackageDatabaseEntry.new("foo/bar", "1.0", "testrepo") ]
- a = db.query(Query::Matches.new('=foo/bar-1.0') & Query::RepositoryHasInstallableInterface.new,
+ a = db.query(Query::Matches.new(pda) & Query::RepositoryHasInstallableInterface.new,
QueryOrder::Whatever)
assert_equal a, [ PackageDatabaseEntry.new("foo/bar", "1.0", "testrepo") ]
- a = db.query(PackageDepSpec.new("=foo/bar-1.0"), InstallState::Any, QueryOrder::Whatever)
+ a = db.query(pda, InstallState::Any, QueryOrder::Whatever)
assert_equal a, [ PackageDatabaseEntry.new("foo/bar", "1.0", "testrepo") ]
- a = db.query("foo/bar", InstallState::InstallableOnly, QueryOrder::OrderByVersion)
+ a = db.query(pda2, InstallState::InstallableOnly, QueryOrder::OrderByVersion)
assert_equal a, [
PackageDatabaseEntry.new("foo/bar", "1.0", "testrepo"),
PackageDatabaseEntry.new("foo/bar", "2.0", "testrepo")
@@ -122,10 +130,10 @@ module Paludis
PackageDatabaseEntry.new("foo/bar", "2.0", "testrepo")
]
- a = db.query(">=foo/bar-27", InstallState::InstallableOnly, QueryOrder::Whatever)
+ a = db.query(PackageDepSpec.new('>=foo/bar-27',PackageDepSpecParseMode::Permissive), InstallState::InstallableOnly, QueryOrder::Whatever)
assert a.empty?
- a = db.query("foo/bar", InstallState::InstalledOnly, QueryOrder::Whatever)
+ a = db.query(pda2, InstallState::InstalledOnly, QueryOrder::Whatever)
assert a.empty?
end
@@ -134,7 +142,7 @@ module Paludis
db.query(123, InstallState::Any)
end
assert_raise TypeError do
- db.query(PackageDepSpec.new("foo/bar"), "Either")
+ db.query(pda2, "Either")
end
end
end
diff --git a/ruby/paludis_ruby_TEST.rb b/ruby/paludis_ruby_TEST.rb
index a98f0b4..df54427 100644
--- a/ruby/paludis_ruby_TEST.rb
+++ b/ruby/paludis_ruby_TEST.rb
@@ -38,8 +38,8 @@ module Paludis
def test_match
env = EnvironmentMaker.instance.make_from_spec("")
- spec_good = PackageDepSpec.new('>=foo/bar-1')
- spec_bad = PackageDepSpec.new('>=foo/bar-2')
+ spec_good = PackageDepSpec.new('>=foo/bar-1', PackageDepSpecParseMode::Permissive)
+ spec_bad = PackageDepSpec.new('>=foo/bar-2', PackageDepSpecParseMode::Permissive)
pde = PackageDatabaseEntry.new('foo/bar','1','test')
assert Paludis::match_package(env, spec_good, pde)
@@ -49,7 +49,7 @@ module Paludis
def test_type_errors
env = EnvironmentMaker.instance.make_from_spec("")
- spec = PackageDepSpec.new('>=foo/bar-1')
+ spec = PackageDepSpec.new('>=foo/bar-1', PackageDepSpecParseMode::Permissive)
pde = PackageDatabaseEntry.new('foo/bar','1','test')
assert_raise TypeError do
diff --git a/ruby/portage_dep_parser.cc b/ruby/portage_dep_parser.cc
index 7afeb8d..dba3424 100644
--- a/ruby/portage_dep_parser.cc
+++ b/ruby/portage_dep_parser.cc
@@ -29,74 +29,159 @@ using namespace paludis::ruby;
namespace
{
static VALUE c_portage_dep_parser;
+ static VALUE c_portage_dep_parser_policy;
+
+ VALUE
+ portage_dep_parser_policy_to_value(const PortageDepParser::Policy & p)
+ {
+ PortageDepParser::Policy * p2 (new PortageDepParser::Policy(p));
+ return Data_Wrap_Struct(c_portage_dep_parser_policy, 0, &Common<PortageDepParser::Policy>::free, p2);
+ }
+
+ PortageDepParser::Policy
+ value_to_portage_dep_parser_policy(VALUE v)
+ {
+ if (rb_obj_is_kind_of(v, c_portage_dep_parser_policy))
+ {
+ PortageDepParser::Policy * v_ptr;
+ Data_Get_Struct(v, PortageDepParser::Policy, v_ptr);
+ return *v_ptr;
+ }
+ else
+ {
+ rb_raise(rb_eTypeError, "Can't convert %s into PortageDepParserPolicy", rb_obj_classname(v));
+ }
+ }
-#ifdef CIARANM_REMOVED_THIS
/*
* call-seq:
- * PortageDepParser.parse(dep_string) -> CompositeDepSpec
- * PortageDepParser.parse(dep_string, spec_type, permit_any_deps) -> CompositeDepSpec
+ * PortageDepParser::parse(dep_string, spec_type, permit_any_deps, package_dep_parse_mode = PmPermissive) -> CompositeDepSpec
*
* Parse a given dependency string, and return an appropriate DepSpec tree.
*/
VALUE
- portage_dep_parser_parse(int argc, VALUE * args, VALUE)
+ portage_dep_parser_parse(VALUE, VALUE dep_string, VALUE policy)
+ {
+ try
+ {
+ return dep_spec_to_value(PortageDepParser::parse(StringValuePtr(dep_string),
+ value_to_portage_dep_parser_policy(policy)));
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
+ * PortageDepParser::parse_depend(dep_string, package_dep_parse_mode) -> CompositeDepSpec
+ *
+ * Convenience wrapper for parsing depend strings.
+ */
+ VALUE
+ portage_dep_parser_parse_depend(VALUE, VALUE string, VALUE parse_mode)
+ {
+ try
+ {
+ return dep_spec_to_value(PortageDepParser::parse_depend(StringValuePtr(string), static_cast<PackageDepSpecParseMode>(NUM2INT(parse_mode))));
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
+ * PortageDepParser::parse_license(dep_string) -> CompositeDepSpec
+ *
+ * Convenience wrapper for parsing license strings.
+ */
+ VALUE
+ portage_dep_parser_parse_license(VALUE, VALUE string)
+ {
+ try
+ {
+ return dep_spec_to_value(PortageDepParser::parse_license(StringValuePtr(string)));
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
+ * Policy::text_is_text_dep_spec(permit_any_deps) -> Policy
+ *
+ * Returns a new policy for a PlainTextDepSpec
+ */
+ VALUE
+ portage_dep_parser_policy_text_is_text_dep_spec(VALUE, VALUE permit_any_deps)
{
try
{
- if (1 == argc)
- return dep_spec_to_value(PortageDepParser::parse(StringValuePtr(args[0])));
- else if (3 == argc)
- {
- bool b(! (args[2] == Qnil || args[2] == Qfalse));
-
- switch (NUM2INT(args[1]))
- {
- case 17:
- if (b)
- return dep_spec_to_value(PortageDepParser::parse(StringValuePtr(args[0]),
- PortageDepParserPolicy<PackageDepSpec, true>::get_instance()));
- else
- return dep_spec_to_value(PortageDepParser::parse(StringValuePtr(args[0]),
- PortageDepParserPolicy<PackageDepSpec, false>::get_instance()));
- case 23:
- if (b)
- return dep_spec_to_value(PortageDepParser::parse(StringValuePtr(args[0]),
- PortageDepParserPolicy<PlainTextDepSpec, true>::get_instance()));
- else
- return dep_spec_to_value(PortageDepParser::parse(StringValuePtr(args[0]),
- PortageDepParserPolicy<PlainTextDepSpec, false>::get_instance()));
- }
-
- rb_raise(rb_eArgError, "Bad value '%d' for PortageDepParser::parse parameter 2", NUM2INT(args[1]));
- }
- else
- rb_raise(rb_eArgError, "PortageDepParser::parse expects one or three arguments, but got %d", argc);
+ bool b(! (permit_any_deps == Qnil || permit_any_deps == Qfalse));
+ return portage_dep_parser_policy_to_value(PortageDepParser::Policy::text_is_text_dep_spec(b));
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
+ * Policy::text_is_text_dep_spec(permit_any_deps, parse_mode) -> Policy
+ *
+ * Returns a new policy for a PackageDepSpec
+ */
+ VALUE
+ portage_dep_parser_policy_text_is_package_dep_spec(VALUE, VALUE permit_any_deps, VALUE parse_mode)
+ {
+ try
+ {
+ bool b(! (permit_any_deps == Qnil || permit_any_deps == Qfalse));
+ return portage_dep_parser_policy_to_value(PortageDepParser::Policy::text_is_package_dep_spec(b,
+ static_cast<PackageDepSpecParseMode>(NUM2INT(parse_mode))));
}
catch (const std::exception & e)
{
exception_to_ruby_exception(e);
}
}
-#endif
void do_register_portage_dep_parser()
{
rb_require("singleton");
/*
- * Document-class: Paludis::PortageDepParser
+ * Document-module: Paludis::PortageDepParser
*
- * The PortageDepParser converts string representations of a dependency specification into a DepSpec instance.
+ * The PortageDepParser module contains methods for converting string representations of a
+ * dependency specification into a DepSpec instance.
*/
- c_portage_dep_parser = rb_define_class_under(paludis_module(), "PortageDepParser", rb_cObject);
- rb_funcall(c_portage_dep_parser, rb_intern("private_class_method"), 1, rb_str_new2("new"));
-#ifdef CIARANM_REMOVED_THIS
+ c_portage_dep_parser = rb_define_module_under(paludis_module(), "PortageDepParser");
rb_define_singleton_method(c_portage_dep_parser, "parse",
- RUBY_FUNC_CAST(&portage_dep_parser_parse), -1);
-#endif
+ RUBY_FUNC_CAST(&portage_dep_parser_parse), 2);
+ rb_define_singleton_method(c_portage_dep_parser, "parse_depend",
+ RUBY_FUNC_CAST(&portage_dep_parser_parse_depend), 2);
+ rb_define_singleton_method(c_portage_dep_parser, "parse_license",
+ RUBY_FUNC_CAST(&portage_dep_parser_parse_license), 1);
- rb_define_const(c_portage_dep_parser, "PackageDepSpec", INT2FIX(17));
- rb_define_const(c_portage_dep_parser, "PlainTextDepSpec", INT2FIX(23));
+ /*
+ * Document-class: Paludis::PortageDepParser::Policy
+ *
+ * The Policy class describes how to convert a string representation of a
+ * dependency specification into a DepSpec instance.
+ */
+ c_portage_dep_parser_policy = rb_define_class_under(c_portage_dep_parser, "Policy", rb_cObject);
+ rb_funcall(c_portage_dep_parser_policy, rb_intern("private_class_method"), 1, rb_str_new2("new"));
+ rb_define_singleton_method(c_portage_dep_parser_policy, "text_is_text_dep_spec",
+ RUBY_FUNC_CAST(&portage_dep_parser_policy_text_is_text_dep_spec), 1);
+ rb_define_singleton_method(c_portage_dep_parser_policy, "text_is_package_dep_spec",
+ RUBY_FUNC_CAST(&portage_dep_parser_policy_text_is_package_dep_spec), 2);
}
}
diff --git a/ruby/portage_dep_parser_TEST.rb b/ruby/portage_dep_parser_TEST.rb
index 9fbe0f6..c0a8ca0 100644
--- a/ruby/portage_dep_parser_TEST.rb
+++ b/ruby/portage_dep_parser_TEST.rb
@@ -21,59 +21,89 @@
require 'test/unit'
require 'Paludis'
-exit 0
-
module Paludis
+ class TestCase_Policy < Test::Unit::TestCase
+ def test_package
+ assert_nothing_raised do
+ policy = PortageDepParser::Policy::text_is_package_dep_spec(true, PackageDepSpecParseMode::Permissive)
+ end
+ end
+
+ def test_text
+ assert_nothing_raised do
+ policy = PortageDepParser::Policy::text_is_text_dep_spec(true)
+ end
+ end
+
+ def test_no_create
+ assert_raise NoMethodError do
+ x = PortageDepParser::Policy.new()
+ end
+ end
+ end
+
class TestCase_PortageDepParser < Test::Unit::TestCase
- def test_one_arg
- spec = PortageDepParser::parse("foo/monkey")
- assert_kind_of AllDepSpec, spec
- assert_equal 1, spec.to_a.length
- assert_equal "foo/monkey", spec.to_a[0].to_s
- assert_kind_of PackageDepSpec, spec.to_a[0]
+ def text_false
+ PortageDepParser::Policy::text_is_text_dep_spec(false)
+ end
+
+ def text_true
+ PortageDepParser::Policy::text_is_text_dep_spec(true)
+ end
+
+ def package_false
+ PortageDepParser::Policy::text_is_package_dep_spec(false, PackageDepSpecParseMode::Permissive);
+ end
+
+ def package_true
+ PortageDepParser::Policy::text_is_package_dep_spec(true, PackageDepSpecParseMode::Permissive);
end
def test_many_args
- spec = PortageDepParser::parse("foo/monkey", PortageDepParser::PlainTextDepSpec, false)
+ spec = PortageDepParser::parse("foo/monkey", text_false)
assert_kind_of AllDepSpec, spec
assert_equal 1, spec.to_a.length
- assert_equal "foo/monkey", spec.to_a[0].to_s
- assert_kind_of PlainTextDepSpec, spec.to_a[0]
+ assert_equal "foo/monkey", spec.to_a.first.to_s
+ assert_kind_of PlainTextDepSpec, spec.to_a.first
- spec = PortageDepParser::parse("foo/monkey", PortageDepParser::PlainTextDepSpec, true)
+ spec = PortageDepParser::parse("foo/monkey", text_true)
assert_kind_of AllDepSpec, spec
assert_equal 1, spec.to_a.length
- assert_equal "foo/monkey", spec.to_a[0].to_s
- assert_kind_of PlainTextDepSpec, spec.to_a[0]
+ assert_equal "foo/monkey", spec.to_a.first.to_s
+ assert_kind_of PlainTextDepSpec, spec.to_a.first
- spec = PortageDepParser::parse("foo/monkey", PortageDepParser::PackageDepSpec, false)
+ spec = PortageDepParser::parse("foo/monkey", package_false)
assert_kind_of AllDepSpec, spec
assert_equal 1, spec.to_a.length
- assert_equal "foo/monkey", spec.to_a[0].to_s
- assert_kind_of PackageDepSpec, spec.to_a[0]
+ assert_equal "foo/monkey", spec.to_a.first.to_s
+ assert_kind_of PackageDepSpec, spec.to_a.first
- spec = PortageDepParser::parse("foo/monkey", PortageDepParser::PackageDepSpec, true)
+ spec = PortageDepParser::parse("foo/monkey", package_true)
assert_kind_of AllDepSpec, spec
assert_equal 1, spec.to_a.length
- assert_equal "foo/monkey", spec.to_a[0].to_s
- assert_kind_of PackageDepSpec, spec.to_a[0]
+ assert_equal "foo/monkey", spec.to_a.first.to_s
+ assert_kind_of PackageDepSpec, spec.to_a.first
assert_raise DepStringParseError do
- PortageDepParser::parse("|| ( foo/bar )", PortageDepParser::PackageDepSpec, false)
+ PortageDepParser::parse("|| ( foo/bar )", package_false)
end
- PortageDepParser::parse("|| ( foo/bar )", PortageDepParser::PackageDepSpec, true)
+ assert_nothing_raised do
+ PortageDepParser::parse("|| ( foo/bar )", package_true)
+ end
assert_raise DepStringParseError do
- PortageDepParser::parse("|| ( foo/bar )", PortageDepParser::PlainTextDepSpec, false)
+ PortageDepParser::parse("|| ( foo/bar )", text_false)
end
- PortageDepParser::parse("|| ( foo/bar )", PortageDepParser::PlainTextDepSpec, true)
+ assert_nothing_raised do
+ PortageDepParser::parse("|| ( foo/bar )", text_true)
+ end
end
-
+
def test_dep_string_nesting_error
assert_raise DepStringNestingError do
- PortageDepParser::parse("|| ( foo/var ", PortageDepParser::PackageDepSpec,true)
+ PortageDepParser::parse("|| ( foo/var ", package_true)
end
end
end
diff --git a/ruby/qualified_package_name_TEST.rb b/ruby/qualified_package_name_TEST.rb
index 1784b1c..a545c0e 100644
--- a/ruby/qualified_package_name_TEST.rb
+++ b/ruby/qualified_package_name_TEST.rb
@@ -95,7 +95,7 @@ module Paludis
def test_to_value_type_error
assert_raise TypeError do
- QualifiedPackageName.new('foo-bar/baz') <=> PackageDepSpec.new('foo-bar/baz')
+ QualifiedPackageName.new('foo-bar/baz') <=> PackageDepSpec.new('foo-bar/baz', PackageDepSpecParseMode::Permissive)
end
end
end
diff --git a/ruby/query_TEST.rb b/ruby/query_TEST.rb
index d8274a5..af9ea58 100644
--- a/ruby/query_TEST.rb
+++ b/ruby/query_TEST.rb
@@ -120,7 +120,7 @@ module Paludis
class TestCase_Matches < Test::Unit::TestCase
def get_query
- Query::Matches.new(PackageDepSpec.new('>=foo-bar/baz-1'))
+ Query::Matches.new(PackageDepSpec.new('>=foo-bar/baz-1', PackageDepSpecParseMode::Permissive))
end
def test_create
diff --git a/ruby/repository_TEST.rb b/ruby/repository_TEST.rb
index 0c3d625..404a15f 100644
--- a/ruby/repository_TEST.rb
+++ b/ruby/repository_TEST.rb
@@ -139,7 +139,7 @@ module Paludis
def test_has_version_error
assert_raise TypeError do
- repo.has_version?('foo/bar', PackageDepSpec.new('foo-bar/baz'))
+ repo.has_version?('foo/bar', PackageDepSpec.new('foo-bar/baz', PackageDepSpecParseMode::Permissive))
end
end
end
diff --git a/ruby/version_metadata.cc b/ruby/version_metadata.cc
index fa40e0f..be6b368 100644
--- a/ruby/version_metadata.cc
+++ b/ruby/version_metadata.cc
@@ -146,7 +146,7 @@ namespace
* Document-method: slot
*
* call-seq:
- * slot
+ * slot -> String
*
* Our slot
*/
@@ -154,7 +154,7 @@ namespace
* Document-method: eapi
*
* call-seq:
- * eapi
+ * eapi -> String
*
* Our eapi
*/
@@ -162,7 +162,7 @@ namespace
* Document-method: homepage
*
* call-seq:
- * homepage
+ * homepage -> String
*
* Our homepage
*/
@@ -170,7 +170,7 @@ namespace
* Document-method: description
*
* call-seq:
- * description
+ * description -> String
*
* Our description
*/
@@ -187,18 +187,32 @@ namespace
};
/*
+ * call-seq:
+ * interactive? -> true or false
+ *
+ * Are we interactive.
+ */
+ VALUE
+ version_metadata_interactive(VALUE self)
+ {
+ std::tr1::shared_ptr<const VersionMetadata> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<const VersionMetadata>, self_ptr);
+ return (*self_ptr)-> interactive ? Qtrue : Qfalse;
+ }
+
+ /*
* Document-method: provide_string
*
* call-seq:
- * provide_string
+ * provide_string -> String
*
* Fetches the package provide_string, if ebuild_interface is not Nil.
*/
/*
- * Document-method: src_uri
+ * Document-method: src_uri_string
*
* call-seq:
- * src_uri
+ * src_uri_string -> String
*
* Fetches the package src_uri, if ebuild_interface is not Nil.
*/
@@ -206,7 +220,7 @@ namespace
* Document-method: restrict_string
*
* call-seq:
- * restrict_string
+ * restrict_string -> String
*
* Fetches the package restrict_string, if ebuild_interface is not Nil.
*/
@@ -214,7 +228,7 @@ namespace
* Document-method: eclass_keywords
*
* call-seq:
- * eclass_keywords
+ * eclass_keywords -> String
*
* Fetches the package eclass_keywords, if ebuild_interface is not Nil.
*/
@@ -222,7 +236,7 @@ namespace
* Document-method: iuse
*
* call-seq:
- * iuse
+ * iuse -> String
*
* Fetches the package iuse, if ebuild_interface is not Nil.
*/
@@ -230,7 +244,7 @@ namespace
* Document-method: inherited
*
* call-seq:
- * inherited
+ * inherited -> String
*
* Fetches the package inherited, if ebuild_interface is not Nil.
*/
@@ -481,6 +495,7 @@ namespace
rb_define_method(c_version_metadata, "homepage", RUBY_FUNC_CAST((&BaseValue<std::string, &VersionMetadataBase::homepage>::fetch)), 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);
rb_define_method(c_version_metadata, "provide_string", RUBY_FUNC_CAST((&EbuildValue<std::string,
&VersionMetadataEbuildInterface::provide_string>::fetch)), 0);
diff --git a/ruby/version_metadata_TEST.rb b/ruby/version_metadata_TEST.rb
index 3609199..3e7b122 100644
--- a/ruby/version_metadata_TEST.rb
+++ b/ruby/version_metadata_TEST.rb
@@ -21,8 +21,6 @@
require 'test/unit'
require 'Paludis'
-exit 0
-
Paludis::Log.instance.log_level = Paludis::LogLevel::Warning
module Paludis
@@ -71,11 +69,12 @@ module Paludis
assert_equal "0", vmd("1.0").slot
assert_equal "0", vmd("1.0").eapi
assert_equal "GPL-2", vmd("1.0").license_string
+ assert !vmd('1.0').interactive?
end
def test_ebuild_members
assert_equal "", vmd("1.0").provide_string
- assert_equal "http://example.com/bar-1.0.tar.bz2", vmd("1.0").src_uri
+ assert_equal "http://example.com/bar-1.0.tar.bz2", vmd("1.0").src_uri_string
assert_equal "monkey", vmd("1.0").restrict_string
assert_equal "test", vmd("1.0").keywords.gsub(%r/\s/, "")
assert_equal "", vmd("1.0").iuse.gsub(%r/\s/, "")