class Paludis::VersionSpec

A VersionSpec represents a version number (for example, 1.2.3b-r1). Includes Comparable

Public Class Methods

new(version_string) → VersionSpec click to toggle source

Creates a new VersionSpec from the given string.

VALUE
    version_spec_new(VALUE self, VALUE s)
    {
        VersionSpec * ptr(0);
        try
        {
            ptr = new VersionSpec(std::string(StringValuePtr(s)), user_version_spec_options());
            VALUE tdata(Data_Wrap_Struct(self, 0, &Common<VersionSpec>::free, ptr));
            rb_obj_call_init(tdata, 1, &s);
            return tdata;
        }
        catch (const std::exception & e)
        {
            delete ptr;
            exception_to_ruby_exception(e);
        }
    }

    /*
     * call-seq:
     *     remove_revision -> VersionSpec
     *
     * Returns a VersionSpec without the revision part.
     */
    VALUE
    version_spec_remove_revision(VALUE self)
    {
        try
        {
            return version_spec_to_value(value_to_version_spec(self).remove_revision());
        }
        catch (const std::exception & e)
        {
            exception_to_ruby_exception(e);
        }
    }

    /*
     * call-seq:
     *     revision_only -> String
     *
     * Revision part only (or "r0").
     */
    VALUE
    version_spec_revision_only(VALUE self)
    {
        try
        {
            return rb_str_new2((value_to_version_spec(self).revision_only().c_str()));
        }
        catch (const std::exception & e)
        {
            exception_to_ruby_exception(e);
        }
    }

    /*
     * call-seq:
     *     bump -> VersionSpec
     *
     * This is used by the ~> operator. It returns a VersionSpec where the next to last number is one greater (e.g. 5.3.1 => 5.4).
     * Any non number parts are stripped (e.g. 1.2.3_alpha4-r5 => 1.3).
     */
    VALUE
    version_spec_bump(VALUE self)
    {
        return version_spec_to_value(value_to_version_spec(self).bump());
    }

    /*
     * call-seq:
     *     is_scm? -> true or false
     *
     * Are we an -scm package, or something pretending to be one?
     */
    VALUE version_spec_is_scm(VALUE self)
    {
        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;
    }

    /*
     *  call-seq:
     *      to_s -> String
     *
     * Return as String
     */
    FAKE_RDOC_METHOD(version_spec_to_s)

    /*
     *  call-seq:
     *      <=>(VersionSpec) -> -1, 0, +1
     *
     * Comparison—Returns -1, 0, or +1 depending on whether provided VersionSpec is less than, equal to, or greater than this VersionSpec. This is the basis for the tests in Comparable.
     */
    FAKE_RDOC_METHOD(version_spec_compare)

    void do_register_version_spec()
    {
        /*
         * Document-class: Paludis::VersionSpec
         *
         * A VersionSpec represents a version number (for example, 1.2.3b-r1). Includes
         * Comparable[http://www.ruby-doc.org/core/classes/Comparable.html]
         */
        c_version_spec = rb_define_class_under(c_paludis_module, "VersionSpec", rb_cObject);
        rb_define_singleton_method(c_version_spec, "new", version_spec_new, 1);
        rb_define_method(c_version_spec, "initialize", version_spec_init, 1);
        rb_define_method(c_version_spec, "<=>", version_spec_compare, 1)
        rb_include_module(c_version_spec, rb_mComparable);
        rb_define_method(c_version_spec, "bump", version_spec_bump, 0);
        rb_define_method(c_version_spec, "is_scm?", version_spec_is_scm, 0);
        rb_define_method(c_version_spec, "has_scm_part?", version_spec_has_scm_part, 0);
        rb_define_method(c_version_spec, "has_try_part?", version_spec_has_try_part, 0);
        rb_define_method(c_version_spec, "remove_revision", version_spec_remove_revision, 0);
        rb_define_method(c_version_spec, "revision_only", version_spec_revision_only, 0);
        rb_define_method(c_version_spec, "to_s", version_spec_to_s, 0)
    }
}

Public Instance Methods

bump → VersionSpec click to toggle source

This is used by the ~> operator. It returns a VersionSpec where the next to last number is one greater (e.g. 5.3.1 => 5.4). Any non number parts are stripped (e.g. 1.2.3_alpha4-r5 => 1.3).

