• Stars
    star
    208
  • Rank 182,908 (Top 4 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Gem.post_install { `git clone gem_source src` }

gem-src

gem-src is a gem plugin && rbenv plugin that automatically git clones the gem's source right after every gem install so you can git log, git grep and of course write your patch there! Plus, gem-src runs git init on each installed gem, and links it to the cloned source repository and the origin repository so that you can easily transfer commits to and from the gem and the repositories.

TL;DR

% git clone https://github.com/amatsuda/gem-src.git "$(rbenv root)/plugins/gem-src"
% mkdir ~/src
% echo "gemsrc_clone_root: ~/src" >> ~/.gemrc

Then you're all set!

Installation

๐ŸŒŸ As an rbenv plugin (recommended)

Alternatively, if you're using rbenv, you can install gem-src as an rbenv plugin:

% git clone https://github.com/amatsuda/gem-src.git "$(rbenv root)/plugins/gem-src"

then you get gem-src enabled for all gem and bundle commands invoked through rbenv.

๐ŸŒŸ As a Bundler plugin (experimental, but also recommended)

gem-src is a bundler plugin that can be installed via bundler plugin install command:

% bundler plugin install gem-src

As a Rubygem

gem-src is a gem plugin that can be installed via gem install command:

% gem install gem-src

Configuration

By default

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).

For example, when you execute

% gem i kaminari

and if the gem is installed into ~/.gem/ruby/1.8/kaminari-0.14.1 directory, you'll see Kaminari's full Git repo at ~/.gem/ruby/1.8/kaminari-0.14.1/src directory.

So, the whole directory structure will be like this.

~/.gem/ruby/1.8
โ”œโ”€โ”€ gems
โ”‚   โ”œโ”€โ”€ arel-3.0.2
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ src
โ”‚   โ”œโ”€โ”€ gem-src-0.2.0
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ src
โ”‚   โ”œโ”€โ”€ kaminari-0.14.0
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ src
โ”‚   โ”œโ”€โ”€ kaminari-0.14.1
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ src
...

Note that you might be cloning the same repository again and again as the gem is updated, or the gem install directory changes. For example, if you're using RVM, each of ~/.rvm/gems/*/gems/* will have it's Git repo inside "src" directory.

๐ŸŒŸ Specifying gemsrc_clone_root (strongly recommended)

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.

This way, git clone will no more be executed per every gem update. This option would be more efficient particularly if you're frequently switching Ruby versions or gemsets, or using bundler with --path per each projects. There are two ways to specify this variable:

1) `GEMSRC_CLONE_ROOT` environment variable
2) add `gemsrc_clone_root` configuration in your .gemrc

For example,

% echo "gemsrc_clone_root: ~/src" >> ~/.gemrc
% gem i active_decorator

will clone the source Git repo into ~/src/active_decorator directory if not exists.

Now, the whole directory structure will look like this.

~
โ”œโ”€โ”€ src
โ”‚   โ”œโ”€โ”€ active_decorator
โ”‚   โ”œโ”€โ”€ capybara
โ”‚   โ”œโ”€โ”€ i18n_generators
...

Using ghq command (also recommended)

You can tell gem-src to rely on ghq command instead of git clone. This requires ghq (https://github.com/motemen/ghq) to be installed, and either of the following two configurations should be made.

1) `GEMSRC_USE_GHQ` environment variable
2) add `gemsrc_use_ghq` configuration in your .gemrc

The directory structure should be like below in this mode.

ghq.root (~/.ghq by default)
โ”œโ”€โ”€ github.com
โ”‚   โ”œโ”€โ”€ amatsuda
โ”‚   โ”‚   โ”œโ”€โ”€ database_rewinder
โ”‚   โ”‚   โ””โ”€โ”€ rfd
โ”‚   โ”œโ”€โ”€ jimweirich
โ”‚   โ”‚   โ””โ”€โ”€ rake
...

Pristine

When you firstly installed this gem, you might want to type in this command right after the installation.

% gem pristine --all

This will reinstall all the already installed gems, and so will git clone all the repos.

Skip cloning

If you want to skip cloning repositories, you can skip cloning by providing an environment variable GEMSRC_SKIP:

% GEMSRC_SKIP=true bundle install

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

More Repositories

1

jb

A simple and fast JSON API template engine for Ruby on Rails
Ruby
1,235
star
2

active_decorator

ORM agnostic truly Object-Oriented view helper for Rails 4, 5, 6, and 7
Ruby
1,051
star
3

traceroute

A Rake task gem that helps you find the unused routes and controller actions for your Rails 3+ app
Ruby
877
star
4

heavens_door

Capybara test scenario recorder for Rails
JavaScript
863
star
5

database_rewinder

minimalist's tiny and ultra-fast database cleaner
Ruby
800
star
6

stateful_enum

A very simple state machine plugin built on top of ActiveRecord::Enum
Ruby
606
star
7

kaminari_themes

HTML
352
star
8

erd

A Rails engine for drawing your app's ER diagram
Ruby
326
star
9

