rubocopter 0.0.6 → 0.0.7
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/README.md +17 -0
- data/git_hooks/pre-commit +9 -0
- data/git_hooks/pre-push +9 -0
- data/lib/rubocopter/cli.rb +56 -12
- data/lib/rubocopter/version.rb +1 -1
- metadata +6 -4
- data/README.rdoc +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5244a6527323ba5bb4b6560925216c8a22200762
|
4
|
+
data.tar.gz: 3c904d1302984791c15420303d62216e9116dc99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4ebc8a3683d5d821293db9730b9c07baed73bd704d0135cab513c8068c8042b94285a8c6bbb2cf23ac4a54f2045696ae5e3780d1052c053b295a46eb190b72f
|
7
|
+
data.tar.gz: 02b50c2d3f4a3b90338609aa0fc8612395a604c554cb849b27f35b26daca47e875cdff34dd7039fb04fcbd6a107159d307c687b96d514a6b752e11475f917f41
|
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Rubocopter
|
2
|
+
|
3
|
+
A simple wrapper gem around [RuboCop](https://github.com/bbatsov/rubocop). Rubocopter aids you in development by providing a convenient way to find ruby style and logic issues in your large .git projects by comparing only the changes from a given commit.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
`gem install rubocopter`
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
`rubocopter`
|
12
|
+
|
13
|
+
Use the `-h` or `--help` flag to see options.
|
14
|
+
|
15
|
+
## License
|
16
|
+
|
17
|
+
This project rocks and uses MIT-LICENSE.
|
data/git_hooks/pre-push
ADDED
data/lib/rubocopter/cli.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'optparse'
|
2
2
|
require 'shellwords'
|
3
3
|
require 'rubocop'
|
4
|
+
require 'pathname'
|
4
5
|
|
5
6
|
RuboCopter::Options = Struct.new(:hash, :debug)
|
6
7
|
|
@@ -11,6 +12,7 @@ class RuboCopter::CLI
|
|
11
12
|
def run(args = ARGV)
|
12
13
|
parse_options(args)
|
13
14
|
check_for_offences
|
15
|
+
show_results
|
14
16
|
|
15
17
|
return $?.exitstatus
|
16
18
|
end
|
@@ -38,25 +40,32 @@ class RuboCopter::CLI
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def check_for_offences
|
43
|
+
# Check for git.
|
41
44
|
if `which git` == ''
|
42
45
|
puts 'git not detected. Running normal rubocop.'
|
43
46
|
system(Shellwords.join(['rubocop', '-R'] + '--out rubocop_result.txt'.split))
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
47
|
+
return
|
48
|
+
end
|
49
|
+
|
50
|
+
# Check for changes
|
51
|
+
`git rev-parse`
|
52
|
+
if $?.exitstatus == 0
|
53
|
+
files = changed_ruby_file_names
|
54
|
+
if files.length == 0
|
55
|
+
puts 'No changes detected, no reason to run rubocop'
|
56
|
+
exit(0)
|
54
57
|
else
|
55
|
-
|
56
|
-
system(Shellwords.join(['rubocop', '-R'] + '--out rubocop_result.txt'.split))
|
58
|
+
system(Shellwords.join(['rubocop', '-R'] + files + '--out rubocop_result.txt'.split))
|
57
59
|
end
|
60
|
+
return
|
58
61
|
end
|
59
62
|
|
63
|
+
# No git directory
|
64
|
+
puts 'git directory not detected. Running normal rubocop.'
|
65
|
+
system(Shellwords.join(['rubocop', '-R'] + '--out rubocop_result.txt'.split))
|
66
|
+
end
|
67
|
+
|
68
|
+
def show_results
|
60
69
|
if File.exists?('rubocop_result.txt')
|
61
70
|
text = File.open('rubocop_result.txt').read
|
62
71
|
puts text
|
@@ -81,6 +90,14 @@ class RuboCopter::CLI
|
|
81
90
|
@options.hash = hash
|
82
91
|
end
|
83
92
|
|
93
|
+
opts.on('--install-git-hooks HOOK', 'write git hooks to rubocopter. options : all, commit, push') do |hook|
|
94
|
+
install_git_hooks(hook)
|
95
|
+
end
|
96
|
+
|
97
|
+
opts.on('--remove-git-hooks HOOK', 'remove git hooks. options : all, commit, push') do |hook|
|
98
|
+
remove_git_hooks(hook)
|
99
|
+
end
|
100
|
+
|
84
101
|
opts.on("--debug", "Prints runtime") do
|
85
102
|
@options.debug = true
|
86
103
|
end
|
@@ -94,4 +111,31 @@ class RuboCopter::CLI
|
|
94
111
|
opt_parser.parse!(args)
|
95
112
|
end
|
96
113
|
|
114
|
+
def install_git_hooks(hook)
|
115
|
+
working_dir_git_hooks = Pathname.new(Dir.pwd).join('.git', 'hooks')
|
116
|
+
current_path = Pathname.new(File.dirname(__FILE__))
|
117
|
+
if hook == 'commit'
|
118
|
+
system(Shellwords.join(['cp', current_path.join('../../git_hooks', 'pre-commit'), working_dir_git_hooks]))
|
119
|
+
elsif hook == 'push'
|
120
|
+
system(Shellwords.join(['cp', current_path.join('../../git_hooks', 'pre-push'), working_dir_git_hooks]))
|
121
|
+
elsif hook == 'all'
|
122
|
+
system(Shellwords.join(['cp', current_path.join('../../git_hooks', 'pre-commit'), working_dir_git_hooks]))
|
123
|
+
system(Shellwords.join(['cp', current_path.join('../../git_hooks', 'pre-push'), working_dir_git_hooks]))
|
124
|
+
end
|
125
|
+
exit(0)
|
126
|
+
end
|
127
|
+
|
128
|
+
def remove_git_hooks(hook)
|
129
|
+
working_dir_git_hooks = Pathname.new(Dir.pwd).join('.git', 'hooks')
|
130
|
+
if hook == 'commit'
|
131
|
+
system(Shellwords.join(['rm', working_dir_git_hooks.join('pre-commit')]))
|
132
|
+
elsif hook == 'push'
|
133
|
+
system(Shellwords.join(['rm', working_dir_git_hooks.join('pre-push')]))
|
134
|
+
elsif hook == 'all'
|
135
|
+
system(Shellwords.join(['rm', working_dir_git_hooks.join('pre-commit')]))
|
136
|
+
system(Shellwords.join(['rm', working_dir_git_hooks.join('pre-push')]))
|
137
|
+
end
|
138
|
+
exit(0)
|
139
|
+
end
|
140
|
+
|
97
141
|
end
|
data/lib/rubocopter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocopter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Basset
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.29.1
|
27
|
-
description: Helps with speeding up
|
27
|
+
description: Helps with speeding up RuboCop checks in large git projects.
|
28
28
|
email:
|
29
29
|
- matthew@quandl.com
|
30
30
|
executables:
|
@@ -33,8 +33,10 @@ extensions: []
|
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
35
|
- MIT-LICENSE
|
36
|
-
- README.
|
36
|
+
- README.md
|
37
37
|
- bin/rubocopter
|
38
|
+
- git_hooks/pre-commit
|
39
|
+
- git_hooks/pre-push
|
38
40
|
- lib/rubocopter.rb
|
39
41
|
- lib/rubocopter/cli.rb
|
40
42
|
- lib/rubocopter/version.rb
|