codeqa 0.4.2 → 0.5.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.
- checksums.yaml +4 -4
- data/CHANGELOG +3 -0
- data/README.md +7 -3
- data/bin/codeqa +1 -1
- data/lib/codeqa.rb +2 -19
- data/lib/codeqa/configuration.rb +1 -1
- data/lib/codeqa/installer.rb +54 -0
- data/lib/codeqa/version.rb +1 -1
- data/lib/templates/{pre-commit → base_hook.rb} +2 -0
- data/lib/templates/git_hook.rb +16 -0
- data/spec/lib/codeqa_spec.rb +4 -4
- metadata +5 -4
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9b19bbc570eb76e3e5a6254ead39215713a363d
|
4
|
+
data.tar.gz: 061d9968aaacf02778dda744ac40a3003b59bb86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 465e4bba1c98ac836288de4b6e5d88dacfb972268a0088cc959e365d3bf108c7b464ca1c36831becbf54d1db53f3c2a511c095b38b50395d161c97c599d6d619
|
7
|
+
data.tar.gz: 2f0daf5c332a5fe9b18b9bbb31eb735960a56f63898ff8ab0e16f3d0e386e4adc20ad26c85d7731b02a86f34d653fbefa449bbde991cec35ec18ce7ae047d14a
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -33,9 +33,9 @@ Since Version 0.3 codeqa uses ruby for configuration, therefore the config file
|
|
33
33
|
is now named `.codeqa.rb`. The loading of configuration files is still the same,
|
34
34
|
meaning we have to following load order:
|
35
35
|
|
36
|
-
1. Initialize with default settings (see `config/default
|
37
|
-
2. load `.codeqa.rb` from your home directory and merge it with the defaults.
|
38
|
-
3. load `.codeqa.rb` placed in the project root, which is determined by finding
|
36
|
+
1. Initialize with default settings (see `config/default.rb`)
|
37
|
+
2. load `.codeqa/config.rb` from your home directory and merge it with the defaults.
|
38
|
+
3. load `.codeqa/config.rb` placed in the project root, which is determined by finding
|
39
39
|
the closest `.git` folder.
|
40
40
|
|
41
41
|
Both the config in your home directory and the project config file are optional
|
@@ -90,6 +90,10 @@ end
|
|
90
90
|
- CheckYard (checks YARD for warnings)
|
91
91
|
- CheckRubySyntax (runs file though `ruby -c`, use RubocopLint if possible)
|
92
92
|
|
93
|
+
## Hooks
|
94
|
+
Since version 0.5 it's possible to run any scripts which are placed at .codeqa/hooks . If they exit with code <> 0
|
95
|
+
the commit is not allowed. The scripts have to be executable.
|
96
|
+
|
93
97
|
## Contributing
|
94
98
|
|
95
99
|
1. Fork it
|
data/bin/codeqa
CHANGED
data/lib/codeqa.rb
CHANGED
@@ -8,25 +8,8 @@ module Codeqa
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def install(root='.')
|
11
|
-
require '
|
12
|
-
|
13
|
-
if File.exist?(git_root)
|
14
|
-
pre_commit_path = git_root.join 'hooks', 'pre-commit'
|
15
|
-
if File.exist?(pre_commit_path)
|
16
|
-
# $stdout.puts 'moving away the old pre-commit hook -> pre-commit.bkp'
|
17
|
-
FileUtils.mv(pre_commit_path,
|
18
|
-
git_root.join('hooks', 'pre-commit.bkp'),
|
19
|
-
:force => true)
|
20
|
-
end
|
21
|
-
pre_commit_template_path = Codeqa.root.join('lib', 'templates', 'pre-commit')
|
22
|
-
# $stdout.puts 'placing new pre-commit hook'
|
23
|
-
FileUtils.cp(pre_commit_template_path, pre_commit_path)
|
24
|
-
FileUtils.chmod('+x', pre_commit_path)
|
25
|
-
true
|
26
|
-
else
|
27
|
-
# $stderr.puts "#{root} is not in a git root"
|
28
|
-
false
|
29
|
-
end
|
11
|
+
require 'codeqa/installer'
|
12
|
+
Codeqa::Installer.call(root)
|
30
13
|
end
|
31
14
|
|
32
15
|
def check(filename, options={})
|
data/lib/codeqa/configuration.rb
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Codeqa
|
4
|
+
class Installer
|
5
|
+
def self.call(app_root)
|
6
|
+
new(app_root).call
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(app_root)
|
10
|
+
@app_root=Pathname.new(File.expand_path(app_root))
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
generate_dot_codeqa
|
15
|
+
install_codeqa_git_hook
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def dot_path(*args)
|
20
|
+
app_path('.codeqa').join(*args)
|
21
|
+
end
|
22
|
+
|
23
|
+
def app_path(*args)
|
24
|
+
@app_root.join(*args)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def template_path(*args)
|
29
|
+
Codeqa.root.join('lib', 'templates').join(*args)
|
30
|
+
end
|
31
|
+
|
32
|
+
def install_codeqa_git_hook
|
33
|
+
git_root = app_path.join(".git")
|
34
|
+
pre_commit_path = git_root.join 'hooks', 'pre-commit'
|
35
|
+
|
36
|
+
return false unless File.exist?(git_root)
|
37
|
+
return false if File.exist?(pre_commit_path)
|
38
|
+
|
39
|
+
FileUtils.mv(pre_commit_path,
|
40
|
+
git_root.join('hooks', 'pre-commit.bkp'),
|
41
|
+
:force => true)
|
42
|
+
pre_commit_path.make_symlink('../../.codeqa/git_hook.rb') #relative path!
|
43
|
+
true
|
44
|
+
end
|
45
|
+
|
46
|
+
def generate_dot_codeqa
|
47
|
+
dot_path.mkdir unless dot_path.exist?
|
48
|
+
dot_path("hooks").mkdir unless dot_path("hooks").exist?
|
49
|
+
FileUtils.cp(template_path('base_hook.rb'), dot_path("hooks","base.rb")) unless dot_path("hooks","base.rb").exist?
|
50
|
+
FileUtils.cp(template_path('git_hook.rb'), dot_path("git_hook.rb")) unless dot_path("git_hook.rb").exist?
|
51
|
+
dot_path("git_hook.rb").chmod(0775)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/codeqa/version.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
APP_ROOT=Pathname.new(File.expand_path(File.join(File.dirname(__FILE__),'..','..')))
|
5
|
+
HOOKS_PATH=APP_ROOT.join('.codeqa','hooks')
|
6
|
+
|
7
|
+
|
8
|
+
#run each hook if one gives an error then commit will fail
|
9
|
+
|
10
|
+
HOOKS_PATH.children(false).sort.each do |filename|
|
11
|
+
exe=HOOKS_PATH.join(filename)
|
12
|
+
ok=system(%{#{exe} APP_ROOT="#{APP_ROOT}"})
|
13
|
+
exit 1 unless ok
|
14
|
+
end
|
15
|
+
|
16
|
+
exit 0
|
data/spec/lib/codeqa_spec.rb
CHANGED
@@ -42,11 +42,11 @@ describe Codeqa do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'should copy pre-commit hook into project git folder' do
|
45
|
-
template_location = Codeqa.root.join('lib', 'templates', 'pre-commit')
|
46
|
-
hook_location = project_dir.join('.git', 'hooks', 'pre-commit')
|
47
|
-
expect(FileUtils).to receive(:cp).with(template_location, hook_location)
|
48
|
-
allow(FileUtils).to receive(:chmod)
|
49
45
|
Codeqa.install project_dir.to_s
|
46
|
+
expect(project_dir.join('.codeqa')).to be_exist
|
47
|
+
expect(project_dir.join('.codeqa','hooks')).to be_exist
|
48
|
+
expect(project_dir.join('.codeqa','hooks','base.rb')).to be_exist
|
49
|
+
expect(project_dir.join('.codeqa','git_hook.rb')).to be_exist
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeqa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Schrammel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-04-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -108,7 +108,6 @@ files:
|
|
108
108
|
- ".gitignore"
|
109
109
|
- ".rspec"
|
110
110
|
- ".rubocop.yml"
|
111
|
-
- ".ruby-version"
|
112
111
|
- ".travis.yml"
|
113
112
|
- ".vimrc"
|
114
113
|
- CHANGELOG
|
@@ -138,13 +137,15 @@ files:
|
|
138
137
|
- lib/codeqa/checkers/rubocop_full.rb
|
139
138
|
- lib/codeqa/checkers/rubocop_lint.rb
|
140
139
|
- lib/codeqa/configuration.rb
|
140
|
+
- lib/codeqa/installer.rb
|
141
141
|
- lib/codeqa/runner.rb
|
142
142
|
- lib/codeqa/runner_decorator.rb
|
143
143
|
- lib/codeqa/sourcefile.rb
|
144
144
|
- lib/codeqa/utils/check_errors.rb
|
145
145
|
- lib/codeqa/utils/erb_sanitizer.rb
|
146
146
|
- lib/codeqa/version.rb
|
147
|
-
- lib/templates/
|
147
|
+
- lib/templates/base_hook.rb
|
148
|
+
- lib/templates/git_hook.rb
|
148
149
|
- spec/fixtures/erb_example.html
|
149
150
|
- spec/fixtures/erb_example.html.erb
|
150
151
|
- spec/fixtures/html_error.html.erb
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ruby-2.1.2
|