checker 0.0.4.2 → 0.0.5

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/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ === version 0.0.5 (released 2012-07-09)
2
+
3
+ * depencendy message - if executable not found,
4
+ then proper message is displayed
5
+ where to fetch executable for module
6
+ * fix ruby module, it should check only .rb files now
7
+ * adding javascript checker using jsl (thx to Tomasz "pewniak747" Pewiński)
8
+
1
9
  === version 0.0.4.2 (released 2012-07-09)
2
10
 
3
11
  * another fix (i hope last one) - pry checking all files, not only .rb
data/README.md CHANGED
@@ -4,18 +4,52 @@ A collection of modules for which every is designed to check syntax in files to
4
4
 
5
5
  ## Usage
6
6
 
7
+ ### Install
8
+ Checker is available in rubygems, so you just need to do:
9
+ ```
10
+ gem install checker
11
+ ```
12
+ If you are using bundler, you can add it to your project via `Gemfile` file (best to put it under `:development` group):
13
+ ```ruby
14
+ group :development do
15
+ gem 'checker'
16
+ end
17
+ ```
18
+
19
+ After installing the gem please follow [Git hook](#git-hook) section for further details.
20
+
7
21
  ### Git hook
8
22
 
9
- To check your source code every time you commit, add to your .git/hooks/pre-commit line:
23
+ #### prepare-commit-msg hook
24
+ If you want every commit be appended with checker approved icon (:checkered_flag:) add to your `.git/hooks/prepare-commit-msg` following:
25
+
26
+ ``` bash
27
+ #!/bin/bash
28
+ checker
29
+
30
+ if [ $? == 1 ]; then
31
+ exit 1
32
+ fi
10
33
 
34
+ echo ":checkered_flag:" >> $1
11
35
  ```
36
+
37
+ #### pre-commit hook
38
+ To just check your source code every time you commit, add to your `.git/hooks/pre-commit` line:
39
+
40
+ ``` bash
41
+ #!/bin/bash
12
42
  checker
13
43
  ```
14
44
 
15
- Don't forget to make the hook file executable:
45
+ Use only either one hook.
46
+
47
+
48
+ Don't forget to make the hooks files executable:
16
49
 
17
50
  ``` bash
18
51
  chmod +x .git/hooks/pre-commit
52
+ chmod +x .git/hooks/prepare-commit-msg
19
53
  ```
20
54
 
21
55
  Now checker will halt the commit if it finds problem with source code:
@@ -31,9 +65,15 @@ FAIL app/models/user.rb found occurence of 'binding.pry'
31
65
  To check only specific filetypes on commit, use `git config` :
32
66
 
33
67
  ``` bash
34
- git config checker.check 'all'
35
-
36
68
  git config checker.check 'ruby, haml, coffeescript'
37
69
  ```
38
70
 
39
- Available options are: all, ruby, haml, pry, coffeescript, sass
71
+ Available options are: ruby, haml, pry, coffeescript, sass
72
+
73
+ ### Dependencies
74
+
75
+ For various modules to work you may need to install additional dependencies:
76
+
77
+ * coffeescript - `npm install -g coffee-script` - see https://github.com/jashkenas/coffee-script/
78
+ * javascript - `npm install -g jshint` - see https://github.com/jshint/node-jshint/#install
79
+ * haml & sass - `gem install haml` `gem install sass`
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'rspec/core/rake_task'
2
+ RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ checker
4
+
5
+ if [ $? == 1 ]; then
6
+ exit 1
7
+ fi
8
+
9
+ echo ":checkered_flag:" >> $1
data/checker.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'checker'
3
- s.version = '0.0.4.2'
4
- s.date = '2012-07-09'
3
+ s.version = '0.0.5'
4
+ s.date = '2012-07-11'
5
5
  s.summary = "Syntax checker for various files"
6
6
  s.description = "A collection of modules which every is designed to check syntax for specific files."
7
7
  s.authors = ["Jacek Jakubik"]
data/lib/checker.rb CHANGED
@@ -7,4 +7,5 @@ require "checker/modules/ruby"
7
7
  require "checker/modules/haml"
8
8
  require "checker/modules/pry"
9
9
  require "checker/modules/coffeescript"
10
+ require "checker/modules/javascript"
10
11
  require "checker/modules/sass"
@@ -20,6 +20,10 @@ module Checker
20
20
  color "[ #{name} ]\n", :light_blue
21
21
  end
22
22
 
23
+ def dependency_message
24
+ "Executable not found, skipping...\n"
25
+ end
26
+
23
27
  def prepare_check
24
28
  @files_to_check = []
25
29
  @results = []
@@ -29,7 +33,7 @@ module Checker
29
33
  if check_for_executable
30
34
  true
31
35
  else
32
- color "executable not found, skipping...\n", :magenta
36
+ color dependency_message, :magenta
33
37
  false
34
38
  end
35
39
  end
@@ -42,7 +46,7 @@ module Checker
42
46
  @files_to_check = self.files
43
47
  if self.class.extensions.any?
44
48
  @files_to_check = @files_to_check.select { |f|
45
- self.class.extensions.map { |ex| f.ends_with?(ex) }.any?
49
+ self.class.extensions.map { |ex| f.ends_with?(".#{ex}") }.any?
46
50
  }
47
51
  end
48
52
  @files_to_check
@@ -100,7 +104,7 @@ module Checker
100
104
  end
101
105
 
102
106
  def color(str, color)
103
- print str.colorize(color)
107
+ print str.colorize(color) if str.length > 0
104
108
  end
105
109
 
106
110
  def name
@@ -10,6 +10,13 @@ module Checker
10
10
  def check_for_executable
11
11
  command('coffee -v', :show_output => false, :append => ">> /dev/null 2>&1")
12
12
  end
13
+
14
+ def dependency_message
15
+ str = "Executable not found\n"
16
+ str << "Install coffeescript from npm: 'npm install -g coffee-script'\n"
17
+ str << "More info: https://github.com/jashkenas/coffee-script/\n"
18
+ str
19
+ end
13
20
  end
14
21
  end
15
22
  end
@@ -6,6 +6,12 @@ module Checker
6
6
  def check_one(file)
7
7
  plain_command("haml --check #{file} >> /dev/null")
8
8
  end
9
+
10
+ def dependency_message
11
+ str = "Executable not found\n"
12
+ str << "Install haml from rubygems: 'gem install haml'\n"
13
+ str
14
+ end
9
15
  end
10
16
  end
11
17
  end
@@ -0,0 +1,30 @@
1
+ module Checker
2
+ module Modules
3
+ class Javascript < Base
4
+ extensions 'js'
5
+ private
6
+ def check_one(file)
7
+ plain_command("jsl -process #{file}")
8
+ end
9
+
10
+ def check_for_executable
11
+ command('jsl -help:conf', :show_output => false, :append => ">> /dev/null 2>&1")
12
+ end
13
+
14
+ def dependency_message
15
+ str = "Executable not found\n"
16
+ str << "Install jsl linter binary\n"
17
+ str << "More info: http://www.javascriptlint.com/download.htm\n"
18
+ str
19
+ end
20
+
21
+ # ignore exit status 1 - warnings
22
+ def plain_command cmd, options={}
23
+ system(cmd)
24
+ exitstatus = $?.exitstatus == 0 || $?.exitstatus == 1
25
+ show_output(exitstatus, options)
26
+ exitstatus
27
+ end
28
+ end
29
+ end
30
+ end
@@ -10,6 +10,13 @@ module Checker
10
10
  def check_for_executable
11
11
  command("sass -v", :use_bundler => true, :show_output => false, :append => ">> /dev/null 2>&1")
12
12
  end
13
+
14
+ def dependency_message
15
+ str = "Executable not found\n"
16
+ str << "Install sass from rubygems: 'gem install sass'\n"
17
+ str << "Sass requires haml to work properly: 'gem install haml'\n"
18
+ str
19
+ end
13
20
  end
14
21
  end
15
22
  end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ module Checker
4
+ module Modules
5
+ class Bogus < Base
6
+ extensions '.test'
7
+ private
8
+ def check_one(file)
9
+ true
10
+ end
11
+
12
+ def check_for_executable
13
+ true
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ describe Checker::CLI do
20
+ before do
21
+ @argv_copy = ARGV
22
+ end
23
+ after do
24
+ ARGV = @argv_copy
25
+ end
26
+
27
+ context "running without arguments" do
28
+ it "should run checks on modules from git config" do
29
+ ARGV.stub(:size).and_return 0
30
+ Checker::CLI.should_receive(:get_modules_to_check).and_return(["bogus"])
31
+ Checker::CLI.should_receive(:exit).with(0).and_return true
32
+ Checker::CLI.execute
33
+ end
34
+ end
35
+
36
+ context "running with argument" do
37
+ it "should run check on modules from argument" do
38
+ ARGV = ["pry"]
39
+ Checker::CLI.should_not_receive(:get_modules_to_check)
40
+ Checker::CLI.should_receive(:exit).with(0).and_return true
41
+ Checker::CLI.execute
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Checker::Modules::Ruby do
4
+ it 'should only check .rb files' do
5
+ files = ['a.rb', 'b.js.erb', 'c.r']
6
+ mod = Checker::Modules::Ruby.new(files)
7
+ mod.stub(:check_one).and_return(true)
8
+ mod.should_receive(:check_one).once
9
+ mod.check
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+
3
+ require 'checker/cli'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.2
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-09 00:00:00.000000000 Z
12
+ date: 2012-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
16
- requirement: &70190454793620 !ruby/object:Gem::Requirement
16
+ requirement: &70291943302500 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
@@ -21,19 +21,22 @@ dependencies:
21
21
  version: 0.5.8
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70190454793620
24
+ version_requirements: *70291943302500
25
25
  description: A collection of modules which every is designed to check syntax for specific
26
26
  files.
27
27
  email: jacek.jakubik@netguru.pl
28
28
  executables:
29
29
  - checker
30
+ - prepare-commit-msg
30
31
  extensions: []
31
32
  extra_rdoc_files: []
32
33
  files:
33
34
  - .gitignore
34
35
  - CHANGELOG
35
36
  - README.md
37
+ - Rakefile
36
38
  - bin/checker
39
+ - bin/prepare-commit-msg
37
40
  - checker.gemspec
38
41
  - lib/checker.rb
39
42
  - lib/checker/cli.rb
@@ -41,9 +44,13 @@ files:
41
44
  - lib/checker/modules/base.rb
42
45
  - lib/checker/modules/coffeescript.rb
43
46
  - lib/checker/modules/haml.rb
47
+ - lib/checker/modules/javascript.rb
44
48
  - lib/checker/modules/pry.rb
45
49
  - lib/checker/modules/ruby.rb
46
50
  - lib/checker/modules/sass.rb
51
+ - spec/checker/cli_spec.rb
52
+ - spec/checker/modules/ruby_spec.rb
53
+ - spec/spec_helper.rb
47
54
  homepage: http://github.com/netguru/checker
48
55
  licenses: []
49
56
  post_install_message: