aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2006-11-30 22:00:41 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2006-11-30 22:00:41 +0000
commitd2efb088f0952c21b9570be5f3356de044a2c3e7 (patch)
treee79195a8c839633e9d090abe05026a75e9fa7241
parent81de25bf6a4a4eaa33d08edb5f9e32a0bdb9ace3 (diff)
downloadpaludis-d2efb088f0952c21b9570be5f3356de044a2c3e7.tar.gz
paludis-d2efb088f0952c21b9570be5f3356de044a2c3e7.tar.xz
Fix ruby QAEnvironment.
-rw-r--r--ruby/check.cc2
-rw-r--r--ruby/environment.cc28
-rw-r--r--ruby/paludis_ruby.cc2
-rw-r--r--ruby/paludis_ruby.hh22
-rw-r--r--ruby/qa_environment.cc11
-rw-r--r--ruby/qa_environment_TEST.rb5
6 files changed, 38 insertions, 32 deletions
diff --git a/ruby/check.cc b/ruby/check.cc
index 5ae236d..f5cc474 100644
--- a/ruby/check.cc
+++ b/ruby/check.cc
@@ -60,7 +60,7 @@ namespace
ptr = new EbuildCheckData(
value_to_qualified_package_name(argv[0]),
value_to_version_spec(argv[1]),
- value_to_environment(argv[2])
+ value_to_environment_data(argv[2])->env_ptr
);
}
else
diff --git a/ruby/environment.cc b/ruby/environment.cc
index 4978ed1..d98e1ed 100644
--- a/ruby/environment.cc
+++ b/ruby/environment.cc
@@ -35,26 +35,6 @@ namespace
static VALUE c_default_config;
static VALUE c_no_config_environment;
- class EnvironmentData
- {
- private:
- Environment * _e;
-
- public:
- Environment * const env_ptr;
-
- EnvironmentData(Environment * const ee, Environment * const free_e = 0) :
- _e(free_e),
- env_ptr(ee)
- {
- }
-
- ~EnvironmentData()
- {
- delete _e;
- }
- };
-
VALUE
environment_query_use(int argc, VALUE * argv, VALUE self)
{
@@ -285,13 +265,13 @@ namespace
}
}
-Environment *
-paludis::ruby::value_to_environment(VALUE v)
+EnvironmentData *
+paludis::ruby::value_to_environment_data(VALUE v)
{
if (rb_obj_is_kind_of(v, c_environment))
{
- Environment * v_ptr;
- Data_Get_Struct(v, Environment, v_ptr);
+ EnvironmentData * v_ptr;
+ Data_Get_Struct(v, EnvironmentData, v_ptr);
return v_ptr;
}
else
diff --git a/ruby/paludis_ruby.cc b/ruby/paludis_ruby.cc
index b561756..ac184bd 100644
--- a/ruby/paludis_ruby.cc
+++ b/ruby/paludis_ruby.cc
@@ -77,7 +77,7 @@ namespace
{
try
{
- Environment * env = value_to_environment(en);
+ Environment * env = value_to_environment_data(en)->env_ptr;
PackageDepAtom::ConstPointer atom = value_to_package_dep_atom(a);
PackageDatabaseEntry target = value_to_package_database_entry(t);
return match_package(env, atom, target) ? Qtrue : Qfalse;
diff --git a/ruby/paludis_ruby.hh b/ruby/paludis_ruby.hh
index 3d14f7d..2e5adc3 100644
--- a/ruby/paludis_ruby.hh
+++ b/ruby/paludis_ruby.hh
@@ -42,6 +42,26 @@ namespace paludis
namespace ruby
{
+
+ class EnvironmentData
+ {
+ private:
+ Environment * _e;
+
+ public:
+ Environment * const env_ptr;
+
+ EnvironmentData(Environment * const ee, Environment * const free_e = 0) :
+ _e(free_e),
+ env_ptr(ee)
+ {
+ }
+
+ ~EnvironmentData()
+ {
+ delete _e;
+ }
+ };
/* general utilities */
void exception_to_ruby_exception(const std::exception &) PALUDIS_ATTRIBUTE((noreturn));
@@ -67,7 +87,7 @@ namespace paludis
PackageDepAtom::ConstPointer value_to_package_dep_atom(VALUE v);
QualifiedPackageName value_to_qualified_package_name(VALUE v);
PackageDatabaseEntry value_to_package_database_entry(VALUE v);
- Environment* value_to_environment(VALUE v);
+ EnvironmentData* value_to_environment_data(VALUE v);
#ifdef ENABLE_RUBY_QA
VALUE paludis_qa_module();
diff --git a/ruby/qa_environment.cc b/ruby/qa_environment.cc
index 566f5a2..651ff7e 100644
--- a/ruby/qa_environment.cc
+++ b/ruby/qa_environment.cc
@@ -41,28 +41,29 @@ namespace
VALUE
qa_environment_new(int argc, VALUE* argv, VALUE self)
{
- QAEnvironment * ptr(0);
+ std::string write_cache;
try
{
if (1 == argc)
{
- ptr = new QAEnvironment(FSEntry(StringValuePtr(argv[0])));
+ write_cache = "/var/empty";
}
else if (2 == argc)
{
- ptr = new QAEnvironment(FSEntry(StringValuePtr(argv[0])), FSEntry(StringValuePtr(argv[1])));
+ write_cache = StringValuePtr(argv[1]);
}
else
{
rb_raise(rb_eArgError, "QAEnvironment expects one or two arguments, but got %d",argc);
}
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<QAEnvironment>::free, ptr));
+ QAEnvironment * e = new QAEnvironment(FSEntry(StringValuePtr(argv[0])), FSEntry(write_cache));
+ EnvironmentData * ptr(new EnvironmentData(e,e));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<EnvironmentData>::free, ptr));
rb_obj_call_init(tdata, argc, argv);
return tdata;
}
catch (const std::exception & e)
{
- delete ptr;
exception_to_ruby_exception(e);
}
}
diff --git a/ruby/qa_environment_TEST.rb b/ruby/qa_environment_TEST.rb
index fd3f595..aecefd9 100644
--- a/ruby/qa_environment_TEST.rb
+++ b/ruby/qa_environment_TEST.rb
@@ -30,6 +30,11 @@ module Paludis
env = QAEnvironment.new('qa_environment_TEST_dir/repo1')
end
+ def test_as_environment
+ env = QAEnvironment.new('qa_environment_TEST_dir/repo1')
+ assert_kind_of PackageDatabase, env.package_database
+ end
+
def test_pass
env = QAEnvironment.new('qa_environment_TEST_dir/repo1')
check = EbuildCheckMaker.instance.find_maker('create_metadata')