How to extract source code of specific gem so that it is possible to edit it locally? Shall I add it to my Rails application folder?
I need that to be able to make changes to the gem's code.
If you find an error in gem, you'd better make pull request on GitHub. But let's suppose you need your private fork of gem. Best workflow for that:
Download the gem source code from GitHub: git clone https://github.com/author/awesome_gem.git.
In your project's Gemfile add gem awesome_gem, path: "/local/path/to/awesome_gem"
Run bundle install
Now you can make changes to the gem locally, and have your project use local copy of it. When you are done making initial changes, push your Gem to your github repository, and change Gemfile line to something like:
gem awesome_gem, github: 'QQQ/awesome_gem' ('QQQ' being your Github's account name)
Related
I'm starting a project where I will work with the base Gollum wiki gem, and add some features to it. I was wondering what is the best way to do this.
Do I need to build and install the gem everytime I need to test it? Is there a way to edit the source code of the gem and test it on-the-fly?
I'm only a beginner at this, so sorry if this is a silly question!
Clone the git into your userspace;
Checkout the source code somewhere into your Projects directory;
Put in your main projects Gemfile the following:
(instead of :git => ...)
# V VERSION IS HERE
gem 'gollum', '~> XXX', :path => '/home/Projects/gollum'
Run bundle update in your main project directory each time you changed smth in gollum. Don’t forget to commit changes to github into your gollum fork and point gem instruction to it into Gemfile before uploading.
Hope it helps.
There a couple different things you can do in this situation if you are using bundler. First, you could simply edit the gem locally. Running bundle show gollum will show you the directory in which the gem is installed and you can simply edit it and the changes will appear in your application. In the end, you will need to either fork the gem and use your own version in your Gemfile. Documentation on using a custom git repository can be found here: http://bundler.io/git.html
Also in that documentation is how to set up a local git repository. If you plan on having a separate gollum repository and pushing it our, you will probably want to work with a local copy. Rather than simply pointing to a separate directory on the filesystem, it is useful to use bundler's "Local Git Repos" feature, which is also documented in the link above.
Either way, once you are ready to push out your code, you will want to point your code to the remote repository so you can actually deploy it.
I am trying to push into rubygems.orge a simple gem following this tutorial. Basically I am using bundler and I have write a simple Hello World class. Then, I try to push the gem as follows:
bundle gem my_first_gem
gem build my_first_gem-0.0.1.gem
and I get:
Signed in.
Pushing gem to https://rubygems.org...
Repushing of gem versions is not allowed.
Please use `gem yank` to remove bad gem releases.
So, I have checked and there is already a gem with such name. So, is there an easy way to rename the gem I have including changing the gem name in all generate by bulder files:
or if I should rename the files by hand, could you tell which are the critical ones?
Instead of renaming files by hand. As it is just a tutorial gem, I would suggest you to create a new gem with
bundle gem gotqn_first_gem
and just move your HelloWorld class in lib. And follow the rest of the commands suggested in Railscasts.
Don't forget that after renaming you need to call git add -A to update your files list.
The reason for that is because (unless that you have changed) your my_first_gem.gemspec have a line like that:
spec.files = `git ls-files -z`.split("\x0")
So, when you call gem build my_first_gem-0.0.1.gem, the above command will search for your older files and ignore the renamed ones.
I'm building a project and I need to override the default styles of bootstrap in the source code . So how do I access the source code ?
find the location of your gem files with gem env.
mine is
INSTALLATION DIRECTORY: /Users/xxx/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0
then the .less files are in /gems/twitter-bootstrap-rails-2.2.8/vendor/toolkit/twitter
I don't know what you want to do, but there are many variables for customizing bootstrap without changing any of the source, see - http://getbootstrap.com/2.3.2/customize.html#variables
just fork the gem in github, clone it to your local, modify it, then push it, after that if you want to use it in your rails project, just add your forked git source in your Gemfile like this:
gem "twitter-bootstrap-rails", git: "https://github.com/xxxx/twitter-bootstrap-rails.git"
Where are the gem files located ?
I'm new to rails and trying o understand how the whole gem functionality works.
My question is how can i follow a gem installation in order to confirm a gem is been installed ?
Where are the installed files located ?
From within your rails app, you can list out all of the gems being used, their versions, and the local path:
bundle show --paths
There's no reason to modify any of these files though. Configuration is typically done through an initializer in /app/initializers, but it depends on the gem being used.
If you need to modify something about the gem, you should fork it on Github and then reference the git location in your Gemfile until your pull request makes it back into the gem:
gem 'some_gem', '4.1.1', git: 'https://github.com/some_github_repo/some_gem.git'
I want to use cloudmade gem but it is not stored in rubyforge so I have to download the .gem and to gem install cloudmade.gem.
Questions:
1)Is it wise to commit this to git repo so that others can use it as well?
1a) If yes, where should I put the gem in my rails app?
1b) If not, how should I share this with other people so that they won't have error when they do 'bundle install'
Best way IMHO :
clone the repo in Github,
in your Gemfile, add the path to your git depo using something like :
gem "abc", :git => "https://github.com........"
So that your team will be able to work on the project.
Try to contact the author of the gem to know if you can be the new maintainer of the gem.
Then upload it on Rubygems if you want.