Class: RPM::Dependency
- Inherits:
-
Object
- Object
- RPM::Dependency
- Defined in:
- ext/rpm/dependency.c
Instance Method Summary collapse
-
#eq? ⇒ Boolean
True if ‘=’, ‘=<’ or ‘>=’ are used to compare the version.
-
#flags ⇒ Number
Dependency flags.
- #flagstag ⇒ Object
-
#ge? ⇒ Boolean
True if ‘>=’ is used to compare the version.
-
#gt? ⇒ Boolean
True if ‘>’ or ‘>=’ are used to compare the version.
- #initialize(name, version, flags, owner) ⇒ Object constructor
-
#le? ⇒ Boolean
True if ‘=<’ is used to compare the version.
-
#lt? ⇒ Boolean
True if ‘<’ or ‘=<’ are used to compare the version.
-
#name ⇒ String
Dependency name.
- #nametag ⇒ Object
-
#owner ⇒ Package
Package this dependency belongs to.
-
#satisfy?(other) ⇒ Boolean
True if
other
satisfies this dependency. -
#version ⇒ String
Dependency version.
- #versiontag ⇒ Object
Constructor Details
#initialize(name, version, flags, owner) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'ext/rpm/dependency.c', line 26
static VALUE
dependency_initialize(VALUE dep, VALUE name, VALUE version,
VALUE flags, VALUE owner)
{
if (TYPE(name) != T_STRING
|| (!NIL_P(version) && rb_obj_is_kind_of(version, rpm_cVersion) == Qfalse)) {
rb_raise(rb_eTypeError, "illegal argument type");
}
rb_ivar_set(dep, id_name, name);
rb_ivar_set(dep, id_ver, version);
rb_ivar_set(dep, id_flags, rb_Integer(flags));
rb_ivar_set(dep, id_owner, owner);
return dep;
}
|
Instance Method Details
#eq? ⇒ Boolean
Returns true if ‘=’, ‘=<’ or ‘>=’ are used to compare the version.
292 293 294 295 296 |
# File 'ext/rpm/dependency.c', line 292
VALUE
rpm_dependency_is_eq(VALUE dep)
{
return (NUM2INT(rb_ivar_get(dep, id_flags)) & RPMSENSE_EQUAL) ? Qtrue : Qfalse;
}
|
#flags ⇒ Number
Returns dependency flags.
237 238 239 240 241 |
# File 'ext/rpm/dependency.c', line 237
VALUE
rpm_dependency_get_flags(VALUE dep)
{
return rb_ivar_get(dep, id_flags);
}
|
#flagstag ⇒ Object
265 266 267 268 269 |
# File 'ext/rpm/dependency.c', line 265
VALUE
rpm_dependency_get_flagstag(VALUE dep)
{
return rb_ivar_get(dep, id_flagstag);
}
|
#ge? ⇒ Boolean
Returns true if ‘>=’ is used to compare the version.
311 312 313 314 315 316 |
# File 'ext/rpm/dependency.c', line 311
VALUE
rpm_dependency_is_ge(VALUE dep)
{
int flags = NUM2INT(rb_ivar_get(dep, id_flags));
return ((flags & RPMSENSE_GREATER) && (flags & RPMSENSE_EQUAL)) ? Qtrue : Qfalse;
}
|
#gt? ⇒ Boolean
Returns true if ‘>’ or ‘>=’ are used to compare the version.
283 284 285 286 287 |
# File 'ext/rpm/dependency.c', line 283
VALUE
rpm_dependency_is_gt(VALUE dep)
{
return (NUM2INT(rb_ivar_get(dep, id_flags)) & RPMSENSE_GREATER) ? Qtrue : Qfalse;
}
|
#le? ⇒ Boolean
Returns true if ‘=<’ is used to compare the version.
301 302 303 304 305 306 |
# File 'ext/rpm/dependency.c', line 301
VALUE
rpm_dependency_is_le(VALUE dep)
{
int flags = NUM2INT(rb_ivar_get(dep, id_flags));
return ((flags & RPMSENSE_LESS) && (flags & RPMSENSE_EQUAL)) ? Qtrue : Qfalse;
}
|
#lt? ⇒ Boolean
Returns true if ‘<’ or ‘=<’ are used to compare the version.
274 275 276 277 278 |
# File 'ext/rpm/dependency.c', line 274
VALUE
rpm_dependency_is_lt(VALUE dep)
{
return (NUM2INT(rb_ivar_get(dep, id_flags)) & RPMSENSE_LESS) ? Qtrue : Qfalse;
}
|
#name ⇒ String
Returns dependency name.
219 220 221 222 223 |
# File 'ext/rpm/dependency.c', line 219
VALUE
rpm_dependency_get_name(VALUE dep)
{
return rb_ivar_get(dep, id_name);
}
|
#nametag ⇒ Object
253 254 255 256 257 |
# File 'ext/rpm/dependency.c', line 253
VALUE
rpm_dependency_get_nametag(VALUE dep)
{
return rb_ivar_get(dep, id_nametag);
}
|
#owner ⇒ Package
Returns package this dependency belongs to.
246 247 248 249 250 |
# File 'ext/rpm/dependency.c', line 246
VALUE
rpm_dependency_get_owner(VALUE dep)
{
return rb_ivar_get(dep, id_owner);
}
|
#satisfy?(other) ⇒ Boolean
Returns true if other
satisfies this dependency.
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'ext/rpm/dependency.c', line 166
VALUE
rpm_dependency_is_satisfy(VALUE dep,VALUE other)
{
int oflag;
int sflag;
char *svre;
char *ovre;
char *name;
char *oname;
if (rb_obj_is_kind_of(other,rpm_cPackage) == Qtrue){
VALUE provide;
VALUE provides = rpm_package_get_provides(other);
while (!NIL_P(provide = rb_ary_pop(provides))){
if (rpm_dependency_is_satisfy(dep,provide) == Qtrue) {
return Qtrue;
}
}
return Qfalse;
}
name = RSTRING_PTR(rb_ivar_get(dep,id_name));
svre = RSTRING_PTR(rpm_version_to_vre(rb_ivar_get(dep,id_ver)));
sflag = NUM2INT(rb_ivar_get(dep, id_flags));
if (rb_obj_is_kind_of(other,rpm_cDependency) == Qtrue){
oflag = NUM2INT(rb_ivar_get(other, id_flags));
oname = RSTRING_PTR(rb_ivar_get(other, id_name));
ovre = RSTRING_PTR(rpm_version_to_vre(rb_ivar_get(other,id_ver)));
other = rb_ivar_get(other,id_ver);
} else if (rb_obj_is_kind_of(other,rpm_cVersion) == Qtrue){
ovre = RSTRING_PTR(rpm_version_to_vre(other));
oname = name;
if (!*ovre)
oflag = 0;
else
oflag = RPMSENSE_EQUAL;
} else {
rb_raise(rb_eTypeError, "illegal argument type");
}
#if RPM_VERSION_CODE < RPM_VERSION(4,1,0)
if (rpmRangesOverlap(name,ovre,oflag, sname,svre,sflag))
#else
if (rpmdsCompare(rpmdsSingle(RPMTAG_PROVIDENAME, oname, ovre, oflag),
rpmdsSingle(RPMTAG_PROVIDENAME, name, svre, sflag)))
#endif
return Qtrue;
return Qfalse;
}
|
#version ⇒ String
Returns dependency version.
228 229 230 231 232 |
# File 'ext/rpm/dependency.c', line 228
VALUE
rpm_dependency_get_version(VALUE dep)
{
return rb_ivar_get(dep, id_ver);
}
|
#versiontag ⇒ Object
259 260 261 262 263 |
# File 'ext/rpm/dependency.c', line 259
VALUE
rpm_dependency_get_versiontag(VALUE dep)
{
return rb_ivar_get(dep, id_versiontag);
}
|