Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

VOS JSON support

  • Loading branch information...
commit aef29e6c3244b080257be08503af200cbfb6dffb 1 parent d46f981
@claylo claylo authored
View
26 Commands/Validate JSON.tmCommand
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>beforeRunningCommand</key>
+ <string>saveActiveFile</string>
+ <key>command</key>
+ <string>#!/usr/bin/env ruby
+require ENV['TM_BUNDLE_SUPPORT'] + "/lib/validate_on_save"
+VOS::Validate.json</string>
+ <key>fallbackInput</key>
+ <string>scope</string>
+ <key>input</key>
+ <string>document</string>
+ <key>keyEquivalent</key>
+ <string>@s</string>
+ <key>name</key>
+ <string>Validate JSON</string>
+ <key>output</key>
+ <string>showAsTooltip</string>
+ <key>scope</key>
+ <string>source.json</string>
+ <key>uuid</key>
+ <string>5A6C8946-B6E1-42B0-B52E-E20602FBC3F0</string>
+</dict>
+</plist>
View
8 README.md
@@ -29,6 +29,7 @@ Supported Languages
* Python (using PyFlakes)
* Ruby
* Sass/Compass (still a bit buggy)
+ * JSON
Installation
@@ -80,6 +81,9 @@ These options are used to specify the full path to the executable binaries for t
If `TM_COMPASS` is set to "false", validation is done using the standard Sass binary.
+### Regarding `env: ... No such file or directory`
+
+If you haven't already done so, make sure your TextMate `PATH` shell variable includes `/usr/local/bin`.
Updating
--------
@@ -107,6 +111,10 @@ If you're using Compass with Rails it runs `compass --update` on your Rails root
CSS validation is done locally using w3c.org's Jigsaw server. This means it's essentially booting up a java based web server, so it can be relatively slow.
+### JSON Validation
+
+JSON validation is done using `jsonlint`, which is installable through the Node Package manager `npm`. For installation details, see [jsonlint](https://github.com/zaach/jsonlint).
+
Credits
-------
View
3  Support/lib/validate_on_save.rb
@@ -37,7 +37,8 @@ def self.validate
:python => { :is => /source\.python/ },
:erb => { :is => /text\.html\.ruby|text\.html source\.ruby/ },
:ruby => { :is => /source\.ruby/, :not => /source\.ruby\.embedded/|/source\.ruby\.embedded.haml/|/text\.html\.ruby/ },
- :sass => { :is => /source\.sass/ }
+ :sass => { :is => /source\.sass/ },
+ :json => { :is => /source\.json/ }
}
scopes.each do |lang, match|
if scope =~ match[:is] && (!match.has_key?(:not) || !(scope =~ match[:not]))
View
1  Support/lib/validate_on_save/validators.rb
@@ -9,3 +9,4 @@
require "validate_on_save/validators/python"
require "validate_on_save/validators/ruby"
require "validate_on_save/validators/sass"
+require "validate_on_save/validators/json"
View
16 Support/lib/validate_on_save/validators/json.rb
@@ -0,0 +1,16 @@
+class VOS
+ class Validate
+ def self.json
+ filename = ENV['TM_FILENAME']
+ filepath = ENV['TM_FILEPATH']
+ binary = ENV['TM_JSONLINT'] || 'jsonlint'
+ VOS.output({
+ :info => "Running syntax check with jsonlint\n",
+ :result => `"#{binary}" #{filepath} --compact --quiet 2>&1`.gsub("#{filepath}: ", ''),
+ :match_ok => /^$/i,
+ :match_line => /line (\d+)/i,
+ :lang => "JSON"
+ })
+ end
+ end
+end
View
2  info.plist
@@ -11,6 +11,7 @@
<string>33995B55-507A-4F3B-839E-70D0A298DC9E</string>
<string>1F48EAC4-2186-4517-8180-DE8B02D40D2C</string>
<string>079F7B17-51B5-4C09-8577-77D6A0D827F2</string>
+ <string>5A6C8946-B6E1-42B0-B52E-E20602FBC3F0</string>
<string>744087D0-6295-4636-A40F-DAA47438BED1</string>
<string>5C4ABB28-6E89-43BF-8514-1E43CDBB2E22</string>
<string>E1B0ADB9-99C8-4086-8248-70D2495B940D</string>
@@ -34,6 +35,7 @@
<string>33995B55-507A-4F3B-839E-70D0A298DC9E</string>
<string>1F48EAC4-2186-4517-8180-DE8B02D40D2C</string>
<string>079F7B17-51B5-4C09-8577-77D6A0D827F2</string>
+ <string>5A6C8946-B6E1-42B0-B52E-E20602FBC3F0</string>
<string>744087D0-6295-4636-A40F-DAA47438BED1</string>
<string>5C4ABB28-6E89-43BF-8514-1E43CDBB2E22</string>
<string>E1B0ADB9-99C8-4086-8248-70D2495B940D</string>
Please sign in to comment.
Something went wrong with that request. Please try again.