Giter Site home page Giter Site logo

jRuby compatibility about pygments.rb HOT 4 CLOSED

hiravgandhi avatar hiravgandhi commented on August 23, 2024
jRuby compatibility

from pygments.rb.

Comments (4)

bartkamphorst avatar bartkamphorst commented on August 23, 2024

@mojavelinux I can get the tests to pass on ruby-2.1.1 using open3 instead of posix-spawn.

# Replace this @pid, @in, @out, @err = popen4(script) with
@in, @out, @err, @wait = Open3.popen3(script)
@pid = @wait[:pid]

So, in theory at least, a solution like this with Open3.popen3 might work for JRuby. POSIX::Spawn is much more efficient, though, so the popen3 solution should be implemented as the fallback option specifically for JRuby.

The other dependency with native extensions is Yajl. If I simply gsub instances of Yajl with JSON, then I get a couple of errors using 2.1.1, and under JRuby it hangs as you describe here. So I get the feeling that the real issue is in the dumping and loading of the json; that there is something specific in the way that Yajl does this. Perhaps a good first step would be to use 'multi_json' with the Yajl adapter, so that swapping in another adapter becomes trivial.

from pygments.rb.

bartkamphorst avatar bartkamphorst commented on August 23, 2024

Just had a chance to quickly do a few tests on JRuby too. It works if I use multi_json with

MultiJson.engine = 'json_gem'

The only thing to pay attention to is that you must close the input stream @in before reading from @out (for example, by calling @in.close in get_header). Hope this helps, @mojavelinux.

from pygments.rb.

mojavelinux avatar mojavelinux commented on August 23, 2024

For reference, if you install the following gem:

$ gem install pygments.rb-jruby

Then replace the call to popen4 as @bartkamphorst suggested:

require 'open3' if RUBY_ENGINE == 'jruby'

...

@in, @out, @err, @wait = Open3.popen3(script)
@pid = @wait[:pid]

Then it works. Of course, that's an older version of the gem ;(

from pygments.rb.

mojavelinux avatar mojavelinux commented on August 23, 2024

I put together a pull request that implements these changes. I'm happy to say it works as expected!

from pygments.rb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.