bigfiles 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +134 -0
  3. data/.envrc +2 -0
  4. data/.git-hooks/pre_commit/circle_ci.rb +21 -0
  5. data/.gitattributes +6 -0
  6. data/.gitignore +65 -0
  7. data/.overcommit.yml +55 -0
  8. data/.rubocop.yml +116 -0
  9. data/.rubocop_todo.yml +13 -0
  10. data/.yamllint.yml +8 -0
  11. data/CODE_OF_CONDUCT.md +104 -46
  12. data/DEVELOPMENT.md +30 -0
  13. data/Gemfile +6 -0
  14. data/Gemfile.lock +110 -0
  15. data/LICENSE +21 -0
  16. data/Makefile +73 -0
  17. data/README.md +3 -2
  18. data/Rakefile +3 -0
  19. data/bigfiles.gemspec +42 -33
  20. data/bin/bigfiles +25 -2
  21. data/bin/bump +29 -0
  22. data/bin/overcommit +29 -0
  23. data/bin/rake +29 -0
  24. data/coverage/.last_run.json +6 -0
  25. data/docs/cookiecutter_input.json +13 -0
  26. data/exe/bigfiles +6 -0
  27. data/feature/big_files_cli_spec.rb +49 -0
  28. data/feature/expected/four_files_results.txt +3 -0
  29. data/feature/expected/no_files_results.txt +0 -0
  30. data/feature/expected/swift_and_ruby_files_results.txt +3 -0
  31. data/feature/expected/swift_zorb_and_ruby_files_excluded_results.txt +3 -0
  32. data/feature/expected/swift_zorb_and_ruby_files_results.txt +3 -0
  33. data/feature/expected/three_files_results.txt +3 -0
  34. data/feature/feature_helper.rb +33 -0
  35. data/feature/pronto_big_files_use_spec.rb +54 -0
  36. data/feature/samples/four_files/five_lines.rb +5 -0
  37. data/feature/samples/four_files/four_lines.rb +4 -0
  38. data/feature/samples/four_files/three_lines.rb +3 -0
  39. data/feature/samples/four_files/two_lines.rb +2 -0
  40. data/feature/samples/no_files/.keepme +0 -0
  41. data/feature/samples/swift_and_ruby_files/five_lines.swift +5 -0
  42. data/feature/samples/swift_and_ruby_files/four_lines.rb +4 -0
  43. data/feature/samples/swift_and_ruby_files/three_lines.rb +3 -0
  44. data/feature/samples/swift_zorb_and_ruby_files/five_lines.swift +5 -0
  45. data/feature/samples/swift_zorb_and_ruby_files/four_lines.zorb +4 -0
  46. data/feature/samples/swift_zorb_and_ruby_files/three_lines.rb +3 -0
  47. data/feature/samples/swift_zorb_and_ruby_files_excluded/excluded.rb +9 -0
  48. data/feature/samples/swift_zorb_and_ruby_files_excluded/five_lines.swift +5 -0
  49. data/feature/samples/swift_zorb_and_ruby_files_excluded/four_lines.zorb +4 -0
  50. data/feature/samples/swift_zorb_and_ruby_files_excluded/three_lines.rb +3 -0
  51. data/feature/samples/three_files/five_lines.rb +5 -0
  52. data/feature/samples/three_files/four_lines.rb +4 -0
  53. data/feature/samples/three_files/three_lines.rb +3 -0
  54. data/fix.sh +371 -0
  55. data/lib/bigfiles/config.rb +1 -0
  56. data/lib/bigfiles/inspector.rb +3 -3
  57. data/lib/bigfiles/option_parser.rb +5 -6
  58. data/lib/bigfiles/version.rb +1 -1
  59. data/lib/bigfiles.rb +7 -6
  60. data/rakelib/citest.rake +4 -0
  61. data/rakelib/clear_metrics.rake +17 -0
  62. data/rakelib/console.rake +6 -0
  63. data/rakelib/default.rake +4 -0
  64. data/rakelib/feature.rake +10 -0
  65. data/rakelib/gem_tasks.rake +3 -0
  66. data/rakelib/localtest.rake +4 -0
  67. data/rakelib/overcommit.rake +6 -0
  68. data/rakelib/quality.rake +4 -0
  69. data/rakelib/repl.rake +4 -0
  70. data/rakelib/spec.rake +9 -0
  71. data/rakelib/undercover.rake +8 -0
  72. data/requirements_dev.txt +2 -0
  73. metadata +132 -30
  74. data/License.txt +0 -20
