summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Rakefile2
-rw-r--r--ext/java/PsychEmitter.java22
-rw-r--r--ext/java/PsychParser.java33
-rw-r--r--lib/psych/versions.rb2
-rw-r--r--psych.gemspec2
5 files changed, 32 insertions, 29 deletions
diff --git a/Rakefile b/Rakefile
index b8f37ff..8c9ec91 100644
--- a/Rakefile
+++ b/Rakefile
@@ -18,7 +18,7 @@ if RUBY_PLATFORM =~ /java/
# and tell maven via system properties the snakeyaml version
# this is basically the same as running from the commandline:
# rmvn dependency:build-classpath -Dsnakeyaml.version='use version from Psych::DEFAULT_SNAKEYAML_VERSION here'
- Maven::Ruby::Maven.new.exec('dependency:build-classpath', "-Dsnakeyaml.version=1.18", '-Dverbose=true')
+ Maven::Ruby::Maven.new.exec('dependency:build-classpath', "-Dsnakeyaml.version=1.21", '-Dverbose=true')
ext.source_version = '1.7'
ext.target_version = '1.7'
ext.classpath = File.read('pkg/classpath')
diff --git a/ext/java/PsychEmitter.java b/ext/java/PsychEmitter.java
index 35eff96..2866a8a 100644
--- a/ext/java/PsychEmitter.java
+++ b/ext/java/PsychEmitter.java
@@ -202,7 +202,7 @@ public class PsychEmitter extends RubyObject {
value.asJavaString(),
NULL_MARK,
NULL_MARK,
- SCALAR_STYLES[(int)style.convertToInteger().getLongValue()]);
+ SCALAR_STYLES[style.convertToInteger().getIntValue()]);
emit(context, event);
return this;
}
@@ -222,7 +222,7 @@ public class PsychEmitter extends RubyObject {
implicit.isTrue(),
NULL_MARK,
NULL_MARK,
- SEQUENCE_BLOCK != style.convertToInteger().getLongValue());
+ SEQUENCE_BLOCK != style.convertToInteger().getLongValue() ? DumperOptions.FlowStyle.BLOCK : DumperOptions.FlowStyle.FLOW);
emit(context, event);
return this;
}
@@ -249,7 +249,7 @@ public class PsychEmitter extends RubyObject {
implicit.isTrue(),
NULL_MARK,
NULL_MARK,
- MAPPING_BLOCK != style.convertToInteger().getLongValue());
+ MAPPING_BLOCK != style.convertToInteger().getLongValue() ? DumperOptions.FlowStyle.BLOCK : DumperOptions.FlowStyle.FLOW);
emit(context, event);
return this;
}
@@ -332,16 +332,16 @@ public class PsychEmitter extends RubyObject {
DumperOptions options = new DumperOptions();
IRubyObject io;
- private static final Mark NULL_MARK = new Mark(null, 0, 0, 0, null, 0);
+ private static final Mark NULL_MARK = new Mark(null, 0, 0, 0, new int[0], 0);
// Map style constants from Psych values (ANY = 0 ... FOLDED = 5)
// to SnakeYaml values; see psych/nodes/scalar.rb.
- private static final Character[] SCALAR_STYLES = new Character[] {
- null, // ANY; we'll choose plain
- null, // PLAIN
- '\'', // SINGLE_QUOTED
- '"', // DOUBLE_QUOTED
- '|', // LITERAL
- '>', // FOLDED
+ private static final DumperOptions.ScalarStyle[] SCALAR_STYLES = new DumperOptions.ScalarStyle[] {
+ DumperOptions.ScalarStyle.PLAIN, // ANY
+ DumperOptions.ScalarStyle.PLAIN,
+ DumperOptions.ScalarStyle.SINGLE_QUOTED,
+ DumperOptions.ScalarStyle.DOUBLE_QUOTED,
+ DumperOptions.ScalarStyle.LITERAL,
+ DumperOptions.ScalarStyle.FOLDED
};
}
diff --git a/ext/java/PsychParser.java b/ext/java/PsychParser.java
index db0306b..aa6ab01 100644
--- a/ext/java/PsychParser.java
+++ b/ext/java/PsychParser.java
@@ -41,6 +41,7 @@ import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyClass;
import org.jruby.RubyEncoding;
+import org.jruby.RubyFixnum;
import org.jruby.RubyIO;
import org.jruby.RubyKernel;
import org.jruby.RubyModule;
@@ -359,24 +360,26 @@ public class PsychParser extends RubyObject {
RubyKernel.raise(context, runtime.getKernel(), new IRubyObject[] { exception }, Block.NULL_BLOCK);
}
- private static int translateStyle(Character style) {
+ private static int translateStyle(DumperOptions.ScalarStyle style) {
if (style == null) return 0; // any
switch (style) {
- case 0: return 1; // plain
- case '\'': return 2; // single-quoted
- case '"': return 3; // double-quoted
- case '|': return 4; // literal
- case '>': return 5; // folded
+ case PLAIN: return 1; // plain
+ case SINGLE_QUOTED: return 2; // single-quoted
+ case DOUBLE_QUOTED: return 3; // double-quoted
+ case LITERAL: return 4; // literal
+ case FOLDED: return 5; // folded
default: return 0; // any
}
}
- private static int translateFlowStyle(Boolean flowStyle) {
- if (flowStyle == null) return 0; // any
-
- if (flowStyle) return 2;
- return 1;
+ private static int translateFlowStyle(DumperOptions.FlowStyle flowStyle) {
+ switch (flowStyle) {
+ case AUTO: return 0;
+ case BLOCK: return 1;
+ case FLOW:
+ default: return 2;
+ }
}
@JRubyMethod
@@ -394,9 +397,9 @@ public class PsychParser extends RubyObject {
if (event == null) {
return ((RubyClass)context.runtime.getClassFromPath("Psych::Parser::Mark")).newInstance(
context,
- runtime.newFixnum(0),
- runtime.newFixnum(0),
- runtime.newFixnum(0),
+ RubyFixnum.zero(runtime),
+ RubyFixnum.zero(runtime),
+ RubyFixnum.zero(runtime),
Block.NULL_BLOCK
);
}
@@ -405,7 +408,7 @@ public class PsychParser extends RubyObject {
return ((RubyClass)context.runtime.getClassFromPath("Psych::Parser::Mark")).newInstance(
context,
- runtime.newFixnum(mark.getIndex()),
+ RubyFixnum.zero(runtime),
runtime.newFixnum(mark.getLine()),
runtime.newFixnum(mark.getColumn()),
Block.NULL_BLOCK
diff --git a/lib/psych/versions.rb b/lib/psych/versions.rb
index 33993ec..07cc904 100644
--- a/lib/psych/versions.rb
+++ b/lib/psych/versions.rb
@@ -4,6 +4,6 @@ module Psych
VERSION = '3.0.2'
if RUBY_ENGINE == 'jruby'
- DEFAULT_SNAKEYAML_VERSION = '1.18'.freeze
+ DEFAULT_SNAKEYAML_VERSION = '1.21'.freeze
end
end
diff --git a/psych.gemspec b/psych.gemspec
index d06e47b..b3fa37a 100644
--- a/psych.gemspec
+++ b/psych.gemspec
@@ -53,7 +53,7 @@ DESCRIPTION
"ext/java/PsychEmitter.java", "ext/java/PsychLibrary.java", "ext/java/PsychParser.java", "ext/java/PsychToRuby.java",
"ext/java/PsychYamlTree.java", "lib/psych_jars.rb", "lib/psych.jar"
]
- s.requirements = "jar org.yaml:snakeyaml, 1.18"
+ s.requirements = "jar org.yaml:snakeyaml, 1.21"
s.add_dependency 'jar-dependencies', '>= 0.1.7'
s.add_development_dependency 'ruby-maven'
else