checker 0.0.1 → 0.7.0

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.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +13 -0
  5. data/CHANGELOG +103 -0
  6. data/Gemfile +3 -0
  7. data/Gemfile.lock +64 -0
  8. data/LICENCE +21 -0
  9. data/README.md +142 -0
  10. data/Rakefile +4 -0
  11. data/bin/checker +1 -0
  12. data/checker.gemspec +11 -4
  13. data/lib/checker.rb +28 -3
  14. data/lib/checker/cli.rb +88 -4
  15. data/lib/checker/core_ext.rb +25 -2
  16. data/lib/checker/helper.rb +20 -0
  17. data/lib/checker/installator.rb +65 -0
  18. data/lib/checker/modules/base.rb +224 -0
  19. data/lib/checker/modules/coffeescript.rb +22 -0
  20. data/lib/checker/modules/conflict.rb +20 -0
  21. data/lib/checker/modules/console_log.rb +20 -0
  22. data/lib/checker/modules/haml.rb +12 -14
  23. data/lib/checker/modules/javascript.rb +32 -0
  24. data/lib/checker/modules/pry.rb +20 -0
  25. data/lib/checker/modules/rubocop.rb +17 -0
  26. data/lib/checker/modules/ruby.rb +5 -21
  27. data/lib/checker/modules/sass.rb +80 -0
  28. data/lib/checker/modules/slim.rb +21 -0
  29. data/lib/checker/modules/yaml.rb +19 -0
  30. data/lib/checker/options.rb +22 -0
  31. data/lib/checker/result.rb +21 -0
  32. data/lib/checker/results/console_log.rb +13 -0
  33. data/lib/checker/results/default.rb +13 -0
  34. data/lib/checker/results/javascript.rb +24 -0
  35. data/lib/checker/results/rubocop.rb +6 -0
  36. data/lib/checker/rvm.rb +16 -0
  37. data/lib/checker/version.rb +3 -0
  38. data/spec/assets/stylesheets/empty +0 -0
  39. data/spec/checker/cli_spec.rb +37 -0
  40. data/spec/checker/fixtures/conflict/with_conflict.rb +5 -0
  41. data/spec/checker/fixtures/conflict/without_conflict.rb +2 -0
  42. data/spec/checker/fixtures/console_log/with_console_log.js +3 -0
  43. data/spec/checker/fixtures/console_log/without_console_log.js +2 -0
  44. data/spec/checker/fixtures/pry/with_both.rb +4 -0
  45. data/spec/checker/fixtures/pry/with_pry.rb +3 -0
  46. data/spec/checker/fixtures/pry/with_pry_remote.rb +3 -0
  47. data/spec/checker/fixtures/pry/without_pry.rb +2 -0
  48. data/spec/checker/fixtures/ruby/bad.rb +2 -0
  49. data/spec/checker/fixtures/ruby/good.rb +3 -0
  50. data/spec/checker/fixtures/yaml/bad.yaml +18 -0
  51. data/spec/checker/fixtures/yaml/good.yaml +18 -0
  52. data/spec/checker/modules/base_spec.rb +53 -0
  53. data/spec/checker/modules/coffeescript_spec.rb +16 -0
  54. data/spec/checker/modules/conflict_spec.rb +23 -0
  55. data/spec/checker/modules/console_log_spec.rb +49 -0
  56. data/spec/checker/modules/haml_spec.rb +18 -0
  57. data/spec/checker/modules/javascript_spec.rb +69 -0
  58. data/spec/checker/modules/pry_spec.rb +35 -0
  59. data/spec/checker/modules/ruby_spec.rb +26 -0
  60. data/spec/checker/modules/sass_spec.rb +101 -0
  61. data/spec/checker/modules/slim_spec.rb +18 -0
  62. data/spec/checker/modules/yaml_spec.rb +27 -0
  63. data/spec/spec_helper.rb +27 -0
  64. data/templates/checker-prepare-commit-msg +15 -0
  65. metadata +125 -15
  66. data/README +0 -4
  67. data/lib/checker/cli/execute.rb +0 -61
  68. data/lib/checker/modules/all.rb +0 -16
  69. data/lib/checker/utils.rb +0 -48
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 894360b4c4709d62126e69e0b01358ab2e9804a1
4
+ data.tar.gz: f0e0e368a70349ada13d3ee4d76135b4040a44ee
5
+ SHA512:
6
+ metadata.gz: cb79267069194530f065c9d344566ef1b28659dfd1b3d6cf454f3b75371141d1df1ff754dc14096b5d0746f870c161145a1da74c7cee88fd99d72f4dd8645f15
7
+ data.tar.gz: ee42f4ce711ca0882ba7542b760d38d2f1e28c9264f30647af22ae809fd0a77157ebb9f6d80ea1b5273cfe7537aeed7c735e5f9e44889d9c464e92387d4e0b55
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ coverage/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color --order rand
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.0
7
+ - 2.2.0
8
+ notifications:
9
+ email:
10
+ recipients:
11
+ - jacek.jakubik@netguru.pl
12
+ - tomasz.pewinski@netguru.pl
13
+
data/CHANGELOG ADDED
@@ -0,0 +1,103 @@
1
+ === version 0.7.0 (released 2015-03-02)
2
+
3
+ * support for ruby 1.8 and ree is now gone
4
+ * added rubocop module
5
+ * some minor changes
6
+
7
+ === version 0.6.6 (released 2013-06-03)
8
+
9
+ * you can now check all files inside specific directory
10
+ * faster checks for binding.pry / console.log / conflict
11
+ * sass check will use rails runner only if @import found in sass file
12
+ * fix bug with no executable found
13
+ * new fancy output
14
+
15
+ === version 0.6.5.rc2 (released 2013-02-23)
16
+
17
+ * works with rbenv
18
+
19
+ === version 0.6.5.rc1 (released 2013-02-21)
20
+
21
+ * release candidate version because of quite much changes
22
+
23
+ KNOWN ISSUES
24
+ * might not work with rbenv
25
+
26
+ CHANGES
27
+ * new state: warning. it is using by couple of checks (console.log, javascript)
28
+ * added two more options: commit-on-warning and rails-for-sass (see readme for docs)
29
+ * added check for console.log existance - returns warning if found
30
+ * added reinstall script for git hook
31
+ * updated sass check to use rails runner if project is using asset-pipeline
32
+ * fixed bug when checker was running from system ruby version from git hook, not current rvm one
33
+ (checker reinstall required)
34
+
35
+ === version 0.6.4 (released 2012-09-24)
36
+
37
+ * fix a prepare-commit-msg hook so it won't destroy line endings in the commit message
38
+
39
+ === version 0.6.3 (released 2012-09-19)
40
+
41
+ * installation script
42
+ * fix two issues (#14, #15)
43
+ * new module: detecting commiting git conflicts
44
+ * added a debug mode
45
+ * added help (command: checker help)
46
+
47
+ === version 0.6.2 (released 2012-08-30)
48
+
49
+ * quick fix for rbenv users
50
+
51
+ === version 0.6.1 (released 2012-08-29)
52
+
53
+ * changed the version numbering
54
+ * fixed rvm looking at wrong gemset if set (issue #9)
55
+
56
+ === version 0.0.6 (released 2012-08-28)
57
+
58
+ * better support for rvm users
59
+ * adding slim support (thanks to Filip Skokan)
60
+ * better check for files which are staged and modified
61
+ * cleanups, speed and refactor
62
+
63
+ === version 0.0.5 (released 2012-07-09)
64
+
65
+ * depencendy message - if executable not found,
66
+ then proper message is displayed
67
+ where to fetch executable for module
68
+ * fix ruby module, it should check only .rb files now
69
+ * adding javascript checker using jsl (thx to Tomasz "pewniak747" Pewiński)
70
+
71
+ === version 0.0.4.2 (released 2012-07-09)
72
+
73
+ * another fix (i hope last one) - pry checking all files, not only .rb
74
+
75
+ === version 0.0.4.1 (released 2012-07-09)
76
+
77
+ * some refactoring (thx again Tomasz Pewiński)
78
+ * fix haml (--check is needed)
79
+
80
+ === version 0.0.4 (released 2012-07-09)
81
+
82
+ * added colors
83
+ * fix for sass
84
+ * should work on rbenv rbenv (thx Tomasz Pewiński)
85
+
86
+ === version 0.0.3 (released 2012-06-07)
87
+
88
+ * fix for ruby checker
89
+ * added coffeescript checker
90
+ * added sass checker
91
+
92
+ === version 0.0.2 (released 2012-04-20)
93
+
94
+ * added ruby checker
95
+ * added pry checker
96
+ * all checker - checks all checkers
97
+ * git config for selecting checkers
98
+
99
+
100
+ === version 0.0.1 (released 2012-04-03)
101
+
102
+ * initial version
103
+ * haml checker
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ checker (0.6.6)
5
+ colorize (~> 0.7.0)
6
+ rubocop (~> 0.28.0)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ ast (2.0.0)
12
+ astrolabe (1.3.0)
13
+ parser (>= 2.2.0.pre.3, < 3.0)
14
+ colorize (0.7.5)
15
+ coveralls (0.7.11)
16
+ multi_json (~> 1.10)
17
+ rest-client (>= 1.6.8, < 2)
18
+ simplecov (~> 0.9.1)
19
+ term-ansicolor (~> 1.3)
20
+ thor (~> 0.19.1)
21
+ diff-lcs (1.1.3)
22
+ docile (1.1.5)
23
+ mime-types (2.4.3)
24
+ multi_json (1.10.1)
25
+ netrc (0.10.3)
26
+ parser (2.2.0.3)
27
+ ast (>= 1.1, < 3.0)
28
+ powerpack (0.0.9)
29
+ rainbow (2.0.0)
30
+ rest-client (1.7.3)
31
+ mime-types (>= 1.16, < 3.0)
32
+ netrc (~> 0.7)
33
+ rspec (2.11.0)
34
+ rspec-core (~> 2.11.0)
35
+ rspec-expectations (~> 2.11.0)
36
+ rspec-mocks (~> 2.11.0)
37
+ rspec-core (2.11.0)
38
+ rspec-expectations (2.11.1)
39
+ diff-lcs (~> 1.1.3)
40
+ rspec-mocks (2.11.1)
41
+ rubocop (0.28.0)
42
+ astrolabe (~> 1.3)
43
+ parser (>= 2.2.0.pre.7, < 3.0)
44
+ powerpack (~> 0.0.6)
45
+ rainbow (>= 1.99.1, < 3.0)
46
+ ruby-progressbar (~> 1.4)
47
+ ruby-progressbar (1.7.1)
48
+ simplecov (0.9.2)
49
+ docile (~> 1.1.0)
50
+ multi_json (~> 1.0)
51
+ simplecov-html (~> 0.9.0)
52
+ simplecov-html (0.9.0)
53
+ term-ansicolor (1.3.0)
54
+ tins (~> 1.0)
55
+ thor (0.19.1)
56
+ tins (1.3.4)
57
+
58
+ PLATFORMS
59
+ ruby
60
+
61
+ DEPENDENCIES
62
+ checker!
63
+ coveralls
64
+ rspec
data/LICENCE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 netguru
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # Checker
2
+ [![Build Status](https://secure.travis-ci.org/netguru/checker.png?branch=master)](http://travis-ci.org/netguru/checker)
3
+ [![Coverage Status](https://coveralls.io/repos/netguru/checker/badge.png?branch=master)](https://coveralls.io/r/netguru/checker)
4
+ [![Code Climate](https://codeclimate.com/github/netguru/checker.png)](https://codeclimate.com/github/netguru/checker)
5
+ [![Gem Version](https://badge.fury.io/rb/checker.png)](http://badge.fury.io/rb/checker)
6
+
7
+ A collection of modules for which every is designed to check syntax in files to be commited via git.
8
+
9
+ ## Compatibility
10
+
11
+ Checker works with rubies 1.9.2, 1.9.3 and 2.x.
12
+ As for Rails with SASS - tested with RoR 3.2.x
13
+
14
+ ## Usage
15
+
16
+ ### Install
17
+ Checker is available in rubygems (current stable version is 0.7.0), so you just need to do:
18
+ ```
19
+ gem install checker
20
+ ```
21
+
22
+ If you are using bundler, you can add it to your project via `Gemfile` file (best to put it under `:development` group).
23
+ Since checker is a command-line utility, there is no need to load it up in the application:
24
+ ```ruby
25
+ group :development do
26
+ gem 'checker', :require => false
27
+ end
28
+ ```
29
+
30
+ After installing the gem please follow [Git hook](#git-hook) section for further details.
31
+
32
+ ### Git hook
33
+
34
+ All you need to do is type in `checker install` and it will automatically install the prepare-commit-msg hook
35
+ to your current git project. It will look something like this:
36
+
37
+ ```
38
+ #!/bin/bash
39
+
40
+ #### Begin of checker script
41
+ if [ -f /Users/user/.rvm/bin/rvm-shell ]; then
42
+ /Users/user/.rvm/bin/rvm-shell 'ruby-1.9.3-p286' -c 'checker'
43
+ else
44
+ checker
45
+ fi
46
+
47
+ if [ $? = 1 ]; then
48
+ exit 1
49
+ fi
50
+
51
+ text=`echo -n ':ok: '; cat $1`
52
+ echo "$text" > $1
53
+ #### End of checker script
54
+ ```
55
+
56
+ If you don't want your commits be prepended by checkered flag you can remove two last lines from the prepare-commit-msg hook.
57
+
58
+ Now checker will halt the commit if it finds problem with source code. Couple examples:
59
+
60
+ #### pry
61
+ ```
62
+ [ PRY - 1 files ]
63
+ Checking app/models/user.rb... [FAIL]
64
+ 46:binding.pry
65
+ ```
66
+
67
+ #### conflict
68
+ ```
69
+ [ CONFLICT - 1 files ]
70
+ Checking a.bad.scss... [FAIL]
71
+ 4:<<<<<<< Updated upstream
72
+ 30:>>>>>>> Stashed changes
73
+ ```
74
+
75
+ #### sass
76
+ ```
77
+ [ SASS - 1 files ]
78
+ Checking a.bad.scss... [FAIL]
79
+ Syntax error: Invalid CSS after "qwe:": expected pseudoclass or pseudoelement, was "asd:"
80
+ on line 1 of .checker-cache/3cc74408b797b92e79207a64d97ae429
81
+ Use --trace for backtrace.
82
+ ```
83
+
84
+ ### Advanced usage
85
+
86
+ You can specify checker behaviour for your project by changing the git config for checker.
87
+ Available options are:
88
+
89
+ * check
90
+
91
+ List of modules, seperated by comma, which checker will use. Defaults to all modules.
92
+ Example: `git config checker.check 'ruby, haml, coffeescript'`
93
+
94
+ * commit-on-warning
95
+
96
+ Boolean value. If given false, checker will not commit when any module returns warning.
97
+ Defaults to true.
98
+ Example: `git config checker.commit-on-warning 'false'`
99
+
100
+ * rails-for-sass
101
+
102
+ Boolean value. Will use rails runner to check for sass syntax using sprockets.
103
+ Works work rails >= 3.1. Defaults to true.
104
+ Example: `git config checker.rails-for-sass 'true'`
105
+
106
+
107
+ ### Available modules
108
+
109
+ #### ruby
110
+ Checks for correct syntax in ruby (.rb) files
111
+
112
+ #### haml
113
+ Checks for correct syntax in haml files
114
+
115
+ #### pry
116
+ Checks for any occurence of `binding.pry` or `binding.remote_pry`
117
+
118
+ #### coffeescript
119
+ Checks for correct syntax in coffeescript (.coffee) files
120
+
121
+ #### sass
122
+ Checks for correct syntax in sass and scss files
123
+
124
+ #### slim
125
+ Checks for correct syntax in slim files
126
+
127
+ #### conflict
128
+ Checks for any occurence of git conflicts when merging (looks for `<<<<<<< ` or `>>>>>>> `)
129
+
130
+ #### rubocop
131
+ Checks for if code follows the style guides ( https://github.com/bbatsov/rubocop )
132
+
133
+ ### Dependencies
134
+
135
+ For various modules to work you may need to install additional dependencies:
136
+
137
+ * coffeescript - `npm install -g coffee-script` - see https://github.com/jashkenas/coffee-script/
138
+ * javascript - install jsl binary - see http://www.javascriptlint.com/download.htm
139
+ * haml & sass & slim - `gem install haml sass slim`
140
+ * rubocop - `gem install rubocop`
141
+
142
+ Copyright (c) 2015 Netguru. See LICENSE for further details.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'rspec/core/rake_task'
2
+ RSpec::Core::RakeTask.new(:spec)
3
+
4
+ task :default => :spec
data/bin/checker CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
2
3
 
3
4
  require 'checker/cli'
4
5
  Checker::CLI.execute
data/checker.gemspec CHANGED
@@ -1,13 +1,20 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require File.expand_path('../lib/checker/version', __FILE__)
3
+
1
4
  Gem::Specification.new do |s|
2
5
  s.name = 'checker'
3
- s.version = '0.0.1'
4
- s.date = '2012-04-03'
6
+ s.version = Checker::VERSION
7
+ s.date = '2015-03-02'
5
8
  s.summary = "Syntax checker for various files"
6
9
  s.description = "A collection of modules which every is designed to check syntax for specific files."
7
- s.authors = ["Jacek Jakubik"]
8
- s.email = 'jacek.jakubik@netguru.pl'
10
+ s.authors = ["Jacek Jakubik", "Tomasz Pewiński"]
11
+ s.email = ['jacek.jakubik@netguru.pl', 'tomasz.pewinski@netguru.pl']
9
12
  s.files = `git ls-files`.split("\n")
10
13
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
11
14
  s.require_paths = ["lib"]
12
15
  s.homepage = 'http://github.com/netguru/checker'
16
+ s.add_dependency 'colorize', '~> 0.7.0'
17
+ s.add_dependency 'rubocop', '~> 0.28.0'
18
+ s.add_development_dependency 'coveralls'
19
+ s.add_development_dependency 'rspec'
13
20
  end
data/lib/checker.rb CHANGED
@@ -1,7 +1,32 @@
1
+ require 'colorize'
2
+ require 'digest/md5'
3
+ require 'erb'
4
+
1
5
  require 'checker/core_ext'
6
+ require 'checker/rvm'
7
+ require 'checker/version'
8
+ require 'checker/installator'
9
+ require 'checker/helper'
10
+ require 'checker/options'
11
+ require 'checker/result'
12
+
13
+ %w[base ruby haml slim pry coffeescript javascript sass yaml conflict console_log rubocop].each do |mod|
14
+ require "checker/modules/#{mod}"
15
+ end
16
+
17
+ %w[default console_log javascript rubocop].each do |res|
18
+ require "checker/results/#{res}"
19
+ end
20
+
21
+ def debug_mode?
22
+ ENV['CHECKER_DEBUG'].to_s == "1"
23
+ end
2
24
 
25
+ if debug_mode?
26
+ puts "Running checker with debug mode!".colorize(:yellow)
27
+ end
3
28
 
4
- require "checker/modules/all"
5
- require "checker/modules/ruby"
6
- require "checker/modules/haml"
29
+ def debug(msg)
30
+ puts "[DEBUG] - #{msg}".colorize(:yellow) if debug_mode?
31
+ end
7
32