package glade files

R

Roeland Moors

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 :)

Thanks,

Roeland
 
C

Chad Fowler

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 :)

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
 
J

Jim Weirich

Chad Fowler said:
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?


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.
 
R

Roeland Moors

Chad Fowler said:

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.
 
M

Mauricio Fernández

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 :)

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
 
M

Masao Mutoh

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,
 
R

Roeland Moors

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 :)

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...


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?
 
B

Barry Sperling

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
 
A

Austin Ziegler

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
 
M

Mikael Brockman

Barry Sperling said:
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
 
M

Mauricio Fernández

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 :)

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...
 
M

Mauricio Fernández

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?

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.
 
E

Edgardo Hames

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 ;) You need to call the #chr
method for integers.

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

Regards,
Ed
 
M

Mikael Brockman

Edgardo Hames said:
I know this one!!!!! I can't believe it ;) 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
 
G

George Ogata

Barry Sperling said:
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.
 
B

Barry Sperling

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top