html5_validators

A gem/plugin for Rails 3, Rails 4, Rails 5, and Rails 6 that enables client-side validation using ActiveModel + HTML5 Form Validation
Ruby
304
star
10

i18n_generators

A pack of Rails generators gem plugin that generates Rails 3 and Rails 2 I18n locale files for almost every known locale.
Ruby
285
star
11

himl

HTML-based Indented Markup Language for Ruby
Ruby
235
star
12

still_life

Rails upgrade's best friend
Ruby
216
star
13

motorhead

A Rails Engine framework that helps safe and rapid feature prototyping
Ruby
181
star
14

nested_scaffold

Nested scaffold generator for Rails 4.2 and 5
Ruby
176
star
15

roundabout

A Rails Engine that generates a page transition diagram for your Rails app from request specs
Ruby
153
star
16

rfd

Ruby on Files & Directories
Ruby
152
star
17

routes_lazy_routes

A boot time booster for Ruby on Rails that defers loading the whole bloody routes so the app can spin up quickly ๐Ÿค˜
Ruby
141
star
18

string_template

A template engine for Rails, focusing on speed, using Ruby's String interpolation syntax
Ruby
125
star
19

kawaii_validation

An ActiveRecord extension that adds more kawaii validation syntax
Ruby
117
star
20

interactive_rspec

RSpec on IRB
Ruby
86
star
21

hocus_pocus

A magical isolated engine gem for Rails 3.1+
Ruby
81
star
22

ljax_rails

render :partial lazy-loader for Rails
Ruby
67
star
23

everywhere

Hash condition syntax for AR query everywhere!
Ruby
58
star
24

kaminari_example

A tutorial project for the basic and advanced usage of Kaminari paginator
Ruby
45
star
25

async_partial

Ruby
33
star
26

turbo_partial

Ruby
27
star
27

future_records

Ruby
25
star
28

lightweight_attributes

Ruby
24
star
29

more_optimized_resolver

Ruby
23
star
30

turbo_urls

Ruby
22
star
31

teriyaki

Automatically imports *_path definitions from config/routes.rb for acceptance testing
Ruby
22
star
32

kawaii_association

An ActiveRecord DSL extension that provides kawaii association syntax
Ruby
21
star
33

arel_ruby

ARel Ruby visitor
Ruby
20
star
34

activerecord-refinements

ActiveRecord + Ruby 2.0 refinements
Ruby
20
star
35

polymorphic_url_cache

Ruby
17
star
36

gem_i

A RubyGems plugin that explicitly aliases `gem i` to `gem install` to avoid ambiguity
Ruby
17
star
37

speed_king

Ruby
14
star
38

nested_layouts

The only fork of "nested_layouts" Rails plugin in Github that correctly bug fixed for Rails 2.3
Ruby
13
star
39

rspec-refinements

RSpec + Ruby 2.0 refinements
Ruby
10
star
40

arenai

Ruby
8
star
41

activecalendar

Rails 2.2.2 ready javascript calendar date renderer
JavaScript
8
star
42

bundler-squash

Ruby
8
star
43

rbenv-gem-shared

Ruby
8
star
44

tatsuzine

Live coded app at Railsๅ‹‰ๅผทไผš@ๆฑไบฌ#59
Ruby
8
star
45

bot_for_ruby-lang

Ruby
7
star
46

factory_factory

a script that transfers existing AR models into factories for factory_girl
Shell
6
star
47

automagic

Ruby
6
star
48

snowman_meltdown

A simple middleware for Rails 3 to vanish _snowman parameterโ˜ƒโ˜ƒโ˜ƒ
Ruby
5
star
49

activesupport-refinements

Ruby
4
star
50

webdb073_tutorial

WEB+DB Press Vol. 73 ็‰น้›†2ใ€Œ่ฉณ่งฃRails 4ใ€ใฎใƒใƒฅใƒผใƒˆใƒชใ‚ขใƒซใฎใ‚ตใƒณใƒ—ใƒซใ‚ณใƒผใƒ‰
Ruby
4
star
51

gitrockets

Ruby
3
star
52

rails3_hands_on

ๆฑไบฌRubyไผš่ญฐ03ใฎใƒฏใƒผใ‚ฏใ‚ทใƒงใƒƒใƒ—ใ€ŒRails 3ใƒใƒณใ‚บใ‚ชใƒณใ€ใฎใ‚ตใƒณใƒ—ใƒซใ‚ขใƒ—ใƒชใ‚ฑใƒผใ‚ทใƒงใƒณ
Ruby
3
star
53

prsnt

prsnt prttyp
3
star
54

git_commands

3
star
55

internationalization

Ruby
3
star
56

qwik

qwik
2
star
57

hfrails

hfrails
2
star
58

atode_yomu

A gem plugin that cleverly installs rdoc and ri for the latest versions of already installed gems
Ruby
2
star
59

gem-diet

Ruby
2
star
60

action_args_with_rbs

Ruby
1
star