chsource 0.0.5 → 0.1.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: 8fb28b6385abde758d7e8e003e52355f35df2a9b
4
- data.tar.gz: 0914b9866173e2e4022dd2139891fc9cac112fc6
3
+ metadata.gz: 4163937645ec8b6e961ab9facddda0d8c81c9fc6
4
+ data.tar.gz: 45a7b7ccfc0072a050fe8bcc04f2f510ac7823cb
5
5
  SHA512:
6
- metadata.gz: 95aeb8827f8a51f0f4aa7b05e4e548c42a54a10716e824dd247a3ac0a636b08147e78e282d959b47bde7ff5a3c333219bedb92dc1969e8f02d529ea4d6450f88
7
- data.tar.gz: d1682cdfc879370877682532413e7985ad197bc09507ab60fe727f0a386cc66b72f49b57cf857380065554ba98373cb4476405c3771671f7b0999fe5da5d2827
6
+ metadata.gz: 98531e33de78438a0213a2249c4a38bb7096eab8e7c06e7ead30821013442266637dcb36ad7b011cae855062a35abba44634ea27e4e462b5fcfd61284a96bce4
7
+ data.tar.gz: 607aba1528118470a29ce1b1a49416a0c3baa57b755ee5cdffd893e63822771e9eca58cd158c2f34e355bfcb1e9fa201354c5f5890c49a7c113c52599e3024e5
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'http://mirrors.tuna.tsinghua.edu.cn/rubygems'
2
2
 
3
3
  # Specify your gem's dependencies in chsource.gemspec
4
4
  gemspec
data/lib/chsource/cli.rb CHANGED
@@ -4,11 +4,26 @@ require 'optparse'
4
4
 
5
5
  module Chsource
6
6
  module CLI
7
+
8
+ def self.check_input
9
+ ARGV << '-h' if ARGV.empty? && $stdin.tty? || invalid_input?
10
+ end
11
+
7
12
  def self.invalid_input?
8
13
  ARGV.size > 1 || !Chsource::Source.keys.include?(ARGV[0].to_sym)
9
14
  end
15
+
16
+ def self.no_gem_file
17
+ if Dir.glob('Gemfile').size == 0
18
+ puts "\e[31mCan't find Gemfile in current directory\e[0m"
19
+ true
20
+ else
21
+ false
22
+ end
23
+ end
24
+
10
25
  def self.start(args)
11
- ARGV << '-h' if ARGV.empty? && $stdin.tty? || invalid_input?
26
+ check_input
12
27
 
13
28
  opts = OptionParser.new do |opts|
14
29
  opts.banner = "Usage: chsource SOURCE"
@@ -37,6 +52,8 @@ module Chsource
37
52
  opts.parse!(args)
38
53
  end
39
54
 
55
+ exit if no_gem_file
56
+
40
57
  Chsource.change_source ARGV[0]
41
58
  end
42
59
  end
@@ -1,3 +1,3 @@
1
1
  module Chsource
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.4"
3
3
  end
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.5
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hao Wei
@@ -56,7 +56,7 @@ description: chsource make you change Gemfile's source quickly
56
56
  email:
57
57
  - imwillmouse@gmail.com
58
58
  executables:
59
- - chsourse
59
+ - chsource
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
@@ -65,7 +65,7 @@ files:
65
65
  - LICENSE.txt
66
66
  - README.md
67
67
  - Rakefile
68
- - bin/chsourse
68
+ - bin/chsource
69
69
  - chsource.gemspec
70
70
  - lib/chsource.rb
71
71
  - lib/chsource/chsource.rb
File without changes