Package glade files

I'm creating a project with ruby/gtk.
This program uses glade files for the interface.
What would be the correct place to store these files?
Should I place these files in lib/ ?

Here is the directory structure RPA suggest:
http://rpa-base.rubyforge.org/wiki/wiki.cgi?GoodPractices
But they don't mention glade files.

I'm asking this because I'm creating packages gem/deb.
Are there gems with glade files as an example?

Wouldn't it be nice if rake could make all these packages in one
step :slight_smile:

Thanks,

Roeland

I'm creating a project with ruby/gtk.
This program uses glade files for the interface.
What would be the correct place to store these files?
Should I place these files in lib/ ?

Here is the directory structure RPA suggest:
http://rpa-base.rubyforge.org/wiki/wiki.cgi?GoodPractices
But they don't mention glade files.

I'm asking this because I'm creating packages gem/deb.

Great!

Are there gems with glade files as an example?

Not that I know of, but I might be wrong. I'm afraid I don't have
much experience with Glade. Is there somewhere we could download your
code and see how it's laid out?

Wouldn't it be nice if rake could make all these packages in one
step :slight_smile:

It _can_ make .tar.gz and gems in one step, but I don't think there's
a debian package task yet. Jim?

Thanks,
Chad

···

On Fri, 27 Aug 2004 17:01:44 +0900, Roeland Moors <roelandmoors@pandora.be> wrote:

I'm creating a project with ruby/gtk.
This program uses glade files for the interface.
What would be the correct place to store these files?
Should I place these files in lib/ ?

They should probably go into $prefix/share/yourapp/; I've seen similar
things under data/ in the sources.
Now, I feel that most of ruby's lib/ should be under share/ruby actually:
if you feel differently about this, lib/ would be a good option for your
glade files too.

Here is the directory structure RPA suggest:
http://rpa-base.rubyforge.org/wiki/wiki.cgi?GoodPractices
But they don't mention glade files.

I'm asking this because I'm creating packages gem/deb.
Are there gems with glade files as an example?

RubyGems doesn't care in general about the layout of your sources,
since they will be packed as-is (you can exclude files, of course),
or more precisely as Rake leaves them after the 'pre-processing' phase.

The only problem is finding the files at runtime. Before RubyGems, it
was safe to access them via
require 'rbconfig'
File.join(::Config::CONFIG["datadir"], "myappname", subdir)

If you're using RubyGems, you have to require 'rubygems', determine the
'gemdir' and the subdirectory you need.

At any rate, please do not use tricks involving File.dirname(__FILE__);
they make it so much more difficult to repackage for systems with some
policy...

Wouldn't it be nice if rake could make all these packages in one
step :slight_smile:

