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
@@ -0,0 +1,101 @@
1
+ require 'spec_helper'
2
+
3
+ describe Checker::Modules::Sass do
4
+ it 'should only check .sass and .scss files' do
5
+ files = ['a.rb', 'b.js.erb', 'c.r', 'd.yml', 'e.yaml', 'f.coffee', 'g.haml', 'h.js', 'i.scss', 'j.sass']
6
+ mod = Checker::Modules::Sass.new(files)
7
+ mod.stub(:check_for_executable).and_return(true)
8
+ mod.stub(:check_one_file).and_return(stub(:success? => true, :status => :ok))
9
+ mod.should_receive(:check_one_file).with('j.sass')
10
+ mod.should_receive(:check_one_file).with('i.scss')
11
+ mod.should_not_receive(:check_one_file).with('h.js')
12
+ mod.should_not_receive(:check_one_file).with('g.haml')
13
+ mod.should_not_receive(:check_one_file).with('f.coffee')
14
+ mod.should_not_receive(:check_one_file).with('e.yaml')
15
+ mod.should_not_receive(:check_one_file).with('d.yml')
16
+ mod.should_not_receive(:check_one_file).with('a.rb')
17
+ mod.should_not_receive(:check_one_file).with('b.js.erb')
18
+ mod.should_not_receive(:check_one_file).with('c.r')
19
+ mod.check
20
+ end
21
+
22
+ context "normal check" do
23
+ before do
24
+ Checker::Options.stub(:use_rails_for_sass).and_return(false)
25
+ end
26
+
27
+ it "gives proper command to sass module while checking .sass files" do
28
+ files = ["a.sass"]
29
+ mod = Checker::Modules::Sass.new(files)
30
+ mod.stub(:check_for_executable).and_return(true)
31
+ mod.should_receive(:plain_command).with("sass -c .checker-cache/69cb154f5eeff19216d2879872ba6569").and_return(0)
32
+ mod.check
33
+ end
34
+
35
+ it "gives proper command to sass module while checking .scss files" do
36
+ files = ["a.scss"]
37
+ mod = Checker::Modules::Sass.new(files)
38
+ mod.stub(:check_for_executable).and_return(true)
39
+ mod.should_receive(:plain_command).with("sass --scss -c .checker-cache/13dbadc466ed1f9bdfbb2b545e45d012").and_return(0)
40
+ mod.check
41
+ end
42
+ end
43
+
44
+ context "rails check" do
45
+ before do
46
+ Checker::Options.stub(:use_rails_for_sass).and_return(true)
47
+ end
48
+
49
+ after do
50
+ `rm -rf spec/assets/stylesheets/checker-cache*`
51
+ end
52
+
53
+ it "runs rails check if preconditions_for_rails are met" do
54
+ files = ["a.sass"]
55
+ mod = Checker::Modules::Sass.new(files)
56
+ mod.stub(:preconditions_for_rails?).and_return(true)
57
+ mod.stub(:rails_project?).and_return(true)
58
+ mod.stub(:rails_with_ap?).and_return(true)
59
+ mod.stub(:check_for_executable).and_return(true)
60
+ mod.stub(:stylesheets_dir).and_return("spec/assets/stylesheets/")
61
+ mod.should_receive(:rails_check).and_return(Checker::Result.result(mod, 0))
62
+ mod.check
63
+ end
64
+
65
+ it "runs normal check if preconditions_for_rails aren't met" do
66
+ files = ["a.sass"]
67
+ mod = Checker::Modules::Sass.new(files)
68
+ mod.stub(:preconditions_for_rails?).and_return(false)
69
+ mod.stub(:rails_project?).and_return(true)
70
+ mod.stub(:rails_with_ap?).and_return(true)
71
+ mod.stub(:check_for_executable).and_return(true)
72
+ mod.stub(:stylesheets_dir).and_return("spec/assets/stylesheets/")
73
+ mod.should_receive(:normal_check).and_return(Checker::Result.result(mod, 0))
74
+ mod.check
75
+ end
76
+
77
+ it "gives proper command to sass module while checking .sass files" do
78
+ files = ["a.sass"]
79
+ mod = Checker::Modules::Sass.new(files)
80
+ mod.stub(:preconditions_for_rails?).and_return(true)
81
+ mod.stub(:rails_project?).and_return(true)
82
+ mod.stub(:rails_with_ap?).and_return(true)
83
+ mod.stub(:check_for_executable).and_return(true)
84
+ mod.stub(:stylesheets_dir).and_return("spec/assets/stylesheets/")
85
+ mod.should_receive(:plain_command).with("rails runner \"Rails.application.assets.find_asset(\\\"#{Dir.pwd}/spec/assets/stylesheets/checker-cachea.sass\\\").to_s\"").and_return(0)
86
+ mod.check
87
+ end
88
+
89
+ it "gives proper command to sass module while checking .scss files" do
90
+ files = ["a.scss"]
91
+ mod = Checker::Modules::Sass.new(files)
92
+ mod.stub(:preconditions_for_rails?).and_return(true)
93
+ mod.stub(:rails_project?).and_return(true)
94
+ mod.stub(:rails_with_ap?).and_return(true)
95
+ mod.stub(:check_for_executable).and_return(true)
96
+ mod.stub(:stylesheets_dir).and_return("spec/assets/stylesheets/")
97
+ mod.should_receive(:plain_command).with("rails runner \"Rails.application.assets.find_asset(\\\"#{Dir.pwd}/spec/assets/stylesheets/checker-cachea.scss\\\").to_s\"").and_return(0)
98
+ mod.check
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Checker::Modules::Slim do
4
+ it 'should only check .slim files' do
5
+ files = ['a.rb', 'b.js.erb', 'c.r', 'd.yml', 'e.yaml', 'f.coffee', 'g.slim']
6
+ mod = Checker::Modules::Slim.new(files)
7
+ mod.stub(:check_for_executable).and_return(true)
8
+ mod.stub(:check_one_file).and_return(stub(:success? => true, :status => :ok))
9
+ mod.should_receive(:check_one_file).with('g.slim')
10
+ mod.should_not_receive(:check_one_file).with('f.coffee')
11
+ mod.should_not_receive(:check_one_file).with('e.yaml')
12
+ mod.should_not_receive(:check_one_file).with('d.yml')
13
+ mod.should_not_receive(:check_one_file).with('a.rb')
14
+ mod.should_not_receive(:check_one_file).with('b.js.erb')
15
+ mod.should_not_receive(:check_one_file).with('c.r')
16
+ mod.check
17
+ end
18
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Checker::Modules::Yaml do
4
+ it 'should only check .yaml and .yml files' do
5
+ files = ['a.rb', 'b.js.erb', 'c.r', 'd.yml', 'e.yaml']
6
+ mod = Checker::Modules::Yaml.new(files)
7
+ mod.stub(:check_one_file).and_return(stub(:success? => true, :status => :ok))
8
+ mod.should_receive(:check_one_file).with('d.yml')
9
+ mod.should_receive(:check_one_file).with('e.yaml')
10
+ mod.should_not_receive(:check_one_file).with('a.rb')
11
+ mod.should_not_receive(:check_one_file).with('b.js.erb')
12
+ mod.should_not_receive(:check_one_file).with('c.r')
13
+ mod.check
14
+ end
15
+
16
+ it "should properly fetch yaml files" do
17
+ files = [fixture("yaml", "good.yaml")]
18
+ mod = Checker::Modules::Yaml.new(files)
19
+ mod.check.should be_true
20
+ end
21
+
22
+ it "should not pass the syntax check" do
23
+ files = [fixture("yaml", "bad.yaml")]
24
+ mod = Checker::Modules::Yaml.new(files)
25
+ mod.check.should be_false
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ require 'digest/md5'
2
+ require 'coveralls'
3
+ Coveralls.wear!
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+
7
+ FIXTURES_PATH = File.join(File.dirname(__FILE__), "checker", "fixtures")
8
+
9
+ def fixture(dir, filename)
10
+ "#{FIXTURES_PATH}/#{dir}/#{filename}"
11
+ end
12
+
13
+ def digest filename
14
+ Digest::MD5.hexdigest(filename)
15
+ end
16
+
17
+ require 'checker/cli'
18
+
19
+ module Checker
20
+ module Modules
21
+ class Base
22
+ def checkout_file file_name, target
23
+ `cp #{file_name} #{checkout_file_name(target)} > /dev/null 2>&1`
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,15 @@
1
+
2
+ #### Begin of checker script
3
+ if [ -f <%= Checker::RVM.rvm_shell %> ]; then
4
+ <%= Checker::RVM.rvm_command("checker") %>
5
+ else
6
+ checker
7
+ fi
8
+
9
+ if [ $? = 1 ]; then
10
+ exit 1
11
+ fi
12
+
13
+ text=`echo -n ':ok: '; cat $1`
14
+ echo "$text" > $1
15
+ #### End of checker script
metadata CHANGED
@@ -1,57 +1,167 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.7.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jacek Jakubik
8
+ - Tomasz Pewiński
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-03 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2015-03-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: colorize
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 0.7.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 0.7.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: rubocop
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 0.28.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 0.28.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: coveralls
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
14
70
  description: A collection of modules which every is designed to check syntax for specific
