rubocopter 0.0.10 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d389ad55ac88f097d06e82294ec6e668d05bd20d
4
- data.tar.gz: a3a157cc49c7edcadcd86abc4fcf9c1a041cabc3
3
+ metadata.gz: 9d2ff96ab1f11fd023566f38011c8797caad35ee
4
+ data.tar.gz: fc144c71f5b107870eb0396f8a3b693d64d81a13
5
5
  SHA512:
6
- metadata.gz: e9dd5171972debabbf28376ac45e7603fa2f643219d71d7108f3813899fdb965c9e7907f5aeb8797beed8ed1fe50cab2e90171e24b406aacc8f487dfc008de79
7
- data.tar.gz: eb58d30c831d4c9fcd138bf2f5f40845d82be3f2ce85d0a42cba42091cfa7e323c99cce70a78d163e9144cdddc1f0a52875141540a3f22f03b21ce0bc0a20263
6
+ metadata.gz: 3e5d81fcba6705107722d93ca419c202405f2c42b6c76cb271c1dc422674cdee39dc3804a56ec7e5dc0266505cdf03374a3271a93aaf95af015165a8536e8335
7
+ data.tar.gz: b74abcd2ab2fdf83137eae74bec90e8215c2dc4cdac95844a79d3e5fed4379e25688d0a5f54fe9fbb42f7e09e5af978a4c730b93d21a08830bfe1fdfb29bea99
@@ -7,15 +7,14 @@ require_relative 'version'
7
7
  RuboCopter::Options = Struct.new(:hash, :debug)
8
8
 
9
9
  class RuboCopter::CLI
10
-
11
10
  attr_reader :options
12
11
 
13
12
  def run(args = ARGV)
14
- parse_options(args)
15
- check_for_offences
13
+ remaining_args = parse_options(args)
14
+ check_for_offences(remaining_args)
16
15
  show_results
17
16
 
18
- return $?.exitstatus
17
+ $CHILD_STATUS.exitstatus
19
18
  end
20
19
 
21
20
  private
@@ -40,34 +39,40 @@ class RuboCopter::CLI
40
39
  rubyfiles
41
40
  end
42
41
 
43
- def check_for_offences
42
+ def check_for_offences(remaining_args = [])
43
+ rubocop_options = ['rubocop', '-R']
44
+ unless remaining_args.include?('--out')
45
+ rubocop_options += '--out rubocop_result.txt'.split
46
+ end
47
+ rubocop_options += remaining_args
48
+
44
49
  # Check for git.
45
50
  if `which git` == ''
46
51
  puts 'git not detected. Running normal rubocop.'
47
- system(Shellwords.join(['rubocop', '-R'] + '--out rubocop_result.txt'.split))
52
+ system(Shellwords.join(rubocop_options))
48
53
  return
49
54
  end
50
55
 
51
56
  # Check for changes
52
57
  `git rev-parse`
53
- if $?.exitstatus == 0
58
+ if $CHILD_STATUS.exitstatus == 0
54
59
  files = changed_ruby_file_names
55
60
  if files.length == 0
56
61
  puts 'No changes detected, no reason to run rubocop'
57
62
  exit(0)
58
63
  else
59
- system(Shellwords.join(['rubocop', '-R'] + files + '--out rubocop_result.txt'.split))
64
+ system(Shellwords.join(rubocop_options + files))
60
65
  end
61
66
  return
62
67
  end
63
68
 
64
69
  # No git directory
65
70
  puts 'git directory not detected. Running normal rubocop.'
66
- system(Shellwords.join(['rubocop', '-R'] + '--out rubocop_result.txt'.split))
71
+ system(Shellwords.join(rubocop_options))
67
72
  end
68
73
 
69
74
  def show_results
70
- if File.exists?('rubocop_result.txt')
75
+ if File.exist?('rubocop_result.txt')
71
76
  text = File.open('rubocop_result.txt').read
72
77
  puts text
73
78
  offense = /(\d+) offense/.match(text.split("\n")[-1])
@@ -85,9 +90,9 @@ class RuboCopter::CLI
85
90
  @options = RuboCopter::Options.new('master', false)
86
91
 
87
92
  opt_parser = OptionParser.new do |opts|
88
- opts.banner = "Rubocopter v:#{RuboCopter::VERSION}\nUsage: rubocopter [options]"
93
+ opts.banner = "Rubocopter v:#{RuboCopter::VERSION}\nRubocop v:#{RuboCop::Version::STRING}\nUsage: rubocopter [options]\n *Any unknown options will be passed to rubocop directly."
89
94
 
90
- opts.on('-c HASH', '--commit HASH', 'git hash to compare against') do |hash|
95
+ opts.on('--commit HASH', 'git hash to compare against') do |hash|
91
96
  @options.hash = hash
92
97
  end
93
98
 
@@ -99,17 +104,31 @@ class RuboCopter::CLI
99
104
  remove_git_hooks(hook)
100
105
  end
101
106
 
102
- opts.on("--debug", "Prints runtime") do
107
+ opts.on('--debug', 'Prints runtime') do
103
108
  @options.debug = true
104
109
  end
105
110
 
106
- opts.on("-h", "--help", "Prints this help") do
111
+ opts.on('-h', '--help', 'Prints this help') do
107
112
  puts opts
108
113
  exit
109
114
  end
110
115
  end
111
116
 
112
- opt_parser.parse!(args)
117
+ remaining_args = {}
118
+ begin
119
+ opt_parser.parse(args)
120
+ rescue OptionParser::InvalidOption => e
121
+ remaining_args = e.args.map do |arg|
122
+ arg_index = args.index(arg)
123
+ if args[arg_index + 1].start_with?('-')
124
+ args[arg_index]
125
+ else
126
+ [args[arg_index], args[arg_index + 1]]
127
+ end
128
+ end.flatten
129
+ end
130
+
131
+ remaining_args
113
132
  end
114
133
 
115
134
  def install_git_hooks(hook)
@@ -138,5 +157,4 @@ class RuboCopter::CLI
138
157
  end
139
158
  exit(0)
140
159
  end
141
-
142
160
  end
@@ -1,3 +1,3 @@
1
1
  module RuboCopter
2
- VERSION = '0.0.10'
2
+ VERSION = '0.1.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocopter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Basset