Debian is missing a dh_ruby* family of helpers atm., so Rake would
have to generate explicitly all the required code in debian/rules.
As for debian/control, since the metadata differs from RubyGems' you'd
end up having to specify quite a lot in the Rakefile -- not to mention
the other files under debian/. At some point you have to see which of
the following options is better:
* having Rake generate debian/* and run dpkg-buildpackage
* generating debian/* manually (maybe automating debian/Changelog) and
  having Rake just call dpkg-buildpackage

···

On Fri, Aug 27, 2004 at 05:01:44PM +0900, Roeland Moors wrote:

--
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Hi,

I'm creating a project with ruby/gtk.
This program uses glade files for the interface.
What would be the correct place to store these files?
Should I place these files in lib/ ?

Usually, I put it on /usr/share/app_dir/glade/ (Fedora).
This rule is used by many applications which use Glade.

You can get "/usr/share" from Config::CONFIG["datadir"].

  ruby -rrbconfig -e "p Config::CONFIG['datadir']"

Aoki-san's setup.rb supports data/ directory for data
files (pixmaps, icons, locale data ...).

rpa-base/gem don't have this feature?
I think many GUI applications require this feature.

Regards,

···

On Fri, 27 Aug 2004 17:01:44 +0900 Roeland Moors <roelandmoors@pandora.be> wrote:
--
.:% Masao Mutoh<mutoh@highway.ne.jp>

Chad Fowler said:

I'm creating a project with ruby/gtk.
This program uses glade files for the interface.
What would be the correct place to store these files?
Should I place these files in lib/ ?

Here is the directory structure RPA suggest:
http://rpa-base.rubyforge.org/wiki/wiki.cgi?GoodPractices
But they don't mention glade files.

I'm asking this because I'm creating packages gem/deb.

Great!

Are there gems with glade files as an example?

Not that I know of, but I might be wrong. I'm afraid I don't have
much experience with Glade. Is there somewhere we could download your
code and see how it's laid out?

Wouldn't it be nice if rake could make all these packages in one
step :slight_smile:

It _can_ make .tar.gz and gems in one step, but I don't think there's
a debian package task yet. Jim?

Hmmm ... no deb packager yet. I've never built a deb package. If you can
tell me what's involved (or point me to a web page), I will look into it.
The rake supplied package task will handle tar/zip/gem packages currently.
Robert Feldt has made some suggestions on making the package task a
little more flexible, so it would be a good time to see how other formats
could be handled.

It would be interesting to know how compatible the GEM metadata spec is
with the Debian version. Ideally you want to specify your meta-data only
once, so I hope we would be able to construct one out of the other.

In the mean time, if you add a deb task by hand, then make the :package
task dependent on your .deb file. Then when you do: "rake package", it
will automatically build your .deb file along with the tar/zip/gem files.
Also tie into the :package_clobber task (I think that's the right name),
so that the package is properly cleaned up when done.

Regarding your glade files ... are they used at run time or are they just
used at build time to construct a GUI? If they are not needed at runtime,
then I would keep them out of "lib". Perhaps etc or src directories,
depending on whether you view the files as configuration data or source
code. If they are needed at run time, then the question is a bit
different because the directory they reside in will need to be located at
runtime. I would suggest either lib or etc in that case.

I hope this helps.

···

On Fri, 27 Aug 2004 17:01:44 +0900, Roeland Moors > <roelandmoors@pandora.be> wrote:

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

> I'm creating a project with ruby/gtk.
> This program uses glade files for the interface.
> What would be the correct place to store these files?
> Should I place these files in lib/ ?
>
> Here is the directory structure RPA suggest:
> http://rpa-base.rubyforge.org/wiki/wiki.cgi?GoodPractices
> But they don't mention glade files.
>
> I'm asking this because I'm creating packages gem/deb.

Great!

> Are there gems with glade files as an example?
>

Not that I know of, but I might be wrong. I'm afraid I don't have
much experience with Glade. Is there somewhere we could download your
code and see how it's laid out?

Here is a project I'm working on:
http://rubyforge.org/projects/photoprep/
This is not a finished project, you're warned :slight_smile:

···

On Fri, Aug 27, 2004 at 09:58:07PM +0900, Chad Fowler wrote:

On Fri, 27 Aug 2004 17:01:44 +0900, Roeland Moors > <roelandmoors@pandora.be> wrote:

> Wouldn't it be nice if rake could make all these packages in one
> step :slight_smile:
>

It _can_ make .tar.gz and gems in one step, but I don't think there's
a debian package task yet. Jim?

Thanks,
Chad

> I'm creating a project with ruby/gtk.
> This program uses glade files for the interface.
> What would be the correct place to store these files?
> Should I place these files in lib/ ?

They should probably go into $prefix/share/yourapp/; I've seen similar
things under data/ in the sources.
Now, I feel that most of ruby's lib/ should be under share/ruby actually:
if you feel differently about this, lib/ would be a good option for your
glade files too.

I my own source I put the glade files in a seperate dir.
If I put them in the lib dir, I would have to type more before I
can use tab completion to open the file.
I know, I'm very lazy :slight_smile:

It would make sence to put it in share/ if it was used by
multiple programs, but that probably will not happen.

> Here is the directory structure RPA suggest:
> http://rpa-base.rubyforge.org/wiki/wiki.cgi?GoodPractices
> But they don't mention glade files.
>
> I'm asking this because I'm creating packages gem/deb.
> Are there gems with glade files as an example?

RubyGems doesn't care in general about the layout of your sources,
since they will be packed as-is (you can exclude files, of course),
or more precisely as Rake leaves them after the 'pre-processing' phase.

The only problem is finding the files at runtime. Before RubyGems, it
was safe to access them via
require 'rbconfig'
File.join(::Config::CONFIG["datadir"], "myappname", subdir)

If you're using RubyGems, you have to require 'rubygems', determine the
'gemdir' and the subdirectory you need.

And for RPA?

At any rate, please do not use tricks involving File.dirname(__FILE__);
they make it so much more difficult to repackage for systems with some
policy...

> Wouldn't it be nice if rake could make all these packages in one
> step :slight_smile:

Debian is missing a dh_ruby* family of helpers atm., so Rake would
have to generate explicitly all the required code in debian/rules.
As for debian/control, since the metadata differs from RubyGems' you'd
end up having to specify quite a lot in the Rakefile -- not to mention
the other files under debian/. At some point you have to see which of
the following options is better:
* having Rake generate debian/* and run dpkg-buildpackage
* generating debian/* manually (maybe automating debian/Changelog) and
  having Rake just call dpkg-buildpackage

* Creating a dh_ruby* helper which rake can use?

···

On Sat, Aug 28, 2004 at 12:37:23AM +0900, Mauricio Fern?ndez wrote:

On Fri, Aug 27, 2004 at 05:01:44PM +0900, Roeland Moors wrote:

--
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

rpa-base works like setup.rb in this regard --- since it installs into
$prefix directly, that is supported easily: the associated "helper"
is installdata which will by default copy the contents of data/ to
File.join(::Config::CONFIG["datadir"], "share"), exactly like setup.rb.

RubyGems doesn't really support per-app data currently but I can think
of the following ways to make it work without resorting to nasty tricks
involving __FILE__:
* provide a Gem-aware (but not gem-dependent!) module in the standard
  Ruby lib., which would provide a functionality similar to rbconfig's
  CONFIG['datadir'], while inferring (if needed) the correct gemdir to
  use, etc...
* perform some (heavy!) "file access magic" in RubyGems: i.e. have
  RubyGems redefine several (singleton) methods from IO, File, etc to
  perform some transparent mapping of the data files at runtime.

Both approaches seem tricky, though.

···

On Sat, Aug 28, 2004 at 01:39:44AM +0900, Masao Mutoh wrote:

Usually, I put it on /usr/share/app_dir/glade/ (Fedora).
This rule is used by many applications which use Glade.

You can get "/usr/share" from Config::CONFIG["datadir"].

  ruby -rrbconfig -e "p Config::CONFIG['datadir']"

Aoki-san's setup.rb supports data/ directory for data
files (pixmaps, icons, locale data ...).

rpa-base/gem don't have this feature?

--
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Chad Fowler said:
>> I'm creating a project with ruby/gtk.
>> This program uses glade files for the interface.
>> What would be the correct place to store these files?
>> Should I place these files in lib/ ?
>>
>> Here is the directory structure RPA suggest:
>> http://rpa-base.rubyforge.org/wiki/wiki.cgi?GoodPractices
>> But they don't mention glade files.
>>
>> I'm asking this because I'm creating packages gem/deb.
>
> Great!
>
>> Are there gems with glade files as an example?
>>
>
> Not that I know of, but I might be wrong. I'm afraid I don't have
> much experience with Glade. Is there somewhere we could download your
> code and see how it's laid out?
>
>> Wouldn't it be nice if rake could make all these packages in one
>> step :slight_smile:
>>
>
> It _can_ make .tar.gz and gems in one step, but I don't think there's
> a debian package task yet. Jim?

Hmmm ... no deb packager yet. I've never built a deb package. If you can
tell me what's involved (or point me to a web page), I will look into it.
The rake supplied package task will handle tar/zip/gem packages currently.
Robert Feldt has made some suggestions on making the package task a
little more flexible, so it would be a good time to see how other formats
could be handled.

I'm not an expert, but I think making a deb is much more work than
creating a gem.
There is a lot of information an creating a deb package:
http://www.debian.org/devel/

It would be interesting to know how compatible the GEM metadata spec is
with the Debian version. Ideally you want to specify your meta-data only
once, so I hope we would be able to construct one out of the other.

That would be nice

In the mean time, if you add a deb task by hand, then make the :package
task dependent on your .deb file. Then when you do: "rake package", it
will automatically build your .deb file along with the tar/zip/gem files.
Also tie into the :package_clobber task (I think that's the right name),
so that the package is properly cleaned up when done.

I'll try that

Regarding your glade files ... are they used at run time or are they just
used at build time to construct a GUI? If they are not needed at runtime,
then I would keep them out of "lib". Perhaps etc or src directories,
depending on whether you view the files as configuration data or source
code. If they are needed at run time, then the question is a bit
different because the directory they reside in will need to be located at
runtime. I would suggest either lib or etc in that case.

They are used at runtime.

At the moment I have a seperate glade dir in the source.
I tried to move files with rake when creating a package, but I have to
specify the files in the gemspec before I move or create the files.
This doen't make it easy.

···

On Fri, Aug 27, 2004 at 10:36:11PM +0900, Jim Weirich wrote:

> On Fri, 27 Aug 2004 17:01:44 +0900, Roeland Moors > > <roelandmoors@pandora.be> wrote:

I hope this helps.

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

Hello,
  I am a nuby and I couldn't find how to get the ASCII value of a character in a variable. I looked in the Pragmatic Programmer and did this:

s = "ABC DE."
s.scan( /./ ) do |a|
      puts ?a
end

but only got the ASCII value of the small letter 'a' ( 97 ). What do I need to do?
  Thanks,
    Barry

I my own source I put the glade files in a seperate dir.
If I put them in the lib dir, I would have to type more before I
can use tab completion to open the file.
I know, I'm very lazy :slight_smile:

It would make sence to put it in share/ if it was used by
multiple programs, but that probably will not happen.

It's not about sharing between programs, but rather about filesystem
standards and platform-independent files...

> The only problem is finding the files at runtime. Before RubyGems, it
> was safe to access them via
> require 'rbconfig'
> File.join(::Config::CONFIG["datadir"], "myappname", subdir)
>
> If you're using RubyGems, you have to require 'rubygems', determine the
> 'gemdir' and the subdirectory you need.
>

And for RPA?

rpa-base installs normally into $prefix so you can access it the normal
way, i.e. through

require 'rbconfig'
Config::CONFIG["datadir"]

You can also get the dir. in the RPA namespace but it's better to use
rbconfig because that way your app. is not tied to RPA/rpa-base.

* Creating a dh_ruby* helper which rake can use?

This would take a bit longer since it has to follow the 'official'
Debian path; but I've seen references to it in #debian-ruby...

···

On Sat, Aug 28, 2004 at 01:45:57AM +0900, Roeland Moors wrote:

--
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

s.each_byte do |a|
  puts a
end

···

On Sat, 28 Aug 2004 01:59:05 +0900, Barry Sperling <barry@angleinc.com> wrote:

Hello,
        I am a nuby and I couldn't find how to get the ASCII value of a
character in a variable. I looked in the Pragmatic Programmer and did this:

s = "ABC DE."
s.scan( /./ ) do |a|
      puts ?a
end

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

Barry Sperling <barry@angleinc.com> writes:

Hello,
  I am a nuby and I couldn't find how to get the ASCII value of a
character in a variable. I looked in the Pragmatic Programmer and did
this:

s = "ABC DE."
s.scan( /./ ) do |a|
      puts ?a
end

but only got the ASCII value of the small letter 'a' ( 97 ). What do
I need to do?
  Thanks,
    Barry

irb(main):005:0> s = "ABC DE."
=> "ABC DE."
irb(main):006:0> s.scan(/./) do |a|
irb(main):007:1* puts a[0]
irb(main):008:1> end
65
66
67
32
68
69
46
=> "ABC DE."
irb(main):009:0> s.each_byte do |a|
irb(main):010:1* puts a
irb(main):011:1> end
65
66
67
32
68
69
46
=> "ABC DE."

  mikael

I know this one!!!!! I can't believe it :wink: You need to call the #chr
method for integers.

s = "ABC DE."
s.scan( /./ ) do |a|
     puts a.chr
end

Regards,
Ed

···

On Sat, 28 Aug 2004 01:59:05 +0900, Barry Sperling <barry@angleinc.com> wrote:

Hello,
       I am a nuby and I couldn't find how to get the ASCII value of a
character in a variable. I looked in the Pragmatic Programmer and did this:

s = "ABC DE."
s.scan( /./ ) do |a|
     puts ?a
end

but only got the ASCII value of the small letter 'a' ( 97 ). What do I
need to do?

--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan

Barry Sperling <barry@angleinc.com> writes:

Hello,
  I am a nuby and I couldn't find how to get the ASCII value of a
character in a variable. I looked in the Pragmatic Programmer and did this:

s = "ABC DE."
s.scan( /./ ) do |a|
      puts ?a
end

but only got the ASCII value of the small letter 'a' ( 97 ). What do I
need to do?
  Thanks,
    Barry

Just to add to what others have said:

`?' is _not_ an operator (in the sense that `!', `~', etc. are).
Rather, `?a' is a literal for the character 'a', just as `10' is the
literal for the integer ten, and 1.0 is the literal for the floating
point number one-point-oh. It also happens that in ruby these
"characters" are really numbers (actually Fixnums), just like in C.
This can be demonstrated in irb:

irb(main):001:0> ?a
=> 97
irb(main):002:0> ?a.class
=> Fixnum
irb(main):003:0> 97.class
=> Fixnum
irb(main):004:0> ?a.equal? 97
=> true

HTH.

Edgardo Hames <ehames@gmail.com> writes:

···

On Sat, 28 Aug 2004 01:59:05 +0900, Barry Sperling <barry@angleinc.com> wrote:
> Hello,
> I am a nuby and I couldn't find how to get the ASCII value of a
> character in a variable. I looked in the Pragmatic Programmer and did this:
>
> s = "ABC DE."
> s.scan( /./ ) do |a|
> puts ?a
> end
>
> but only got the ASCII value of the small letter 'a' ( 97 ). What do I
> need to do?

I know this one!!!!! I can't believe it :wink: You need to call the #chr
method for integers.

s = "ABC DE."
s.scan( /./ ) do |a|
     puts a.chr
end

Regards,
Ed

Hate to rain on your parade, but #chr is actually a method on Fixnum,
and converts an integer to a string. (Barry wanted the integer value,
but had only the string value.)

  mikael

Thanks Austin, Mikael and Edgardo! That's what I was looking for. And I can use the .chr to reverse the process, so that was useful, too!
Barry

Austin Ziegler wrote:

···

On Sat, 28 Aug 2004 01:59:05 +0900, Barry Sperling <barry@angleinc.com> wrote:

Hello,
       I am a nuby and I couldn't find how to get the ASCII value of a
character in a variable. I looked in the Pragmatic Programmer and did this:

s = "ABC DE."
s.scan( /./ ) do |a|
     puts ?a
end

s.each_byte do |a|
  puts a
end