VALUE
    version_spec_bump(VALUE self)
    {
        return version_spec_to_value(value_to_version_spec(self).bump());
    }

    /*
     * call-seq:
     *     is_scm? -> true or false
     *
     * Are we an -scm package, or something pretending to be one?
     */
    VALUE version_spec_is_scm(VALUE self)
    {
        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;
    }

    /*
     *  call-seq:
     *      to_s -> String
     *
     * Return as String
     */
    FAKE_RDOC_METHOD(version_spec_to_s)

    /*
     *  call-seq:
     *      <=>(VersionSpec) -> -1, 0, +1
     *
     * Comparison—Returns -1, 0, or +1 depending on whether provided VersionSpec is less than, equal to, or greater than this VersionSpec. This is the basis for the tests in Comparable.
     */
    FAKE_RDOC_METHOD(version_spec_compare)

    void do_register_version_spec()
    {
        /*
         * Document-class: Paludis::VersionSpec
         *
         * A VersionSpec represents a version number (for example, 1.2.3b-r1). Includes
         * Comparable[http://www.ruby-doc.org/core/classes/Comparable.html]
         */
        c_version_spec = rb_define_class_under(c_paludis_module, "VersionSpec", rb_cObject);
        rb_define_singleton_method(c_version_spec, "new", version_spec_new, 1);
        rb_define_method(c_version_spec, "initialize", version_spec_init, 1);
        rb_define_method(c_version_spec, "<=>", version_spec_compare, 1)
        rb_include_module(c_version_spec, rb_mComparable);
        rb_define_method(c_version_spec, "bump", version_spec_bump, 0);
        rb_define_method(c_version_spec, "is_scm?", version_spec_is_scm, 0);
        rb_define_method(c_version_spec, "has_scm_part?", version_spec_has_scm_part, 0);
        rb_define_method(c_version_spec, "has_try_part?", version_spec_has_try_part, 0);
        rb_define_method(c_version_spec, "remove_revision", version_spec_remove_revision, 0);
        rb_define_method(c_version_spec, "revision_only", version_spec_revision_only, 0);
        rb_define_method(c_version_spec, "to_s", version_spec_to_s, 0)
    }
}
has_scm_part? → true or false click to toggle source

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;
    }

    /*
     *  call-seq:
     *      to_s -> String
     *
     * Return as String
     */
    FAKE_RDOC_METHOD(version_spec_to_s)

    /*
     *  call-seq:
     *      <=>(VersionSpec) -> -1, 0, +1
     *
     * Comparison—Returns -1, 0, or +1 depending on whether provided VersionSpec is less than, equal to, or greater than this VersionSpec. This is the basis for the tests in Comparable.
     */
    FAKE_RDOC_METHOD(version_spec_compare)

    void do_register_version_spec()
    {
        /*
         * Document-class: Paludis::VersionSpec
         *
         * A VersionSpec represents a version number (for example, 1.2.3b-r1). Includes
         * Comparable[http://www.ruby-doc.org/core/classes/Comparable.html]
         */
        c_version_spec = rb_define_class_under(c_paludis_module, "VersionSpec", rb_cObject);
        rb_define_singleton_method(c_version_spec, "new", version_spec_new, 1);
        rb_define_method(c_version_spec, "initialize", version_spec_init, 1);
        rb_define_method(c_version_spec, "<=>", version_spec_compare, 1)
        rb_include_module(c_version_spec, rb_mComparable);
        rb_define_method(c_version_spec, "bump", version_spec_bump, 0);
        rb_define_method(c_version_spec, "is_scm?", version_spec_is_scm, 0);
        rb_define_method(c_version_spec, "has_scm_part?", version_spec_has_scm_part, 0);
        rb_define_method(c_version_spec, "has_try_part?", version_spec_has_try_part, 0);
        rb_define_method(c_version_spec, "remove_revision", version_spec_remove_revision, 0);
        rb_define_method(c_version_spec, "revision_only", version_spec_revision_only, 0);
        rb_define_method(c_version_spec, "to_s", version_spec_to_s, 0)
    }
}
has_try_part? → true or false click to toggle source

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;
    }

    /*
     *  call-seq:
     *      to_s -> String
     *
     * Return as String
     */
    FAKE_RDOC_METHOD(version_spec_to_s)

    /*
     *  call-seq:
     *      <=>(VersionSpec) -> -1, 0, +1
     *
     * Comparison—Returns -1, 0, or +1 depending on whether provided VersionSpec is less than, equal to, or greater than this VersionSpec. This is the basis for the tests in Comparable.
     */
    FAKE_RDOC_METHOD(version_spec_compare)

    void do_register_version_spec()
    {
        /*
         * Document-class: Paludis::VersionSpec
         *
         * A VersionSpec represents a version number (for example, 1.2.3b-r1). Includes
         * Comparable[http://www.ruby-doc.org/core/classes/Comparable.html]
         */
        c_version_spec = rb_define_class_under(c_paludis_module, "VersionSpec", rb_cObject);
        rb_define_singleton_method(c_version_spec, "new", version_spec_new, 1);
        rb_define_method(c_version_spec, "initialize", version_spec_init, 1);
        rb_define_method(c_version_spec, "<=>", version_spec_compare, 1)
        rb_include_module(c_version_spec, rb_mComparable);
        rb_define_method(c_version_spec, "bump", version_spec_bump, 0);
        rb_define_method(c_version_spec, "is_scm?", version_spec_is_scm, 0);
        rb_define_method(c_version_spec, "has_scm_part?", version_spec_has_scm_part, 0);
        rb_define_method(c_version_spec, "has_try_part?", version_spec_has_try_part, 0);
        rb_define_method(c_version_spec, "remove_revision", version_spec_remove_revision, 0);
        rb_define_method(c_version_spec, "revision_only", version_spec_revision_only, 0);
        rb_define_method(c_version_spec, "to_s", version_spec_to_s, 0)
    }
}
is_scm? → true or false click to toggle source

