gem-src 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7bdbdaa6e01ab1155713781bc4b8790b21873ee
4
- data.tar.gz: b2b2f64ebb5815991146b3658cdc68acc9ea4c86
3
+ metadata.gz: 829ded2173fdb56252ef40be2bbea300a0eb14da
4
+ data.tar.gz: 42f85aed1c4311f9a8d3f9d70e17e5f32bbab116
5
5
  SHA512:
6
- metadata.gz: 320ce85e5a4fcf917c093587027c9b25e3c57354bfe882f58db194d8c0e2de2188883a36e0354651e067926f3147adf362d565d66321e9ea9e4f369540ba82e3
7
- data.tar.gz: 3754ba1cbc6e7065cbf716e72f177741a92748020d1219bf32a24e30c48eb75daaefa992eb8a3b3d21327876ff53ef7081e5ec02c3619751a372f9c6065ffbdd
6
+ metadata.gz: a2e655aa543cc0d462c3f007a9a47b7a4ea492f1788a95416beeaaa3efba99ace4e9681c053ac7d527170ed8fead517704b90d6d955466cdb73acedcba11d7c4
7
+ data.tar.gz: a9f999c47b8e8148b7bcf491a0f442e10364f491eefdc74e17f8dd60bd1f54e278d1b97773f1a71aa35388fd9b498cb28a9c5aed3e5d65a4bbd21b4bd3f2b1a3
data/README.md CHANGED
@@ -1,18 +1,29 @@
1
1
  # gem-src
2
2
 
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!
3
+ gem-src is a gem plugin && rbenv 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
 
6
6
  ## Installation
7
7
 
8
+ ### As a Rubygem
9
+
10
+ gem-src is a gem plugin that can be installed via gem install command:
11
+
8
12
  $ gem install gem-src
9
13
 
14
+ ### As an rbenv plugin (recommended)
15
+
16
+ Alternatively, if you're using rbenv, you can install gem-src as an rbenv plugin:
17
+
18
+ $ git clone https://github.com/amatsuda/gem-src.git ~/.rbenv/plugins/gem-src
19
+
20
+ then you get gem-src enabled for all `gem` and `bundle` commands invoked through rbenv.
10
21
 
11
22
  ## Configuration
12
23
 
13
24
  ### By default
14
25
 
15
- With this gem installed, every `gem install` you perform will be followed by automatic `git clone` into the installed gem's "src" directory (if the gemspec's "homepage" property points to a Git repo).
26
+ With this gem plugin installed, every `gem install` you perform will be followed by automatic `git clone` of the online repo into the installed gem's "src" directory (if the gemspec's "homepage" property points to a Git repo).
16
27
 
17
28
  For example, when you execute
18
29
 
@@ -32,14 +43,15 @@ So, the whole directory structure will be like this.
32
43
  │ ├── kaminari-0.14.1
33
44
  │   │   ├── src
34
45
  ...
35
- Note that if you're using RVM, each of `~/.rvm/gems/*/gems/*` will have it's Git repo inside "src" directory.
46
+ Note that you might be cloning the same repository again and again as the gem is updated, or the gem install directory changes.
47
+ For example, if you're using RVM, each of `~/.rvm/gems/*/gems/*` will have it's Git repo inside "src" directory.
36
48
 
37
- ### specifying gemsrc_clone_root
49
+ ### specifying gemsrc_clone_root (strongly recommended)
38
50
 
39
51
  Instead of cloning the repo under installed gem directory for each `gem install`, you can specify one single directory to keep all the cloned source repositories.
40
52
 
41
53
  This way, `git clone` will no more be executed per every `gem update`.
42
- This option would be more efficient particularly if you're frequently switching RVM gemsets, or using bundler with `--path` per each projects.
54
+ This option would be more efficient particularly if you're frequently switching Ruby versions or gemsets, or using bundler with `--path` per each projects.
43
55
  There are two ways to specify this variable:
44
56
 
45
57
  1) `GEMSRC_CLONE_ROOT` environment variable
@@ -61,7 +73,7 @@ Now, the whole directory structure will look like this.
61
73
  ...
62
74
 
63
75
 
64
- ## Usage
76
+ ## Pristine
65
77
 
66
78
  When you firstly installed this gem, you might want to type in this command right after the installation.
67
79
 
@@ -69,13 +81,6 @@ When you firstly installed this gem, you might want to type in this command righ
69
81
  This will reinstall all the already installed gems, and so will `git clone` all the repos.
70
82
 
71
83
 
72
- ## Todo
73
-
74
- * Bundler
75
-
76
- * specs
77
-
78
-
79
84
  ## Contributing
80
85
 
81
86
  1. Fork it
