yaml 0.1.2 → 0.2.3

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.
Files changed (39) hide show
  1. package/History.md +22 -0
  2. package/Makefile +2 -1
  3. package/examples/boolean.yaml +7 -0
  4. package/examples/config.yml +1 -1
  5. package/examples/dates.yaml +7 -0
  6. package/examples/null.yaml +8 -0
  7. package/lib/yaml.js +46 -11
  8. package/package.json +1 -1
  9. package/spec/fixtures/comments.yml +0 -6
  10. package/spec/fixtures/document.yml +0 -4
  11. package/spec/fixtures/hash.hash.yml +0 -7
  12. package/spec/fixtures/hash.inline.invalid.yml +0 -1
  13. package/spec/fixtures/hash.inline.whitespace.yml +0 -4
  14. package/spec/fixtures/hash.inline.yml +0 -1
  15. package/spec/fixtures/hash.list.yml +0 -3
  16. package/spec/fixtures/hash.yml +0 -2
  17. package/spec/fixtures/list.hash.yml +0 -4
  18. package/spec/fixtures/list.inline.invalid.yml +0 -1
  19. package/spec/fixtures/list.inline.yml +0 -1
  20. package/spec/fixtures/list.invalid.yml +0 -5
  21. package/spec/fixtures/list.list.yml +0 -7
  22. package/spec/fixtures/list.lists.yml +0 -6
  23. package/spec/fixtures/list.yml +0 -3
  24. package/spec/lib/images/bg.png +0 -0
  25. package/spec/lib/images/hr.png +0 -0
  26. package/spec/lib/images/loading.gif +0 -0
  27. package/spec/lib/images/sprites.bg.png +0 -0
  28. package/spec/lib/images/sprites.png +0 -0
  29. package/spec/lib/images/vr.png +0 -0
  30. package/spec/lib/jspec.css +0 -149
  31. package/spec/lib/jspec.growl.js +0 -115
  32. package/spec/lib/jspec.jquery.js +0 -79
  33. package/spec/lib/jspec.js +0 -1889
  34. package/spec/lib/jspec.nodejs.js +0 -18
  35. package/spec/lib/jspec.shell.js +0 -39
  36. package/spec/lib/jspec.timers.js +0 -90
  37. package/spec/lib/jspec.xhr.js +0 -208
  38. package/spec/node.js +0 -9
  39. package/spec/spec.core.js +0 -222
