gitgem 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/gitgem +151 -37
- data/lib/gitgem/action.rb +14 -9
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62f651ebd2d42e35bb2fe68b6234ba1317fbacad
|
4
|
+
data.tar.gz: cd48647a970eea69fb6e42d7fa8d0221206a7808
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2926ba3404ad80d45b8ad7b60a7aca47ac1b4eeb1e871145ca5f6a55dfd78044812357d61f61494c2559673434b442f42090304b67929bafefd48d940a68d457
|
7
|
+
data.tar.gz: 9329f01fc6682e2d054132fac344593913281045ea5567127434de0578952e975a3a8a38bf1e3b00d5ac78c1be67fc4641072895353c1c87319c90e256f35e89
|
data/bin/gitgem
CHANGED
@@ -1,53 +1,167 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- coding: UTF-8 -*-
|
3
3
|
|
4
|
-
|
4
|
+
lib = File.expand_path(File.join(__dir__, "../lib"))
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
6
|
|
6
|
-
require '
|
7
|
+
require 'gli'
|
7
8
|
|
9
|
+
require 'version'
|
8
10
|
require 'gitgem/action'
|
9
11
|
|
10
|
-
|
11
|
-
action = ARGV.shift unless ARGV.first.start_with?("-")
|
12
|
+
include GLI::App
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
opts.banner = "Here is help messages of the command line tool.\nAction Suppored: 'add', 'remove', 'install', 'uninstall'."
|
14
|
+
program_desc 'Install gem from git repo'
|
15
|
+
version GitGem::VERSION
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
subcommand_option_handling :normal
|
18
|
+
arguments :strict
|
19
|
+
|
20
|
+
desc "Add git repo"
|
21
|
+
arg_name '-r repo -a alias'
|
22
|
+
command :add do |c|
|
23
|
+
|
24
|
+
c.desc 'Specify git repo'
|
25
|
+
c.arg_name 'ssh@xxx.git'
|
26
|
+
c.flag [:r, :repo]
|
27
|
+
|
28
|
+
c.desc 'Specify a short name of git repo'
|
29
|
+
c.arg_name 'alias'
|
30
|
+
c.flag [:a, :alias]
|
31
|
+
|
32
|
+
c.action do |_, opts, _|
|
33
|
+
repo = options[:r]
|
34
|
+
repo_alias = options[:a]
|
35
|
+
GitGem::Action.add(repo_alias, repo)
|
19
36
|
end
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "Remove git repo by alias"
|
40
|
+
arg_name '-a alias'
|
41
|
+
command :remove do |c|
|
20
42
|
|
21
|
-
|
22
|
-
|
43
|
+
c.desc 'Alias of git repo'
|
44
|
+
c.arg_name 'alias'
|
45
|
+
c.flag [:a, :alias]
|
46
|
+
|
47
|
+
c.action do |_, opts, _|
|
48
|
+
repo_alias = options[:a]
|
49
|
+
GitGem::Action.remove(repo_alias)
|
23
50
|
end
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Install gem from git repo"
|
54
|
+
arg_name '-a alias -g gem -n bindir'
|
55
|
+
command :install do |c|
|
56
|
+
|
57
|
+
c.desc 'Alias of git repo'
|
58
|
+
c.arg_name 'alias'
|
59
|
+
c.flag [:a, :alias]
|
60
|
+
|
61
|
+
c.desc 'Name of gem'
|
62
|
+
c.arg_name 'gitgem'
|
63
|
+
c.flag [:g, :gem]
|
24
64
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
65
|
+
c.desc 'dir will install'
|
66
|
+
c.arg_name '/usr/local/bin'
|
67
|
+
c.flag [:n, :bindir]
|
68
|
+
|
69
|
+
c.action do |_, opts, _|
|
70
|
+
repo = options[:a]
|
71
|
+
gem_name = options[:g]
|
72
|
+
bindir = options[:n]
|
73
|
+
GitGem::Action.install(repo, gem_name, bindir)
|
29
74
|
end
|
75
|
+
end
|
76
|
+
|
77
|
+
desc "Uninstall gem"
|
78
|
+
arg_name '-a alias -g gem'
|
79
|
+
command :uninstall do |c|
|
80
|
+
|
81
|
+
c.desc 'Alias of git repo'
|
82
|
+
c.arg_name 'alias'
|
83
|
+
c.flag [:a, :alias]
|
84
|
+
|
85
|
+
c.desc 'Name of gem'
|
86
|
+
c.arg_name 'gitgem'
|
87
|
+
c.flag [:g, :gem]
|
30
88
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
repo = options[:alias]
|
42
|
-
GitGem::Action.remove(repo)
|
43
|
-
when 'install'
|
44
|
-
repo = options[:alias]
|
45
|
-
gem_dir = options[:gem_dir]
|
46
|
-
GitGem::Action.install(repo, gem_dir)
|
47
|
-
when 'uninstall'
|
48
|
-
repo = options[:alias]
|
49
|
-
gem_dir = options[:gem_dir]
|
50
|
-
GitGem::Action.uninstall(repo, gem_dir)
|
51
|
-
else
|
52
|
-
abort("Could not find action named '#{action}'")
|
89
|
+
c.desc 'dir will uninstall'
|
90
|
+
c.arg_name '/usr/local/bin'
|
91
|
+
c.flag [:n, :bindir]
|
92
|
+
|
93
|
+
c.action do |_, opts, _|
|
94
|
+
repo = options[:a]
|
95
|
+
gem_name = options[:g]
|
96
|
+
bindir = options[:n]
|
97
|
+
GitGem::Action.uninstall(repo, gem_name, bindir)
|
98
|
+
end
|
53
99
|
end
|
100
|
+
|
101
|
+
exit run(ARGV)
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
# ARGV << '-h' if ARGV.empty?
|
125
|
+
# action = ARGV.shift unless ARGV.first.start_with?("-")
|
126
|
+
#
|
127
|
+
# options = {}
|
128
|
+
# option_parser = OptionParser.new do |opts|
|
129
|
+
# opts.banner = "Here is help messages of the command line tool.\nAction Suppored: 'add', 'remove', 'install', 'uninstall'."
|
130
|
+
#
|
131
|
+
# opts.on('-r REPO', '--repo Repo', 'Specify git repo') do |value|
|
132
|
+
# options[:repo] = value
|
133
|
+
# end
|
134
|
+
#
|
135
|
+
# opts.on('-a ALIAS', '--alias Alias', 'Make Alias') do |value|
|
136
|
+
# options[:alias] = value
|
137
|
+
# end
|
138
|
+
#
|
139
|
+
# opts.on('-g GEM', '--gem Gem', 'Install GEM') do |value|
|
140
|
+
# argvs = value.split("/")
|
141
|
+
# options[:alias] = argvs.shift
|
142
|
+
# options[:gem_dir] = argvs.join("/")
|
143
|
+
# end
|
144
|
+
#
|
145
|
+
# opts.on('-h', '--help', 'Show this message') { puts opts; exit }
|
146
|
+
# opts.on('-v', '--version', 'Show version') { exit }
|
147
|
+
# end.parse!
|
148
|
+
#
|
149
|
+
# case action
|
150
|
+
# when 'add'
|
151
|
+
# repo = options[:repo]
|
152
|
+
# repo_alias = options[:alias]
|
153
|
+
# GitGem::Action.add(repo_alias, repo)
|
154
|
+
# when 'remove'
|
155
|
+
# repo = options[:alias]
|
156
|
+
# GitGem::Action.remove(repo)
|
157
|
+
# when 'install'
|
158
|
+
# repo = options[:alias]
|
159
|
+
# gem_dir = options[:gem_dir]
|
160
|
+
# GitGem::Action.install(repo, gem_dir)
|
161
|
+
# when 'uninstall'
|
162
|
+
# repo = options[:alias]
|
163
|
+
# gem_dir = options[:gem_dir]
|
164
|
+
# GitGem::Action.uninstall(repo, gem_dir)
|
165
|
+
# else
|
166
|
+
# abort("Could not find action named '#{action}'")
|
167
|
+
# end
|
data/lib/gitgem/action.rb
CHANGED
@@ -36,7 +36,7 @@ module GitGem
|
|
36
36
|
system("sed -i '' '/#{repo_alias}=/d' #{alias_path}")
|
37
37
|
end
|
38
38
|
|
39
|
-
def install(repo_alias, gem_dir)
|
39
|
+
def install(repo_alias, gem_dir, bindir)
|
40
40
|
abort("Please specify alias like alias/gem") if repo_alias.nil? || repo_alias.empty?
|
41
41
|
result = read_alias(repo_alias)
|
42
42
|
abort("Could not find alias named #{repo_alias}, please check again.") if result.nil?
|
@@ -64,7 +64,11 @@ module GitGem
|
|
64
64
|
abort("Could not find gemspec in #{File.join(Dir.pwd)}") if gemspecs.nil? || gemspecs.empty?
|
65
65
|
abort("Mutiple gemspecs found in #{File.join(Dir.pwd)}") if gemspecs.count > 1
|
66
66
|
|
67
|
-
|
67
|
+
Dir.glob("*.gem").each do |gem|
|
68
|
+
FileUtils.rm_rf(gem)
|
69
|
+
end
|
70
|
+
|
71
|
+
result = system("sudo gem build #{gemspecs.first}")
|
68
72
|
|
69
73
|
abort("Fail to build gemspec") unless result
|
70
74
|
|
@@ -72,14 +76,15 @@ module GitGem
|
|
72
76
|
abort("Could not find gem in #{File.join(Dir.pwd)}") if gemspecs.nil? || gemspecs.empty?
|
73
77
|
|
74
78
|
# 获取最新 gem
|
75
|
-
gem = gems.
|
79
|
+
gem = gems.first
|
80
|
+
bin = "-n #{bindir}" unless bindir.nil?
|
76
81
|
|
77
|
-
system("gem install #{gem}")
|
82
|
+
system("sudo gem install #{gem} #{bin}")
|
78
83
|
|
79
84
|
Dir.chdir(pwd)
|
80
85
|
end
|
81
86
|
|
82
|
-
def uninstall(repo_alias,
|
87
|
+
def uninstall(repo_alias, gem_name, bindir)
|
83
88
|
abort("Please specify alias like alias/gem") if repo_alias.nil? || repo_alias.empty?
|
84
89
|
result = read_alias(repo_alias)
|
85
90
|
abort("Could not find alias named #{repo_alias}, please check again.") if result.nil?
|
@@ -90,10 +95,10 @@ module GitGem
|
|
90
95
|
|
91
96
|
gems = Dir.glob(File.join(repo_dir, gem_dir, "*.gem"))
|
92
97
|
abort("Could not find gem in #{File.join(repo_dir, gem_dir)}") if gems.nil? || gems.empty?
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
98
|
+
|
99
|
+
bin = "-n #{bindir}" unless bindir.nil?
|
100
|
+
gem_name = File.basename(gems.first, ".gem").split("-")[0...-1].join("-")
|
101
|
+
system("sudo gem unisntall #{gem_name} #{bin}")
|
97
102
|
end
|
98
103
|
|
99
104
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitgem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- saitjr
|
@@ -9,7 +9,27 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2018-01-10 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gli
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.17'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.17.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.17'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.17.1
|
13
33
|
description: Install gem from git repo !
|
14
34
|
email: tangjr.work@gmail.com
|
15
35
|
executables:
|