scratch – Diff between revs 75 and 125
?pathlinks?
Rev 75 | Rev 125 | |||
---|---|---|---|---|
1 | // Generated by CoffeeScript 1.10.0 |
1 | // Generated by CoffeeScript 1.12.4 |
|
2 | var Dumper, Parser, Utils, Yaml; |
2 | var Dumper, Parser, Utils, Yaml; |
|
3 | |
3 | |
|
4 | Parser = require('./Parser'); |
4 | Parser = require('./Parser'); |
|
5 | |
5 | |
|
6 | Dumper = require('./Dumper'); |
6 | Dumper = require('./Dumper'); |
|
7 | |
7 | |
|
8 | Utils = require('./Utils'); |
8 | Utils = require('./Utils'); |
|
9 | |
9 | |
|
10 | Yaml = (function() { |
10 | Yaml = (function() { |
|
11 | function Yaml() {} |
11 | function Yaml() {} |
|
12 | |
12 | |
|
13 | Yaml.parse = function(input, exceptionOnInvalidType, objectDecoder) { |
13 | Yaml.parse = function(input, exceptionOnInvalidType, objectDecoder) { |
|
14 | if (exceptionOnInvalidType == null) { |
14 | if (exceptionOnInvalidType == null) { |
|
15 | exceptionOnInvalidType = false; |
15 | exceptionOnInvalidType = false; |
|
16 | } |
16 | } |
|
17 | if (objectDecoder == null) { |
17 | if (objectDecoder == null) { |
|
18 | objectDecoder = null; |
18 | objectDecoder = null; |
|
19 | } |
19 | } |
|
20 | return new Parser().parse(input, exceptionOnInvalidType, objectDecoder); |
20 | return new Parser().parse(input, exceptionOnInvalidType, objectDecoder); |
|
21 | }; |
21 | }; |
|
22 | |
22 | |
|
23 | Yaml.parseFile = function(path, callback, exceptionOnInvalidType, objectDecoder) { |
23 | Yaml.parseFile = function(path, callback, exceptionOnInvalidType, objectDecoder) { |
|
24 | var input; |
24 | var input; |
|
25 | if (callback == null) { |
25 | if (callback == null) { |
|
26 | callback = null; |
26 | callback = null; |
|
27 | } |
27 | } |
|
28 | if (exceptionOnInvalidType == null) { |
28 | if (exceptionOnInvalidType == null) { |
|
29 | exceptionOnInvalidType = false; |
29 | exceptionOnInvalidType = false; |
|
30 | } |
30 | } |
|
31 | if (objectDecoder == null) { |
31 | if (objectDecoder == null) { |
|
32 | objectDecoder = null; |
32 | objectDecoder = null; |
|
33 | } |
33 | } |
|
34 | if (callback != null) { |
34 | if (callback != null) { |
|
35 | return Utils.getStringFromFile(path, (function(_this) { |
35 | return Utils.getStringFromFile(path, (function(_this) { |
|
36 | return function(input) { |
36 | return function(input) { |
|
37 | var result; |
37 | var result; |
|
38 | result = null; |
38 | result = null; |
|
39 | if (input != null) { |
39 | if (input != null) { |
|
40 | result = _this.parse(input, exceptionOnInvalidType, objectDecoder); |
40 | result = _this.parse(input, exceptionOnInvalidType, objectDecoder); |
|
41 | } |
41 | } |
|
42 | callback(result); |
42 | callback(result); |
|
43 | }; |
43 | }; |
|
44 | })(this)); |
44 | })(this)); |
|
45 | } else { |
45 | } else { |
|
46 | input = Utils.getStringFromFile(path); |
46 | input = Utils.getStringFromFile(path); |
|
47 | if (input != null) { |
47 | if (input != null) { |
|
48 | return this.parse(input, exceptionOnInvalidType, objectDecoder); |
48 | return this.parse(input, exceptionOnInvalidType, objectDecoder); |
|
49 | } |
49 | } |
|
50 | return null; |
50 | return null; |
|
51 | } |
51 | } |
|
52 | }; |
52 | }; |
|
53 | |
53 | |
|
54 | Yaml.dump = function(input, inline, indent, exceptionOnInvalidType, objectEncoder) { |
54 | Yaml.dump = function(input, inline, indent, exceptionOnInvalidType, objectEncoder) { |
|
55 | var yaml; |
55 | var yaml; |
|
56 | if (inline == null) { |
56 | if (inline == null) { |
|
57 | inline = 2; |
57 | inline = 2; |
|
58 | } |
58 | } |
|
59 | if (indent == null) { |
59 | if (indent == null) { |
|
60 | indent = 4; |
60 | indent = 4; |
|
61 | } |
61 | } |
|
62 | if (exceptionOnInvalidType == null) { |
62 | if (exceptionOnInvalidType == null) { |
|
63 | exceptionOnInvalidType = false; |
63 | exceptionOnInvalidType = false; |
|
64 | } |
64 | } |
|
65 | if (objectEncoder == null) { |
65 | if (objectEncoder == null) { |
|
66 | objectEncoder = null; |
66 | objectEncoder = null; |
|
67 | } |
67 | } |
|
68 | yaml = new Dumper(); |
68 | yaml = new Dumper(); |
|
69 | yaml.indentation = indent; |
69 | yaml.indentation = indent; |
|
70 | return yaml.dump(input, inline, 0, exceptionOnInvalidType, objectEncoder); |
70 | return yaml.dump(input, inline, 0, exceptionOnInvalidType, objectEncoder); |
|
71 | }; |
71 | }; |
|
72 | |
- | ||
73 | Yaml.register = function() { |
- | ||
74 | var require_handler; |
- | ||
75 | require_handler = function(module, filename) { |
- | ||
76 | return module.exports = YAML.parseFile(filename); |
- | ||
77 | }; |
- | ||
78 | if ((typeof require !== "undefined" && require !== null ? require.extensions : void 0) != null) { |
- | ||
79 | require.extensions['.yml'] = require_handler; |
- | ||
80 | return require.extensions['.yaml'] = require_handler; |
- | ||
81 | } |
- | ||
82 | }; |
- | ||
83 | |
72 | |
|
84 | Yaml.stringify = function(input, inline, indent, exceptionOnInvalidType, objectEncoder) { |
73 | Yaml.stringify = function(input, inline, indent, exceptionOnInvalidType, objectEncoder) { |
|
85 | return this.dump(input, inline, indent, exceptionOnInvalidType, objectEncoder); |
74 | return this.dump(input, inline, indent, exceptionOnInvalidType, objectEncoder); |
|
86 | }; |
75 | }; |
|
87 | |
76 | |
|
88 | Yaml.load = function(path, callback, exceptionOnInvalidType, objectDecoder) { |
77 | Yaml.load = function(path, callback, exceptionOnInvalidType, objectDecoder) { |
|
89 | return this.parseFile(path, callback, exceptionOnInvalidType, objectDecoder); |
78 | return this.parseFile(path, callback, exceptionOnInvalidType, objectDecoder); |
|
90 | }; |
79 | }; |
|
91 | |
80 | |
|
92 | return Yaml; |
81 | return Yaml; |
|
93 | |
82 | |
|
94 | })(); |
83 | })(); |
|
95 | |
84 | |
|
96 | if (typeof window !== "undefined" && window !== null) { |
85 | if (typeof window !== "undefined" && window !== null) { |
|
97 | window.YAML = Yaml; |
86 | window.YAML = Yaml; |
|
98 | } |
87 | } |
|
99 | |
88 | |
|
100 | if (typeof window === "undefined" || window === null) { |
89 | if (typeof window === "undefined" || window === null) { |
|
101 | this.YAML = Yaml; |
90 | this.YAML = Yaml; |
|
102 | } |
91 | } |
|
103 | |
92 | |
|
104 | module.exports = Yaml; |
93 | module.exports = Yaml; |
|
105 | |
94 | |