osteele-jcon 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +21 -0
- data/README.rdoc +46 -0
- data/TODO +26 -0
- metadata +64 -0
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2008 Oliver Steele
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
= JCon -- JavaScript Type Conformance Checking
|
2
|
+
|
3
|
+
JCON (the "JavaScript Conformance" gem), is a companion to JSON. It
|
4
|
+
tests JSON values against ECMAScript 4.0-style type definitions
|
5
|
+
(PDF[http://www.ecmascript.org/es4/spec/overview.pdf]), such as
|
6
|
+
<code>string?</code>, <code>(int, boolean)</code>, or <code>[string, (int, boolean), {x:double, y:double}?]</code>.
|
7
|
+
|
8
|
+
JCON also defines an RSpec matcher, <code>conforms_to_js</code>.
|
9
|
+
|
10
|
+
Use JCON together with the {JavaScript
|
11
|
+
Fu Rails plugin}[http://osteele.com/archives/2008/04/javascript-fu-rails-plugin] to test the argument values in generated JavaScript function calls.
|
12
|
+
|
13
|
+
|
14
|
+
== Install
|
15
|
+
|
16
|
+
gem install rcon
|
17
|
+
|
18
|
+
== Usage
|
19
|
+
|
20
|
+
type = JCON::parse "[string, int]"
|
21
|
+
type.contains?(['a', 1]) # => true
|
22
|
+
type.contains?(['a', 'b']) # => false
|
23
|
+
type.contains?(['a', 1, 2]) # => true
|
24
|
+
|
25
|
+
type = JCON::parse "type S = (string, int); {a: [S], b: int}"
|
26
|
+
type.contains?({:a => [1, 'b'], :b => 2}) # => true
|
27
|
+
|
28
|
+
== RSpec Matcher
|
29
|
+
|
30
|
+
[1, 'xyzzy'].should conform_to_js('[int, string]')
|
31
|
+
[1, 2, 'xyzzy'].should_not conform_to_js('[int, string]')
|
32
|
+
{:x => 1}.should conform_to_js('{x: int}')
|
33
|
+
|
34
|
+
Use this with the {JavaScript Fu Rails plugin}[http://osteele.com/archives/2008/04/javascript-fu-rails-plugin] to test JSON arguments:
|
35
|
+
|
36
|
+
'<script>fn("id", {x:1, y:2}, true)</script>'.should call_js('fn') do |args|
|
37
|
+
args[0].should conform_to_js('string')
|
38
|
+
args[1].should conform_to_js('{x:int, y:int}')
|
39
|
+
args[2].should conform_to_js('boolean')
|
40
|
+
# or:
|
41
|
+
args.should conform_to_js('[string, {x:int, y:int}, boolean]')
|
42
|
+
end
|
43
|
+
|
44
|
+
== License
|
45
|
+
|
46
|
+
Copyright 2008 by {Oliver Steele}[http://workingwithrails.com/person/12359-oliver-steele]. All rights reserved. Released under the MIT License.
|
data/TODO
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
= JCon TODO
|
2
|
+
|
3
|
+
Next:
|
4
|
+
* docs -- add the README
|
5
|
+
* check the spec
|
6
|
+
* add method to display path to mismatch
|
7
|
+
* rename SimpleType
|
8
|
+
|
9
|
+
Error detection:
|
10
|
+
* circular references
|
11
|
+
* duplicate definitions
|
12
|
+
|
13
|
+
Test cases:
|
14
|
+
* recursive types
|
15
|
+
|
16
|
+
Parser:
|
17
|
+
* can property name be string?
|
18
|
+
|
19
|
+
Conformance:
|
20
|
+
* byte
|
21
|
+
|
22
|
+
Future:
|
23
|
+
* function(this:T | T | T= | ... | ...[T]) : T | void
|
24
|
+
* 'class'
|
25
|
+
* js implementation
|
26
|
+
* includes
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: osteele-jcon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Oliver Steele
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-22 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Test JSON values for conformance with ECMAScript 4.0 types.
|
17
|
+
email: steele@osteele.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.rdoc
|
24
|
+
- TODO
|
25
|
+
- LICENSE
|
26
|
+
files:
|
27
|
+
- README.rdoc
|
28
|
+
- TODO
|
29
|
+
- LICENSE
|
30
|
+
has_rdoc: true
|
31
|
+
homepage: http://jcon.rubyforge.org
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options:
|
34
|
+
- --title
|
35
|
+
- "JCON: Test JSON values against a schema"
|
36
|
+
- --main
|
37
|
+
- README
|
38
|
+
- --exclude
|
39
|
+
- spec/.*
|
40
|
+
- --inline-source
|
41
|
+
- --charset=UTF-8
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0"
|
49
|
+
version:
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
requirements: []
|
57
|
+
|
58
|
+
rubyforge_project: jcon
|
59
|
+
rubygems_version: 1.2.0
|
60
|
+
signing_key:
|
61
|
+
specification_version: 2
|
62
|
+
summary: Test JSON values against a schema.
|
63
|
+
test_files: []
|
64
|
+
|