# Using Rake to Build Gem

**URL:** <https://www.ruby-forum.com/t/using-rake-to-build-gem/135070>\
**Category:** Ruby\
**Created:** [April 17, 2008, 4:50pm UTC](https://www.ruby-forum.com/t/using-rake-to-build-gem/135070 "2008-04-17T16:50:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![roxah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/54ee81/32.png) [@roxah](https://www.ruby-forum.com/u/roxah)\
**Post date:** [April 17, 2008, 4:50pm UTC](https://www.ruby-forum.com/t/using-rake-to-build-gem/135070/1 "2008-04-17T16:50:56Z")

</div>

Hello all,

I’m using Rake to build a gem for my Ruby application and I was  
wondering if  
there’s a way to exclude certain files and/or directories from rdoc  
generation.

---

<div class="post-metadata">

**Author:** ![roxah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/54ee81/32.png) [@roxah](https://www.ruby-forum.com/u/roxah)\
**Post date:** [April 17, 2008, 5:25pm UTC](https://www.ruby-forum.com/t/using-rake-to-build-gem/135070/2 "2008-04-17T17:25:41Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Bryan R. wrote:  
| Hello all,  
|  
| I’m using Rake to build a gem for my Ruby application and I was  
wondering if  
| there’s a way to exclude certain files and/or directories from rdoc  
| generation.

Here’s an example from the Rakefile I use for one of my projects:  
~ g.files = FileList[‘lib/**/_.rb’, '[A-Z]_',  
'test/**/\*’].exclude(‘smtp\_tls.rb’).to\_a

#exclude from Rake’s FileList makes sure that ‘smtp\_tls.rb’ isn’t used.

AFAIK, #exclude can use an Array, too, if you want to exclude multiple  
files (I don’t know about globs, though).

* * *

Phillip G.  
Twitter: [twitter.com/cynicalryan](http://twitter.com/cynicalryan)

~ “To make a bad day worse, spend it wishing for the impossible.”  
-Calvin  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.8 (MingW32)  
Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org](http://enigmail.mozdev.org)

iEYEARECAAYFAkgHa7YACgkQbtAgaoJTgL+C0ACgojLcMzhwfepSsB+aCRVfMNc5  
I6IAn06WndJ0WekjY1VbddfOJwIlNdB1  
=P1mS  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![roxah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/54ee81/32.png) [@roxah](https://www.ruby-forum.com/u/roxah)\
**Post date:** [April 17, 2008, 7:10pm UTC](https://www.ruby-forum.com/t/using-rake-to-build-gem/135070/3 "2008-04-17T19:10:19Z")

</div>

On Apr 17, 2008, at 8:50 AM, Bryan R. wrote:

> Hello all,
> 
> I’m using Rake to build a gem for my Ruby application and I was  
> wondering if  
> there’s a way to exclude certain files and/or directories from rdoc  
> generation.

Take a look at Mr Bones. It provides a skeleton for Ruby projects, and  
it is not viral – you won’t have to include Mr Bones as a dependency  
to use your gem. The project skeleton has a collection of rake tasks  
for managing your project including building a gem. You can explicitly  
include or exclude files for rdoc generation …

PROJ.rdoc.exclude = %w[^some/dir/ .tmp$]  
PROJ.rdoc.include = %w[.txt$]

the syntax here is just an array of regexp snippets specifying the  
file types you want to ignore or include.

[http://bones.rubyforge.org/](http://bones.rubyforge.org/)

If you just want the rake tasks and Rakefile, create a throw away  
project using the “bones” command line. Copy the “tasks” folder and  
the Rakefile to your project.

Blessings,  
TwP
