Package org.jruby

Examples of org.jruby.RubyHash$Visitor


        if (options.containsKey(Options.BASEDIR)) {
            rubyRuntime.setCurrentDirectory((String) options.get(Options.BASEDIR));
        }

        RubyHash rubyHash = RubyHashUtil.convertMapToRubyHashWithSymbols(rubyRuntime, options);

        Object object = this.asciidoctorModule.convertFile(filename.getAbsolutePath(), rubyHash);

        // we restore current directory to its original value.
        rubyRuntime.setCurrentDirectory(currentDirectory);
View Full Code Here


        return renderFiles(asciidoctorFiles, options);
    }

    @Override
    public Document load(String content, Map<String, Object> options) {
        RubyHash rubyHash = RubyHashUtil.convertMapToRubyHashWithSymbols(rubyRuntime, options);
        return new Document(this.asciidoctorModule.load(content, rubyHash), this.rubyRuntime);
    }
View Full Code Here

        return new Document(this.asciidoctorModule.load(content, rubyHash), this.rubyRuntime);
    }

    @Override
    public Document loadFile(File file, Map<String, Object> options) {
        RubyHash rubyHash = RubyHashUtil.convertMapToRubyHashWithSymbols(rubyRuntime, options);
        return new Document(this.asciidoctorModule.load(file.getAbsolutePath(), rubyHash), this.rubyRuntime);

    }
View Full Code Here

        return documentDelegate.basebackend(backend);
    }

    @Override
    public Object doctitle(Map<Object, Object> opts) {
        RubyHash mapWithSymbols = RubyHashUtil.convertMapToRubyHashWithSymbolsIfNecessary(runtime, opts);

        Object doctitle = documentDelegate.doctitle(mapWithSymbols);

        if (doctitle instanceof IRubyObject) {
            doctitle = RubyUtils.rubyToJava(runtime, (IRubyObject) doctitle, Title.class);
View Full Code Here

  }

// line 623 "Parser.rl"

            if (parser.createAdditions) {
                RubyHash match_string = parser.match_string;
                if (match_string != null) {
                    final IRubyObject[] memoArray = { result, null };
                    try {
                      match_string.visitAll(new RubyHash.Visitor() {
                          @Override
                          public void visit(IRubyObject pattern, IRubyObject klass) {
                              if (pattern.callMethod(context, "===", memoArray[0]).isTrue()) {
                                  memoArray[1] = klass;
                                  throw JumpException.SPECIAL_JUMP;
View Full Code Here

        return (RubyClass)value;
    }

    public RubyHash getHash(String key) {
        IRubyObject value = get(key);
        if (value == null || value.isNil()) return new RubyHash(runtime);
        return (RubyHash) value;
    }
View Full Code Here

     * @return the hash
     */
    @JRubyMethod(alias = "to_hash")
    public RubyHash to_h(ThreadContext context) {
        Ruby runtime = context.getRuntime();
        RubyHash result = RubyHash.newHash(runtime);

        result.op_aset(context, runtime.newSymbol("indent"), indent_get(context));
        result.op_aset(context, runtime.newSymbol("space"), space_get(context));
        result.op_aset(context, runtime.newSymbol("space_before"), space_before_get(context));
        result.op_aset(context, runtime.newSymbol("object_nl"), object_nl_get(context));
        result.op_aset(context, runtime.newSymbol("array_nl"), array_nl_get(context));
        result.op_aset(context, runtime.newSymbol("allow_nan"), allow_nan_p(context));
        result.op_aset(context, runtime.newSymbol("ascii_only"), ascii_only_p(context));
        result.op_aset(context, runtime.newSymbol("quirks_mode"), quirks_mode_p(context));
        result.op_aset(context, runtime.newSymbol("max_nesting"), max_nesting_get(context));
        result.op_aset(context, runtime.newSymbol("depth"), depth_get(context));
        result.op_aset(context, runtime.newSymbol("buffer_initial_length"), buffer_initial_length_get(context));
        for (String name: getInstanceVariableNameList()) {
            result.op_aset(context, runtime.newSymbol(name.substring(1)), getInstanceVariables().getInstanceVariable(name));
        }
        return result;
    }
View Full Code Here

     *                       supported
     * @return               analogous Ruby type
     * @throws ExecException object contains a key that can't be convert to a Ruby type
     */
    public static <T> RubyHash pigToRuby(Ruby ruby, Map<T, ?> object) throws ExecException {
        RubyHash newMap = RubyHash.newHash(ruby);

        boolean checkType = false;

        for (Map.Entry<T, ?> entry : object.entrySet()) {
            T key = entry.getKey();
            if (!checkType) {
                if (!(key instanceof String))
                    throw new ExecException("pigToRuby only supports converting Maps with String keys");
                checkType = true;
            }
            newMap.put(key, pigToRuby(ruby, entry.getValue()));
        }

        return newMap;
    }
View Full Code Here

             * bag, or an error will be thrown. The value to that key must be an array, and
             * each element will be passed to this method and then added to the Schema for
             * the key.
             */
            } else if (arg instanceof RubyHash) {
                RubyHash hash = (RubyHash)arg;
                Schema hashSchema = new Schema();
                for (Object o : hash.keySet()) {
                    Schema s = rubyArgToSchema(o);
                    if (s.size() != 1) {
                        throw new RuntimeException("Hash key must be singular");
                    }
                    Schema.FieldSchema fs = s.getField(0);
                    Object v = hash.get(o);
                    if (v instanceof RubyArray) {
                        byte type = fs.type;
                        if (type == DataType.BAG) {
                            fs.schema = rubyArgToSchema(v);
                        } else if (type == DataType.TUPLE || type == DataType.MAP) {
View Full Code Here

        cX509Name.setConstant("ONELINE",runtime.newFixnum(ONELINE));
        cX509Name.setConstant("MULTILINE",runtime.newFixnum(MULTILINE));

        cX509Name.setConstant("DEFAULT_OBJECT_TYPE",runtime.newFixnum(DERTags.UTF8_STRING));

        RubyHash hash = new RubyHash(runtime, runtime.newFixnum(DERTags.UTF8_STRING));
        hash.op_aset(runtime.getCurrentContext(), runtime.newString("C"),runtime.newFixnum(DERTags.PRINTABLE_STRING));
        hash.op_aset(runtime.getCurrentContext(), runtime.newString("countryName"),runtime.newFixnum(DERTags.PRINTABLE_STRING));
        hash.op_aset(runtime.getCurrentContext(), runtime.newString("serialNumber"),runtime.newFixnum(DERTags.PRINTABLE_STRING));
        hash.op_aset(runtime.getCurrentContext(), runtime.newString("dnQualifier"),runtime.newFixnum(DERTags.PRINTABLE_STRING));
        hash.op_aset(runtime.getCurrentContext(), runtime.newString("DC"),runtime.newFixnum(DERTags.IA5_STRING));
        hash.op_aset(runtime.getCurrentContext(), runtime.newString("domainComponent"),runtime.newFixnum(DERTags.IA5_STRING));
        hash.op_aset(runtime.getCurrentContext(), runtime.newString("emailAddress"),runtime.newFixnum(DERTags.IA5_STRING));
        cX509Name.setConstant("OBJECT_TYPE_TEMPLATE", hash);
    }
View Full Code Here

TOP

Related Classes of org.jruby.RubyHash$Visitor

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.