Forum: JRuby jruby -S gem maven ... html_to_pdf.rb

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6f608b6766f79343062a2aa3985933dc?d=identicon&s=25 Stephen Bannasch (Guest)
on 2009-04-18 17:27
(Received via mailing list)
I was playing with Charlie's maven gem to make a small sample app
that takse and xhtml page and print's it to a pdf.

There are some maven version strings that are not valid gem version
strings. Specifically the flying saucer pom specifies a version
string of something like:  'R8pre6'.

Gem version strings must start with a number and a '.'

here's a hacky patch for maven gem to fix this:

   http://gist.github.com/97636

and here's my initial sample app

   html_to_pdf.rb
   http://gist.github.com/97646

my xhtml is not valid yet so I'm not yet sure this works

comments or revisions most welcome!

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2009-04-18 20:34
(Received via mailing list)
Stephen Bannasch wrote:
>
>   http://gist.github.com/97636

Ahh this is a great start. I noticed this was new in RubyGems 1.3.2. I
think it may consider this to be a development version though, yes?

This is definitely a good first solution. Maybe I should get the
maven_gem sources pushed to github so you can maintain a fork...

> and here's my initial sample app
>
>   html_to_pdf.rb
>   http://gist.github.com/97646

That's really cool :) Maybe we're on to something here!

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2009-04-18 21:08
(Received via mailing list)
Charles Oliver Nutter wrote:
> Ahh this is a great start. I noticed this was new in RubyGems 1.3.2. I
> think it may consider this to be a development version though, yes?
>
> This is definitely a good first solution. Maybe I should get the
> maven_gem sources pushed to github so you can maintain a fork...

http://github.com/jruby/maven_gem/tree/master

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
6f608b6766f79343062a2aa3985933dc?d=identicon&s=25 Stephen Bannasch (Guest)
on 2009-04-20 07:35
(Received via mailing list)
>Charles Oliver Nutter wrote:
>>Ahh this is a great start. I noticed this was new in RubyGems
>>1.3.2. I think it may consider this to be a development version
>>though, yes?
>>
>>This is definitely a good first solution. Maybe I should get the
>>maven_gem sources pushed to github so you can maintain a fork...
>
>http://github.com/jruby/maven_gem/tree/master
>

Thanks,

Here's a revised and improved version of my patch:


http://github.com/stepheneb/maven_gem/commit/86ab7...

I sent you a pull request.

And here's a test script that I ran on my local maven repo to see
what the result of the new algorithm for generating gem version
strings from maven version strings produces.

   http://gist.github.com/98383

I'd appreciate it if other folks who have large local repos could run
this script and scan to see if the conversions look reasonable.

It's important to keep the maven version string around if we later
add dependency resolution so the ruby file created for loading the
maven jar now also codes these two constants:

   <classname>::VERSION
   <classname>::MAVEN_VERSION

So installing:

   jruby -S gem maven org/xhtmlrenderer core-renderer R8pre2

Produces this ruby file in the new gem:

$ cat
$JRUBY_HOME/lib/ruby/gems/1.8/gems/core-renderer-8.2-java/lib/core-renderer.rb
class CoreRenderer
   VERSION = '8.2'
   MAVEN_VERSION = 'R8pre2'
end
begin
   require 'java'
   require File.dirname(__FILE__) + '/core-renderer-8.2.jar'
rescue LoadError
   puts 'JAR-based gems require JRuby to load. Please visit
www.jruby.org.'
   raise
end


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2009-04-20 14:30
(Received via mailing list)
Stephen Bannasch wrote:
> I sent you a pull request.

Applied!

> dependency resolution so the ruby file created for loading the maven jar
>
> $ cat
> $JRUBY_HOME/lib/ruby/gems/1.8/gems/core-renderer-8.2-java/lib/core-renderer.rb
>
> class CoreRenderer
>   VERSION = '8.2'
>   MAVEN_VERSION = 'R8pre2'  end

I think I'll change this to a module, since that seems more typical.

I also thought of another cool thing we could do with these
libraries...set up pre-imported modules for them!

So for example, if you installed itext, everything under the
com.lowagie.text package would go under the IText module, making my
itext example script like so:

require 'rubygems'
require 'itext'

file = File.open('Hello.pdf', 'w')
document = Itext::Document.new
writer = Itext::Pdf::PdfWriter.get_instance(document,
file.to_outputstream)
paragraph = IText::Paragraph.new('Hello iText!')

document.open
document.add(paragraph)
document.close

I'd like to be able to do this programmatically if possible, maybe by
looking at the packages present in the jar and mapping the lowest
package to a module named the same as the Maven artifact (here itext
becomes Itext, and subpackages get leading caps the same way).

Thoughts?

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.