bigfiles 0.1.3 → 0.2.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: 40abc4d318260355a33bfe37f192ed8b5463b0ae
4
- data.tar.gz: 82e7a2cbd78368b63210e29f24f49b0fe09b8f2f
3
+ metadata.gz: f98e9edfdf5e80acdb888bcff5925860185cdb75
4
+ data.tar.gz: a7ba3c286b3fd6d54027fab10c83098dc63526d7
5
5
  SHA512:
6
- metadata.gz: 5174d80ccd1b0658b8c0f30f7cee3bd6004dc213dd009f1c6a3c247d12803b92daffc7aa46b4c1c843033a7a0bc5eb4f79830508396af612a6a5c09f7cef453c
7
- data.tar.gz: 99c57e01f56fe495c80c19a53db08d3e7eca5b7c188174169bc0f9394d57a230ac27ab50a61ee0da12c0bd8963cedfd6f18e568a2db0c55a9a349a0174288015
6
+ metadata.gz: 27c3ea11512e8608a75c0ef4dc28f2a936e637131252b8f7e72d188d02f915e6545f859d2dabd41c31dccb4f4ed2a98595dd122e0f63583c1e16983dcc2fe9f9
7
+ data.tar.gz: c21ba07a949deebe99b71647146ed4bed2faad4f73f041db6538b1d51b58006f91d6ce493bae3c516daa2434f4423b8ada6e65415a48d741af6058419dc15bc6
@@ -0,0 +1,75 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual
26
+ attention or advances
27
+ * Trolling, insulting/derogatory comments, and personal or political
28
+ attacks
29
+ * Public or private harassment
30
+ * Publishing others' private information, such as a physical or electronic
31
+ address, without explicit permission
32
+ * Other conduct which could reasonably be considered inappropriate in a
33
+ professional setting
34
+
35
+ ## Our Responsibilities
36
+
37
+ Project maintainers are responsible for clarifying the standards of acceptable
38
+ behavior and are expected to take appropriate and fair corrective action in
39
+ response to any instances of unacceptable behavior.
40
+
41
+ Project maintainers have the right and responsibility to remove, edit, or
42
+ reject comments, commits, code, wiki edits, issues, and other contributions
43
+ that are not aligned to this Code of Conduct, or to ban temporarily or
44
+ permanently any contributor for other behaviors that they deem inappropriate,
45
+ threatening, offensive, or harmful.
46
+
47
+ ## Scope
48
+
49
+ This Code of Conduct applies both within project spaces and in public spaces
50
+ when an individual is representing the project or its community. Examples of
51
+ representing a project or community include using an official project e-mail
52
+ address, posting via an official social media account, or acting as an appointed
53
+ representative at an online or offline event. Representation of a project may be
54
+ further defined and clarified by project maintainers.
55
+
56
+ ## Enforcement
57
+
58
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
59
+ reported by contacting the project team at vince.broz@bluelabs.com. All
60
+ complaints will be reviewed and investigated and will result in a response that
61
+ is deemed necessary and appropriate to the circumstances. The project team is
62
+ obligated to maintain confidentiality with regard to the reporter of an incident.
63
+ Further details of specific enforcement policies may be posted separately.
64
+
65
+ Project maintainers who do not follow or enforce the Code of Conduct in good
66
+ faith may face temporary or permanent repercussions as determined by other
67
+ members of the project's leadership.
68
+
69
+ ## Attribution
70
+
71
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
72
+ version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
73
+
74
+ [homepage]: http://contributor-covenant.org
75
+ [version]: http://contributor-covenant.org/version/1/4/
@@ -0,0 +1,59 @@
1
+ # BigFiles
2
+
3
+ [![Build Status](https://travis-ci.org/apiology/bigfiles.svg?branch=master)](https://travis-ci.org/apiology/bigfiles)
4
+
5
+ Simple tool to find the largest source files in your project - maybe
6
+ to target for refactoring!
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'bigfiles'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ ```sh
19
+ bundle
20
+ ```
21
+
22
+ Or install it yourself as:
23
+
24
+ ```sh
25
+ gem install bigfiles
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ This is typically used as part of general use of the
31
+ [quality](https://github.com/apiology/quality) gem. You can also run
32
+ it on the command line directly:
33
+
34
+ ```sh
35
+ $ bigfiles
36
+ 165: spec/big_files/big_files_spec.rb
37
+ 76: .rubocop.yml
38
+ 59: spec/big_files/file_with_lines_spec.rb
39
+ $
40
+ ```
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on
45
+ [GitHub](https://github.com/apiology/bigfiles). This project
46
+ is intended to be a safe, welcoming space for collaboration, and
47
+ contributors are expected to adhere to the
48
+ [Contributor Covenant](http://contributor-covenant.org) code of conduct.
49
+
50
+ ## License
51
+
52
+ The gem is available as open source under the terms of the
53
+ [MIT License](https://opensource.org/licenses/MIT).
54
+
55
+ ## Code of Conduct
56
+
57
+ Everyone interacting in the Pronto::Punchlist project’s codebases,
58
+ issue trackers, chat rooms and mailing lists is expected to follow the
59
+ [code of conduct](https://github.com/apiology/bigfiles/blob/master/CODE_OF_CONDUCT.md).
@@ -1,5 +1,6 @@
1
1
  # ; -*-Ruby-*-
2
- # -*- encoding: utf-8 -*-
2
+ # frozen_string_literal: true
3
+
3
4
  $LOAD_PATH.push File.join(File.dirname(__FILE__), 'lib')
4
5
  require 'bigfiles/version'
5
6
 
@@ -27,8 +28,11 @@ Gem::Specification.new do |s|
27
28
 
28
29
  s.add_dependency('source_finder', ['>=2'])
29
30
  s.add_development_dependency('bundler')
31
+ s.add_development_dependency('pronto')
32
+ s.add_development_dependency('pronto-punchlist')
33
+ s.add_development_dependency('pronto-rubocop')
34
+ s.add_development_dependency('quality', '~> 37')
30
35
  s.add_development_dependency('rake')
31
- s.add_development_dependency('quality')
32
36
  s.add_development_dependency('rspec')
33
37
  s.add_development_dependency('simplecov')
34
38
  end
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require_relative '../lib/bigfiles'
4
5
 
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'optparse'
2
4
 
3
5
  require_relative 'bigfiles/file_with_lines'
6
+ require_relative 'bigfiles/option_parser'
7
+ require_relative 'bigfiles/inspector'
4
8
  require 'source_finder/source_file_globber'
5
9
  require 'source_finder/option_parser'
6
10
 
@@ -13,71 +17,30 @@ module BigFiles
13
17
  exiter: Kernel,
14
18
  file_with_lines: FileWithLines,
15
19
  source_file_globber: SourceFinder::SourceFileGlobber.new,
16
- option_parser_class: OptionParser,
17
- source_finder_option_parser: SourceFinder::OptionParser.new)
18
- @io = io
19
- @exiter = exiter
20
- @file_with_lines = file_with_lines
21
- @source_file_globber = source_file_globber
22
- @option_parser_class = option_parser_class
23
- @source_finder_option_parser = source_finder_option_parser
24
- @options = parse_options(args)
25
- end
26
-
27
- def parse_options(args)
28
- options = nil
29
- @option_parser_class.new do |opts|
30
- options = setup_options(opts)
31
- @option_parser = opts
32
- end.parse!(args)
33
- options
34
- end
35
-
36
- def glob
37
- @options[:glob] || @source_finder_option_parser.default_source_files_glob
38
- end
39
-
40
- def exclude_glob
41
- @options[:exclude] ||
42
- @source_finder_option_parser.default_source_files_exclude_glob
43
- end
44
-
45
- def add_help_option(opts, options)
46
- opts.on('-h', '--help', 'This message') do |_|
47
- options[:help] = true
48
- end
49
- end
50
-
51
- def setup_options(opts)
52
- options = {}
53
- opts.banner = 'Usage: bigfiles [options]'
54
- @source_finder_option_parser.add_options(opts, options)
55
- add_help_option(opts, options)
56
- options
57
- end
58
-
59
- def usage
60
- @io.puts @option_parser
61
- @exiter.exit 1
62
- end
63
-
64
- def find_analyze_and_report_on_files
65
- @source_file_globber.source_files_glob = glob
66
- @source_file_globber.source_files_exclude_glob = exclude_glob
67
- file_list = @source_file_globber.source_files_arr
68
- files_with_lines = file_list.map do |filename|
69
- @file_with_lines.new(filename)
70
- end
71
- files_with_lines.sort.reverse[0..2].each do |file|
72
- @io.puts "#{file.num_lines}: #{file.filename}"
73
- end
20
+ inspector_class: Inspector,
21
+ option_parser_class: ::OptionParser,
22
+ source_finder_option_parser: SourceFinder::OptionParser.new,
23
+ bigfiles_option_parser:
24
+ ::BigFiles::OptionParser
25
+ .new(option_parser_class: option_parser_class,
26
+ io: io,
27
+ exiter: exiter,
28
+ source_finder_option_parser:
29
+ source_finder_option_parser),
30
+ config: bigfiles_option_parser.parse_options(args))
31
+ @bigfiles_option_parser = bigfiles_option_parser
32
+ @config = config
33
+ @inspector = inspector_class.new(source_file_globber: source_file_globber,
34
+ config: config,
35
+ file_with_lines: file_with_lines,
36
+ io: io)
74
37
  end
75
38
 
76
39
  def run
77
- if @options[:help]
78
- usage
40
+ if @config.help
41
+ @bigfiles_option_parser.usage
79
42
  else
80
- find_analyze_and_report_on_files
43
+ @inspector.find_analyze_and_report_on_files
81
44
  end
82
45
  end
83
46
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'source_finder/option_parser'
4
+ require 'quality/threshold'
5
+
6
+ module BigFiles
7
+ # Configuration for bigfiles gem
8
+ class Config
9
+ NUM_FILES_DEFAULT = 3
10
+
11
+ attr_reader :help, :num_files, :glob, :exclude, :minimum_high_water_mark
12
+ def initialize(source_finder_option_parser: SourceFinder::OptionParser.new,
13
+ num_files: Config::NUM_FILES_DEFAULT,
14
+ quality_threshold: ::Quality::Threshold.new('bigfiles'),
15
+ minimum_high_water_mark: 300,
16
+ help: false,
17
+ glob: source_finder_option_parser.default_source_files_glob,
18
+ exclude: source_finder_option_parser
19
+ .default_source_files_exclude_glob)
20
+ @num_files = num_files
21
+ @help = help
22
+ @glob = glob
23
+ @exclude = exclude
24
+ @quality_threshold = quality_threshold
25
+ @minimum_high_water_mark = minimum_high_water_mark
26
+ end
27
+
28
+ def high_water_mark
29
+ @quality_threshold.threshold || @minimum_high_water_mark
30
+ end
31
+
32
+ def under_limit?(num_lines)
33
+ num_lines <= high_water_mark
34
+ end
35
+ end
36
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module BigFiles
2
4
  # Encapsulates a file which has a certain number of lines
3
5
  class FileWithLines
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'config'
4
+ require_relative 'file_with_lines'
5
+
6
+ # Simple tool to find the largest source files in your project.
7
+ module BigFiles
8
+ # Investigate a project and generate a report on the n biggest files
9
+ class Inspector
10
+ def initialize(config: Config.new,
11
+ source_file_globber: SourceFinder::SourceFileGlobber.new,
12
+ file_with_lines: FileWithLines,
13
+ io: Kernel)
14
+ @config = config
15
+ @source_file_globber = source_file_globber
16
+ @file_with_lines = file_with_lines
17
+ @io = io
18
+ end
19
+
20
+ def find_and_analyze
21
+ @source_file_globber.source_files_glob = @config.glob
22
+ @source_file_globber.source_files_exclude_glob = @config.exclude
23
+ file_list = @source_file_globber.source_files_arr
24
+ file_list.map do |filename|
25
+ @file_with_lines.new(filename)
26
+ end.sort.reverse[0..(@config.num_files - 1)]
27
+ end
28
+
29
+ def find_analyze_and_report_on_files
30
+ find_and_analyze.each do |file|
31
+ @io.puts "#{file.num_lines}: #{file.filename}"
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'config'
4
+
5
+ module BigFiles
6
+ # Parse options passed to bigfiles command
7
+ class OptionParser
8
+ def initialize(option_parser_class: ::OptionParser,
9
+ io: Kernel,
10
+ exiter: Kernel,
11
+ source_finder_option_parser:)
12
+ @option_parser_class = option_parser_class
13
+ @io = io
14
+ @exiter = exiter
15
+ @source_finder_option_parser = source_finder_option_parser
16
+ end
17
+
18
+ def setup_options(opts)
19
+ options = {}
20
+ opts.banner = 'Usage: bigfiles [options]'
21
+ @source_finder_option_parser.add_options(opts, options)
22
+ add_help_option(opts, options)
23
+ add_num_files_option(opts, options)
24
+ options
25
+ end
26
+
27
+ def add_num_files_option(opts, options)
28
+ opts.on('-n', '--num-files number-here',
29
+ Integer,
30
+ "Top number of files to show--" \
31
+ "default #{Config::NUM_FILES_DEFAULT}") do |n|
32
+ options[:num_files] = n
33
+ end
34
+ end
35
+
36
+ def add_help_option(opts, options)
37
+ opts.on('-h', '--help', 'This message') { |_| options[:help] = true }
38
+ end
39
+
40
+ def parse_options(args)
41
+ options = nil
42
+ @option_parser_class.new do |opts|
43
+ options = setup_options(opts)
44
+ @option_parser = opts
45
+ end.parse!(args)
46
+ Config.new(**options,
47
+ source_finder_option_parser: @source_finder_option_parser)
48
+ end
49
+
50
+ def usage
51
+ @io.puts @option_parser
52
+ @exiter.exit(1)
53
+ end
54
+ end
55
+ end
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Tool to find the largest source files in your project
2
4
  module BigFiles
3
- VERSION = '0.1.3'
5
+ VERSION = '0.2.0'
4
6
  end
metadata CHANGED
@@ -1,97 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigfiles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.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-11-22 00:00:00.000000000 Z
11
+ date: 2020-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: source_finder
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: pronto
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pronto-punchlist
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pronto-rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
53
81
  - !ruby/object:Gem::Version
54
82
  version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: quality
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
- - - '>='
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '37'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '37'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
60
102
  - !ruby/object:Gem::Version
61
103
  version: '0'
62
104
  type: :development
63
105
  prerelease: false
64
106
  version_requirements: !ruby/object:Gem::Requirement
65
107
  requirements:
66
- - - '>='
108
+ - - ">="
67
109
  - !ruby/object:Gem::Version
68
110
  version: '0'
69
111
  - !ruby/object:Gem::Dependency
70
112
  name: rspec
71
113
  requirement: !ruby/object:Gem::Requirement
72
114
  requirements:
73
- - - '>='
115
+ - - ">="
74
116
  - !ruby/object:Gem::Version
75
117
  version: '0'
76
118
  type: :development
77
119
  prerelease: false
78
120
  version_requirements: !ruby/object:Gem::Requirement
79
121
  requirements:
80
- - - '>='
122
+ - - ">="
81
123
  - !ruby/object:Gem::Version
82
124
  version: '0'
83
125
  - !ruby/object:Gem::Dependency
84
126
  name: simplecov
85
127
  requirement: !ruby/object:Gem::Requirement
86
128
  requirements:
87
- - - '>='
129
+ - - ">="
88
130
  - !ruby/object:Gem::Version
89
131
  version: '0'
90
132
  type: :development
91
133
  prerelease: false
92
134
  version_requirements: !ruby/object:Gem::Requirement
93
135
  requirements:
94
- - - '>='
136
+ - - ">="
95
137
  - !ruby/object:Gem::Version
96
138
  version: '0'
97
139
  description: bigfiles finds the largest source files in your project and reports on
@@ -103,11 +145,16 @@ executables:
103
145
  extensions: []
104
146
  extra_rdoc_files: []
105
147
  files:
148
+ - CODE_OF_CONDUCT.md
106
149
  - License.txt
150
+ - README.md
107
151
  - bigfiles.gemspec
108
152
  - bin/bigfiles
109
153
  - lib/bigfiles.rb
154
+ - lib/bigfiles/config.rb
110
155
  - lib/bigfiles/file_with_lines.rb
156
+ - lib/bigfiles/inspector.rb
157
+ - lib/bigfiles/option_parser.rb
111
158
  - lib/bigfiles/version.rb
112
159
  homepage: http://github.com/apiology/bigfiles
113
160
  licenses:
@@ -119,17 +166,17 @@ require_paths:
119
166
  - lib
120
167
  required_ruby_version: !ruby/object:Gem::Requirement
121
168
  requirements:
122
- - - '>='
169
+ - - ">="
123
170
  - !ruby/object:Gem::Version
124
171
  version: '0'
125
172
  required_rubygems_version: !ruby/object:Gem::Requirement
126
173
  requirements:
127
- - - '>='
174
+ - - ">="
128
175
  - !ruby/object:Gem::Version
129
176
  version: '0'
130
177
  requirements: []
131
178
  rubyforge_project:
132
- rubygems_version: 2.4.6
179
+ rubygems_version: 2.6.14.4
133
180
  signing_key:
134
181
  specification_version: 4
135
182
  summary: Finds largest source files in a project