Class: Rugged::Settings
- Inherits:
-
Object
- Object
- Rugged::Settings
- Defined in:
- ext/rugged/rugged_settings.c
Class Method Summary collapse
-
.[](option) ⇒ Object
Gets the value of a libgit2 library option.
-
.[]=(option) ⇒ Object
Sets a libgit2 library option.
-
.Rugged::Settings.max_cache_size ⇒ Object
Returns the maximum amount of memory the cache will consume.
-
.Rugged::Settings.used_cache_size ⇒ Object
Returns the amount of memory the cache is currently consuming.
Class Method Details
.[](option) ⇒ Object
Gets the value of a libgit2 library option.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'ext/rugged/rugged_settings.c', line 102
static VALUE rb_git_get_option(VALUE self, VALUE option)
{
const char *opt;
Check_Type(option, T_STRING);
opt = StringValueCStr(option);
if (strcmp(opt, "mwindow_size") == 0) {
size_t val;
git_libgit2_opts(GIT_OPT_GET_MWINDOW_SIZE, &val);
return SIZET2NUM(val);
}
else if (strcmp(opt, "mwindow_mapped_limit") == 0) {
size_t val;
git_libgit2_opts(GIT_OPT_GET_MWINDOW_MAPPED_LIMIT, &val);
return SIZET2NUM(val);
}
else if (strcmp(opt, "search_path_global") == 0) {
return get_search_path(GIT_CONFIG_LEVEL_GLOBAL);
}
else if (strcmp(opt, "search_path_xdg") == 0) {
return get_search_path(GIT_CONFIG_LEVEL_XDG);
}
else if (strcmp(opt, "search_path_system") == 0) {
return get_search_path(GIT_CONFIG_LEVEL_SYSTEM);
}
else {
rb_raise(rb_eArgError, "Unknown option specified");
}
}
|
.[]=(option) ⇒ Object
Sets a libgit2 library option.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'ext/rugged/rugged_settings.c', line 51
static VALUE rb_git_set_option(VALUE self, VALUE option, VALUE value)
{
const char *opt;
Check_Type(option, T_STRING);
opt = StringValueCStr(option);
if (strcmp(opt, "mwindow_size") == 0) {
size_t val;
Check_Type(value, T_FIXNUM);
val = NUM2SIZET(value);
git_libgit2_opts(GIT_OPT_SET_MWINDOW_SIZE, val);
}
else if (strcmp(opt, "mwindow_mapped_limit") == 0) {
size_t val;
Check_Type(value, T_FIXNUM);
val = NUM2SIZET(value);
git_libgit2_opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, val);
}
else if (strcmp(opt, "search_path_global") == 0) {
set_search_path(GIT_CONFIG_LEVEL_GLOBAL, value);
}
else if (strcmp(opt, "search_path_xdg") == 0) {
set_search_path(GIT_CONFIG_LEVEL_XDG, value);
}
else if (strcmp(opt, "search_path_system") == 0) {
set_search_path(GIT_CONFIG_LEVEL_SYSTEM, value);
}
else if (strcmp(opt, "strict_object_creation") == 0) {
int strict = RTEST(value) ? 1 : 0;
git_libgit2_opts(GIT_OPT_ENABLE_STRICT_OBJECT_CREATION, strict);
}
else {
rb_raise(rb_eArgError, "Unknown option specified");
}
return Qnil;
}
|
.Rugged::Settings.max_cache_size ⇒ Object
Returns the maximum amount of memory the cache will consume.
144 145 146 147 148 149 |
# File 'ext/rugged/rugged_settings.c', line 144
static VALUE rb_git_get_max_cache_size(VALUE mod) {
size_t val;
size_t max;
git_libgit2_opts(GIT_OPT_GET_CACHED_MEMORY, &val, &max);
return SIZET2NUM(max);
}
|
.Rugged::Settings.used_cache_size ⇒ Object
Returns the amount of memory the cache is currently consuming.
157 158 159 160 161 162 |
# File 'ext/rugged/rugged_settings.c', line 157
static VALUE rb_git_get_used_cache_size(VALUE mod) {
size_t val;
size_t max;
git_libgit2_opts(GIT_OPT_GET_CACHED_MEMORY, &val, &max);
return SIZET2NUM(val);
}
|