@@ -0,0 +1,34 @@
1
+ # This code is borrowed from https://github.com/sstephenson/rbenv-gem-rehash.
2
+ #
3
+ # Copyright (c) 2013 Sam Stephenson <<sstephenson@gmail.com>>
4
+ #
5
+ # Copyright (c) 2013 Joshua Peek <<josh@joshpeek.com>>
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining
8
+ # a copy of this software and associated documentation files (the
9
+ # "Software"), to deal in the Software without restriction, including
10
+ # without limitation the rights to use, copy, modify, merge, publish,
11
+ # distribute, sublicense, and/or sell copies of the Software, and to
12
+ # permit persons to whom the Software is furnished to do so, subject to
13
+ # the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be
16
+ # included in all copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
+
26
+ # Remember the current directory, then change to the plugin's root.
27
+ cwd="$PWD"
28
+ cd "${BASH_SOURCE%/*}/../../../lib"
29
+
30
+ # Make sure `rubygems_plugin.rb` is discovered by RubyGems by adding
31
+ # its directory to Ruby's load path.
32
+ export RUBYLIB="$PWD:$RUBYLIB"
33
+
34
+ cd "$cwd"
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.4.2'
7
+ gem.version = '0.5.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` }'
@@ -17,4 +17,13 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ["lib"]
18
18
 
19
19
  gem.add_development_dependency 'rspec', ['>= 0']
20
+
21
+ gem.post_install_message = <<-END
22
+ [gem-src] If you have not yet configured "gemsrc_clone_root", we strongly recommend you to add the configuration to your .gemrc.
23
+
24
+ e.g.)
25
+ % echo "gemsrc_clone_root: ~/src" >> ~/.gemrc
26
+
27
+ See README for more details.
28
+ END
20
29
  end
@@ -9,7 +9,7 @@ module Gem
9
9
  attr_reader :installer
10
10
 
11
11
  def initialize(installer)
12
- @installer = installer
12
+ @installer, @tested_repositories = installer, []
13
13
  end
14
14
 
15
15
  def clone_dir
@@ -56,22 +56,32 @@ module Gem
56
56
  api[/^homepage_uri: (.*)$/, 1]
57
57
  end
58
58
 
59
+ def github_organization_uri(name)
60
+ "https://github.com/#{name}/#{name}"
61
+ end
62
+
59
63
  def git_clone(repository)
60
- system 'git', 'clone', repository, clone_dir if repository && !repository.empty? && git?(repository)
64
+ return if repository.nil? || repository.empty?
65
+ return if @tested_repositories.include? repository
66
+ @tested_repositories << repository
67
+ system 'git', 'clone', repository, clone_dir if git?(repository)
61
68
  end
62
69
 
63
- def git_clone_homepage_or_source_code_uri_or_homepage_uri
70
+ def git_clone_homepage_or_source_code_uri_or_homepage_uri_or_github_organization_uri
64
71
  return false if File.exist? clone_dir
65
72
  git_clone(installer.spec.homepage) ||
66
73
  git_clone(github_url(installer.spec.homepage)) ||
67
74
  git_clone(source_code_uri) ||
68
75
  git_clone(homepage_uri) ||
69
- git_clone(github_url(homepage_uri))
76
+ git_clone(github_url(homepage_uri)) ||
77
+ git_clone(github_organization_uri(installer.spec.name))
70
78
  end
71
79
  end
72
80
  end
73
81
 
74
82
 
75
83
  Gem.post_install do |installer|
76
- Gem::Src.new(installer).git_clone_homepage_or_source_code_uri_or_homepage_uri
84
+ next true if installer.class.name == 'Bundler::Source::Path::Installer'
85
+ Gem::Src.new(installer).git_clone_homepage_or_source_code_uri_or_homepage_uri_or_github_organization_uri
86
+ true
77
87
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-src
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Matsuda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-15 00:00:00.000000000 Z
11
+ date: 2014-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -36,12 +36,19 @@ files:
36
36
  - LICENSE.txt
37
37
  - README.md
38
38
  - Rakefile
39
+ - etc/rbenv.d/exec/~gem-src.bash
39
40
  - gem-src.gemspec
40
41
  - lib/rubygems_plugin.rb
41
42
  homepage: https://github.com/amatsuda/gem-src
42
43
  licenses: []
43
44
  metadata: {}
44
- post_install_message:
45
+ post_install_message: |
46
+ [gem-src] If you have not yet configured "gemsrc_clone_root", we strongly recommend you to add the configuration to your .gemrc.
47
+
48
+ e.g.)
49
+ % echo "gemsrc_clone_root: ~/src" >> ~/.gemrc
50
+
51
+ See README for more details.
45
52
  rdoc_options: []
46
53
  require_paths:
47
54
  - lib
@@ -57,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
64
  version: '0'
58
65
  requirements: []
59
66
  rubyforge_project:
60
- rubygems_version: 2.2.0
67
+ rubygems_version: 2.2.2
61
68
  signing_key:
62
69
  specification_version: 4
63
70
  summary: Gem.post_install { `git clone gem_source src` }