@@ -1,18 +0,0 @@
1
-
2
- // JSpec - node - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
3
-
4
- JSpec
5
- .include({
6
- name: 'node',
7
-
8
- // --- Matchers
9
-
10
- matchers : {
11
- have_enumerable_property: 'actual.propertyIsEnumerable(expected)',
12
- have_writable_property: 'Object.getOwnPropertyDescriptor(actual, expected).writable === true',
13
- have_configurable_property: 'Object.getOwnPropertyDescriptor(actual, expected).configurable === true',
14
- have_keys: 'does(Object.keys(actual), "eql", expected)',
15
- have_prototype: 'Object.getPrototypeOf(actual) === expected'
16
- }
17
- })
18
-
@@ -1,39 +0,0 @@
1
-
2
- // JSpec - Shell - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
3
-
4
- ;(function(){
5
-
6
- var _quit = quit
7
-
8
- Shell = {
9
-
10
- // --- Global
11
-
12
- main: this,
13
-
14
- // --- Commands
15
-
16
- commands: {
17
- quit: ['Terminate the shell', function(){ _quit() }],
18
- exit: ['Terminate the shell', function(){ _quit() }],
19
- p: ['Inspect an object', function(o){ return o.toSource() }]
20
- },
21
-
22
- /**
23
- * Start the interactive shell.
24
- *
25
- * @api public
26
- */
27
-
28
- start : function() {
29
- for (var name in this.commands)
30
- if (this.commands.hasOwnProperty(name))
31
- this.commands[name][1].length ?
32
- this.main[name] = this.commands[name][1] :
33
- this.main.__defineGetter__(name, this.commands[name][1])
34
- }
35
- }
36
-
37
- Shell.start()
38
-
39
- })()
@@ -1,90 +0,0 @@
1
-
2
- // JSpec - Mock Timers - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
3
-
4
- ;(function(){
5
-
6
- /**
7
- * Version.
8
- */
9
-
10
- mockTimersVersion = '1.0.2'
11
-
12
- /**
13
- * Localized timer stack.
14
- */
15
-
16
- var timers = []
17
-
18
- /**
19
- * Set mock timeout with _callback_ and timeout of _ms_.
20
- *
21
- * @param {function} callback
22
- * @param {int} ms
23
- * @return {int}
24
- * @api public
25
- */
26
-
27
- setTimeout = function(callback, ms) {
28
- var id
29
- return id = setInterval(function(){
30
- callback()
31
- clearInterval(id)
32
- }, ms)
33
- }
34
-
35
- /**
36
- * Set mock interval with _callback_ and interval of _ms_.
37
- *
38
- * @param {function} callback
39
- * @param {int} ms
40
- * @return {int}
41
- * @api public
42
- */
43
-
44
- setInterval = function(callback, ms) {
45
- callback.step = ms, callback.current = callback.last = 0
46
- return timers[timers.length] = callback, timers.length
47
- }
48
-
49
- /**
50
- * Destroy timer with _id_.
51
- *
52
- * @param {int} id
53
- * @return {bool}
54
- * @api public
55
- */
56
-
57
- clearInterval = clearTimeout = function(id) {
58
- return delete timers[--id]
59
- }
60
-
61
- /**
62
- * Reset timers.
63
- *
64
- * @return {array}
65
- * @api public
66
- */
67
-
68
- resetTimers = function() {
69
- return timers = []
70
- }
71
-
72
- /**
73
- * Increment each timers internal clock by _ms_.
74
- *
75
- * @param {int} ms
76
- * @api public
77
- */
78
-
79
- tick = function(ms) {
80
- for (var i = 0, len = timers.length; i < len; ++i)
81
- if (timers[i] && (timers[i].current += ms))
82
- if (timers[i].current - timers[i].last >= timers[i].step) {
83
- var times = Math.floor((timers[i].current - timers[i].last) / timers[i].step)
84
- var remainder = (timers[i].current - timers[i].last) % timers[i].step
85
- timers[i].last = timers[i].current - remainder
86
- while (times-- && timers[i]) timers[i]()
87
- }
88
- }
89
-
90
- })()
@@ -1,208 +0,0 @@
1
-
2
- // JSpec - XHR - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
3
-
4
- (function(){
5
-
6
- var lastRequest
7
-
8
- // --- Original XMLHttpRequest
9
-
10
- var OriginalXMLHttpRequest = 'XMLHttpRequest' in this ?
11
- XMLHttpRequest :
12
- function(){}
13
- var OriginalActiveXObject = 'ActiveXObject' in this ?
14
- ActiveXObject :
15
- undefined
16
-
17
- // --- MockXMLHttpRequest
18
-
19
- var MockXMLHttpRequest = function() {
20
- this.requestHeaders = {}
21
- }
22
-
23
- MockXMLHttpRequest.prototype = {
24
- status: 0,
25
- async: true,
26
- readyState: 0,
27
- responseXML: null,
28
- responseText: '',
29
- abort: function(){},
30
- onreadystatechange: function(){},
31
-
32
- /**
33
- * Return response headers hash.
34
- */
35
-
36
- getAllResponseHeaders : function(){
37
- return this.responseHeaders
38
- },
39
-
40
- /**
41
- * Return case-insensitive value for header _name_.
42
- */
43
-
44
- getResponseHeader : function(name) {
45
- return this.responseHeaders[name.toLowerCase()]
46
- },
47
-
48
- /**
49
- * Set case-insensitive _value_ for header _name_.
50
- */
51
-
52
- setRequestHeader : function(name, value) {
53
- this.requestHeaders[name.toLowerCase()] = value
54
- },
55
-
56
- /**
57
- * Open mock request.
58
- */
59
-
60
- open : function(method, url, async, user, password) {
61
- this.user = user
62
- this.password = password
63
- this.url = url
64
- this.readyState = 1
65
- this.method = method.toUpperCase()
66
- if (async != undefined) this.async = async
67
- if (this.async) this.onreadystatechange()
68
- },
69
-
70
- /**
71
- * Send request _data_.
72
- */
73
-
74
- send : function(data) {
75
- var self = this
76
- this.data = data
77
- this.readyState = 4
78
- if (this.method == 'HEAD') this.responseText = null
79
- this.responseHeaders['content-length'] = (this.responseText || '').length
80
- if(this.async) this.onreadystatechange()
81
- this.populateResponseXML()
82
- lastRequest = function(){
83
- return self
84
- }
85
- },
86
-
87
- /**
88
- * Parse request body and populate responseXML if response-type is xml
89
- * Based on the standard specification : http://www.w3.org/TR/XMLHttpRequest/
90
- */
91
- populateResponseXML: function() {
92
- var type = this.getResponseHeader("content-type")
93
- if (!type || !this.responseText || !type.match(/(text\/xml|application\/xml|\+xml$)/g))
94
- return
95
- this.responseXML = JSpec.parseXML(this.responseText)
96
- }
97
- }
98
-
99
- // --- Response status codes
100
-
101
- JSpec.statusCodes = {
102
- 100: 'Continue',
103
- 101: 'Switching Protocols',
104
- 200: 'OK',
105
- 201: 'Created',
106
- 202: 'Accepted',
107
- 203: 'Non-Authoritative Information',
108
- 204: 'No Content',
109
- 205: 'Reset Content',
110
- 206: 'Partial Content',
111
- 300: 'Multiple Choice',
112
- 301: 'Moved Permanently',
113
- 302: 'Found',
114
- 303: 'See Other',
115
- 304: 'Not Modified',
116
- 305: 'Use Proxy',
117
- 307: 'Temporary Redirect',
118
- 400: 'Bad Request',
119
- 401: 'Unauthorized',
120
- 402: 'Payment Required',
121
- 403: 'Forbidden',
122
- 404: 'Not Found',
123
- 405: 'Method Not Allowed',
124
- 406: 'Not Acceptable',
125
- 407: 'Proxy Authentication Required',
126
- 408: 'Request Timeout',
127
- 409: 'Conflict',
128
- 410: 'Gone',
129
- 411: 'Length Required',
130
- 412: 'Precondition Failed',
131
- 413: 'Request Entity Too Large',
132
- 414: 'Request-URI Too Long',
133
- 415: 'Unsupported Media Type',
134
- 416: 'Requested Range Not Satisfiable',
135
- 417: 'Expectation Failed',
136
- 422: 'Unprocessable Entity',
137
- 500: 'Internal Server Error',
138
- 501: 'Not Implemented',
139
- 502: 'Bad Gateway',
140
- 503: 'Service Unavailable',
141
- 504: 'Gateway Timeout',
142
- 505: 'HTTP Version Not Supported'
143
- }
144
-
145
- /**
146
- * Mock XMLHttpRequest requests.
147
- *
148
- * mockRequest().and_return('some data', 'text/plain', 200, { 'X-SomeHeader' : 'somevalue' })
149
- *
150
- * @return {hash}
151
- * @api public
152
- */
153
-
154
- function mockRequest() {
155
- return { and_return : function(body, type, status, headers) {
156
- XMLHttpRequest = MockXMLHttpRequest
157
- ActiveXObject = false
158
- status = status || 200
159
- headers = headers || {}
160
- headers['content-type'] = type
161
- JSpec.extend(XMLHttpRequest.prototype, {
162
- responseText: body,
163
- responseHeaders: headers,
164
- status: status,
165
- statusText: JSpec.statusCodes[status]
166
- })
167
- }}
168
- }
169
-
170
- /**
171
- * Unmock XMLHttpRequest requests.
172
- *
173
- * @api public
174
- */
175
-
176
- function unmockRequest() {
177
- XMLHttpRequest = OriginalXMLHttpRequest
178
- ActiveXObject = OriginalActiveXObject
179
- }
180
-
181
- JSpec.include({
182
- name: 'Mock XHR',
183
-
184
- // --- Utilities
185
-
186
- utilities : {
187
- mockRequest: mockRequest,
188
- unmockRequest: unmockRequest
189
- },
190
-
191
- // --- Hooks
192
-
193
- afterSpec : function() {
194
- unmockRequest()
195
- },
196
-
197
- // --- DSLs
198
-
199
- DSLs : {
200
- snake : {
201
- mock_request: mockRequest,
202
- unmock_request: unmockRequest,
203
- last_request: function(){ return lastRequest() }
204
- }
205
- }
206
-
207
- })
208
- })()
package/spec/node.js DELETED
@@ -1,9 +0,0 @@
1
-
2
- require.paths.unshift('spec', './spec/lib', 'lib')
3
- require('jspec')
4
- yaml = require('yaml')
5
-
6
- JSpec
7
- .exec('spec/spec.core.js')
8
- .run({ reporter: JSpec.reporters.Terminal, fixturePath: 'spec/fixtures', failuresOnly: true })
9
- .report()
package/spec/spec.core.js DELETED
@@ -1,222 +0,0 @@
1
-
2
- describe 'yaml'
3
- before
4
- assert = function(path, expected) {
5
- yaml.eval(fixture(path + '.yml')).should.eql expected
6
- }
7
- end
8
-
9
- describe '.version'
10
- it 'should be a triplet'
11
- yaml.version.should.match(/^\d+\.\d+\.\d+$/)
12
- end
13
- end
14
-
15
- describe 'lexer'
16
- describe 'indentation'
17
- it 'should work'
18
- var tokens = yaml.tokenize('\n 1\n 2\n 3\n 4\n')
19
- tokens[0][0].should.eql 'indent'
20
- tokens[1][0].should.eql 'int'
21
- tokens[2][0].should.eql 'int'
22
- tokens[3][0].should.eql 'indent'
23
- tokens[4][0].should.eql 'int'
24
- tokens[5][0].should.eql 'indent'
25
- tokens[6][0].should.eql 'int'
26
- tokens[7][0].should.eql 'dedent'
27
- tokens[8][0].should.eql 'dedent'
28
- tokens[9][0].should.eql 'dedent'
29
- end
30
- end
31
- end
32
-
33
- describe 'int'
34
- it 'should convert to a number'
35
- yaml.eval('1').should.equal 1
36
- end
37
- end
38
-
39
- describe 'float'
40
- it 'should convert to a number'
41
- yaml.eval('1.5').should.equal 1.5
42
- end
43
- end
44
-
45
- describe '"string"'
46
- it 'should convert to a string'
47
- yaml.eval('"foo"').should.eql 'foo'
48
- yaml.eval("'foo'").should.eql 'foo'
49
- end
50
- end
51
-
52
- describe 'bools'
53
- describe 'true'
54
- it 'true'
55
- yaml.eval('true').should.equal true
56
- end
57
-
58
- it 'yes'
59
- yaml.eval('yes').should.equal true
60
- end
61
-
62
- it 'on'
63
- yaml.eval('on').should.equal true
64
- end
65
-
66
- it 'enabled'
67
- yaml.eval('enabled').should.equal true
68
- end
69
- end
70
-
71
- describe 'false'
72
- it 'false'
73
- yaml.eval('false').should.equal false
74
- end
75
-
76
- it 'no'
77
- yaml.eval('no').should.equal false
78
- end
79
-
80
- it 'off'
81
- yaml.eval('off').should.equal false
82
- end
83
-
84
- it 'disabled'
85
- yaml.eval('disabled').should.equal false
86
- end
87
- end
88
- end
89
-
90
- describe 'indentation'
91
- describe 'when invalid'
92
- it 'should throw an error'
93
- -{ yaml.eval(fixture('list.invalid.yml')) }.should.throw_error 'invalid indentation, got 3 instead of 2'
94
- end
95
- end
96
- end
97
-
98
- describe 'comments'
99
- it 'should work'
100
- assert('comments', [1,2,3])
101
- end
102
- end
103
-
104
- describe 'list'
105
- it 'should work'
106
- assert('list', [1,2,3])
107
- end
108
-
109
- it 'should work with arbitrary text'
110
- assert('hash.text', {
111
- user: {
112
- name: 'tj',
113
- date: '1987-05-25',
114
- position: 'web developer and ceo of Vision Media'
115
- }
116
- })
117
- end
118
-
119
- describe 'inline'
120
- it 'should work'
121
- assert('list.inline', ['tj', 23])
122
- end
123
-
124
- it 'should work when empty'
125
- yaml.eval('[]').should.eql []
126
- end
127
-
128
- it 'should fail when comma is missing'
129
- -{ assert('list.inline.invalid') }.should.throw_error 'expected comma, near "1]"'
130
- end
131
- end
132
-
133
- describe 'with nested hash'
134
- it 'should work'
135
- assert('list.hash', [{ name: 'tj' }, { name: 'simon' }])
136
- end
137
- end
138
-
139
- describe 'with nested list'
140
- it 'should work'
141
- assert('list.list', [[1,2,3,[4,5]]])
142
- end
143
- end
144
-
145
- describe 'with nested lists'
146
- it 'should work'
147
- assert('list.lists', [1, [2, [3]], 4])
148
- end
149
- end
150
- end
151
-
152
- describe 'hash'
153
- it 'should work'
154
- assert('hash', { a: 1, b: 2 })
155
- end
156
-
157
- describe 'keys'
158
- it 'should allow words'
159
- yaml.eval('foo: "bar"').should.eql { foo: 'bar' }
160
- end
161
-
162
- it 'should allow underscores'
163
- yaml.eval('user_name: "tj"').should.eql { user_name: 'tj' }
164
- end
165
-
166
- it 'should allow spaces'
167
- yaml.eval('user name: "tj"').should.eql { 'user name': 'tj' }
168
- end
169
- end
170
-
171
- describe 'inline'
172
- it 'should work'
173
- assert('hash.inline', { name: 'tj', email: 'tj@vision-media.ca' })
174
- end
175
-
176
- it 'should ignore whitespace'
177
- assert('hash.inline.whitespace', { tj: { name: 'tj', age: 23 }})
178
- end
179
-
180
- it 'should work when empty'
181
- yaml.eval('{}').should.eql {}
182
- end
183
-
184
- describe 'keys'
185
- it 'should allow words'
186
- yaml.eval('{ foo: "bar" }').should.eql { foo: 'bar' }
187
- end
188
-
189
- it 'should allow underscores'
190
- yaml.eval('{ user_name: "tj" }').should.eql { user_name: 'tj' }
191
- end
192
-
193
- it 'should allow spaces'
194
- yaml.eval('{ user name: "tj" }').should.eql { 'user name': 'tj' }
195
- end
196
- end
197
-
198
- it 'should fail when comma is missing'
199
- -{ assert('hash.inline.invalid') }.should.throw_error(/expected comma, near "email: /)
200
- end
201
- end
202
-
203
- describe 'with nested list'
204
- it 'should work'
205
- assert('hash.list', { pets: ['niko', 'simon'] })
206
- end
207
- end
208
-
209
- describe 'with nested hash'
210
- it 'should work'
211
- assert('hash.hash', { pets: { niko: 2, simon: 14 }, birthMonths: { niko: "May", simon: "June" }})
212
- end
213
- end
214
- end
215
-
216
- describe 'documents'
217
- it 'should work'
218
- assert('document', [1,2,3])
219
- end
220
- end
221
-
222
- end