aboutsummaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-11-06 14:08:54 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-11-06 18:35:00 +0000
commit40281ddc9fcadf6c196d435339c75934a3c876af (patch)
treec11f7407f653568c8fa0b8c7c917b27ea736ae4e /ruby
parenta360e94b28c1bbd9c3c0f3cf6046428fcdecba25 (diff)
downloadpaludis-40281ddc9fcadf6c196d435339c75934a3c876af.tar.gz
paludis-40281ddc9fcadf6c196d435339c75934a3c876af.tar.xz
Expose less about profiles
Diffstat (limited to 'ruby')
-rw-r--r--ruby/environment.cc1
-rw-r--r--ruby/paludis_ruby.hh1
-rw-r--r--ruby/repository.cc197
-rw-r--r--ruby/repository_TEST.rb81
4 files changed, 3 insertions, 277 deletions
diff --git a/ruby/environment.cc b/ruby/environment.cc
index d3b5f6fc6..67de47656 100644
--- a/ruby/environment.cc
+++ b/ruby/environment.cc
@@ -391,6 +391,7 @@ namespace
value_for<n::extra_params>(std::tr1::shared_ptr<Map<std::string, std::string> >()),
value_for<n::extra_repository_dirs>(extra_repository_dirs),
value_for<n::master_repository_name>(master_repository_name),
+ value_for<n::profiles_if_not_auto>(""),
value_for<n::repository_dir>(FSEntry(path)),
value_for<n::repository_type>(no_config_environment::ncer_auto),
value_for<n::write_cache>(write_cache)
diff --git a/ruby/paludis_ruby.hh b/ruby/paludis_ruby.hh
index 93f6d21b5..40234e6b8 100644
--- a/ruby/paludis_ruby.hh
+++ b/ruby/paludis_ruby.hh
@@ -119,7 +119,6 @@ namespace paludis
QualifiedPackageName value_to_qualified_package_name(VALUE v);
std::tr1::shared_ptr<Environment> value_to_environment(VALUE v);
std::tr1::shared_ptr<NoConfigEnvironment> value_to_no_config_environment(VALUE v);
- RepositoryEInterface::ProfilesDescLine value_to_profiles_desc_line(VALUE v);
std::tr1::shared_ptr<Repository> value_to_repository(VALUE);
std::tr1::shared_ptr<const SupportsActionTestBase> value_to_supports_action_test_base(VALUE v);
std::tr1::shared_ptr<Action> value_to_action(VALUE v);
diff --git a/ruby/repository.cc b/ruby/repository.cc
index b27d7b965..1c26e1605 100644
--- a/ruby/repository.cc
+++ b/ruby/repository.cc
@@ -43,18 +43,10 @@ using namespace paludis::ruby;
namespace
{
static VALUE c_repository;
- static VALUE c_profiles_desc_line;
static VALUE c_fake_repository_base;
static VALUE c_fake_repository;
static VALUE c_fake_installed_repository;
- VALUE
- profiles_desc_line_to_value(const RepositoryEInterface::ProfilesDescLine & v)
- {
- RepositoryEInterface::ProfilesDescLine * vv(new RepositoryEInterface::ProfilesDescLine(v));
- return Data_Wrap_Struct(c_profiles_desc_line, 0, &Common<RepositoryEInterface::ProfilesDescLine>::free, vv);
- }
-
std::tr1::shared_ptr<FakeRepositoryBase>
value_to_fake_repository_base(VALUE v)
{
@@ -395,158 +387,6 @@ namespace
/*
* call-seq:
- * profiles -> Array
- *
- * Fetch an array of our profiles, as ProfilesDescLine.
- */
- VALUE
- repository_profiles(VALUE self)
- {
- try
- {
- std::tr1::shared_ptr<Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
- if ((**self_ptr).e_interface())
- {
- VALUE result(rb_ary_new());
- for (RepositoryEInterface::ProfilesConstIterator i((**self_ptr).e_interface()->begin_profiles()),
- i_end((**self_ptr).e_interface()->end_profiles()) ; i != i_end ; ++i)
- {
- rb_ary_push(result, profiles_desc_line_to_value(*i));
- }
- return result;
- }
- else
- {
- return Qnil;
- }
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * find_profile(profile_location) -> ProfilesDescLine
- *
- * Fetches the named profile.
- */
- VALUE
- repository_find_profile(VALUE self, VALUE profile)
- {
- try
- {
- std::tr1::shared_ptr<Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
-
- if ((**self_ptr).e_interface())
- {
- RepositoryEInterface::ProfilesConstIterator p((**self_ptr).e_interface()->find_profile(FSEntry(StringValuePtr(profile))));
-
- if (p == (**self_ptr).e_interface()->end_profiles())
- return Qnil;
-
- return profiles_desc_line_to_value(*p);
- }
- else
- {
- return Qnil;
- }
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * set_profile(profile) -> Nil
- *
- * Sets the repository profile to the given profile.
- */
- VALUE
- repository_set_profile(VALUE self, VALUE profile)
- {
- try
- {
- std::tr1::shared_ptr<Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
- if ((**self_ptr).e_interface())
- (**self_ptr).e_interface()->set_profile(
- (**self_ptr).e_interface()->find_profile(
- value_to_profiles_desc_line(profile).path()));
- return Qnil;
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * profile_variable(variable) -> String
- *
- * Fetches the named variable.
- */
- VALUE
- repository_profile_variable(VALUE self, VALUE var)
- {
- try
- {
- std::tr1::shared_ptr<Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
- if ((**self_ptr).e_interface())
- return rb_str_new2(((**self_ptr).e_interface()->profile_variable(StringValuePtr(var))).c_str());
- return Qnil;
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * Document-method: arch
- *
- * call-seq:
- * arch -> String
- *
- * Fetch arch for this ProfilesDescLine.
- */
- /*
- * Document-method: status
- *
- * call-seq:
- * status -> String
- *
- * Fetch status for this ProfilesDescLine.
- */
- /*
- * Document-method: path
- *
- * call-seq:
- * path -> String
- *
- * Fetch path to this ProfilesDescLine.
- */
- template <typename K_, typename V_, NamedValue<V_, K_> (RepositoryEInterface::ProfilesDescLine::* f_)>
- struct DescLineValue
- {
- static VALUE
- fetch(VALUE self)
- {
- RepositoryEInterface::ProfilesDescLine * ptr;
- Data_Get_Struct(self, RepositoryEInterface::ProfilesDescLine, ptr);
- return rb_str_new2(stringify(((*ptr).*f_)()).c_str());
- }
- };
-
- /*
- * call-seq:
* add_category(category_name) -> Nil
*
* Add a category.
@@ -843,16 +683,8 @@ namespace
n::provides_interface, RepositoryProvidesInterface, &Repository::provides_interface>::fetch)), 0);
rb_define_method(c_repository, "virtuals_interface", RUBY_FUNC_CAST((&Interface<
n::virtuals_interface, RepositoryVirtualsInterface, &Repository::virtuals_interface>::fetch)), 0);
- rb_define_method(c_repository, "e_interface", RUBY_FUNC_CAST((&Interface<
- n::e_interface, RepositoryEInterface, &Repository::e_interface>::fetch)), 0);
-
rb_define_method(c_repository, "some_ids_might_support_action", RUBY_FUNC_CAST(&repository_some_ids_might_support_action), 1);
- rb_define_method(c_repository, "profiles", RUBY_FUNC_CAST(&repository_profiles),0);
- rb_define_method(c_repository, "find_profile", RUBY_FUNC_CAST(&repository_find_profile),1);
- rb_define_method(c_repository, "profile_variable", RUBY_FUNC_CAST(&repository_profile_variable),1);
- rb_define_method(c_repository, "set_profile", RUBY_FUNC_CAST(&repository_set_profile),1);
-
rb_define_method(c_repository, "[]", RUBY_FUNC_CAST(&repository_subscript), 1);
rb_define_method(c_repository, "each_metadata", RUBY_FUNC_CAST(&repository_each_metadata), 0);
rb_define_method(c_repository, "format_key",
@@ -867,20 +699,6 @@ namespace
rb_define_method(c_repository, "mirrors", RUBY_FUNC_CAST(&repository_mirrors), 1);
/*
- * Document-class: Paludis::ProfilesDescLine
- *
- *
- */
- c_profiles_desc_line = rb_define_class_under(paludis_module(), "ProfilesDescLine", rb_cObject);
- rb_funcall(c_profiles_desc_line, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_profiles_desc_line, "path",
- RUBY_FUNC_CAST((&DescLineValue<FSEntry, n::path, &RepositoryEInterface::ProfilesDescLine::path>::fetch)), 0);
- rb_define_method(c_profiles_desc_line, "arch",
- RUBY_FUNC_CAST((&DescLineValue<std::string, n::arch, &RepositoryEInterface::ProfilesDescLine::arch>::fetch)), 0);
- rb_define_method(c_profiles_desc_line, "status",
- RUBY_FUNC_CAST((&DescLineValue<std::string, n::status, &RepositoryEInterface::ProfilesDescLine::status>::fetch)), 0);
-
- /*
* Document-class: Paludis::FakeRepositoryBase
*
* A FakeRepositoryBase is a Repository subclass whose subclasses are used for
@@ -952,21 +770,6 @@ paludis::ruby::value_to_repository(VALUE v)
}
}
-RepositoryEInterface::ProfilesDescLine
-paludis::ruby::value_to_profiles_desc_line(VALUE v)
-{
- if (rb_obj_is_kind_of(v, c_profiles_desc_line))
- {
- RepositoryEInterface::ProfilesDescLine * v_ptr;
- Data_Get_Struct(v, RepositoryEInterface::ProfilesDescLine, v_ptr);
- return *v_ptr;
- }
- else
- {
- rb_raise(rb_eTypeError, "Can't convert %s into ProfilesDescLine", rb_obj_classname(v));
- }
-}
-
RegisterRubyClass::Register paludis_ruby_register_repository PALUDIS_ATTRIBUTE((used))
(&do_register_repository);
diff --git a/ruby/repository_TEST.rb b/ruby/repository_TEST.rb
index e3826994f..4d3f8a594 100644
--- a/ruby/repository_TEST.rb
+++ b/ruby/repository_TEST.rb
@@ -167,14 +167,14 @@ module Paludis
repo = no_config_testrepo.main_repository
[
:mirrors_interface, :environment_variable_interface,
- :provides_interface, :virtuals_interface, :e_interface].each do |sym|
+ :provides_interface, :virtuals_interface].each do |sym|
assert_respond_to repo, sym
end
end
def test_interfaces
assert_equal installed_repo.name, installed_repo.provides_interface.name
- assert_nil installed_repo.e_interface
+ assert_nil installed_repo.mirrors_interface
end
def text_repository_environment_interface
@@ -254,83 +254,6 @@ module Paludis
end
end
- class TestCase_RepositoryPortageInterface < Test::Unit::TestCase
- include RepositoryTestCase
-
- def test_responds
- repo = no_config_testrepo.main_repository
- [:profile_variable, :profiles, :find_profile, :set_profile].each do |sym|
- assert_respond_to repo, sym
- end
- end
-
- def test_profiles
- repo = no_config_testrepo.main_repository
- assert_kind_of Array, repo.profiles
- end
-
- def test_find_profile
- repo = no_config_testrepo.main_repository
- assert_nothing_raised do
- profile = repo.find_profile(Dir.getwd().to_s + '/repository_TEST_dir/testrepo/profiles/testprofile')
- assert_kind_of ProfilesDescLine, profile
- profile = repo.find_profile('broken')
- assert profile.nil?
- end
- end
-
- def test_set_profile
- repo = no_config_testrepo.main_repository
- assert_nothing_raised do
- profile = repo.profiles.first
- repo.set_profile(profile)
- end
- end
-
- def test_profile_variable
- repo = no_config_testrepo.main_repository
- assert_nothing_raised do
- assert_equal 'test', repo.profile_variable('ARCH')
- end
- end
- end
-
- class TestCase_ProfilesDescLine < Test::Unit::TestCase
- include RepositoryTestCase
-
- def profiles
- no_config_testrepo.main_repository.profiles
- end
-
- def test_profiles
- assert_kind_of Array, profiles
- assert_equal 1, profiles.length
- assert_kind_of ProfilesDescLine, profiles.first
- end
-
- def test_respond
- assert_respond_to profiles.first, :path
- assert_respond_to profiles.first, :arch
- assert_respond_to profiles.first, :status
- end
-
- def test_profile_path
- assert_kind_of String, profiles.first.path
- assert_equal Dir.getwd().to_s + "/repository_TEST_dir/testrepo/profiles/testprofile",
- profiles.first.path
- end
-
- def test_profile_arch
- assert_kind_of String, profiles.first.arch
- assert_equal 'x86', profiles.first.arch
- end
-
- def test_profile_status
- assert_kind_of String, profiles.first.status
- assert_equal 'stable', profiles.first.status
- end
- end
-
class TestCase_RepositorySomeIdsMightSupport < Test::Unit::TestCase
include RepositoryTestCase