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 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.2'
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` }'
@@ -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") && !`git ls-remote #{installer.spec.homepage} 2> /dev/null`.empty?
5
- Dir.chdir installer.gem_dir do
6
- `git clone #{installer.spec.homepage} src`
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-src
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: