void Init_rugged() { rb_mRugged = rb_define_module("Rugged"); rb_define_module_function(rb_mRugged, "hex_to_raw", rb_git_hex_to_raw, 1); rb_define_module_function(rb_mRugged, "raw_to_hex", rb_git_raw_to_hex, 1); rb_define_module_function(rb_mRugged, "type_to_string", rb_git_type_to_string, 1); rb_define_module_function(rb_mRugged, "string_to_type", rb_git_string_to_type, 1); Init_rugged_signature(); Init_rugged_object(); Init_rugged_commit(); Init_rugged_tree(); Init_rugged_tag(); Init_rugged_blob(); Init_rugged_index(); Init_rugged_repo(); Init_rugged_revwalk(); Init_rugged_reference(); Init_rugged_backend(); /* Constants */ rb_define_const(rb_mRugged, "SORT_NONE", INT2FIX(0)); rb_define_const(rb_mRugged, "SORT_TOPO", INT2FIX(1)); rb_define_const(rb_mRugged, "SORT_DATE", INT2FIX(2)); rb_define_const(rb_mRugged, "SORT_REVERSE", INT2FIX(4)); rb_define_const(rb_mRugged, "OBJ_ANY", INT2FIX(GIT_OBJ_ANY)); rb_define_const(rb_mRugged, "OBJ_BAD", INT2FIX(GIT_OBJ_BAD)); rb_define_const(rb_mRugged, "OBJ_COMMIT", INT2FIX(GIT_OBJ_COMMIT)); rb_define_const(rb_mRugged, "OBJ_TREE", INT2FIX(GIT_OBJ_TREE)); rb_define_const(rb_mRugged, "OBJ_BLOB", INT2FIX(GIT_OBJ_BLOB)); rb_define_const(rb_mRugged, "OBJ_TAG", INT2FIX(GIT_OBJ_TAG)); rb_define_const(rb_mRugged, "REF_OID", INT2FIX(GIT_REF_OID)); rb_define_const(rb_mRugged, "REF_SYMBOLIC", INT2FIX(GIT_REF_SYMBOLIC)); }
void Init_rugged(void) { rb_mRugged = rb_define_module("Rugged"); /* Initialize the Error classes */ { int i; rb_eRuggedError = rb_define_class_under(rb_mRugged, "Error", rb_eStandardError); rb_eRuggedErrors[0] = Qnil; /* 0 return value -- no exception */ rb_eRuggedErrors[1] = rb_define_class_under(rb_mRugged, RUGGED_ERROR_NAMES[1], rb_eNoMemError); rb_eRuggedErrors[2] = rb_define_class_under(rb_mRugged, RUGGED_ERROR_NAMES[2], rb_eIOError); rb_eRuggedErrors[3] = rb_define_class_under(rb_mRugged, RUGGED_ERROR_NAMES[3], rb_eArgError); for (i = 4; i < RUGGED_ERROR_COUNT; ++i) { rb_eRuggedErrors[i] = rb_define_class_under(rb_mRugged, RUGGED_ERROR_NAMES[i], rb_eRuggedError); } } rb_define_module_function(rb_mRugged, "libgit2_version", rb_git_libgit2_version, 0); rb_define_module_function(rb_mRugged, "features", rb_git_features, 0); rb_define_module_function(rb_mRugged, "valid_full_oid?", rb_git_valid_full_oid, 1); rb_define_module_function(rb_mRugged, "hex_to_raw", rb_git_hex_to_raw, 1); rb_define_module_function(rb_mRugged, "raw_to_hex", rb_git_raw_to_hex, 1); rb_define_module_function(rb_mRugged, "minimize_oid", rb_git_minimize_oid, -1); rb_define_module_function(rb_mRugged, "prettify_message", rb_git_prettify_message, -1); rb_define_module_function(rb_mRugged, "__cache_usage__", rb_git_cache_usage, 0); Init_rugged_reference(); Init_rugged_reference_collection(); Init_rugged_object(); Init_rugged_commit(); Init_rugged_tree(); Init_rugged_tag(); Init_rugged_tag_collection(); Init_rugged_blob(); Init_rugged_index(); Init_rugged_repo(); Init_rugged_revwalk(); Init_rugged_branch(); Init_rugged_branch_collection(); Init_rugged_config(); Init_rugged_remote(); Init_rugged_remote_collection(); Init_rugged_notes(); Init_rugged_settings(); Init_rugged_submodule(); Init_rugged_submodule_collection(); Init_rugged_diff(); Init_rugged_patch(); Init_rugged_diff_delta(); Init_rugged_diff_hunk(); Init_rugged_diff_line(); Init_rugged_blame(); Init_rugged_cred(); Init_rugged_backend(); /* * Sort the repository contents in no particular ordering; * this sorting is arbitrary, implementation-specific * and subject to change at any time. * This is the default sorting for new walkers. */ rb_define_const(rb_mRugged, "SORT_NONE", INT2FIX(GIT_SORT_NONE)); /* * Sort the repository contents in topological order * (parents before children); this sorting mode * can be combined with time sorting. */ rb_define_const(rb_mRugged, "SORT_TOPO", INT2FIX(GIT_SORT_TOPOLOGICAL)); /* * Sort the repository contents by commit time; * this sorting mode can be combined with * topological sorting. */ rb_define_const(rb_mRugged, "SORT_DATE", INT2FIX(GIT_SORT_TIME)); /* * Iterate through the repository contents in reverse * order; this sorting mode can be combined with * any of the above. */ rb_define_const(rb_mRugged, "SORT_REVERSE", INT2FIX(GIT_SORT_REVERSE)); /* Initialize libgit2 */ git_libgit2_init(); /* Hook a global object to cleanup the library * on shutdown */ rb_mShutdownHook = Data_Wrap_Struct(rb_cObject, NULL, &cleanup_cb, NULL); rb_global_variable(&rb_mShutdownHook); }
void Init_rugged(void) { rb_mRugged = rb_define_module("Rugged"); /* Initialize the Error classes */ { int i; rb_eRuggedError = rb_define_class_under(rb_mRugged, "Error", rb_eStandardError); rb_eRuggedErrors[0] = rb_define_class_under(rb_mRugged, RUGGED_ERROR_NAMES[0], rb_eNoMemError); rb_eRuggedErrors[1] = rb_define_class_under(rb_mRugged, RUGGED_ERROR_NAMES[1], rb_eIOError); rb_eRuggedErrors[2] = rb_define_class_under(rb_mRugged, RUGGED_ERROR_NAMES[2], rb_eArgError); for (i = 3; i < RUGGED_ERROR_COUNT; ++i) { rb_eRuggedErrors[i] = rb_define_class_under(rb_mRugged, RUGGED_ERROR_NAMES[i], rb_eRuggedError); } } rb_define_module_function(rb_mRugged, "libgit2_version", rb_git_libgit2_version, 0); rb_define_module_function(rb_mRugged, "capabilities", rb_git_capabilities, 0); rb_define_module_function(rb_mRugged, "hex_to_raw", rb_git_hex_to_raw, 1); rb_define_module_function(rb_mRugged, "raw_to_hex", rb_git_raw_to_hex, 1); rb_define_module_function(rb_mRugged, "minimize_oid", rb_git_minimize_oid, -1); rb_define_module_function(rb_mRugged, "prettify_message", rb_git_prettify_message, 2); rb_define_module_function(rb_mRugged, "__cache_usage__", rb_git_cache_usage, 0); Init_rugged_object(); Init_rugged_commit(); Init_rugged_tree(); Init_rugged_tag(); Init_rugged_blob(); Init_rugged_index(); Init_rugged_repo(); Init_rugged_revwalk(); Init_rugged_reference(); Init_rugged_branch(); Init_rugged_config(); Init_rugged_remote(); Init_rugged_notes(); Init_rugged_settings(); Init_rugged_diff(); Init_rugged_diff_patch(); Init_rugged_diff_delta(); Init_rugged_diff_hunk(); Init_rugged_diff_line(); /* Constants */ rb_define_const(rb_mRugged, "SORT_NONE", INT2FIX(0)); rb_define_const(rb_mRugged, "SORT_TOPO", INT2FIX(1)); rb_define_const(rb_mRugged, "SORT_DATE", INT2FIX(2)); rb_define_const(rb_mRugged, "SORT_REVERSE", INT2FIX(4)); /* Initialize libgit2 */ git_threads_init(); /* Hook a global object to cleanup the library * on shutdown */ rb_mShutdownHook = Data_Wrap_Struct(rb_cObject, NULL, &cleanup_cb, NULL); rb_global_variable(&rb_mShutdownHook); }