Login  Register

Re: copycss attribute causes exception in asciidoctor-java-integration

Posted by asotobu on May 05, 2013; 6:34pm
URL: https://discuss.asciidoctor.org/copycss-attribute-causes-exception-in-asciidoctor-java-integration-tp179p182.html

Dan suggested in the issue:

After giving it some more thought, I realized there is a third solution. I can put the default CSS into a constant in a Ruby file, then load that Ruby file using require when it is needed and read the value off the constant.

...which brings up another data point when looking into this issue. Somewhere in JRuby (I think in JRubyKernel.java), JRuby is able to read files out of the classpath for the require statement. Thus, there must be some way in Ruby to read the file contents from a file on the LOAD_PATH without evaluating it. Maybe Kernel#open?


and I have replied there and now I write here too:

Ok, then one idea that I was discarding at first (implementing copycss feature inside java). it seems that would be the best one. I agree that the best way would be trying to read the file from the gem with a method (Kernel#open) could be an option if works. But it comes to my mind one thing:

If we add a specific behaviour in one attribute, maybe in future we will add another one, and another one, ... and we can finish by having some logic duplicated in Java and Ruby part. I think this would not be the case, but opens the door to do it again.

Of course I think third option could be the best one, but I don't like this duplication.