punchlist 0.0.2 → 1.0.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: 5e83dc434aafca7c85c72221ac0a8327b3ec19ea
4
- data.tar.gz: 575957e7f721877fce24d8366d09e42c97e63d5b
3
+ metadata.gz: 6b24e5a71761e3b922d69c22ecc75f783b5a1e52
4
+ data.tar.gz: 774499da75a38f680a5b8576ae46a89ed33c9f33
5
5
  SHA512:
6
- metadata.gz: 7d59c636e7382621dc0ff81e94faec5262c8ccc53d660132e79cf0b7969a30d4f07d2382a881092e028baa6696d7cee4d74025a637b3fc2aaf9ad90f088d8775
7
- data.tar.gz: 6564e53503c64110055c93d8cfffe7c97a3f86d29d83c0aafa865d770c4b97de565c638e99c8632d1f2b3a26709f04a84295fe8d4337f99cfcbef6b0deb73559
6
+ metadata.gz: 0464696dabb58e2936812720133e0287a5ffa13c806c44ba946860c48f8fec76176ba57db05f2265003945039345c003850dbd260de919074c2163e375701ebe
7
+ data.tar.gz: f56075dc8576ae3121bb4263545bb46aac9d8a4c128df19c28f47f3a7f37b71f89186fa6c9e760c15969d8d57871fb5aea99409e31a2714a71368c596b385e61
data/bin/punchlist CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require_relative '../lib/punchlist'
4
4
 
5
- Punchlist::Punchlist.new(ARGV).run
5
+ Punchlist::Punchlist.new.run
data/lib/punchlist.rb CHANGED
@@ -1,26 +1,23 @@
1
+ require_relative 'punchlist/options'
2
+
1
3
  # XXX: need to include BUG in list
2
4
  # XXX: need to include BUG in my rubocop config
3
5
  # BUG need to fix the fact that we create blank lines on files with no issues
4
6
  module Punchlist
5
7
  # Counts the number of 'todo' comments in your code.
6
8
  class Punchlist
7
- def initialize(args,
8
- outputter: STDOUT,
9
+ def initialize(outputter: STDOUT,
9
10
  globber: Dir,
10
- file_opener: File)
11
- @args = args
11
+ file_opener: File,
12
+ options_parser: Options.new(default_punchlist_line_regexp))
12
13
  @outputter = outputter
13
14
  @globber = globber
14
15
  @file_opener = file_opener
16
+ @options_parser = options_parser
15
17
  end
16
18
 
17
19
  def run
18
- if @args[0] == '--glob'
19
- @source_files_glob = @args[1]
20
- elsif @args[0]
21
- @outputter.puts "USAGE: punchlist\n"
22
- return 0 # XXX: need to vary return based on good or bad arguments
23
- end
20
+ @options = @options_parser.parse_options
24
21
 
25
22
  analyze_files
26
23
 
@@ -28,7 +25,7 @@ module Punchlist
28
25
  end
29
26
 
30
27
  def source_files_glob
31
- @source_files_glob ||=
28
+ @options[:glob] ||
32
29
  '{app,lib,test,spec,feature}/**/*.{rb,swift,scala,js,cpp,c,java,py}'
33
30
  end
34
31
 
@@ -44,10 +41,21 @@ module Punchlist
44
41
  @globber.glob(source_files_glob)
45
42
  end
46
43
 
47
- def punchlist_line_regexp
44
+ def default_punchlist_line_regexp
48
45
  /XXX|TODO/
49
46
  end
50
47
 
48
+ def punchlist_line_regexp
49
+ return @regexp if @regexp
50
+
51
+ regexp_string = @options[:regexp]
52
+ if regexp_string
53
+ @regexp = Regexp.new(regexp_string)
54
+ else
55
+ default_punchlist_line_regexp
56
+ end
57
+ end
58
+
51
59
  def look_for_punchlist_items(filename)
52
60
  lines = []
53
61
  line_num = 0
@@ -0,0 +1,33 @@
1
+ require 'optparse'
2
+
3
+ module Punchlist
4
+ class Options
5
+ attr_reader :default_punchlist_line_regexp
6
+
7
+ def initialize(default_punchlist_line_regexp)
8
+ @default_punchlist_line_regexp = default_punchlist_line_regexp
9
+ end
10
+
11
+ def setup_options(opts)
12
+ options = {}
13
+ opts.banner = 'Usage: punchlist [options]'
14
+ opts.on('-g', '--glob g', 'Filename glob to identify source files') do |v|
15
+ options[:glob] = v
16
+ end
17
+ opts.on('-r', '--regexp r',
18
+ 'Regexp to trigger on - ' \
19
+ 'default is XXX|TODO') do |v|
20
+ options[:regexp] = v
21
+ end
22
+ options
23
+ end
24
+
25
+ def parse_options
26
+ options = nil
27
+ OptionParser.new do |opts|
28
+ options = setup_options(opts)
29
+ end.parse!
30
+ options
31
+ end
32
+ end
33
+ end
@@ -1,5 +1,5 @@
1
1
  # Counts the number of 'todo' comments in your code ('Comment
2
2
  # annotations').
3
3
  module Punchlist
4
- VERSION = '0.0.2'
4
+ VERSION = '1.0.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: punchlist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-08 00:00:00.000000000 Z
11
+ date: 2015-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -93,6 +93,7 @@ files:
93
93
  - Rakefile
94
94
  - bin/punchlist
95
95
  - lib/punchlist.rb
96
+ - lib/punchlist/options.rb
96
97
  - lib/punchlist/version.rb
97
98
  - punchlist.gemspec
98
99
  homepage: http://github.com/apiology/punchlist