Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

osteele-jcon

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

osteele-jcon

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= JCon -- JavaScript Type Conformance Checking

JCON (the "JavaScript Conformance" gem), is a companion to JSON. It tests JSON values against ECMAScript 4.0-style type definitions (PDF[http://www.ecmascript.org/es4/spec/overview.pdf]), such as string?, (int, boolean), or [string, (int, boolean), {x:double, y:double}?].

JCON also defines an RSpec matcher, conforms_to_js.

Use JCON together with the {JavaScript Fu Rails plugin}[http://osteele.com/archives/2008/04/javascript-fu-rails-plugin] to test the argument values in generated JavaScript function calls.

== Install

gem install rcon

== Usage

type = JCON::parse "[string, int]" type.contains?(['a', 1]) # => true type.contains?(['a', 'b']) # => false type.contains?(['a', 1, 2]) # => true

type = JCON::parse "type S = (string, int); {a: [S], b: int}" type.contains?({:a => [1, 'b'], :b => 2}) # => true

== RSpec Matcher

[1, 'xyzzy'].should conform_to_js('[int, string]') [1, 2, 'xyzzy'].should_not conform_to_js('[int, string]') {:x => 1}.should conform_to_js('{x: int}')

Use this with the {JavaScript Fu Rails plugin}[http://osteele.com/archives/2008/04/javascript-fu-rails-plugin] to test JSON arguments:

''.should call_js('fn') do |args| args[0].should conform_to_js('string') args[1].should conform_to_js('{x:int, y:int}') args[2].should conform_to_js('boolean') # or: args.should conform_to_js('[string, {x:int, y:int}, boolean]') end

== License

Copyright 2008 by {Oliver Steele}[http://workingwithrails.com/person/12359-oliver-steele]. All rights reserved. Released under the MIT License.

FAQs

Package last updated on 10 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc