aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-06 14:40:53 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-06 14:40:53 +0000
commitf7096d1f89430e7b199f2e2c26b33c8c233fb728 (patch)
tree3578c58ff10854c7293e159f77d905f97fc7069a
parent550c857e9c3aa30b6084c6d4927b0ccc5f102ca8 (diff)
downloadpaludis-f7096d1f89430e7b199f2e2c26b33c8c233fb728.tar.gz
paludis-f7096d1f89430e7b199f2e2c26b33c8c233fb728.tar.xz
(ruby) Add missing VersionSpec methods to Ruby. Implement example_version_spec in Ruby.
-rw-r--r--doc/api/index.html.part2
-rw-r--r--doc/api/ruby/Makefile.am3
-rw-r--r--doc/api/ruby/example_version_spec.rb26
-rw-r--r--ruby/version_spec.cc26
-rw-r--r--ruby/version_spec_TEST.rb12
5 files changed, 65 insertions, 4 deletions
diff --git a/doc/api/index.html.part b/doc/api/index.html.part
index f281693..3d7ee0c 100644
--- a/doc/api/index.html.part
+++ b/doc/api/index.html.part
@@ -153,7 +153,7 @@ how concepts map on to different language bindings.</p>
<tr>
<td>example_version_spec</td>
<td><a href="cplusplus/example__version__spec_8cc-example.html">C++</a></td>
- <td></td>
+ <td><a href="ruby/example_version_spec.html">Ruby</a></td>
<td></td>
</tr>
</table>
diff --git a/doc/api/ruby/Makefile.am b/doc/api/ruby/Makefile.am
index b7e305b..91b8cf6 100644
--- a/doc/api/ruby/Makefile.am
+++ b/doc/api/ruby/Makefile.am
@@ -26,7 +26,8 @@ examples = \
example_about.rb \
example_action.rb \
example_contents.rb \
- example_dep_spec.rb
+ example_dep_spec.rb \
+ example_version_spec.rb
EXTRA_DIST = $(examples)
diff --git a/doc/api/ruby/example_version_spec.rb b/doc/api/ruby/example_version_spec.rb
new file mode 100644
index 0000000..8a2669d
--- /dev/null
+++ b/doc/api/ruby/example_version_spec.rb
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+# vim: set sw=4 sts=4 et tw=100 :
+
+require 'Paludis'
+
+include Paludis
+
+# Make a set of versions
+versions = %w{1.0 1.1 1.2 1.2-r1 2.0 2.0-try1 2.0-scm 9999}.map do | v |
+ VersionSpec.new v
+end.sort
+
+# For each version...
+versions.each do | v |
+ puts "#{v}:"
+
+ # Show the output of various members.
+ puts " Remove revision: #{v.remove_revision}"
+ puts " Revision only: #{v.revision_only}"
+ puts " Bump: #{v.bump}"
+ puts " Is SCM? #{v.is_scm?}"
+ puts " Has -try? #{v.has_try_part?}"
+ puts " Has -scm? #{v.has_scm_part?}"
+ puts
+end
+
diff --git a/ruby/version_spec.cc b/ruby/version_spec.cc
index c754360..60701c0 100644
--- a/ruby/version_spec.cc
+++ b/ruby/version_spec.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh
+ * Copyright (c) 2006, 2007 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -122,6 +122,28 @@ namespace
return value_to_version_spec(self).is_scm() ? Qtrue : Qfalse;
}
+ /*
+ * call-seq:
+ * has_scm_part? -> true or false
+ *
+ * Do we have an -scm part?
+ */
+ VALUE version_spec_has_scm_part(VALUE self)
+ {
+ return value_to_version_spec(self).has_scm_part() ? Qtrue : Qfalse;
+ }
+
+ /*
+ * call-seq:
+ * has_try_part? -> true or false
+ *
+ * Do we have a -try part?
+ */
+ VALUE version_spec_has_try_part(VALUE self)
+ {
+ return value_to_version_spec(self).has_try_part() ? Qtrue : Qfalse;
+ }
+
void do_register_version_spec()
{
/*
@@ -140,6 +162,8 @@ namespace
rb_define_method(c_version_spec, "revision_only", RUBY_FUNC_CAST(&version_spec_revision_only), 0);
rb_define_method(c_version_spec, "bump", RUBY_FUNC_CAST(&version_spec_bump), 0);
rb_define_method(c_version_spec, "is_scm?", RUBY_FUNC_CAST(&version_spec_is_scm), 0);
+ rb_define_method(c_version_spec, "has_try_part?", RUBY_FUNC_CAST(&version_spec_has_try_part), 0);
+ rb_define_method(c_version_spec, "has_scm_part?", RUBY_FUNC_CAST(&version_spec_has_scm_part), 0);
}
}
diff --git a/ruby/version_spec_TEST.rb b/ruby/version_spec_TEST.rb
index 10fa2eb..cf9c416 100644
--- a/ruby/version_spec_TEST.rb
+++ b/ruby/version_spec_TEST.rb
@@ -2,7 +2,7 @@
# vim: set sw=4 sts=4 et tw=80 :
#
-# Copyright (c) 2006 Ciaran McCreesh
+# Copyright (c) 2006, 2007 Ciaran McCreesh
#
# This file is part of the Paludis package manager. Paludis is free software;
# you can redistribute it and/or modify it under the terms of the GNU General
@@ -69,6 +69,16 @@ module Paludis
assert_equal false, VersionSpec.new('0.1').is_scm?
end
+ def test_has_scm_part?
+ assert_equal true, VersionSpec.new('scm').has_scm_part?
+ assert_equal false, VersionSpec.new('0.1').has_scm_part?
+ end
+
+ def test_has_try_part?
+ assert_equal true, VersionSpec.new('1.2-try3').has_try_part?
+ assert_equal false, VersionSpec.new('0.1').has_try_part?
+ end
+
def test_bump
assert_equal VersionSpec.new('2'), VersionSpec.new('1').bump
assert_equal VersionSpec.new('2'), VersionSpec.new('1.2').bump