data/Gemfile.lock ADDED
@@ -0,0 +1,110 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bigfiles (0.2.2)
5
+ high_water_mark
6
+ source_finder (>= 2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ bump (0.10.0)
13
+ childprocess (4.1.0)
14
+ coderay (1.1.3)
15
+ diff-lcs (1.4.4)
16
+ docile (1.4.0)
17
+ ffi (1.15.4-java)
18
+ high_water_mark (0.1.0)
19
+ imagen (0.1.8)
20
+ parser (>= 2.5, != 2.5.1.1)
21
+ iniparse (1.5.0)
22
+ method_source (1.0.0)
23
+ overcommit (0.58.0)
24
+ childprocess (>= 0.6.3, < 5)
25
+ iniparse (~> 1.4)
26
+ rexml (~> 3.2)
27
+ parallel (1.21.0)
28
+ parser (3.0.2.0)
29
+ ast (~> 2.4.1)
30
+ pry (0.14.1)
31
+ coderay (~> 1.1)
32
+ method_source (~> 1.0)
33
+ pry (0.14.1-java)
34
+ coderay (~> 1.1)
35
+ method_source (~> 1.0)
36
+ spoon (~> 0.0)
37
+ rainbow (3.0.0)
38
+ rake (13.0.6)
39
+ regexp_parser (2.1.1)
40
+ rexml (3.2.5)
41
+ rspec (3.10.0)
42
+ rspec-core (~> 3.10.0)
43
+ rspec-expectations (~> 3.10.0)
44
+ rspec-mocks (~> 3.10.0)
45
+ rspec-core (3.10.1)
46
+ rspec-support (~> 3.10.0)
47
+ rspec-expectations (3.10.1)
48
+ diff-lcs (>= 1.2.0, < 2.0)
49
+ rspec-support (~> 3.10.0)
50
+ rspec-mocks (3.10.2)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.10.0)
53
+ rspec-support (3.10.3)
54
+ rubocop (1.23.0)
55
+ parallel (~> 1.10)
56
+ parser (>= 3.0.0.0)
57
+ rainbow (>= 2.2.2, < 4.0)
58
+ regexp_parser (>= 1.8, < 3.0)
59
+ rexml
60
+ rubocop-ast (>= 1.12.0, < 2.0)
61
+ ruby-progressbar (~> 1.7)
62
+ unicode-display_width (>= 1.4.0, < 3.0)
63
+ rubocop-ast (1.13.0)
64
+ parser (>= 3.0.1.1)
65
+ rubocop-rake (0.6.0)
66
+ rubocop (~> 1.0)
67
+ rubocop-rspec (2.6.0)
68
+ rubocop (~> 1.19)
69
+ ruby-progressbar (1.11.0)
70
+ rugged (1.1.1)
71
+ simplecov (0.21.2)
72
+ docile (~> 1.1)
73
+ simplecov-html (~> 0.11)
74
+ simplecov_json_formatter (~> 0.1)
75
+ simplecov-html (0.12.3)
76
+ simplecov-lcov (0.8.0)
77
+ simplecov_json_formatter (0.1.3)
78
+ source_finder (3.2.1)
79
+ spoon (0.0.6)
80
+ ffi
81
+ undercover (0.4.3)
82
+ imagen (>= 0.1.8)
83
+ rainbow (>= 2.1, < 4.0)
84
+ rugged (>= 0.27, < 1.2)
85
+ unicode-display_width (2.1.0)
86
+
87
+ PLATFORMS
88
+ java
89
+ ruby
90
+ x86_64-darwin-19
91
+ x86_64-darwin-20
92
+ x86_64-linux
93
+
94
+ DEPENDENCIES
95
+ bigfiles!
96
+ bump
97
+ bundler
98
+ overcommit (>= 0.58.0)
99
+ pry
100
+ rake (~> 13.0)
101
+ rspec (>= 3.4)
102
+ rubocop
103
+ rubocop-rake
104
+ rubocop-rspec
105
+ simplecov (>= 0.18.0)
106
+ simplecov-lcov
107
+ undercover
108
+
109
+ BUNDLED WITH
110
+ 2.2.25
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2013-2021, Vince Broz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/Makefile ADDED
@@ -0,0 +1,73 @@
1
+ .PHONY: clean test help quality localtest spec feature
2
+ .DEFAULT_GOAL := default
3
+
4
+ define PRINT_HELP_PYSCRIPT
5
+ import re, sys
6
+
7
+ for line in sys.stdin:
8
+ match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
9
+ if match:
10
+ target, help = match.groups()
11
+ print("%-20s %s" % (target, help))
12
+ endef
13
+ export PRINT_HELP_PYSCRIPT
14
+
15
+ help:
16
+ @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
17
+
18
+ default: localtest ## run default tests and quality
19
+
20
+ requirements_dev.txt.installed: requirements_dev.txt
21
+ pip install -q --disable-pip-version-check -r requirements_dev.txt
22
+ touch requirements_dev.txt.installed
23
+
24
+ pip_install: requirements_dev.txt.installed ## Install Python dependencies
25
+
26
+ # bundle install doesn't get run here so that we can catch it below in
27
+ # fresh-checkout and fresh-rbenv cases
28
+ Gemfile.lock: Gemfile
29
+
30
+ # Ensure any Gemfile.lock changes ensure a bundle is installed.
31
+ Gemfile.lock.installed: Gemfile.lock
32
+ bundle install
33
+ touch Gemfile.lock.installed
34
+
35
+ bundle_install: Gemfile.lock.installed ## Install Ruby dependencies
36
+
37
+ clear_metrics: ## remove or reset result artifacts created by tests and quality tools
38
+ bundle exec rake clear_metrics
39
+
40
+ clean: clear_metrics ## remove all built artifacts
41
+
42
+ test: spec ## run tests quickly
43
+
44
+ overcommit: ## run precommit quality checks
45
+ bundle exec overcommit --run
46
+
47
+ quality: overcommit ## run precommit quality checks
48
+
49
+ spec: ## Run lower-level tests
50
+ @bundle exec rake spec
51
+
52
+ feature: ## Run higher-level tests
53
+ @bundle exec rake feature
54
+
55
+ localtest: ## run default local actions
56
+ @bundle exec rake localtest
57
+
58
+ repl: ## Load up bigfiles in pry
59
+ @bundle exec rake repl
60
+
61
+ update_from_cookiecutter: ## Bring in changes from template project used to create this repo
62
+ bundle exec overcommit --uninstall
63
+ IN_COOKIECUTTER_PROJECT_UPGRADER=1 cookiecutter_project_upgrader || true
64
+ git checkout cookiecutter-template && git push && git checkout main
65
+ git checkout main && git pull && git checkout -b update-from-cookiecutter-$$(date +%Y-%m-%d-%H%M)
66
+ git merge cookiecutter-template || true
67
+ bundle exec overcommit --install
68
+ @echo
69
+ @echo "Please resolve any merge conflicts below and push up a PR with:"
70
+ @echo
71
+ @echo ' gh pr create --title "Update from cookiecutter" --body "Automated PR to update from cookiecutter boilerplate"'
72
+ @echo
73
+ @echo
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # BigFiles
2
2
 
