Documatic tutorial broken

10 views
Skip to first unread message

Jbiolaz

unread,
Sep 1, 2008, 9:44:14 AM9/1/08
to Ruby Reports
Hye,

I try a few minute ago the tutorials of Documatic (http://
stonecode.svnrepository.com/documatic/trac.cgi/wiki/
DocumaticTutorial).
The first Tutorial (with .odt) isn't working on my computer. I got the
following error :
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/rexml/document.rb:187:in `write': undefined local variable or
method `trans' for <UNDEFINED> ... </>:REXML::Document (NameError)
from /Library/Ruby/Gems/1.8/gems/documatic-0.2.0/lib/documatic/
open_document_text/template.rb:205:in `pretty_xml'
from /Library/Ruby/Gems/1.8/gems/documatic-0.2.0/lib/documatic/
open_document_text/template.rb:148:in `compile'
from /Library/Ruby/Gems/1.8/gems/documatic-0.2.0/lib/documatic/
open_document_text/template.rb:106:in `process'
from /Library/Ruby/Gems/1.8/gems/documatic-0.2.0/lib/documatic/
open_document_text/template.rb:83:in `process_template'
from /Library/Ruby/Gems/1.8/gems/documatic-0.2.0/lib/documatic/
formatter/open_document.rb:18:in `build_table_body'
from /Library/Ruby/Gems/1.8/gems/ruport-1.6.1/lib/ruport/
controller.rb:598:in `send'
from /Library/Ruby/Gems/1.8/gems/ruport-1.6.1/lib/ruport/
controller.rb:598:in `maybe'
from /Library/Ruby/Gems/1.8/gems/ruport-1.6.1/lib/ruport/
controller.rb:584:in `execute_stages'
from /Library/Ruby/Gems/1.8/gems/ruport-1.6.1/lib/ruport/
controller.rb:583:in `each'
from /Library/Ruby/Gems/1.8/gems/ruport-1.6.1/lib/ruport/
controller.rb:583:in `execute_stages'
from /Library/Ruby/Gems/1.8/gems/ruport-1.6.1/lib/ruport/
controller.rb:574:in `_run_'
from /Library/Ruby/Gems/1.8/gems/ruport-1.6.1/lib/ruport/
controller.rb:520:in `run'
from /Library/Ruby/Gems/1.8/gems/ruport-1.6.1/lib/ruport/
controller.rb:436:in `render'
from /Library/Ruby/Gems/1.8/gems/ruport-1.6.1/lib/ruport/
controller.rb:173:in `as'
from /Library/Ruby/Gems/1.8/gems/ruport-1.6.1/lib/ruport/data/
table.rb:869:in `method_missing'
from tutorial.rb:28


Is that a problem form my version of ruby (ruby 1.8.6 (2008-03-03
patchlevel 114) [universal-darwin9.0]) ?
I didn't find how to fix it !!

Thanks for help !!

Jonathan
the other one (with.ods) work well.

Gregory Brown

unread,
Sep 1, 2008, 10:34:58 AM9/1/08
to ruby-r...@googlegroups.com, Dave Nelson
On Mon, Sep 1, 2008 at 9:44 AM, Jbiolaz <jbi...@gmail.com> wrote:

> Is that a problem form my version of ruby (ruby 1.8.6 (2008-03-03
> patchlevel 114) [universal-darwin9.0]) ?
> I didn't find how to fix it !!

I *hope* Documatic is targeting Ruby 1.8.6, as there are no plans to
support Ruby 1.8.7 in Ruport, and although plans for 1.9 support are
in the works, it won't be there for a while.

--
Technical Blaag at: http://blog.majesticseacreature.com | Non-tech
stuff at: http://metametta.blogspot.com

Jbiolaz

unread,
Sep 2, 2008, 4:47:40 AM9/2/08
to Ruby Reports
ok, so, what I suppose to do to make this very simple example work ??
I really need to render Document (like .odt) that must be editable
outside the app.
May be there is another gem available ?

Thanks

On 1 sep, 16:34, "Gregory Brown" <gregory.t.br...@gmail.com> wrote:

Sylvain Abélard

unread,
Sep 2, 2008, 5:05:55 AM9/2/08
to ruby-r...@googlegroups.com
> I really need to render Document (like .odt) that must be editable
> outside the app.

I did not dive deep enough in all Ruport's magic (have quite a big
TODO-list at the moment), but if you're off for another solution, this
might be helpful : MS Word (even the "97" version) can export files as
XML. If you save these xml files as ".doc", it seamlessly opens in MS
Office (though being XML inside). ODT's are XML (or zipped XML) too !

I suggest you just make a template document, open the XML in a text
editor, then replace your placeholder text by ERB. You then just have
to use erb your script, or save your XML-with-code as .rhtml or
.html.erb if using Rails. And voilà ! I've already done it quickly and
successfully a few times.

Just a hint if using MS Word's XML format : it's horrible and bloated.
You HAVE to use an XML beautifier (indent and whatever) and syntax
highlighter to work with it. Then you can take some time to remove
most of the useless tags and properties, so your document is reduced
from, say, 2Mos to 4Kos (these are the numbers I had).

Simple and effective, yet not Ruport-esque ^^

--
Sylvain Abélard
"J'ai décidé d'être heureux, c'est meilleur pour la santé." -Voltaire

Jbiolaz

unread,
Sep 2, 2008, 5:30:50 AM9/2/08
to Ruby Reports
Thanks for the answer,
I plan to not use Microsoft product (I'm developing a web app which
will remplace an older one that works only on windows).
Here is more détail of my needs:
The user edit a .odt file (insert his own logo etc) in openOffice or
NeoOffice. Then he will use his web app and then, in one click (render
document), the web app fill the .odt document. The web app shoould
work offline, so a mongrel server is launch on his computer.

Your solution look good, but may be a little complicated for a
"lambda" user. But, do you have a simple example ?

I try a hack in the ruby file that broke documatic (document.rb), I
comment the lines that cause the problem. It solve my problem localy,
but if I deploy my app, it will be broken !

Thanks for all your help

Sylvain Abélard

unread,
Sep 2, 2008, 5:55:19 AM9/2/08
to ruby-r...@googlegroups.com
> Here is more détail of my needs:
> The user edit a .odt file (insert his own logo etc) in openOffice or
> NeoOffice. Then he will use his web app and then, in one click (render
> document), the web app fill the .odt document. The web app shoould
> work offline, so a mongrel server is launch on his computer.

Thanks for your needs' explanation.
I find quite strange that this "web application" should work "offline".
A traditional desktop application or Ruby script may do the job better
? But well...

> Your solution look good, but may be a little complicated for a
> "lambda" user. But, do you have a simple example ?

Sorry I don't have a sample code for you, but here is how I'd do it :

#1 give a sample ODT to your customers
Your application may be smart, but guessing everything is really
too error-prone.

#2 your user edits the file and uploads it (offline : send it to script)

#3 use your server (script) to run commands (or ruby calls) like unzip
or whatever to extract the XML, then process it with regexen.
To avoid blocking the server in the "online" use case, you should
make it run in background.
If your application must be cross-platform, Windows will be a huge
problem (no lib for DRb works in Windows AFAIK).

#4 send it back to the user

This process does not depend on any web framework or so. Doing it
locally should be as easy.

> I try a hack in the ruby file that broke documatic (document.rb), I
> comment the lines that cause the problem. It solve my problem localy,
> but if I deploy my app, it will be broken !

Why ? With Ruby you can change behaviour at runtime.
If you deploy your app with the "monkeypatch" fixes to Documatic,
there should be no problem.
Just try to find out how you can alter Documatic's classes in your
code without changing the original source file.
If this seems a bit complicated, tell us how you patched Documatic and
we might find how to do it dynamically.

Jbiolaz

unread,
Sep 4, 2008, 5:30:15 AM9/4/08
to Ruby Reports
Hye,

We find another to made the tutorial working:
On my machine I update ruby to patch 287,
And for the deployment, we plane to make a package that include all
the stuff needed bye the app (ruby and the gem).

Thanks for your help
Reply all
Reply to author
Forward
0 new messages