Package org.jruby

Examples of org.jruby.RubyString$TR


    private String cssClasspathLocation() {
        return "/" + gemClasspath() + "/" + STYLESHEETS_ASCIIDOCTOR_CSS;
    }

    private String gemClasspath() {
        RubyString gemLocationRubyObject = (RubyString) evaler.eval(runtime,
                "Gem.loaded_specs['asciidoctor'].full_gem_path");
        String gemLocation = gemLocationRubyObject.asJavaString();

        return gemLocation.substring(gemLocation.indexOf("gems"), gemLocation.length());
    }
View Full Code Here


     */
    private RubyString reinterpretEncoding(ThreadContext context,
            RubyString str, String sniffedEncoding) {
        RubyEncoding actualEncoding = info.getEncoding(context, sniffedEncoding);
        RubyEncoding targetEncoding = info.utf8.get();
        RubyString dup = (RubyString)str.dup();
        dup.force_encoding(context, actualEncoding);
        return (RubyString)dup.encode_bang(context, targetEncoding);
    }
View Full Code Here

        int guessSize(Session session, T object) {
            return 4;
        }

        RubyString generateNew(Session session, T object) {
            RubyString result;
            ByteList buffer = new ByteList(guessSize(session, object));
            generate(session, object, buffer);
            result = RubyString.newString(session.getRuntime(), buffer);
            ThreadContext context = session.getContext();
            RuntimeInfo info = session.getInfo();
            if (info.encodingsSupported()) {
                result.force_encoding(context, info.utf8.get());
            }
            return result;
        }
View Full Code Here

            this.decoder = new StringDecoder(context);
            this.dc = new DoubleConverter();
        }

        private RaiseException unexpectedToken(int absStart, int absEnd) {
            RubyString msg = getRuntime().newString("unexpected token at '")
                    .cat(data, absStart, absEnd - absStart)
                    .cat((byte)'\'');
            return newException(Utils.M_PARSER_ERROR, msg);
        }
View Full Code Here

                parseString(res, p, pe);
                if (res.result == null) {
                    p--;
                    { p += 1; _goto_targ = 5; if (truecontinue _goto;}
                } else {
                    RubyString name = (RubyString)res.result;
                    if (parser.symbolizeNames) {
                        lastName = context.getRuntime().is1_9()
                                       ? name.intern19()
                                       : name.intern();
                    } else {
                        lastName = name;
                    }
                    {p = (( res.p))-1;}
                }
View Full Code Here

     * @throws RaiseException <code>TypeError</code> if the value does not
     *                        evaluate to <code>false</code> and can't be
     *                        converted to string
     */
    ByteList getString(String key) {
        RubyString str = getString(key, null);
        return str == null ? null : str.getByteList().dup();
    }
View Full Code Here

    RubyString getString(String key, RubyString defaultValue) {
        IRubyObject value = get(key);
        if (value == null || !value.isTrue()) return defaultValue;

        RubyString str = value.convertToString();
        RuntimeInfo info = getRuntimeInfo();
        if (info.encodingsSupported() && str.encoding(context) != info.utf8.get()) {
            str = (RubyString)str.encode(context, info.utf8.get());
        }
        return str;
    }
View Full Code Here

     * the result. If no valid JSON document can be created this method raises
     * a GeneratorError exception.
     */
    @JRubyMethod
    public IRubyObject generate(ThreadContext context, IRubyObject obj) {
        RubyString result = Generator.generateJson(context, obj, this);
        if (!quirksMode && !objectOrArrayLiteral(result)) {
            throw Utils.newException(context, Utils.M_GENERATOR_ERROR,
                    "only generation of JSON objects or arrays allowed");
        }
        RuntimeInfo info = RuntimeInfo.forRuntime(context.getRuntime());
        if (info.encodingsSupported()) {
            result.force_encoding(context, info.utf8.get());
        }
        return result;
    }
View Full Code Here

        depth = RubyNumeric.fix2int(vDepth);
        return vDepth;
    }

    private ByteList prepareByteList(ThreadContext context, IRubyObject value) {
        RubyString str = value.convertToString();
        RuntimeInfo info = RuntimeInfo.forRuntime(context.getRuntime());
        if (info.encodingsSupported() && str.encoding(context) != info.utf8.get()) {
            str = (RubyString)str.encode(context, info.utf8.get());
        }
        return str.getByteList().dup();
    }
View Full Code Here

  public void they_should_be_available_inside_ruby_engine() {
   
    JRubyAsciidoctor asciidoctor = (JRubyAsciidoctor) JRubyAsciidoctor.create("My_gem_path");
    IRubyObject evalScriptlet = asciidoctor.rubyRuntime.evalScriptlet("ENV['GEM_PATH']");
   
    RubyString gemPathValue = (RubyString)evalScriptlet;
    assertThat(gemPathValue.asJavaString(), is("My_gem_path"));
   
   
  }
View Full Code Here

TOP

Related Classes of org.jruby.RubyString$TR

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.