15
71
  files.
16
- email: jacek.jakubik@netguru.pl
72
+ email:
73
+ - jacek.jakubik@netguru.pl
74
+ - tomasz.pewinski@netguru.pl
17
75
  executables:
18
76
  - checker
19
77
  extensions: []
20
78
  extra_rdoc_files: []
21
79
  files:
22
- - README
80
+ - ".gitignore"
81
+ - ".rspec"
82
+ - ".travis.yml"
83
+ - CHANGELOG
84
+ - Gemfile
85
+ - Gemfile.lock
86
+ - LICENCE
87
+ - README.md
88
+ - Rakefile
23
89
  - bin/checker
24
90
  - checker.gemspec
25
91
  - lib/checker.rb
26
92
  - lib/checker/cli.rb
27
- - lib/checker/cli/execute.rb
28
93
  - lib/checker/core_ext.rb
29
- - lib/checker/modules/all.rb
94
+ - lib/checker/helper.rb
95
+ - lib/checker/installator.rb
96
+ - lib/checker/modules/base.rb
97
+ - lib/checker/modules/coffeescript.rb
98
+ - lib/checker/modules/conflict.rb
99
+ - lib/checker/modules/console_log.rb
30
100
  - lib/checker/modules/haml.rb
101
+ - lib/checker/modules/javascript.rb
102
+ - lib/checker/modules/pry.rb
103
+ - lib/checker/modules/rubocop.rb
31
104
  - lib/checker/modules/ruby.rb
