bigfiles 0.0.3 → 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: d6cefc72283ccb733aac758efef36fb092e9ab06
4
- data.tar.gz: c01b4493074f206eb84f4e3b85139331235228b6
3
+ metadata.gz: 41d328a76b807f9b04515205d044fb073501e061
4
+ data.tar.gz: aaf0ace57859750f58e8b96317d6c454d143cb8f
5
5
  SHA512:
6
- metadata.gz: 9f2c59d88b45fa32bd4381362a7a533bbaac513c02f43e4a7b59f17b5dd967a8f2209ca7613d2c207e01069ce39924e5e2c278807222c4ee60cde9b84fc8f572
7
- data.tar.gz: c56569877f892751b3d5047610c72ba827d9a1942dc2fecd5dc96fa22f267e113c10990636e23f8fc059b9d82c9cce966aecbeab04e9a1482be0a1867686903d
6
+ metadata.gz: 2bfd66a70391b9772bcfe9f4403bd568b9f3bad61630361bedb310b58441767b90d1cb24a33c68ff560bcdda415954d9d902a5995b45095f5e02341f88203414
7
+ data.tar.gz: 0079f1c6572aef4fd1a5694ec29a6723c225daf65bdce97064f71f3d25e9663d2a7cbb9aa530e7d3c36f7aeb4385d004fcbf73a80fa5196c9472098e0bda02c9
data/Rakefile CHANGED
@@ -16,7 +16,7 @@ end
16
16
  desc 'Run features'
17
17
  RSpec::Core::RakeTask.new(:feature) do |task|
18
18
  task.pattern = 'feature/**/*_spec.rb'
19
- task.rspec_opts = "--format doc"
19
+ task.rspec_opts = '--format doc'
20
20
  end
21
21
 
22
22
  task :clear_metrics do |_t|
@@ -9,8 +9,8 @@ module BigFiles
9
9
  @globber = globber
10
10
  end
11
11
 
12
- def find(glob)
13
- @globber.glob(glob)
12
+ def find(glob, exclude_glob)
13
+ @globber.glob(glob) - @globber.glob(exclude_glob)
14
14
  end
15
15
  end
16
16
  end
@@ -1,4 +1,4 @@
1
1
  # Tool to find the largest source files in your project
2
2
  module BigFiles
3
- VERSION = '0.0.3'
3
+ VERSION = '0.1.0'
4
4
  end
data/lib/bigfiles.rb CHANGED
@@ -3,6 +3,9 @@ require 'optparse'
3
3
  require_relative 'bigfiles/source_code_finder'
4
4
  require_relative 'bigfiles/file_with_lines'
5
5
 
6
+ # XXX: Take out source_file_globber.rb from quality into its own gem
7
+ # and start building on that.
8
+
6
9
  # Simple tool to find the largest source files in your project.
7
10
  module BigFiles
8
11
  # Simple tool to find the largest source files in your project.
@@ -12,17 +15,20 @@ module BigFiles
12
15
  exiter: Kernel,
13
16
  file_with_lines: FileWithLines,
14
17
  source_file_finder: SourceCodeFinder.new,
15
- option_parser: OptionParser)
16
- @io, @exiter, @file_with_lines = io, exiter, file_with_lines
18
+ option_parser_class: OptionParser)
19
+ @io = io
20
+ @exiter = exiter
21
+ @file_with_lines = file_with_lines
17
22
  @source_file_finder = source_file_finder
18
- @option_parser = option_parser
23
+ @option_parser_class = option_parser_class
19
24
  @options = parse_options(args)
20
25
  end
21
26
 
22
27
  def parse_options(args)
23
28
  options = nil
24
- @option_parser.new do |opts|
29
+ @option_parser_class.new do |opts|
25
30
  options = setup_options(opts)
31
+ @option_parser = opts
26
32
  end.parse!(args)
27
33
  options
28
34
  end
@@ -34,26 +40,46 @@ module BigFiles
34
40
  @options[:glob] || DEFAULT_GLOB
35
41
  end
36
42
 
37
- def setup_options(opts)
38
- options = {}
39
- opts.banner = 'Usage: bigfiles [options]'
43
+ def exclude_glob
44
+ @options[:exclude] || ''
45
+ end
46
+
47
+ def add_glob_option(opts, options)
40
48
  opts.on('-g glob here', '--glob',
41
49
  "Which files to parse - default is #{DEFAULT_GLOB}") do |v|
42
50
  options[:glob] = v
43
51
  end
52
+ end
53
+
54
+ def add_exclude_glob_option(opts, options)
55
+ opts.on('-e glob here', '--exclude-glob',
56
+ 'Files to exclude - default is none') do |v|
57
+ options[:exclude] = v
58
+ end
59
+ end
60
+
61
+ def add_help_option(opts, options)
44
62
  opts.on('-h', '--help', 'This message') do |_|
45
63
  options[:help] = true
46
64
  end
65
+ end
66
+
67
+ def setup_options(opts)
68
+ options = {}
69
+ opts.banner = 'Usage: bigfiles [options]'
70
+ add_glob_option(opts, options)
71
+ add_exclude_glob_option(opts, options)
72
+ add_help_option(opts, options)
47
73
  options
48
74
  end
49
75
 
50
76
  def usage
51
- @io.puts "USAGE: bigfiles [-n <top n files>]\n"
77
+ @io.puts @option_parser
52
78
  @exiter.exit 1
53
79
  end
54
80
 
55
81
  def find_analyze_and_report_on_files
56
- file_list = @source_file_finder.find(glob)
82
+ file_list = @source_file_finder.find(glob, exclude_glob)
57
83
  files_with_lines = file_list.map do |filename|
58
84
  @file_with_lines.new(filename)
59
85
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigfiles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.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-07 00:00:00.000000000 Z
11
+ date: 2015-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler