jsv.rb 0.0.1.pre → 0.0.1.pre2
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.
- data/JSV_LICENSE +28 -0
- data/README +23 -3
- data/lib/jsv/context.rb +13 -0
- data/lib/jsv/environment.rb +1 -1
- data/lib/jsv/version.rb +1 -1
- data/spec/jsv/context_spec.rb +20 -0
- metadata +5 -2
data/JSV_LICENSE
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
This software contains Gary Court's JSV, which is made available under the
|
2
|
+
following license.
|
3
|
+
|
4
|
+
Copyright 2010 Gary Court. All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without modification, are
|
7
|
+
permitted provided that the following conditions are met:
|
8
|
+
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this list of
|
10
|
+
conditions and the following disclaimer.
|
11
|
+
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
13
|
+
of conditions and the following disclaimer in the documentation and/or other materials
|
14
|
+
provided with the distribution.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY GARY COURT ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
17
|
+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARY COURT OR
|
19
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
20
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
21
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
22
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
23
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
24
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
25
|
+
|
26
|
+
The views and conclusions contained in the software and documentation are those of the
|
27
|
+
authors and should not be interpreted as representing official policies, either expressed
|
28
|
+
or implied, of Gary Court or the JSON Schema specification.
|
data/README
CHANGED
@@ -13,17 +13,37 @@ suitable for use in ExecJS. It also contains a Ruby shim for communicating
|
|
13
13
|
with JSV.
|
14
14
|
|
15
15
|
jsv.rb was written at Northwestern University's Biomedical Informatics
|
16
|
-
Center[2] for use in NCS Navigator Cases[3].
|
16
|
+
Center[2] for use in NCS Navigator Cases[3]. It embeds JSV 4.0.2.
|
17
17
|
|
18
|
-
2.
|
18
|
+
2. Usage
|
19
|
+
|
20
|
+
The short version:
|
21
|
+
|
22
|
+
require 'jsv'
|
23
|
+
|
24
|
+
schema = %Q{{"properties":{"foo":{"type":"integer"}}}}
|
25
|
+
|
26
|
+
jsv = JSV::Context.new
|
27
|
+
env = jsv.create_environment
|
28
|
+
report = env.validate('{"foo":"bar"}', schema)
|
29
|
+
|
30
|
+
report.has_errors? # => true
|
31
|
+
report.errors # => a list of errors; see JSV's documentation for
|
32
|
+
# error object structure
|
33
|
+
|
34
|
+
See USAGE for more details.
|
35
|
+
|
36
|
+
3. License
|
19
37
|
|
20
38
|
Copyright (c) 2013 David Yip. Made available under the MIT License; see
|
21
39
|
LICENSE for details.
|
22
40
|
|
23
|
-
|
41
|
+
4. Special thanks
|
24
42
|
|
25
43
|
she, Kap Slap, Starsmith, Neon Indian, Florence + the Machine.
|
26
44
|
|
27
45
|
[1]: https://github.com/garycourt/JSV
|
28
46
|
[2]: http://projects.nubic.northwestern.edu/
|
29
47
|
[3]: https://github.com/NUBIC/ncs_navigator_core
|
48
|
+
|
49
|
+
# vim:ts=2:sw=2:et:tw=78
|
data/lib/jsv/context.rb
CHANGED
@@ -33,5 +33,18 @@ module JSV
|
|
33
33
|
json,
|
34
34
|
schema)
|
35
35
|
end
|
36
|
+
|
37
|
+
# Public: A custom inspect.
|
38
|
+
#
|
39
|
+
# When using the RubyRacer runtime, weak references to Ruby wrappers for
|
40
|
+
# Javascript objects will show up in inspect output. When those wrappers
|
41
|
+
# are GCed, references will break and Object#inspect breaks too.
|
42
|
+
#
|
43
|
+
# This implementation of inspect avoids the problem by not inspecting the
|
44
|
+
# execjs context. (The context still appears to be fully functional after
|
45
|
+
# GC.)
|
46
|
+
def inspect
|
47
|
+
"#<#{self.class.name}:0x#{object_id.to_s(16)}>"
|
48
|
+
end
|
36
49
|
end
|
37
50
|
end
|
data/lib/jsv/environment.rb
CHANGED
data/lib/jsv/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module JSV
|
4
|
+
describe Context do
|
5
|
+
describe '#inspect' do
|
6
|
+
it 'does not raise an error after a GC cycle' do
|
7
|
+
ctx = JSV::Context.new
|
8
|
+
env = ctx.create_environment
|
9
|
+
report = env.validate('{}', '{}')
|
10
|
+
runs_before = GC.count
|
11
|
+
|
12
|
+
until GC.count > runs_before do
|
13
|
+
(1...1000).to_a
|
14
|
+
end
|
15
|
+
|
16
|
+
lambda { ctx.inspect }.should_not raise_error
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsv.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.pre2
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -89,11 +89,13 @@ files:
|
|
89
89
|
- lib/jsv/environment.rb
|
90
90
|
- lib/jsv/report.rb
|
91
91
|
- lib/jsv/version.rb
|
92
|
+
- spec/jsv/context_spec.rb
|
92
93
|
- spec/jsv/environment_spec.rb
|
93
94
|
- spec/spec_helper.rb
|
94
95
|
- js/build/jsv.rb.js
|
95
96
|
- README
|
96
97
|
- LICENSE
|
98
|
+
- JSV_LICENSE
|
97
99
|
homepage: https://github.com/NUBIC/jsv.rb
|
98
100
|
licenses: []
|
99
101
|
post_install_message:
|
@@ -108,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
110
|
version: '0'
|
109
111
|
segments:
|
110
112
|
- 0
|
111
|
-
hash:
|
113
|
+
hash: 2983618420019040952
|
112
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
115
|
none: false
|
114
116
|
requirements:
|
@@ -122,5 +124,6 @@ signing_key:
|
|
122
124
|
specification_version: 3
|
123
125
|
summary: Run JSV in Ruby applications
|
124
126
|
test_files:
|
127
|
+
- spec/jsv/context_spec.rb
|
125
128
|
- spec/jsv/environment_spec.rb
|
126
129
|
- spec/spec_helper.rb
|