32
- - lib/checker/utils.rb
105
+ - lib/checker/modules/sass.rb
106
+ - lib/checker/modules/slim.rb
107
+ - lib/checker/modules/yaml.rb
108
+ - lib/checker/options.rb
109
+ - lib/checker/result.rb
110
+ - lib/checker/results/console_log.rb
111
+ - lib/checker/results/default.rb
112
+ - lib/checker/results/javascript.rb
113
+ - lib/checker/results/rubocop.rb
114
+ - lib/checker/rvm.rb
115
+ - lib/checker/version.rb
116
+ - spec/assets/stylesheets/empty
117
+ - spec/checker/cli_spec.rb
118
+ - spec/checker/fixtures/conflict/with_conflict.rb
119
+ - spec/checker/fixtures/conflict/without_conflict.rb
120
+ - spec/checker/fixtures/console_log/with_console_log.js
121
+ - spec/checker/fixtures/console_log/without_console_log.js
122
+ - spec/checker/fixtures/pry/with_both.rb
123
+ - spec/checker/fixtures/pry/with_pry.rb
124
+ - spec/checker/fixtures/pry/with_pry_remote.rb
125
+ - spec/checker/fixtures/pry/without_pry.rb
126
+ - spec/checker/fixtures/ruby/bad.rb
127
+ - spec/checker/fixtures/ruby/good.rb
128
+ - spec/checker/fixtures/yaml/bad.yaml
129
+ - spec/checker/fixtures/yaml/good.yaml
130
+ - spec/checker/modules/base_spec.rb
131
+ - spec/checker/modules/coffeescript_spec.rb
132
+ - spec/checker/modules/conflict_spec.rb
133
+ - spec/checker/modules/console_log_spec.rb
134
+ - spec/checker/modules/haml_spec.rb
135
+ - spec/checker/modules/javascript_spec.rb
136
+ - spec/checker/modules/pry_spec.rb
137
+ - spec/checker/modules/ruby_spec.rb
138
+ - spec/checker/modules/sass_spec.rb
139
+ - spec/checker/modules/slim_spec.rb
140
+ - spec/checker/modules/yaml_spec.rb
141
+ - spec/spec_helper.rb
142
+ - templates/checker-prepare-commit-msg
33
143
  homepage: http://github.com/netguru/checker
