wg 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/bin/wg_r +42 -0
- data/lib/wg.rb +20 -2
- data/lib/wg/version.rb +1 -1
- data/wg.gemspec +1 -1
- metadata +5 -5
- data/bin/wgr +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d40fb70dddc4f1f06e2900b9ea5cce9fd507f3f
|
4
|
+
data.tar.gz: 697f151ab10c2d55b875c62f8e61537b4dcbfe3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c44505dd9d1a63e3463689e307fb426fdf52f9311e42070a9629086d5c918a5417472de3c52d93b59b67127aea99adf97dd77e1c64102f42b6a134b7000494eb
|
7
|
+
data.tar.gz: bd71cd38b45c7fdc9f770e7724acc249f3f7d476b3f51df161ac9036392a0da6b6e2a2483156f9e51ac495b7e9ccbc206a4272913a1ae01b25226dd1db11a3f2
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ wg is packaged as a ruby gem, but due to the limitations of the shell, you also
|
|
10
10
|
|
11
11
|
First, install wg with: `gem install wg`
|
12
12
|
|
13
|
-
Then, add
|
13
|
+
Then, add `function wg { resp="$(wg_r $@)"; if [[ ${resp:0:1} == "!" ]] ; then cd "${resp:1}"; else echo "${resp}"; fi }` to your `.bashrc` file (or whatever shell's rc file you use (`.zshrc`, etc...)).
|
14
14
|
|
15
15
|
Happy wg'ing!
|
16
16
|
|
@@ -20,8 +20,8 @@ Happy wg'ing!
|
|
20
20
|
|
21
21
|
### Options
|
22
22
|
|
23
|
-
- `-h --help` displays a delightful help message.
|
24
23
|
- `-l --lab` will clone from gitlab instead of github or open `~/w/g/l/user/repo`
|
24
|
+
- `-h --help` displays a delightful help message.
|
25
25
|
|
26
26
|
## Contributing
|
27
27
|
|
data/bin/wg_r
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'wg'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
|
8
|
+
OptionParser.new do |opts|
|
9
|
+
opts.banner = "Usage: wg [options] USERNAME/REPONAME"
|
10
|
+
opts.separator ""
|
11
|
+
|
12
|
+
opts.on("-l", "--lab", "Uses gitlab and ~/w/g/l") do |l|
|
13
|
+
options[:lab] = l
|
14
|
+
end
|
15
|
+
|
16
|
+
opts.on("-h", "--help", "Prints this help dialog.") do
|
17
|
+
puts opts
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
end.parse!
|
21
|
+
|
22
|
+
args = ARGV
|
23
|
+
|
24
|
+
# If there are no options given, just display a nice little message
|
25
|
+
if args.length == 0 or args.length > 1 then
|
26
|
+
puts "Welcome to wg - your git workspace assistant. Try: wg --help"
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
|
30
|
+
# Otherwise, let's enter the regular flow.
|
31
|
+
repo = args[0]
|
32
|
+
git = options[:lab] ? :gitlab : :github
|
33
|
+
directory = Wg.build_directory(repo, git)
|
34
|
+
|
35
|
+
# If the directory doesn't exist, clone it first.
|
36
|
+
if !Wg.dir_exists?(directory)
|
37
|
+
Wg.clone_repo(repo, git)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Finally, change directory to the repo
|
41
|
+
# The "!" bang tells the function to cd the result.
|
42
|
+
puts "!#{directory}"
|
data/lib/wg.rb
CHANGED
@@ -1,7 +1,25 @@
|
|
1
1
|
require "wg/version"
|
2
2
|
|
3
3
|
module Wg
|
4
|
-
|
5
|
-
|
4
|
+
@workspace_dir = "#{Dir.home}/w/"
|
5
|
+
@git_dirs = {
|
6
|
+
:github => "g/h/",
|
7
|
+
:gitlab => "g/l/"
|
8
|
+
}
|
9
|
+
@git_urls = {
|
10
|
+
:github => "github.com",
|
11
|
+
:gitlab => "gitlab.com"
|
12
|
+
}
|
13
|
+
|
14
|
+
def self.build_directory(reponame, git = :github)
|
15
|
+
"#{@workspace_dir}#{@git_dirs[git]}#{reponame}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.dir_exists?(directory)
|
19
|
+
File.directory?(directory)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.clone_repo(reponame, git = :github)
|
23
|
+
exec "git clone git@#{@git_urls[git]}:#{reponame}.git #{self.build_directory(reponame, git)}"
|
6
24
|
end
|
7
25
|
end
|
data/lib/wg/version.rb
CHANGED
data/wg.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
24
|
spec.bindir = "bin"
|
25
|
-
spec.executables = "
|
25
|
+
spec.executables = "wg_r"
|
26
26
|
spec.require_paths = ["lib"]
|
27
27
|
|
28
28
|
spec.add_development_dependency "bundler", "~> 1.12"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Ginn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -57,7 +57,7 @@ description: wg is a simple git(hub|lab) command line tool to manage git project
|
|
57
57
|
email:
|
58
58
|
- sam@samginn.com
|
59
59
|
executables:
|
60
|
-
-
|
60
|
+
- wg_r
|
61
61
|
extensions: []
|
62
62
|
extra_rdoc_files: []
|
63
63
|
files:
|
@@ -70,7 +70,7 @@ files:
|
|
70
70
|
- Rakefile
|
71
71
|
- bin/console
|
72
72
|
- bin/setup
|
73
|
-
- bin/
|
73
|
+
- bin/wg_r
|
74
74
|
- lib/wg.rb
|
75
75
|
- lib/wg/version.rb
|
76
76
|
- wg.gemspec
|
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
98
|
+
rubygems_version: 2.4.6
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: simple git(hub|lab) command line tool
|
data/bin/wgr
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'wg'
|
4
|
-
require 'optparse'
|
5
|
-
|
6
|
-
options = {}
|
7
|
-
|
8
|
-
OptionParser.new do |parser|
|
9
|
-
parser.on("-n", "--name NAME", "The name of the person to greet.") do |v|
|
10
|
-
options[:name] = v
|
11
|
-
end
|
12
|
-
|
13
|
-
parser.on("-h", "--help", "Prints this help dialog.") do
|
14
|
-
puts parser
|
15
|
-
exit
|
16
|
-
end
|
17
|
-
end.parse!
|
18
|
-
|
19
|
-
puts "!./lib" if options[:name]
|