jshintrb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ /.project
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "vendor/jshint"]
2
+ path = vendor/jshint
3
+ url = https://github.com/jshint/jshint.git
data/.travis.yml ADDED
@@ -0,0 +1,22 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - jruby
6
+ before_script: "git submodule update --init --recursive"
7
+ env:
8
+ - EXECJS_RUNTIME=RubyRacer
9
+ - EXECJS_RUNTIME=Mustang
10
+ - EXECJS_RUNTIME=RubyRhino
11
+ matrix:
12
+ exclude:
13
+ - rvm: 1.8.7
14
+ env: EXECJS_RUNTIME=RubyRhino
15
+ - rvm: 1.9.2
16
+ env: EXECJS_RUNTIME=RubyRhino
17
+ - rvm: 1.9.3
18
+ env: EXECJS_RUNTIME=RubyRhino
19
+ - rvm: jruby
20
+ env: EXECJS_RUNTIME=RubyRacer
21
+ - rvm: jruby
22
+ env: EXECJS_RUNTIME=Mustang
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in jshintrb.gemspec
4
+ gemspec
5
+
6
+ # Depend on defined ExecJS runtime
7
+ execjs_runtimes = {
8
+ "RubyRacer" => "therubyracer",
9
+ "RubyRhino" => "therubyrhino",
10
+ "Mustang" => "mustang"
11
+ }
12
+
13
+ if ENV["EXECJS_RUNTIME"] && execjs_runtimes[ENV["EXECJS_RUNTIME"]]
14
+ gem execjs_runtimes[ENV["EXECJS_RUNTIME"]], :group => :development
15
+ end
16
+
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # jshintrb
2
+ [![Build Status](https://secure.travis-ci.org/stereobooster/jshintrb.png?branch=master)](http://travis-ci.org/stereobooster/jshintrb)
3
+
4
+ Ruby wrapper for [JSHint](https://github.com/jshint/jshint/). The main difference from [jshint](https://github.com/liquid/jshint_on_rails) it does not depend on Java. Instead, it uses [ExecJS](https://github.com/sstephenson/execjs).
5
+
6
+ ## Installation
7
+
8
+ jshintrb is available as ruby gem.
9
+
10
+ $ gem install jshintrb
11
+
12
+ Ensure that your environment has a JavaScript interpreter supported by [ExecJS](https://github.com/sstephenson/execjs). Usually, installing therubyracer gem is the best alternative.
13
+
14
+ ## Usage
15
+
16
+ require 'jshintrb'
17
+
18
+ Jshintrb.lint(File.read("source.js"))
19
+ # => array of warnings
20
+
21
+ Jshintrb.report(File.read("source.js"))
22
+ # => string
23
+
24
+ When initializing jshintrb, you can pass options
25
+
26
+ Uglifier.new(:undef => true).compile(source)
27
+
28
+ # Or
29
+ Uglifier.compile(source, :undef => true)
30
+
31
+ Available options and their defaults are
32
+
33
+ {
34
+ :bitwise => true,
35
+ :curly => true,
36
+ :eqeqeq => true,
37
+ :forin => true,
38
+ :immed => true,
39
+ :latedef => true,
40
+ :newcap => true,
41
+ :noarg => true,
42
+ :noempty => true,
43
+ :nonew => true,
44
+ :plusplus => true,
45
+ :regexp => true,
46
+ :undef => true,
47
+ :strict => true,
48
+ :trailing => true,
49
+ :browser => true
50
+ }
51
+
52
+ ## TODO
53
+
54
+ - add rake task which will accept pattern for files
55
+ - add color reporter
56
+ - add more tests
57
+
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ [:build, :install, :release].each do |task_name|
4
+ Rake::Task[task_name].prerequisites << :spec
5
+ end
6
+
7
+ desc "Update git submodules"
8
+ task :git do
9
+ sh "git submodule update --init --recursive"
10
+ cp "vendor/jshint/jshint.js", "lib/js/jshint.js"
11
+ end
12
+
13
+ require "rspec/core/rake_task"
14
+
15
+ desc "Run specs"
16
+ RSpec::Core::RakeTask.new
17
+
18
+ task :default => :spec
19
+
20
+ #desc "Generate code coverage"
21
+ # RSpec::Core::RakeTask.new(:coverage) do |t|
22
+ # t.rcov = true
23
+ # t.rcov_opts = ["--exclude", "spec"]
24
+ # end
data/jshintrb.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "jshintrb/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "jshintrb"
7
+ s.version = Jshintrb::VERSION
8
+ s.authors = ["stereobooster"]
9
+ s.email = ["stereobooster@gmail.com"]
10
+ s.homepage = "https://github.com/stereobooster/jshintrb"
11
+ s.summary = %q{Ruby wrapper for JSHint}
12
+ s.description = %q{Ruby wrapper for JSHint. The main difference from jshint it does not depend on Java. Instead, it uses ExecJS}
13
+
14
+ s.rubyforge_project = "jshintrb"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ s.add_development_dependency "rspec"
23
+ s.add_runtime_dependency "rake"
24
+
25
+ s.add_dependency "multi_json"
26
+ s.add_dependency "execjs"
27
+ end