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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3b9a8413e6c7a81bcb8f0b21f9c11889fdee3f7
4
- data.tar.gz: 6bef9dd833af45bdd6c84ba10c0040edbf97de7b
3
+ metadata.gz: f84c08846f81a7725ead61afcb34b819fe3105bd
4
+ data.tar.gz: c2b3165c1d8e1b11e81270551a8de65b05ecf489
5
5
  SHA512:
6
- metadata.gz: 460eba1c2441e9c3ea6ea597218184d188b1640881e56c96a82378a3dceda2a1cb3c188233588906a73d92e308363fffdd021fce86542e8e3e998de07712347d
7
- data.tar.gz: 18a1012a20da25ae5994c22d7bd13526d2dfcaa08850ef69b19f6b54c5015f25034527bde5a9082bcf06fbda77aab50d3923b57bf1ed976601bf0e292d409d41
6
+ metadata.gz: a6cd95305aa60798da6747a3d5a934aa4e222e865a821d214967b06f4f5813b9287a0588b001c442a82811d97e6f7f31c63bc964361c80db6f198cac6ab873d1
7
+ data.tar.gz: 680ced7a452c1a6d615d1271ebbf5830360be7ecda04591ceefef637fff11cead212c5377437ccb7dcdad6e65382d1e6a8417fbbe082849d30492eede26ff19f
@@ -8,30 +8,28 @@ module Chsource
8
8
  tsinghua: "source 'http://mirrors.tuna.tsinghua.edu.cn/rubygems'"
9
9
  }
10
10
 
11
- class << self
12
- def change_source(new_source)
13
- @text = File.read(Gemfile)
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
- replace_source
15
+ replace_source
17
16
 
18
- if @text.include? new_source
19
- write_to_file
20
- else
21
- puts "\e[31mSomething goes wrong! please make sure your Gemfile has something like:\nsource 'http://rubygems.org'\e[0m"
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
- def replace_source
26
- @text.gsub!(/source ['"]https?:\/\/[\S]+['"]/, @new_source)
27
- end
24
+ def self.replace_source
25
+ @text.gsub!(/source ['"]https?:\/\/[\S]+['"]/, @new_source)
26
+ end
28
27
 
29
- def write_to_file
30
- File.open(Gemfile, 'w') do |file|
31
- file.write @text
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
@@ -22,7 +22,7 @@ module Chsource
22
22
  opts.separator "Options:"
23
23
 
24
24
  opts.on("-v", "--version", "Print the version") do |v|
25
- puts "Chsource v#{Version}"
25
+ puts "Chsource v#{VERSION}"
26
26
  exit
27
27
  end
28
28
 
@@ -1,3 +1,3 @@
1
1
  module Chsource
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/test/test_helper.rb CHANGED
@@ -1,6 +1,4 @@
1
1
  require 'minitest/autorun'
2
- require 'minitest/pride'
3
- # require 'bundler/setup'
4
2
 
5
3
  testdir = File.dirname(__FILE__)
6
4
  $LOAD_PATH.unshift testdir unless $LOAD_PATH.include?(testdir)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chsource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hao Wei