Yesterday I wondered if there was a good reason we couldn't
gem install <url to git repository>
and thought I'd have a look at adding it to
rubygems for fun's sake.
Then I saw how many files there were and decided
gem install from git with a shell script would be easily achieved in just a few minutes.
#!/bin/bash
gemifgTMPDIR=$TMPDIR"_gemifg"
git clone $1 $gemifgTMPDIR
gemifgOWD=$PWD
cd $gemifgTMPDIR
gem build *.gemspec
gem install *.gem
if [ ! -z "$gemifgTMPDIR" ]
then
rm -rf $gemifgTMPDIR
fi
cd $gemifgOWD
Let me know what you think, or if there are some repositories where it doesn't work for you. I only tested it on
utility-belt.
Hey! Why don't you make your life easier and subscribe to the full post
or short blurb RSS feed? I'm so confident you'll love my smelly pasta plate
wisdom that I'm offering a no-strings-attached, lifetime money back guarantee!
Leave a comment
Nice idea to get a "snapshot" build gem. But is it convention for a gem to have a .gemspec in the root directory? E.g. I have my gemspec usually inside the Rakefile. You could check for it and use Rake as well (if you want your script to be general).
Posted by
Peter Kofler
on Jul 16, 2011 at 04:10 PM UTC - 6 hrs
Hey Peter,
That's a good idea. In fact I had originally written it to do `rake build` but then I noticed there was no rakefile in utility-belt.
I've looked up some gem projects this morning - haml, rails, chronic and all have a build task that references a gemspec they also have.
Do you know of an example of one that doesn't include a gemspec that I could use to test on?
Also, do you name the rake task for building the gem 'build' or do you know of any other common task names that people use for the same purpose?
Thanks for the feedback!
Posted by
Sammy Larbi
on Jul 18, 2011 at 08:12 AM UTC - 6 hrs
I usually put everything inside a Rakefile, see
https://code.google.com/p/javaclass-rb/source/brow...I copied all the targets together from different OS projects, but can't remember where I took the basic layout from. It's hosted using HG, so I'm not sure it of any use for you. (Although the clone command is similar.)
On the other hand, would you say that including a .gemspec is common usage? So I should follow the lead ;-)
Or with some "magic" you could extract the gemspec definition (that has to live somewhere) from the Rakefile and work using it standalone.
Posted by
Peter Kofler
on Jul 18, 2011 at 09:16 AM UTC - 6 hrs
Judging from the results of looking up those 4 gems, I'd guess it is common to include a .gemspec, but of course I'd hate to extrapolate that out into a rule without doing further analysis. =)
Posted by
Sammy Larbi
on Jul 18, 2011 at 02:09 PM UTC - 6 hrs
Awesome, thanks for sharing that. I was still mulling over how to generalize it, but after reading Yehuda's take, I think I won't expend the effort. =)
How did you come across it?
Posted by
Sammy Larbi
on Jul 22, 2011 at 07:33 PM UTC - 6 hrs
I already had decided to extract the .gemspec out of the Rakefile and was googling for the best way to do that. I didn't find anything. My Rakefile needs information from the gemspec for some tasks so I ended up with
gemspec = eval(IO.readlines('javaclass.gemspec').join)
which I do not like. "load" would be nicer but does not give me back the instance created in the .gemspec.
On the other hand, some tools, like Jeweler can't have a .gemspec, see
http://jeffkreeftmeijer.com/2010/dont-put-your-gem...
Posted by
Peter Kofler
on Jul 23, 2011 at 01:06 PM UTC - 6 hrs
Cool, thanks. I've enjoyed reading those posts. I like to see the tradeoffs in different ways of doing things, and I hadn't really considered the alternatives in this case.
Posted by
Sammy Larbi
on Jul 23, 2011 at 01:18 PM UTC - 6 hrs
Leave a comment