34
144
  licenses: []
145
+ metadata: {}
35
146
  post_install_message:
36
147
  rdoc_options: []
37
148
  require_paths:
38
149
  - lib
39
150
  required_ruby_version: !ruby/object:Gem::Requirement
40
- none: false
41
151
  requirements:
42
- - - ! '>='
152
+ - - ">="
43
153
  - !ruby/object:Gem::Version
44
154
  version: '0'
45
155
  required_rubygems_version: !ruby/object:Gem::Requirement
46
- none: false
47
156
  requirements:
48
- - - ! '>='
157
+ - - ">="
49
158
  - !ruby/object:Gem::Version
50
159
  version: '0'
51
160
  requirements: []
52
161
  rubyforge_project:
53
- rubygems_version: 1.8.10
162
+ rubygems_version: 2.2.2
54
163
  signing_key:
55
- specification_version: 3
164
+ specification_version: 4
56
165
  summary: Syntax checker for various files
57
166
  test_files: []
167
+ has_rdoc:
data/README DELETED
@@ -1,4 +0,0 @@
1
- Soon...
2
-
3
- git config checker.check 'all'
4
- git config checker.check 'ruby, haml, coffeescript'
@@ -1,61 +0,0 @@
1
- class CoreExt
2
- def self.constantize(camel_cased_word)
3
- names = camel_cased_word.split('::')
4
- names.shift if names.empty? || names.first.empty?
5
-
6
- constant = Object
7
- names.each do |name|
8
- constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
9
- end
10
- constant
11
- end
12
- end
13
-
14
- class String
15
- def constantize
16
- CoreExt.constantize(self)
17
- end
18
- end
19
-
20
- module Checker
21
- class CLI
22
- module Execute
23
- def self.included(base)
24
- base.extend(ClassMethods)
25
- end
26
-
27
- module ClassMethods
28
- def execute
29
- if ARGV.size == 0
30
- modules = Utils.get_modules_to_check
31
- else
32
- modules = ARGV.map(&:downcase)
33
- end
34
- ## by default lets check all
35
- if modules.empty?
36
- modules = ["all"]
37
- end
38
-
39
- ## check all the modules
40
- if modules.include?("all")
41
- exit (Checker::Modules::All.check ? 0 : 1)
42
- else
43
- Utils.check_module_availability(modules) do |result|
44
- puts "Modules not available: #{result.join(", ")}.\n"
45
- puts "Available: #{Utils.available_modules.join(", ")}\n"
46
- puts "Check your git config checker.check\n"
47
- exit 1
48
- end
49
-
50
- checked = []
51
- modules.each do |mod|
52
- klass = "Checker::Modules::#{mod.downcase.capitalize}".constantize
53
- checked << klass.check
54
- end
55
- exit (checked.all_true? ? 0 : 1)
56
- end
57
- end
58
- end
59
- end
60
- end
61
- end