chsource 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/chsource/chsource.rb +16 -18
- data/lib/chsource/cli.rb +1 -1
- data/lib/chsource/version.rb +1 -1
- data/test/test_helper.rb +0 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f84c08846f81a7725ead61afcb34b819fe3105bd
|
4
|
+
data.tar.gz: c2b3165c1d8e1b11e81270551a8de65b05ecf489
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6cd95305aa60798da6747a3d5a934aa4e222e865a821d214967b06f4f5813b9287a0588b001c442a82811d97e6f7f31c63bc964361c80db6f198cac6ab873d1
|
7
|
+
data.tar.gz: 680ced7a452c1a6d615d1271ebbf5830360be7ecda04591ceefef637fff11cead212c5377437ccb7dcdad6e65382d1e6a8417fbbe082849d30492eede26ff19f
|
data/lib/chsource/chsource.rb
CHANGED
@@ -8,30 +8,28 @@ module Chsource
|
|
8
8
|
tsinghua: "source 'http://mirrors.tuna.tsinghua.edu.cn/rubygems'"
|
9
9
|
}
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
@new_source = Source[new_source.to_sym]
|
11
|
+
def self.change_source(new_source)
|
12
|
+
@text = File.read(Gemfile)
|
13
|
+
@new_source = Source[new_source.to_sym]
|
15
14
|
|
16
|
-
|
15
|
+
replace_source
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
17
|
+
if @text.include? new_source
|
18
|
+
write_to_file
|
19
|
+
else
|
20
|
+
puts "\e[31mSomething goes wrong! please make sure your Gemfile has something like:\nsource 'http://rubygems.org'\e[0m"
|
23
21
|
end
|
22
|
+
end
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
def self.replace_source
|
25
|
+
@text.gsub!(/source ['"]https?:\/\/[\S]+['"]/, @new_source)
|
26
|
+
end
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
puts "\e[32mChange to #{@new_source} successfully!\e[0m"
|
28
|
+
def self.write_to_file
|
29
|
+
File.open(Gemfile, 'w') do |file|
|
30
|
+
file.write @text
|
34
31
|
end
|
32
|
+
puts "\e[32mChange to #{@new_source} successfully!\e[0m"
|
35
33
|
end
|
36
34
|
end
|
37
35
|
end
|
data/lib/chsource/cli.rb
CHANGED
data/lib/chsource/version.rb
CHANGED
data/test/test_helper.rb
CHANGED