Are we an -scm package, or something pretending to be one?

VALUE version_spec_is_scm(VALUE self)
    {
        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;
    }

    /*
     *  call-seq:
     *      to_s -> String
     *
     * Return as String
     */
    FAKE_RDOC_METHOD(version_spec_to_s)

    /*
     *  call-seq:
     *      <=>(VersionSpec) -> -1, 0, +1
     *
     * Comparison—Returns -1, 0, or +1 depending on whether provided VersionSpec is less than, equal to, or greater than this VersionSpec. This is the basis for the tests in Comparable.
     */
    FAKE_RDOC_METHOD(version_spec_compare)

    void do_register_version_spec()
    {
        /*
         * Document-class: Paludis::VersionSpec
         *
         * A VersionSpec represents a version number (for example, 1.2.3b-r1). Includes
         * Comparable[http://www.ruby-doc.org/core/classes/Comparable.html]
         */
        c_version_spec = rb_define_class_under(c_paludis_module, "VersionSpec", rb_cObject);
        rb_define_singleton_method(c_version_spec, "new", version_spec_new, 1);
        rb_define_method(c_version_spec, "initialize", version_spec_init, 1);
        rb_define_method(c_version_spec, "<=>", version_spec_compare, 1)
        rb_include_module(c_version_spec, rb_mComparable);
        rb_define_method(c_version_spec, "bump", version_spec_bump, 0);
        rb_define_method(c_version_spec, "is_scm?", version_spec_is_scm, 0);
        rb_define_method(c_version_spec, "has_scm_part?", version_spec_has_scm_part, 0);
        rb_define_method(c_version_spec, "has_try_part?", version_spec_has_try_part, 0);
        rb_define_method(c_version_spec, "remove_revision", version_spec_remove_revision, 0);
        rb_define_method(c_version_spec, "revision_only", version_spec_revision_only, 0);
        rb_define_method(c_version_spec, "to_s", version_spec_to_s, 0)
    }
}
remove_revision → VersionSpec click to toggle source

Returns a VersionSpec without the revision part.

