psych 2.0.17-java → 2.1.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +4 -11
- data/Rakefile +27 -119
- data/ext/psych/extconf.rb +1 -0
- data/ext/psych/yaml/loader.c +2 -2
- data/ext/psych/yaml/scanner.c +17 -17
- data/lib/psych.rb +14 -8
- data/lib/psych/class_loader.rb +1 -0
- data/lib/psych/coder.rb +1 -0
- data/lib/psych/core_ext.rb +1 -0
- data/lib/psych/deprecated.rb +1 -0
- data/lib/psych/exception.rb +1 -0
- data/lib/psych/handler.rb +1 -0
- data/lib/psych/handlers/document_stream.rb +1 -0
- data/lib/psych/handlers/recorder.rb +1 -0
- data/lib/psych/json/ruby_events.rb +1 -0
- data/lib/psych/json/stream.rb +1 -0
- data/lib/psych/json/tree_builder.rb +1 -0
- data/lib/psych/json/yaml_events.rb +1 -0
- data/lib/psych/nodes.rb +1 -0
- data/lib/psych/nodes/alias.rb +1 -0
- data/lib/psych/nodes/document.rb +1 -0
- data/lib/psych/nodes/mapping.rb +1 -0
- data/lib/psych/nodes/node.rb +1 -0
- data/lib/psych/nodes/scalar.rb +1 -0
- data/lib/psych/nodes/sequence.rb +1 -0
- data/lib/psych/nodes/stream.rb +1 -0
- data/lib/psych/omap.rb +1 -0
- data/lib/psych/parser.rb +1 -0
- data/lib/psych/scalar_scanner.rb +2 -1
- data/lib/psych/set.rb +1 -0
- data/lib/psych/stream.rb +1 -0
- data/lib/psych/streaming.rb +1 -0
- data/lib/psych/syntax_error.rb +1 -0
- data/lib/psych/tree_builder.rb +1 -0
- data/lib/psych/versions.rb +1 -0
- data/lib/psych/visitors.rb +1 -0
- data/lib/psych/visitors/depth_first.rb +1 -0
- data/lib/psych/visitors/emitter.rb +1 -0
- data/lib/psych/visitors/json_tree.rb +1 -0
- data/lib/psych/visitors/to_ruby.rb +1 -0
- data/lib/psych/visitors/visitor.rb +1 -0
- data/lib/psych/visitors/yaml_tree.rb +3 -2
- data/lib/psych/y.rb +1 -0
- data/lib/psych_jars.rb +1 -0
- data/test/psych/handlers/test_recorder.rb +1 -0
- data/test/psych/helper.rb +1 -0
- data/test/psych/json/test_stream.rb +1 -0
- data/test/psych/nodes/test_enumerable.rb +1 -0
- data/test/psych/test_alias_and_anchor.rb +1 -0
- data/test/psych/test_array.rb +1 -0
- data/test/psych/test_boolean.rb +1 -0
- data/test/psych/test_class.rb +1 -0
- data/test/psych/test_coder.rb +1 -0
- data/test/psych/test_date_time.rb +1 -0
- data/test/psych/test_deprecated.rb +1 -0
- data/test/psych/test_document.rb +1 -0
- data/test/psych/test_emitter.rb +19 -0
- data/test/psych/test_encoding.rb +1 -0
- data/test/psych/test_exception.rb +1 -0
- data/test/psych/test_hash.rb +1 -0
- data/test/psych/test_json_tree.rb +1 -0
- data/test/psych/test_merge_keys.rb +1 -0
- data/test/psych/test_nil.rb +1 -0
- data/test/psych/test_null.rb +1 -0
- data/test/psych/test_numeric.rb +1 -0
- data/test/psych/test_object.rb +1 -0
- data/test/psych/test_object_references.rb +1 -0
- data/test/psych/test_omap.rb +1 -0
- data/test/psych/test_parser.rb +1 -0
- data/test/psych/test_psych.rb +6 -0
- data/test/psych/test_safe_load.rb +1 -0
- data/test/psych/test_scalar.rb +1 -0
- data/test/psych/test_scalar_scanner.rb +5 -0
- data/test/psych/test_serialize_subclasses.rb +1 -0
- data/test/psych/test_set.rb +1 -0
- data/test/psych/test_stream.rb +1 -0
- data/test/psych/test_string.rb +5 -0
- data/test/psych/test_struct.rb +1 -0
- data/test/psych/test_symbol.rb +1 -0
- data/test/psych/test_tainted.rb +1 -0
- data/test/psych/test_to_yaml_properties.rb +1 -0
- data/test/psych/test_tree_builder.rb +1 -0
- data/test/psych/test_yaml.rb +1 -0
- data/test/psych/test_yamldbm.rb +1 -0
- data/test/psych/test_yamlstore.rb +1 -0
- data/test/psych/visitors/test_depth_first.rb +1 -0
- data/test/psych/visitors/test_emitter.rb +1 -0
- data/test/psych/visitors/test_to_ruby.rb +1 -0
- data/test/psych/visitors/test_yaml_tree.rb +7 -0
- metadata +27 -44
- data/.autotest +0 -18
- data/.gemtest +0 -0
- data/Manifest.txt +0 -114
- data/lib/psych.jar +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e9dc0b94275e4a1293ff5f5d00f6a81d6f5a39c1
|
|
4
|
+
data.tar.gz: 680468b64f8d7b1b9b703f0adbd5249c2f9cd48b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7cd7a891073f8c4469729780b92f90a7fe08277ae74b859b8d0c8a76180a016f223c4ed63908925cdd9accbdb29d277d2152ead31d2486008cfef338f88cb9a8
|
|
7
|
+
data.tar.gz: 3ac6acb3cdcc50b90870e2e0f5870470c8353725f06b75a9baa800beefd5dfc084ca9c43359f6c47c513dc320e1d38be2598ed778d45f15b748adfecbfb5888d
|
data/.travis.yml
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
rvm:
|
|
2
2
|
- 2.0.0
|
|
3
|
-
- 2.1
|
|
4
|
-
- 2.2
|
|
3
|
+
- 2.1
|
|
4
|
+
- 2.2
|
|
5
|
+
- 2.3.0
|
|
5
6
|
- ruby-head
|
|
6
|
-
|
|
7
|
-
before_script:
|
|
8
|
-
- gem install hoe
|
|
9
|
-
- gem install rake-compiler
|
|
10
|
-
- gem install minitest -v '~> 5.0'
|
|
11
|
-
script: rake test
|
|
12
|
-
matrix:
|
|
13
|
-
allow_failures:
|
|
14
|
-
- rvm: rbx-2
|
|
7
|
+
before_install: gem install bundler --no-document
|
data/Rakefile
CHANGED
|
@@ -1,123 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
$hoe = Hoe.spec 'psych' do
|
|
25
|
-
license 'MIT'
|
|
26
|
-
developer 'Aaron Patterson', 'aaron@tenderlovemaking.com'
|
|
27
|
-
|
|
28
|
-
self.extra_rdoc_files = Dir['*.rdoc']
|
|
29
|
-
self.history_file = 'CHANGELOG.rdoc'
|
|
30
|
-
self.readme_file = 'README.rdoc'
|
|
31
|
-
self.testlib = :minitest
|
|
32
|
-
|
|
33
|
-
extra_dev_deps << ['rake-compiler', '>= 0.4.1']
|
|
34
|
-
extra_dev_deps << ['minitest', '~> 5.0']
|
|
35
|
-
|
|
36
|
-
self.spec_extras = {
|
|
37
|
-
:required_ruby_version => '>= 1.9.2'
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if java?
|
|
41
|
-
require './lib/psych/versions.rb'
|
|
42
|
-
extra_deps << ['jar-dependencies', '>= 0.1.7']
|
|
43
|
-
|
|
44
|
-
# the jar declaration for jar-dependencies
|
|
45
|
-
self.spec_extras[ 'requirements' ] = "jar org.yaml:snakeyaml, #{Psych::DEFAULT_SNAKEYAML_VERSION}"
|
|
46
|
-
self.spec_extras[ 'platform' ] = 'java'
|
|
47
|
-
# TODO: clean this section up.
|
|
48
|
-
require "rake/javaextensiontask"
|
|
49
|
-
Rake::JavaExtensionTask.new("psych", spec) do |ext|
|
|
50
|
-
require 'maven/ruby/maven'
|
|
51
|
-
# uses Mavenfile to write classpath into pkg/classpath
|
|
52
|
-
# and tell maven via system properties the snakeyaml version
|
|
53
|
-
# this is basically the same as running from the commandline:
|
|
54
|
-
# rmvn dependency:build-classpath -Dsnakeyaml.version='use version from Psych::DEFAULT_SNAKEYAML_VERSION here'
|
|
55
|
-
Maven::Ruby::Maven.new.exec( 'dependency:build-classpath', "-Dsnakeyaml.version=#{Psych::DEFAULT_SNAKEYAML_VERSION}", '-Dverbose=true')#, '--quiet' )
|
|
56
|
-
ext.source_version = '1.7'
|
|
57
|
-
ext.target_version = '1.7'
|
|
58
|
-
ext.classpath = File.read('pkg/classpath')
|
|
59
|
-
ext.ext_dir = 'ext/java'
|
|
60
|
-
end
|
|
61
|
-
else
|
|
62
|
-
self.spec_extras[:extensions] = ["ext/psych/extconf.rb"]
|
|
63
|
-
Rake::ExtensionTask.new "psych", spec do |ext|
|
|
64
|
-
ext.lib_dir = File.join(*['lib', ENV['FAT_DIR']].compact)
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def gem_build_path
|
|
70
|
-
File.join 'pkg', $hoe.spec.full_name
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def add_file_to_gem relative_path
|
|
74
|
-
target_path = File.join gem_build_path, relative_path
|
|
75
|
-
target_dir = File.dirname(target_path)
|
|
76
|
-
mkdir_p target_dir unless File.directory?(target_dir)
|
|
77
|
-
rm_f target_path
|
|
78
|
-
safe_ln relative_path, target_path
|
|
79
|
-
$hoe.spec.files.concat [relative_path]
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
if java?
|
|
83
|
-
task gem_build_path => [:compile] do
|
|
84
|
-
add_file_to_gem 'lib/psych.jar'
|
|
1
|
+
require "bundler/gem_tasks"
|
|
2
|
+
require "rake/testtask"
|
|
3
|
+
|
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
|
5
|
+
t.libs << "test"
|
|
6
|
+
t.libs << "lib"
|
|
7
|
+
t.test_files = FileList['test/**/test_*.rb']
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
if RUBY_PLATFORM =~ /java/
|
|
11
|
+
require 'rake/javaextensiontask'
|
|
12
|
+
Rake::JavaExtensionTask.new("psych") do |ext|
|
|
13
|
+
require 'maven/ruby/maven'
|
|
14
|
+
# uses Mavenfile to write classpath into pkg/classpath
|
|
15
|
+
# and tell maven via system properties the snakeyaml version
|
|
16
|
+
# this is basically the same as running from the commandline:
|
|
17
|
+
# rmvn dependency:build-classpath -Dsnakeyaml.version='use version from Psych::DEFAULT_SNAKEYAML_VERSION here'
|
|
18
|
+
Maven::Ruby::Maven.new.exec( 'dependency:build-classpath', "-Dsnakeyaml.version=#{Psych::DEFAULT_SNAKEYAML_VERSION}", '-Dverbose=true')#, '--quiet' )
|
|
19
|
+
ext.source_version = '1.7'
|
|
20
|
+
ext.target_version = '1.7'
|
|
21
|
+
ext.classpath = File.read('pkg/classpath')
|
|
22
|
+
ext.ext_dir = 'ext/java'
|
|
85
23
|
end
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
task :test => :compile
|
|
91
|
-
|
|
92
|
-
task :hack_spec do
|
|
93
|
-
$hoe.spec.extra_rdoc_files.clear
|
|
94
|
-
end
|
|
95
|
-
task 'core:spec' => [:hack_spec, 'gem:spec']
|
|
96
|
-
|
|
97
|
-
desc "merge psych in to ruby trunk"
|
|
98
|
-
namespace :merge do
|
|
99
|
-
basedir = File.expand_path File.dirname __FILE__
|
|
100
|
-
rubydir = File.join ENV['HOME'], 'git', 'ruby'
|
|
101
|
-
mergedirs = {
|
|
102
|
-
# From # To
|
|
103
|
-
[basedir, 'ext', 'psych/'] => [rubydir, 'ext', 'psych/'],
|
|
104
|
-
[basedir, 'lib/'] => [rubydir, 'ext', 'psych', 'lib/'],
|
|
105
|
-
[basedir, 'test', 'psych/'] => [rubydir, 'test', 'psych/'],
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
rsync = 'rsync -av --exclude lib --exclude ".*" --exclude "*.o" --exclude Makefile --exclude mkmf.log --delete'
|
|
109
|
-
|
|
110
|
-
task :to_ruby do
|
|
111
|
-
mergedirs.each do |from, to|
|
|
112
|
-
sh "#{rsync} #{File.join(*from)} #{File.join(*to)}"
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
task :from_ruby do
|
|
117
|
-
mergedirs.each do |from, to|
|
|
118
|
-
sh "#{rsync} #{File.join(*to)} #{File.join(*from)}"
|
|
119
|
-
end
|
|
24
|
+
else
|
|
25
|
+
require 'rake/extensiontask'
|
|
26
|
+
Rake::ExtensionTask.new("psych") do |ext|
|
|
27
|
+
ext.lib_dir = File.join(*['lib', ENV['FAT_DIR']].compact)
|
|
120
28
|
end
|
|
121
29
|
end
|
|
122
30
|
|
|
123
|
-
|
|
31
|
+
task :default => [:compile, :test]
|
data/ext/psych/extconf.rb
CHANGED
data/ext/psych/yaml/loader.c
CHANGED
|
@@ -239,8 +239,8 @@ yaml_parser_register_anchor(yaml_parser_t *parser,
|
|
|
239
239
|
if (strcmp((char *)alias_data->anchor, (char *)anchor) == 0) {
|
|
240
240
|
yaml_free(anchor);
|
|
241
241
|
return yaml_parser_set_composer_error_context(parser,
|
|
242
|
-
"found duplicate anchor; first
|
|
243
|
-
alias_data->mark, "second
|
|
242
|
+
"found duplicate anchor; first occurrence",
|
|
243
|
+
alias_data->mark, "second occurrence", data.mark);
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
|
data/ext/psych/yaml/scanner.c
CHANGED
|
@@ -1251,7 +1251,7 @@ yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
|
|
|
1251
1251
|
|
|
1252
1252
|
/*
|
|
1253
1253
|
* Pop indentation levels from the indents stack until the current level
|
|
1254
|
-
* becomes less or equal to the column. For each
|
|
1254
|
+
* becomes less or equal to the column. For each indentation level, append
|
|
1255
1255
|
* the BLOCK-END token.
|
|
1256
1256
|
*/
|
|
1257
1257
|
|
|
@@ -1266,7 +1266,7 @@ yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column)
|
|
|
1266
1266
|
if (parser->flow_level)
|
|
1267
1267
|
return 1;
|
|
1268
1268
|
|
|
1269
|
-
/* Loop through the
|
|
1269
|
+
/* Loop through the indentation levels in the stack. */
|
|
1270
1270
|
|
|
1271
1271
|
while (parser->indent > column)
|
|
1272
1272
|
{
|
|
@@ -2775,15 +2775,15 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
|
2775
2775
|
|
|
2776
2776
|
if (IS_DIGIT(parser->buffer))
|
|
2777
2777
|
{
|
|
2778
|
-
/* Check that the
|
|
2778
|
+
/* Check that the indentation is greater than 0. */
|
|
2779
2779
|
|
|
2780
2780
|
if (CHECK(parser->buffer, '0')) {
|
|
2781
2781
|
yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
|
|
2782
|
-
start_mark, "found an
|
|
2782
|
+
start_mark, "found an indentation indicator equal to 0");
|
|
2783
2783
|
goto error;
|
|
2784
2784
|
}
|
|
2785
2785
|
|
|
2786
|
-
/* Get the
|
|
2786
|
+
/* Get the indentation level and eat the indicator. */
|
|
2787
2787
|
|
|
2788
2788
|
increment = AS_DIGIT(parser->buffer);
|
|
2789
2789
|
|
|
@@ -2797,7 +2797,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
|
2797
2797
|
{
|
|
2798
2798
|
if (CHECK(parser->buffer, '0')) {
|
|
2799
2799
|
yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
|
|
2800
|
-
start_mark, "found an
|
|
2800
|
+
start_mark, "found an indentation indicator equal to 0");
|
|
2801
2801
|
goto error;
|
|
2802
2802
|
}
|
|
2803
2803
|
|
|
@@ -2847,7 +2847,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
|
2847
2847
|
|
|
2848
2848
|
end_mark = parser->mark;
|
|
2849
2849
|
|
|
2850
|
-
/* Set the
|
|
2850
|
+
/* Set the indentation level if it was specified. */
|
|
2851
2851
|
|
|
2852
2852
|
if (increment) {
|
|
2853
2853
|
indent = parser->indent >= 0 ? parser->indent+increment : increment;
|
|
@@ -2913,7 +2913,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
|
2913
2913
|
|
|
2914
2914
|
if (!READ_LINE(parser, leading_break)) goto error;
|
|
2915
2915
|
|
|
2916
|
-
/* Eat the following
|
|
2916
|
+
/* Eat the following indentation spaces and line breaks. */
|
|
2917
2917
|
|
|
2918
2918
|
if (!yaml_parser_scan_block_scalar_breaks(parser,
|
|
2919
2919
|
&indent, &trailing_breaks, start_mark, &end_mark)) goto error;
|
|
@@ -2948,8 +2948,8 @@ error:
|
|
|
2948
2948
|
}
|
|
2949
2949
|
|
|
2950
2950
|
/*
|
|
2951
|
-
* Scan
|
|
2952
|
-
*
|
|
2951
|
+
* Scan indentation spaces and line breaks for a block scalar. Determine the
|
|
2952
|
+
* indentation level if needed.
|
|
2953
2953
|
*/
|
|
2954
2954
|
|
|
2955
2955
|
static int
|
|
@@ -2961,11 +2961,11 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
|
|
|
2961
2961
|
|
|
2962
2962
|
*end_mark = parser->mark;
|
|
2963
2963
|
|
|
2964
|
-
/* Eat the
|
|
2964
|
+
/* Eat the indentation spaces and line breaks. */
|
|
2965
2965
|
|
|
2966
2966
|
while (1)
|
|
2967
2967
|
{
|
|
2968
|
-
/* Eat the
|
|
2968
|
+
/* Eat the indentation spaces. */
|
|
2969
2969
|
|
|
2970
2970
|
if (!CACHE(parser, 1)) return 0;
|
|
2971
2971
|
|
|
@@ -2978,12 +2978,12 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
|
|
|
2978
2978
|
if ((int)parser->mark.column > max_indent)
|
|
2979
2979
|
max_indent = (int)parser->mark.column;
|
|
2980
2980
|
|
|
2981
|
-
/* Check for a tab character messing the
|
|
2981
|
+
/* Check for a tab character messing the indentation. */
|
|
2982
2982
|
|
|
2983
2983
|
if ((!*indent || (int)parser->mark.column < *indent)
|
|
2984
2984
|
&& IS_TAB(parser->buffer)) {
|
|
2985
2985
|
return yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
|
|
2986
|
-
start_mark, "found a tab character where an
|
|
2986
|
+
start_mark, "found a tab character where an indentation space is expected");
|
|
2987
2987
|
}
|
|
2988
2988
|
|
|
2989
2989
|
/* Have we found a non-empty line? */
|
|
@@ -3504,12 +3504,12 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
|
|
|
3504
3504
|
{
|
|
3505
3505
|
if (IS_BLANK(parser->buffer))
|
|
3506
3506
|
{
|
|
3507
|
-
/* Check for tab character that abuse
|
|
3507
|
+
/* Check for tab character that abuse indentation. */
|
|
3508
3508
|
|
|
3509
3509
|
if (leading_blanks && (int)parser->mark.column < indent
|
|
3510
3510
|
&& IS_TAB(parser->buffer)) {
|
|
3511
3511
|
yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
|
|
3512
|
-
start_mark, "found a tab character that violate
|
|
3512
|
+
start_mark, "found a tab character that violate indentation");
|
|
3513
3513
|
goto error;
|
|
3514
3514
|
}
|
|
3515
3515
|
|
|
@@ -3542,7 +3542,7 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
|
|
|
3542
3542
|
if (!CACHE(parser, 1)) goto error;
|
|
3543
3543
|
}
|
|
3544
3544
|
|
|
3545
|
-
/* Check
|
|
3545
|
+
/* Check indentation level. */
|
|
3546
3546
|
|
|
3547
3547
|
if (!parser->flow_level && (int)parser->mark.column < indent)
|
|
3548
3548
|
break;
|
data/lib/psych.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: false
|
|
1
2
|
case RUBY_ENGINE
|
|
2
3
|
when 'jruby'
|
|
3
4
|
require 'psych_jars'
|
|
@@ -223,11 +224,13 @@ require 'psych/class_loader'
|
|
|
223
224
|
|
|
224
225
|
module Psych
|
|
225
226
|
# The version is Psych you're using
|
|
226
|
-
VERSION = '2.0
|
|
227
|
+
VERSION = '2.1.0'
|
|
227
228
|
|
|
228
229
|
# The version of libyaml Psych is using
|
|
229
230
|
LIBYAML_VERSION = Psych.libyaml_version.join '.'
|
|
230
231
|
|
|
232
|
+
FALLBACK = Struct.new :to_ruby # :nodoc:
|
|
233
|
+
|
|
231
234
|
###
|
|
232
235
|
# Load +yaml+ in to a Ruby data structure. If multiple documents are
|
|
233
236
|
# provided, the object contained in the first document will be returned.
|
|
@@ -247,8 +250,8 @@ module Psych
|
|
|
247
250
|
# ex.file # => 'file.txt'
|
|
248
251
|
# ex.message # => "(file.txt): found character that cannot start any token"
|
|
249
252
|
# end
|
|
250
|
-
def self.load yaml, filename = nil
|
|
251
|
-
result = parse(yaml, filename)
|
|
253
|
+
def self.load yaml, filename = nil, fallback = false
|
|
254
|
+
result = parse(yaml, filename, fallback)
|
|
252
255
|
result ? result.to_ruby : result
|
|
253
256
|
end
|
|
254
257
|
|
|
@@ -320,11 +323,11 @@ module Psych
|
|
|
320
323
|
# end
|
|
321
324
|
#
|
|
322
325
|
# See Psych::Nodes for more information about YAML AST.
|
|
323
|
-
def self.parse yaml, filename = nil
|
|
326
|
+
def self.parse yaml, filename = nil, fallback = false
|
|
324
327
|
parse_stream(yaml, filename) do |node|
|
|
325
328
|
return node
|
|
326
329
|
end
|
|
327
|
-
|
|
330
|
+
fallback
|
|
328
331
|
end
|
|
329
332
|
|
|
330
333
|
###
|
|
@@ -465,9 +468,12 @@ module Psych
|
|
|
465
468
|
|
|
466
469
|
###
|
|
467
470
|
# Load the document contained in +filename+. Returns the yaml contained in
|
|
468
|
-
# +filename+ as a Ruby object
|
|
469
|
-
|
|
470
|
-
|
|
471
|
+
# +filename+ as a Ruby object, or if the file is empty, it returns
|
|
472
|
+
# the specified default return value, which defaults to an empty Hash
|
|
473
|
+
def self.load_file filename, fallback = false
|
|
474
|
+
File.open(filename, 'r:bom|utf-8') { |f|
|
|
475
|
+
self.load f, filename, FALLBACK.new(fallback)
|
|
476
|
+
}
|
|
471
477
|
end
|
|
472
478
|
|
|
473
479
|
# :stopdoc:
|
data/lib/psych/class_loader.rb
CHANGED
data/lib/psych/coder.rb
CHANGED
data/lib/psych/core_ext.rb
CHANGED
data/lib/psych/deprecated.rb
CHANGED
data/lib/psych/exception.rb
CHANGED
data/lib/psych/handler.rb
CHANGED
data/lib/psych/json/stream.rb
CHANGED