gem-src 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/gem-src.gemspec +1 -1
- data/lib/rubygems_plugin.rb +18 -3
- metadata +1 -1
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# gem-src
|
2
2
|
|
3
|
-
A gem plugin that automatically `git clone`s the gem's source right after every `gem install`
|
3
|
+
A gem plugin that automatically `git clone`s the gem's source right after every `gem install` so you can `git log`, `git grep` and of course write your patch there!
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
data/gem-src.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "gem-src"
|
7
|
-
gem.version = '0.0
|
7
|
+
gem.version = '0.1.0'
|
8
8
|
gem.authors = ["Akira Matsuda"]
|
9
9
|
gem.email = ["ronnie@dio.jp"]
|
10
10
|
gem.description = 'Gem.post_install { `git clone gem_source src` }'
|
data/lib/rubygems_plugin.rb
CHANGED
@@ -1,9 +1,24 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
3
|
Gem.post_install do |installer|
|
4
|
-
if installer.spec.homepage && !installer.spec.homepage.empty? && !File.exists?("#{installer.gem_dir}/src")
|
5
|
-
|
6
|
-
|
4
|
+
if installer.spec.homepage && !installer.spec.homepage.empty? && !File.exists?("#{installer.gem_dir}/src")
|
5
|
+
repo = installer.spec.homepage
|
6
|
+
if repo =~ /\Ahttps?:\/\/([^.]+)\.github.com\/(.+)/
|
7
|
+
repo = if $1 == 'www'
|
8
|
+
"https://github.com/#{$2}"
|
9
|
+
elsif $1 == 'wiki'
|
10
|
+
# https://wiki.github.com/foo/bar => https://github.com/foo/bar
|
11
|
+
"https://github.com/#{$2}"
|
12
|
+
else
|
13
|
+
# https://foo.github.com/bar => https://github.com/foo/bar
|
14
|
+
"https://github.com/#{$1}/#{$2}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
if !`git ls-remote #{repo} 2> /dev/null`.empty?
|
19
|
+
Dir.chdir installer.gem_dir do
|
20
|
+
`git clone #{repo} src`
|
21
|
+
end
|
7
22
|
end
|
8
23
|
end
|
9
24
|
end
|