VALUE
    version_spec_remove_revision(VALUE self)
    {
        try
        {
            return version_spec_to_value(value_to_version_spec(self).remove_revision());
        }
        catch (const std::exception & e)
        {
            exception_to_ruby_exception(e);
        }
    }

    /*
     * call-seq:
     *     revision_only -> String
     *
     * Revision part only (or "r0").
     */
    VALUE
    version_spec_revision_only(VALUE self)
    {
        try
        {
            return rb_str_new2((value_to_version_spec(self).revision_only().c_str()));
        }
        catch (const std::exception & e)
        {
            exception_to_ruby_exception(e);
        }
    }

    /*
     * call-seq:
     *     bump -> VersionSpec
     *
     * This is used by the ~> operator. It returns a VersionSpec where the next to last number is one greater (e.g. 5.3.1 => 5.4).
     * Any non number parts are stripped (e.g. 1.2.3_alpha4-r5 => 1.3).
     */
    VALUE
    version_spec_bump(VALUE self)
    {
        return version_spec_to_value(value_to_version_spec(self).bump());
    }

    /*
     * call-seq:
     *     is_scm? -> true or false
     *
     * Are we an -scm package, or something pretending to be one?
     */
    VALUE version_spec_is_scm(VALUE self)
    {
        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;
    }

    /*
     *  call-seq:
     *      to_s -> String
     *
     * Return as String
     */
    FAKE_RDOC_METHOD(version_spec_to_s)

    /*
     *  call-seq:
     *      <=>(VersionSpec) -> -1, 0, +1
     *
     * Comparison—Returns -1, 0, or +1 depending on whether provided VersionSpec is less than, equal to, or greater than this VersionSpec. This is the basis for the tests in Comparable.
     */
    FAKE_RDOC_METHOD(version_spec_compare)

    void do_register_version_spec()
    {
        /*
         * Document-class: Paludis::VersionSpec
         *
         * A VersionSpec represents a version number (for example, 1.2.3b-r1). Includes
         * Comparable[http://www.ruby-doc.org/core/classes/Comparable.html]
         */
        c_version_spec = rb_define_class_under(c_paludis_module, "VersionSpec", rb_cObject);
        rb_define_singleton_method(c_version_spec, "new", version_spec_new, 1);
        rb_define_method(c_version_spec, "initialize", version_spec_init, 1);
        rb_define_method(c_version_spec, "<=>", version_spec_compare, 1)
        rb_include_module(c_version_spec, rb_mComparable);
        rb_define_method(c_version_spec, "bump", version_spec_bump, 0);
        rb_define_method(c_version_spec, "is_scm?", version_spec_is_scm, 0);
        rb_define_method(c_version_spec, "has_scm_part?", version_spec_has_scm_part, 0);
        rb_define_method(c_version_spec, "has_try_part?", version_spec_has_try_part, 0);
        rb_define_method(c_version_spec, "remove_revision", version_spec_remove_revision, 0);
        rb_define_method(c_version_spec, "revision_only", version_spec_revision_only, 0);
        rb_define_method(c_version_spec, "to_s", version_spec_to_s, 0)
    }
}
revision_only → String click to toggle source

Revision part only (or “r0”).

VALUE
    version_spec_revision_only(VALUE self)
    {
        try
        {
            return rb_str_new2((value_to_version_spec(self).revision_only().c_str()));
        }
        catch (const std::exception & e)
        {
            exception_to_ruby_exception(e);
        }
    }

    /*
     * call-seq:
     *     bump -> VersionSpec
     *
     * This is used by the ~> operator. It returns a VersionSpec where the next to last number is one greater (e.g. 5.3.1 => 5.4).
     * Any non number parts are stripped (e.g. 1.2.3_alpha4-r5 => 1.3).
     */
    VALUE
    version_spec_bump(VALUE self)
    {
        return version_spec_to_value(value_to_version_spec(self).bump());
    }

    /*
     * call-seq:
     *     is_scm? -> true or false
     *
     * Are we an -scm package, or something pretending to be one?
     */
    VALUE version_spec_is_scm(VALUE self)
    {
        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;
    }

    /*
     *  call-seq:
     *      to_s -> String
     *
     * Return as String
     */
    FAKE_RDOC_METHOD(version_spec_to_s)

    /*
     *  call-seq:
     *      <=>(VersionSpec) -> -1, 0, +1
     *
     * Comparison—Returns -1, 0, or +1 depending on whether provided VersionSpec is less than, equal to, or greater than this VersionSpec. This is the basis for the tests in Comparable.
     */
    FAKE_RDOC_METHOD(version_spec_compare)

    void do_register_version_spec()
    {
        /*
         * Document-class: Paludis::VersionSpec
         *
         * A VersionSpec represents a version number (for example, 1.2.3b-r1). Includes
         * Comparable[http://www.ruby-doc.org/core/classes/Comparable.html]
         */
        c_version_spec = rb_define_class_under(c_paludis_module, "VersionSpec", rb_cObject);
        rb_define_singleton_method(c_version_spec, "new", version_spec_new, 1);
        rb_define_method(c_version_spec, "initialize", version_spec_init, 1);
        rb_define_method(c_version_spec, "<=>", version_spec_compare, 1)
        rb_include_module(c_version_spec, rb_mComparable);
        rb_define_method(c_version_spec, "bump", version_spec_bump, 0);
        rb_define_method(c_version_spec, "is_scm?", version_spec_is_scm, 0);
        rb_define_method(c_version_spec, "has_scm_part?", version_spec_has_scm_part, 0);
        rb_define_method(c_version_spec, "has_try_part?", version_spec_has_try_part, 0);
        rb_define_method(c_version_spec, "remove_revision", version_spec_remove_revision, 0);
        rb_define_method(c_version_spec, "revision_only", version_spec_revision_only, 0);
        rb_define_method(c_version_spec, "to_s", version_spec_to_s, 0)
    }
}