3
- [![Build Status](https://travis-ci.org/apiology/bigfiles.svg?branch=master)](https://travis-ci.org/apiology/bigfiles)
3
+ [![CircleCI](https://circleci.com/gh/apiology/bigfiles.svg?style=svg)](https://circleci.com/gh/apiology/bigfiles)
4
+
4
5
 
5
6
  Simple tool to find the largest source files in your project - maybe
6
7
  to target for refactoring!
@@ -56,4 +57,4 @@ The gem is available as open source under the terms of the
56
57
 
57
58
  Everyone interacting in the Pronto::Punchlist project’s codebases,
58
59
  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).
60
+ [code of conduct](https://github.com/apiology/bigfiles/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+ # Add your own tasks in files placed in rakelib/ ending in .rake,
3
+ # for example rakelib/capistrano.rake, and they will automatically be available to Rake.
data/bigfiles.gemspec CHANGED
@@ -1,40 +1,49 @@
1
- # ; -*-Ruby-*-
1
+ # coding: ascii
2
2
  # frozen_string_literal: true
3
3
 
4
- $LOAD_PATH.push File.join(File.dirname(__FILE__), 'lib')
4
+ lib = File.expand_path('lib', __dir__)
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
6
  require 'bigfiles/version'
6
7
 
7
- Gem::Specification.new do |s|
8
- s.name = 'bigfiles'
9
- s.version = BigFiles::VERSION
8
+ Gem::Specification.new do |spec|
9
+ spec.name = 'bigfiles'
10
+ spec.version = BigFiles::VERSION
11
+ spec.authors = ['Vince Broz']
12
+ spec.email = ['vince@broz.cc']
13
+ spec.summary = 'Finds largest source files in a project'
14
+ spec.homepage = 'https://github.com/apiology/bigfiles'
15
+ spec.license = 'MIT license'
16
+ spec.required_ruby_version = '>= 2.6'
10
17
 
11
- s.authors = ['Vince Broz']
12
- s.description = 'bigfiles finds the largest source files in your project ' \
13
- 'and reports on them'
14
- s.email = ['vince@broz.cc']
15
- s.executables = ['bigfiles']
16
- # s.extra_rdoc_files = ["CHANGELOG", "License.txt"]
17
- s.license = 'MIT'
18
- s.files = Dir['CODE_OF_CONDUCT.md', 'License.txt', 'README.md',
19
- '{lib}/bigfiles.rb',
20
- '{lib}/bigfiles/**/*.rb',
21
- 'bigfiles.gemspec']
22
- # s.rdoc_options = ["--main", "README.md"]
23
- s.require_paths = ['lib']
24
- s.homepage = 'http://github.com/apiology/bigfiles'
25
- # s.rubyforge_project = %q{bigfiles}
26
- s.rubygems_version = '1.3.6'
27
- s.summary = 'Finds largest source files in a project'
18
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
+ `git ls-files -z`.split("\x0").reject do |f|
20
+ f.match(%r{^(test|spec|features)/})
21
+ end
22
+ end
23
+ spec.bindir = 'exe'
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ['lib']
28
26
 
29
- s.add_dependency('high_water_mark')
30
- s.add_dependency('source_finder', ['>=2'])
31
- s.add_development_dependency('bundler')
32
- s.add_development_dependency('pronto')
33
- s.add_development_dependency('pronto-bigfiles')
34
- s.add_development_dependency('pronto-punchlist')
35
- s.add_development_dependency('pronto-rubocop')
36
- s.add_development_dependency('quality', '~> 37')
37
- s.add_development_dependency('rake')
38
- s.add_development_dependency('rspec')
39
- s.add_development_dependency('simplecov')
27
+ spec.add_dependency('high_water_mark')
28
+ spec.add_dependency('source_finder', ['>=2'])
29
+
30
+ spec.add_development_dependency 'bump'
31
+ spec.add_development_dependency 'bundler'
32
+ # 0.58.0 and 0.57.0 don't seem super compatible with signatures, and
33
+ # magit doesn't seem to want to use the bundled version at the moment,
34
+ # so let's favor the more recent version...
35
+ spec.add_development_dependency 'overcommit', ['>=0.58.0']
36
+ spec.add_development_dependency 'pry'
37
+ spec.add_development_dependency 'rake', '~> 13.0'
38
+ spec.add_development_dependency 'rspec', '>=3.4'
39
+ spec.add_development_dependency 'rubocop'
40
+ spec.add_development_dependency 'rubocop-rake'
41
+ spec.add_development_dependency 'rubocop-rspec'
42
+ # ensure version with branch coverage
43
+ spec.add_development_dependency 'simplecov', ['>=0.18.0']
44
+ spec.add_development_dependency 'simplecov-lcov'
45
+ spec.add_development_dependency 'undercover'
46
+ spec.metadata = {
47
+ 'rubygems_mfa_required' => 'true',
48
+ }
40
49
  end
data/bin/bigfiles CHANGED
@@ -1,6 +1,29 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require_relative '../lib/bigfiles'
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bigfiles' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
5
10
 
6
- BigFiles::BigFiles.new(ARGV).run
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("bigfiles", "bigfiles")
data/bin/bump ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bump' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("bump", "bump")
data/bin/overcommit ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'overcommit' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("overcommit", "overcommit")
data/bin/rake ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rake", "rake")
@@ -0,0 +1,6 @@
1
+ {
2
+ "result": {
3
+ "line": 100.0,
4
+ "branch": 100.0
5
+ }
6
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "_template": "https://github.com/apiology/cookiecutter-gem",
3
+ "email": "vince@broz.cc",
4
+ "full_name": "Vince Broz",
5
+ "github_username": "apiology",
6
+ "module_name": "BigFiles",
7
+ "open_source_license": "MIT license",
8
+ "project_name": "BigFiles",
9
+ "project_short_description": "Simple tool to find the largest source files in your project.",
10
+ "project_slug": "bigfiles",
11
+ "type_of_github_repo": "public",
12
+ "version": "0.1.0"
13
+ }
data/exe/bigfiles ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../lib/bigfiles'
5
+
6
+ BigFiles::BigFiles.new(ARGV).run
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'feature_helper'
4
+
5
+ describe BigFiles do
6
+ let(:default_glob) do
7
+ '{Dockerfile,Rakefile,{*,.*}.{c,clj,cljs,cpp,gemspec,groovy,html,' \
8
+ 'java,js,json,py,rake,rb,scala,sh,swift,yml},{app,config,db,feature,' \
9
+ 'lib,spec,src,test,tests,vars,www}/**/{*,.*}.{c,clj,cljs,cpp,gemspec,' \
10
+ 'groovy,html,java,js,json,py,rake,rb,scala,sh,swift,yml}}'
11
+ end
12
+
13
+ let(:usage) do
14
+ "Usage: bigfiles [options]\n" \
15
+ " -g, --glob glob here " \
16
+ "Which files to parse - default is #{default_glob}" \
17
+ "\n" \
18
+ " -e, --exclude-glob glob here " \
19
+ "Files to exclude - default is none\n" \
20
+ " -h, --help This message\n" \
21
+ " -n, --num-files number-here " \
22
+ "Top number of files to show--default 3\n"
23
+ end
24
+
25
+ it 'starts up with no arguments' do
26
+ expect(exec_io('bigfiles -h')).to eq(usage)
27
+ end
28
+
29
+ # three_files one_file two_files some_nonsource_files many_files
30
+ # zero_byte_file
31
+ %w[no_files three_files four_files swift_and_ruby_files
32
+ swift_zorb_and_ruby_files
33
+ swift_zorb_and_ruby_files_excluded].each do |type|
34
+ context "with #{type}" do
35
+ let(:command) do
36
+ "cd feature/samples/#{type} && " \
37
+ "RUBYLIB=`pwd`/../../lib:\"\$RUBYLIB\" bigfiles " \
38
+ "--glob '*.{rb,swift,zorb}' " \
39
+ "--exclude-glob " \
40
+ "'{excluded.rb}'"
41
+ end
42
+
43
+ it "handles #{type} case" do
44
+ expect(exec_io(command))
45
+ .to eq(File.read("feature/expected/#{type}_results.txt"))
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ 5: five_lines.rb
2
+ 4: four_lines.rb
3
+ 3: three_lines.rb
File without changes
@@ -0,0 +1,3 @@
1
+ 5: five_lines.swift
2
+ 4: four_lines.rb
3
+ 3: three_lines.rb
@@ -0,0 +1,3 @@
1
+ 5: five_lines.swift
2
+ 4: four_lines.zorb
3
+ 3: three_lines.rb
@@ -0,0 +1,3 @@
1
+ 5: five_lines.swift
2
+ 4: four_lines.zorb
3
+ 3: three_lines.rb
@@ -0,0 +1,3 @@
1
+ 5: five_lines.rb
2
+ 4: four_lines.rb
3
+ 3: three_lines.rb
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+ require 'bigfiles'
5
+
6
+ # Add the bin directory, to allow testing of gem executables as if the gem is
7
+ # already installed.
8
+ root_dir = RSpec::Core::RubyProject.root
9
+ exec_dir = File.join(File::SEPARATOR, root_dir, 'bin')
10
+ ENV['PATH'] = [exec_dir, ENV['PATH']].join(File::PATH_SEPARATOR)
11
+
12
+ # Courtesy of:
13
+ # https://raw.github.com/cupakromer/tao-of-tdd/master/adder/spec/support/
14
+ # capture_exec.rb
15
+ def exec_io(*cmd)
16
+ cmd = cmd.flatten
17
+ out_err, _exit_code = Open3.capture2e(*cmd)
18
+
19
+ out_err
20
+ end
21
+
22
+ RSpec.configure do |config|
23
+ config.run_all_when_everything_filtered = true
24
+ config.order = 'random'
25
+ config.alias_it_should_behave_like_to :has_behavior
26
+ config.alias_it_should_behave_like_to :it_has_behavior, 'has behavior:'
27
+ end
28
+
29
+ def let_double(*doubles)
30
+ doubles.each do |double_sym|
31
+ let(double_sym) { double(double_sym.to_s) }
32
+ end
33
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tmpdir'
4
+
5
+ # Example use from https://github.com/apiology/pronto-bigfiles
6
+
7
+ # This spec is here to make sure we don't break backwards
8
+ # compatibility with how this is used elsewhere (i.e., establish a
9
+ # public interface).
10
+
11
+ describe BigFiles do
12
+ let(:bigfiles_config) { ::BigFiles::Config.new }
13
+
14
+ let(:bigfiles_inspector) { ::BigFiles::Inspector.new }
15
+
16
+ let(:bigfiles_results) { bigfiles_inspector.find_and_analyze }
17
+
18
+ let(:under_limit) { bigfiles_config.under_limit?(total_lines) }
19
+
20
+ let(:total_lines) { bigfiles_results.map(&:num_lines).reduce(:+) }
21
+
22
+ let(:sample_filename) { 'file_with_two_lines.rb' }
23
+
24
+ let(:file_with_line) do
25
+ bigfiles_results.find { |f| f.filename == sample_filename }
26
+ end
27
+
28
+ let(:example_files) do
29
+ {
30
+ sample_filename => "\n\n",
31
+ }
32
+ end
33
+
34
+ around do |example|
35
+ Dir.mktmpdir do |dir|
36
+ Dir.chdir(dir) do
37
+ system('git init')
38
+ system('git config user.email "you@example.com"')
39
+ system('git config user.name "Fake User"')
40
+ example_files.each do |filename, contents|
41
+ File.write(filename, contents)
42
+ end
43
+ system('git add .')
44
+ system('git commit -m "First commit"')
45
+ example.run
46
+ end
47
+ end
48
+ end
49
+
50
+ it 'continues to behave like it did' do
51
+ expect(file_with_line).not_to eq(nil)
52
+ expect(under_limit).to be(true)
53
+ end
54
+ end
@@ -0,0 +1,5 @@
1
+ #
2
+ #
3
+ #
4
+ #
5
+ #
@@ -0,0 +1,4 @@
1
+ #
2
+ #
3
+ #
4
+ #
@@ -0,0 +1,3 @@
1
+ #
2
+ #
3
+ #
@@ -0,0 +1,2 @@
1
+ puts 'one'
2
+ puts 'two'
File without changes