-
-
Notifications
You must be signed in to change notification settings - Fork 166
/
Ruby.c
123 lines (97 loc) · 3.1 KB
/
Ruby.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <[email protected]>
* Contributors : Nil Null <[email protected]>
* Created On : <2023-08-29>
* Last Modified : <2024-11-22>
* ------------------------------------------------------------*/
static SourceProvider_t UpstreamRuby =
{
"upstream", "RubyGems.org", "上游默认源 RubyGems.org", "https://rubygems.org",
{NotSkip, NA, NA, "https://rubygems.org/gems/nokogiri-1.15.0-java.gem"}
};
static MirrorSite_t RubyChina =
{
"rubychina", "RubyChina", "Ruby China 社区", "https://gems.ruby-china.com/",
{NotSkip, NA, NA, "https://gems.ruby-china.com/rubygems/gems/nokogiri-1.15.0-java.gem"} // 9.9 MB
};
/**
* @update 2024-09-04
* @sync https://github.com/RubyMetric/chsrc/wiki/Ruby-MirrorSite
* @sync https://github.com/RubyMetric/chsrc/discussions/62
*
* @note 曾经的问题 https://ruby-china.org/topics/43331
*/
static Source_t pl_ruby_sources[] =
{
{&UpstreamRuby, "https://rubygems.org"},
{&RubyChina, "https://gems.ruby-china.com/"},
{&Ustc, "https://mirrors.ustc.edu.cn/rubygems/"}
// {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/rubygems/"},
// {&Bfsu, "https://mirrors.bfsu.edu.cn/rubygems/"},
// {&Tencent, "https://mirrors.tencent.com/rubygems/"},
// {&Tencent_Intra, "https://mirrors.tencentyun.com/rubygems/"},
// {&Ali, "https://mirrors.aliyun.com/rubygems/"},
// {&Huawei, "https://mirrors.huaweicloud.com/repository/rubygems/"},
};
def_sources_n(pl_ruby);
void
pl_ruby_getsrc (char *option)
{
chsrc_run ("gem sources", RunOpt_Default);
chsrc_run ("bundle config get mirror.https://rubygems.org", RunOpt_Default);
}
void
pl_ruby_remove_gem_source (const char *source)
{
char *cmd = NULL;
if (is_url (source))
{
cmd = xy_str_delete_suffix (source, "\n");
cmd = xy_2strjoin ("gem sources -r ", cmd);
chsrc_run (cmd, RunOpt_Default);
}
}
/**
* @consult https://gitee.com/RubyMetric/rbenv-cn
*/
void
pl_ruby_setsrc (char *option)
{
chsrc_ensure_program ("gem");
chsrc_yield_source_and_confirm (pl_ruby);
char *cmd = NULL;
xy_run ("gem sources -l", 0, pl_ruby_remove_gem_source);
cmd = xy_2strjoin ("gem source -a ", source.url);
chsrc_run (cmd, RunOpt_Default);
chsrc_ensure_program ("bundle");
char *where = " --global ";
if (CliOpt_Locally==true)
{
where = " --local ";
}
cmd = xy_strjoin (4, "bundle config", where, "'mirror.https://rubygems.org' ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line);
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
}
void
pl_ruby_resetsrc (char *option)
{
pl_ruby_setsrc (option);
}
Feature_t
pl_ruby_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = PartiallyCan;
f.cap_locally_explain = "Support `bundler`. No support for `gem`";
f.can_english = true;
f.can_user_define = true;
f.note = NULL;
return f;
}
def_target_gsrf(pl_ruby);