-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preload specified Ruby libraries #32
Comments
That sounds like a great idea! On Thu, May 9, 2013 at 4:20 AM, Alex Soto notifications@github.com wrote:
Jason Porter |
Yes I think so, another thing to research, briefly with @ajuckel we will have OSGI integration (Which maybe also fixes the problem with AS 7). Also I am working with copycss problem, and then it will be the time for preloading libraries. Of course if you have any idea feel free to write it here. |
I think that preloading libraries should work perhaps like the ruby cli. If you run
This option can be passed multiple times. Therefore, it's reasonable for the Asciidoctor Factory method (or something similar) accept an array of library names to load. For now, we can assume these libraries are available on the Ruby LOAD_PATH and thus a simple string name will do. We could do some smart preloading:
These should take care of most of the use cases for needing to preload a library at the moment. |
I have been thinking about this issue and it comes to possible implementations:
something like: if(libraryIsNotPreloadedYet("libraryName")) {
evaler.eval(runtime, "require 'libraryName'");
} Of course if you render two files if the second one does not require libraryName, that library would be already preloaded, but I think this is not a problem. Note that runtime instance is always the same so once the libraries are preloaded, they will be there until Ruby instance become eligible for GC. What you think? |
I have been researching something more about how to preload libraries, it seems that defineModule method can do that work too instead of calling a Ruby script like: if(libraryIsNotPreloadedYet("libraryName")) {
evaler.eval(runtime, "require 'libraryName'");
} The problem is that I am not pretty sure that defineModule approach would support defining them dynamically, because at construction time I create a RubyObject (Asciidoctor) from an script and this object is reused for all future executions. So I guess it is not possible to preload libraries for that object dynamically because it is already instantiated. Maybe as first version we can give the option to user to create Asciidoctor class with static preloaded libraries, and in future we can create a refreshable method which re-instantiates a new Asciidcotor instance with the new libraries. The good news is that I think it won't affect the performance because Ruby environment will be the same so it is already initialized. What you think? |
sorry defineModule cannot be used for preloading libraries because it is used for defining the module structure, not for loading them, you still need to call require anyway, defineMethod is used for calling Java from JRuby. So maybe the first approach is the best one. |
resolves asciidoctor#31 support attributes as String, List and Array
the Asciidoctor Java integration could preload specified libraries when it boots JRuby, removing the possibility of any problems or warnings.
Related with Issue
The text was updated successfully, but these errors were encountered: