[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How do I put empty directories into a gem package?

Luke

2/11/2007 9:35:00 PM

I feel like an idiot for being unable to get this working...

I'm trying to put together a general purpose "project templating
engine" and I'd like to just package a directory full of project
templates that get copied and rendered in ERB on demand. These
templates often include empty directories that I can't seem to get
packaged into my gem - no matter what I do.

I'm pretty sure I'm doing something really dumb, but I can't seem to
figure out what it is!

It occurred to me that I might pack these templates up in a zip or tar
file and just unpack them on request, but I couldn't get the empty
directories into the zip file either. At this point, that makes me
think I'm just doing something wrong, so rather than going to the pack/
unpack scheme - it seems like I ought to just ask you folks how to do
it correctly.

So -

Does anyone know how to get empty directories into a gem package?

Here's what I have in my rake file:

PKG_LIST = FileList['[a-zA-Z]*',
'bin/**/*',
'lib/**/*',
'templates',
'templates/**/*',
'templates/**/.[a-z]*'
]

PKG_LIST.exclude('.svn')
PKG_LIST.each do |file|
puts 'file: ' + file
task :package => file
end

When I run "rake package", I see all of the desired files *and* all of
the desired directories on screen, but when I install the gem, they're
not there!

I'm guessing there is some simple exclude directive that I'm not able
to find? I dug around in the rake package task code, but can't see
anything obvious (to me at least)


Thanks,


lb.

10 Answers

Austin Ziegler

2/12/2007 12:14:00 AM

0

On 2/11/07, Luke <lbayes@gmail.com> wrote:
> I'm trying to put together a general purpose "project templating
> engine" and I'd like to just package a directory full of project
> templates that get copied and rendered in ERB on demand. These
> templates often include empty directories that I can't seem to get
> packaged into my gem - no matter what I do.

Um. I'm not sure that's what you want to do. Why not consider
approaching this from a slightly different perspective? Make a .tar.gz
file that gets deployed with your other files and then use
Archive::Tar::Minitar to unpack it on the fly (Ruwiki does this) and
render with ERB as usual. Archive::Tar::Minitar can easily handle this
on both ends and you don't need to try to trick RubyGems.

-austin
--
Austin Ziegler * halostatue@gmail.com * http://www.halo...
* austin@halostatue.ca * http://www.halo...feed/
* austin@zieglers.ca

Luke

2/12/2007 12:40:00 AM

0

I definitely considered that direction, and even got it mostly-
working, but then I started having problems with my test cases.

I was writing tests that unpack the actual tarball and found that my
tests now had a dependency on a successful build, but I couldn't get a
successful build unless my tests passed! :-(

I recognize that this is a simple problem and could be fixed by
packing up the tarball in the test_helper or setup methods, but then
it felt like I was violating dry principles by putting my packing
logic (more importantly - the file selection) into the rake file *and*
into my test cases. I wanted to verify that the actual templates being
shipped in the gem are in fact what we're testing against, and I'd
like the test cases stay up to date if our inclusion globs change over
time...

This also puts another dependency into my gem and I was hoping to
minimize those external dependencies.

It just feels like I'm missing some simple setting in the gem package
task...

Something like:
prune_empty_directories = false

Another reason I don't want to tar them up, is because I'm optionally
duplicating them into user_home and/or project_home, and I would
prefer not to have different copy logic when they come out of
gem_home, and it's essential that users can easily modify these
templates when they're placed into those other two locations - so they
can't be tarred up in there.

The final reason it felt strange to tar the templates was simply
because my understanding is that gem is already tarring everything up,
so shouldn't I just be able to get that one working?

> Um. I'm not sure that's what you want to do. Why not consider
> approaching this from a slightly different perspective? Make a .tar.gz
> file that gets deployed with your other files and then use
> Archive::Tar::Minitar to unpack it on the fly (Ruwiki does this) and
> render with ERB as usual. Archive::Tar::Minitar can easily handle this
> on both ends and you don't need to try to trick RubyGems.

Thanks for the response.


Luke
www.asunit.org

Luke

3/22/2007 9:43:00 PM

0

Does anyone else have any ideas about how to solve this problem?

For what it's worth, I wound up writing a rake task that injects a
bunch of junk files into the entire template directory and then added
these file names to my "ignore list" when copying out of the installed
gem.

Definitely *not* elegant but it works.


Luke Bayes

Eric Hodel

3/27/2007 8:16:00 PM

0

On Mar 22, 2007, at 14:45, Luke wrote:
> Does anyone else have any ideas about how to solve this problem?
>
> For what it's worth, I wound up writing a rake task that injects a
> bunch of junk files into the entire template directory and then added
> these file names to my "ignore list" when copying out of the installed
> gem.
>
> Definitely *not* elegant but it works.

Please give some code that shows how this is broken.


ivanmaxim

12/12/2013 3:53:00 PM

0

On Thursday, December 12, 2013 10:47:20 AM UTC-5, William Sommerwerck wrote:
> "Christopher Webber" wrote in message
>
> news:bgu2o1Fb6odU1@mid.individual.net...
>
> On 12/12/2013 14:19, William Sommerwerck wrote:
>
>
>
> >> I just saw this. Does the music in the first section ring a bell?
>
>
>
> > Perhaps the hack who's responsible for the score has come
>
> > to an arrangement with the Ligeti estate? Otherwise there
>
> > might be a nasty Atmosphere.
>
>
>
> So you heard the same thing. Thank you.
>
>
>
> Trailers sometimes use music not in the film's score. Still...

and they also sometimes use scenes not in the released film.

Norman Schwartz

12/12/2013 4:57:00 PM

0

Christopher Webber wrote:
> On 12/12/2013 14:19, William Sommerwerck wrote:
>> I just saw this. Does the music in the first section ring a bell?
>
> Perhaps the hack who's responsible for the score has come to an
> arrangement with the Ligeti estate? Otherwise there might be a nasty
> Atmosphere.
>
As in 2001 Space Odyssey? (I have both the BD and the complete soundtrack CD
which inlcudes yet another *^## Blue Danube.)



> Doesn't look as if the shade of Akira Ifukube has anything to fear
> from this one...


Christopher Webber

12/12/2013 5:29:00 PM

0

On 12/12/2013 16:57, Norman Schwartz wrote:
> I have both the BD and the complete soundtrack CD
> which inlcudes yet another *^## Blue Danube.

Oh, but you can't have too many Blue Danubes, Norman! That Introduction
alone is worth a million pounds a minute.

Interesting story of course about the band and conductor of the version
of 'Also Sprach Zarathustra' heard at the start of '2001', which I'm
sure has been related here before.

The good thing is, that the fabulous Blu-ray restoration of the film
restores the correct names to the credits. Names which (rather to their
owners' later chagrin) weren't allowed to appear originally, for what
they thought of as a cheap Magic Lantern Show.

Norman Schwartz

12/12/2013 5:54:00 PM

0

Christopher Webber wrote:
> On 12/12/2013 16:57, Norman Schwartz wrote:
>> I have both the BD and the complete soundtrack CD
>> which inlcudes yet another *^## Blue Danube.
>
> Oh, but you can't have too many Blue Danubes, Norman! That
> Introduction alone is worth a million pounds a minute.
>

In the past, having collected New Year's Day concerts, etc., I think I have
more Blue Danubes than Eine Kleine Nachtmusics, Albinoni Adagios, Pachelbel
Canons all combined, and while I'm at it I'll throw in some 1812s.

During my last 2001 BD viewing I hit the 'mute' button when the Blue Danube
hit the receiver.

> Interesting story of course about the band and conductor of the
> version of 'Also Sprach Zarathustra' heard at the start of '2001',
> which I'm sure has been related here before.
>
> The good thing is, that the fabulous Blu-ray restoration of the film
> restores the correct names to the credits. Names which (rather to
> their owners' later chagrin) weren't allowed to appear originally,
> for what they thought of as a cheap Magic Lantern Show.


O

12/12/2013 7:31:00 PM

0

In article <5Lmqu.502805$9P6.311966@fx22.iad>, Norman Schwartz
<nmsz@optonline.net> wrote:

> Christopher Webber wrote:
> > On 12/12/2013 16:57, Norman Schwartz wrote:
> >> I have both the BD and the complete soundtrack CD
> >> which inlcudes yet another *^## Blue Danube.
> >
> > Oh, but you can't have too many Blue Danubes, Norman! That
> > Introduction alone is worth a million pounds a minute.
> >
>
> In the past, having collected New Year's Day concerts, etc., I think I have
> more Blue Danubes than Eine Kleine Nachtmusics, Albinoni Adagios, Pachelbel
> Canons all combined, and while I'm at it I'll throw in some 1812s.
>
> During my last 2001 BD viewing I hit the 'mute' button when the Blue Danube
> hit the receiver.

I can't really condemn you for this -- I think it's ruled justifiable
Danubicide.

-Owen, You Decide or Danubicide.

Christopher Webber

12/12/2013 7:39:00 PM

0

On 12/12/2013 19:30, O wrote:
> I can't really condemn you for this -- I think it's ruled justifiable
> Danubicide.

I can - because quite aside from the intrinsic quality of the piece, it
destroys Kubrick's choreography of the 2001 space sequences if you
aren't hearing the music. He took a lot of care over that, you know!