bundler-dependencies 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +3 -0
- data/.rubocop.yml +30 -0
- data/.ruby-version +1 -0
- data/.travis.yml +22 -0
- data/CHANGES.md +9 -0
- data/Gemfile +8 -0
- data/LICENSE +7 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/bundle-dependencies +10 -0
- data/bin/bundler-dependencies +3 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bundler-dependencies.gemspec +48 -0
- data/lib/bundler/dependencies.rb +20 -0
- data/lib/bundler/dependencies/cli.rb +40 -0
- data/lib/bundler/dependencies/cli/command.rb +63 -0
- data/lib/bundler/dependencies/cli/count.rb +32 -0
- data/lib/bundler/dependencies/cli/graph.rb +24 -0
- data/lib/bundler/dependencies/graph.rb +85 -0
- data/lib/bundler/dependencies/scanner.rb +36 -0
- data/lib/bundler/dependencies/spec.rb +38 -0
- data/lib/bundler/dependencies/version.rb +5 -0
- data/lib/bundler/dependencies/visitor.rb +12 -0
- data/lib/bundler/dependencies/visitors/shell_tree.rb +30 -0
- metadata +173 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c16e60328617e09d591746dda98147960439c09872d72f19c190cfd9db7dc507
|
4
|
+
data.tar.gz: f47346858b2f17ce75367442716e57d954a858bd7bb5e41d7021b1086b4e6ea6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '09d8abbe0cf1bc3bec621640976db86f8ce8a9b7cb1e15cfa6ea8b28721249e66f5145de0c09438cd2a556ffe232fc038cb5d9dbe79748c97a79c9ac36efc990'
|
7
|
+
data.tar.gz: 01bb7b0342df912eb034bb583e5abac4c487ed60a98ea94b491ad22e8bb4c950f4a23d7768ec7b6b7139f578b6b028011423b2328cf2430f0fc8443864c075fa
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
inherit_gem:
|
2
|
+
rubocop_defaults: .rubocop.yml
|
3
|
+
|
4
|
+
inherit_mode:
|
5
|
+
merge:
|
6
|
+
- Exclude
|
7
|
+
- IgnoredMethods
|
8
|
+
|
9
|
+
AllCops:
|
10
|
+
TargetRubyVersion: 2.6
|
11
|
+
Exclude:
|
12
|
+
- .pryrc
|
13
|
+
|
14
|
+
Layout/IndentFirstArrayElement:
|
15
|
+
EnforcedStyle: consistent
|
16
|
+
|
17
|
+
RSpec/ExampleLength:
|
18
|
+
Max: 10
|
19
|
+
Exclude:
|
20
|
+
- spec/bundler/dependencies/cli_spec.rb
|
21
|
+
|
22
|
+
Style/FormatStringToken:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Style/NumericPredicate:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
Style/MethodCallWithArgsParentheses:
|
29
|
+
IgnoredMethods:
|
30
|
+
- method_option
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.2
|
data/.travis.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
---
|
2
|
+
os: linux
|
3
|
+
language: ruby
|
4
|
+
cache: bundler
|
5
|
+
rvm:
|
6
|
+
- 2.6.5
|
7
|
+
- 2.5.7
|
8
|
+
- 2.4.9
|
9
|
+
- 2.7.0-preview2
|
10
|
+
before_install: gem install bundler -v 2.0.1
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
include:
|
14
|
+
- stage: lint
|
15
|
+
rvm: 2.6.5
|
16
|
+
script: bundle exec rubocop
|
17
|
+
allow_failures:
|
18
|
+
- rvm: 2.7.0.preview2
|
19
|
+
|
20
|
+
stages:
|
21
|
+
- lint
|
22
|
+
- test
|
data/CHANGES.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright 2019 Daniel Vandersluis
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Bundler::Dependencies
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/dvandersluis/bundler-dependencies.svg?branch=master)](https://travis-ci.org/dvandersluis/bundler-dependencies)
|
4
|
+
|
5
|
+
Bundler plugin to inspect dependencies of gems used by your project.
|
6
|
+
|
7
|
+
## Commands
|
8
|
+
|
9
|
+
### Count
|
10
|
+
|
11
|
+
Check how many dependencies each gem in the Gemfile has (use the `--minimum N` switch to limit the output to gems with at least `N` dependencies):
|
12
|
+
|
13
|
+
```sh
|
14
|
+
bundle dependencies [count] [--minimum N]
|
15
|
+
```
|
16
|
+
|
17
|
+
### Graph
|
18
|
+
|
19
|
+
See a graph of all dependencies:
|
20
|
+
```sh
|
21
|
+
bundle dependencies graph
|
22
|
+
```
|
23
|
+
|
24
|
+
See a graph of all dependencies for a specific gem:
|
25
|
+
```sh
|
26
|
+
bundle dependencies graph GEMNAME
|
27
|
+
```
|
28
|
+
|
29
|
+
### Command Options
|
30
|
+
|
31
|
+
* `--path PATH`: User the Gemfile for the project at `PATH`, rather than the current project's Gemfile.
|
32
|
+
* `--without foo bar baz`/`-W foo bar baz`: Exclude the listed gems from the scan. Any uses either directly in your Gemfile or as dependencies will be excluded, and not be counted.
|
33
|
+
* `--without-rails`/`-R`: Quick option to exclude all 1st party Rails gems from the scan.
|
34
|
+
|
35
|
+
## Development
|
36
|
+
|
37
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
38
|
+
|
39
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/dvandersluis/bundler-dependencies.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'bundler/dependencies'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'bundler/dependencies/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'bundler-dependencies'
|
7
|
+
spec.version = Bundler::Dependencies::VERSION
|
8
|
+
spec.authors = ['Daniel Vandersluis']
|
9
|
+
spec.email = ['daniel.vandersluis@gmail.com']
|
10
|
+
spec.licenses = ['MIT']
|
11
|
+
|
12
|
+
spec.summary = 'Find gems in your Gemfile with too many dependencies'
|
13
|
+
spec.homepage = 'https://github.com/dvandersluis/bundler-dependencies'
|
14
|
+
|
15
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
19
|
+
|
20
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
21
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
22
|
+
spec.metadata['changelog_uri'] = "#{spec.homepage}/CHANGES.md"
|
23
|
+
else
|
24
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
25
|
+
'public gem pushes.'
|
26
|
+
end
|
27
|
+
|
28
|
+
# Specify which files should be added to the gem when it is released.
|
29
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
30
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
31
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
32
|
+
end
|
33
|
+
|
34
|
+
glob = lambda { |patterns| spec.files & Dir[*patterns] }
|
35
|
+
spec.executables = glob['bin/bundle*'].map { |path| File.basename(path) }
|
36
|
+
spec.default_executable = spec.executables.first if Gem::VERSION < '1.7.'
|
37
|
+
|
38
|
+
spec.require_paths = ['lib']
|
39
|
+
|
40
|
+
spec.add_dependency 'bundler', '~> 2.0'
|
41
|
+
spec.add_dependency 'thor', '~> 0.20.3'
|
42
|
+
|
43
|
+
spec.add_development_dependency 'pry', '~> 0.12.2'
|
44
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
45
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
46
|
+
spec.add_development_dependency 'rubocop', '~> 0.76.0'
|
47
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 1.36.0'
|
48
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'bundler/dependencies/version'
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
|
5
|
+
require 'bundler/dependencies/cli'
|
6
|
+
require 'bundler/dependencies/graph'
|
7
|
+
require 'bundler/dependencies/scanner'
|
8
|
+
require 'bundler/dependencies/spec'
|
9
|
+
require 'bundler/dependencies/visitor'
|
10
|
+
|
11
|
+
require 'bundler/dependencies/cli/command'
|
12
|
+
require 'bundler/dependencies/cli/count'
|
13
|
+
require 'bundler/dependencies/cli/graph'
|
14
|
+
|
15
|
+
require 'bundler/dependencies/visitors/shell_tree'
|
16
|
+
|
17
|
+
module Bundler
|
18
|
+
module Dependencies
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'bundler'
|
3
|
+
require 'bundler/vendored_thor'
|
4
|
+
|
5
|
+
require 'bundler/dependencies'
|
6
|
+
|
7
|
+
module Bundler
|
8
|
+
module Dependencies
|
9
|
+
class CLI < ::Thor
|
10
|
+
def self.shared_options
|
11
|
+
method_option :path, type: :string, desc: 'Path to Gemfile.lock to scan'
|
12
|
+
method_option :without, type: :array, desc: 'Gems to ignore', aliases: ['-W']
|
13
|
+
method_option :without_rails, type: :boolean, default: false, desc: 'Ignore all Rails gems', aliases: ['-R']
|
14
|
+
end
|
15
|
+
|
16
|
+
default_task :count
|
17
|
+
map '--version' => :version
|
18
|
+
|
19
|
+
desc 'count', 'Checks for gems that install too many dependencies'
|
20
|
+
shared_options
|
21
|
+
method_option :minimum, type: :numeric, desc: 'Report only gems with a minimum N dependencies', aliases: ['-m'], default: 0
|
22
|
+
|
23
|
+
def count
|
24
|
+
Count.new(options).output
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'graph [GEM]', 'Outputs a dependency graph'
|
28
|
+
shared_options
|
29
|
+
|
30
|
+
def graph(gem = nil)
|
31
|
+
Graph.new(gem, options).output
|
32
|
+
end
|
33
|
+
|
34
|
+
desc 'version', 'Prints the bundler-dependencies version'
|
35
|
+
def version
|
36
|
+
puts "#{File.basename($PROGRAM_NAME)} #{VERSION}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Bundler
|
2
|
+
module Dependencies
|
3
|
+
class CLI < ::Thor
|
4
|
+
class Command < ::Thor
|
5
|
+
RAILS_GEMS = %w(
|
6
|
+
rails actioncable actionmailbox actionmailer actionpack actiontext actionview
|
7
|
+
activejob activemodel activerecord activestorage activesupport railties
|
8
|
+
).freeze
|
9
|
+
|
10
|
+
def initialize(options)
|
11
|
+
@options = options
|
12
|
+
end
|
13
|
+
|
14
|
+
no_commands do
|
15
|
+
def output
|
16
|
+
to_s
|
17
|
+
rescue Bundler::GemfileNotFound
|
18
|
+
error("Could not locate Gemfile at #{SharedHelpers.pwd}.")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :options
|
25
|
+
|
26
|
+
def scanner
|
27
|
+
@scanner ||= Scanner.new(path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def graph
|
31
|
+
@graph ||= scanner.graph
|
32
|
+
end
|
33
|
+
|
34
|
+
def path
|
35
|
+
return options.path if valid_gemfile?(options.path)
|
36
|
+
|
37
|
+
SharedHelpers.chdir(File.dirname(options.path)) if options.path
|
38
|
+
SharedHelpers.default_lockfile
|
39
|
+
end
|
40
|
+
|
41
|
+
def valid_gemfile?(path)
|
42
|
+
return false unless path && File.exist?(path)
|
43
|
+
|
44
|
+
%w(Gemfile.lock gems.locked).include?(File.basename(path))
|
45
|
+
end
|
46
|
+
|
47
|
+
def without
|
48
|
+
(options.without || []).tap do |gems|
|
49
|
+
gems.concat(RAILS_GEMS) if options.without_rails?
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def warn(message)
|
54
|
+
say(message, %i(bold yellow))
|
55
|
+
end
|
56
|
+
|
57
|
+
def error(message)
|
58
|
+
say(message, %i(bold red))
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Bundler
|
2
|
+
module Dependencies
|
3
|
+
class CLI < ::Thor
|
4
|
+
class Count < Command
|
5
|
+
private
|
6
|
+
|
7
|
+
def to_s
|
8
|
+
say(scanner.to_s, :bold)
|
9
|
+
warnings
|
10
|
+
format_counts
|
11
|
+
end
|
12
|
+
|
13
|
+
def counts
|
14
|
+
@counts ||= graph.without(*without).counts(min: options.minimum)
|
15
|
+
end
|
16
|
+
|
17
|
+
def warnings
|
18
|
+
warn("#{counts.count} gems with at least #{options.minimum} dependencies.") if options.minimum > 0
|
19
|
+
warn("#{counts.count} gems found after applying exclusions.") if options.without
|
20
|
+
end
|
21
|
+
|
22
|
+
def format_counts
|
23
|
+
puts "\nUnique dependencies per gem:"
|
24
|
+
|
25
|
+
counts.each do |gem, count|
|
26
|
+
puts format('%5d %s', count, gem) unless gem == File.basename($PROGRAM_NAME)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Bundler
|
2
|
+
module Dependencies
|
3
|
+
class CLI < ::Thor
|
4
|
+
class Graph < Command
|
5
|
+
def initialize(gem, options)
|
6
|
+
@gem = gem
|
7
|
+
super(options)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
attr_reader :gem
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
Visitors::ShellTree.new.walk(graph.without(*without), shell)
|
16
|
+
end
|
17
|
+
|
18
|
+
def graph
|
19
|
+
gem ? Bundler::Dependencies::Graph.new(specs: [Spec.find(gem)]) : super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Bundler
|
2
|
+
module Dependencies
|
3
|
+
class Graph
|
4
|
+
include Enumerable
|
5
|
+
|
6
|
+
def initialize(lockfile: nil, specs: [])
|
7
|
+
@lockfile = lockfile
|
8
|
+
|
9
|
+
if lockfile
|
10
|
+
load_lockfile
|
11
|
+
else
|
12
|
+
@specs = specs
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize_copy(source)
|
17
|
+
super
|
18
|
+
@gems = source.send(:gems).dup
|
19
|
+
end
|
20
|
+
|
21
|
+
def empty?
|
22
|
+
gems.empty?
|
23
|
+
end
|
24
|
+
|
25
|
+
def each(&block)
|
26
|
+
gems.each(&block)
|
27
|
+
end
|
28
|
+
|
29
|
+
def counts(min: 0)
|
30
|
+
@counts ||= map do |gem|
|
31
|
+
count = gem.dependency_count
|
32
|
+
next if count < min
|
33
|
+
|
34
|
+
[gem.name, gem.dependency_count]
|
35
|
+
end.compact.sort_by(&:last).reverse.to_h
|
36
|
+
end
|
37
|
+
|
38
|
+
def delete(*specs)
|
39
|
+
specs.each do |gem|
|
40
|
+
spec = Spec.new(gem) unless gem.is_a?(Spec)
|
41
|
+
gems.delete(spec)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def include?(gem)
|
46
|
+
gem = Spec.new(gem) unless gem.is_a?(Spec)
|
47
|
+
gems.include?(gem)
|
48
|
+
end
|
49
|
+
|
50
|
+
def include_dependency?(gem)
|
51
|
+
gem = Spec.new(gem) unless gem.is_a?(Spec)
|
52
|
+
include?(gem) || any? { |spec| spec.dependencies.include_dependency?(gem) }
|
53
|
+
end
|
54
|
+
|
55
|
+
def without(*gems)
|
56
|
+
graph = dup
|
57
|
+
graph.delete(*gems)
|
58
|
+
graph.walk { |gem| gem.dependencies.delete(*gems) }
|
59
|
+
end
|
60
|
+
|
61
|
+
def walk(&block)
|
62
|
+
Visitor.walk(self, &block)
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
attr_reader :lockfile, :specs
|
69
|
+
|
70
|
+
def gems
|
71
|
+
@gems ||= if lockfile
|
72
|
+
lockfile.dependencies.keys.map { |name| Spec.new(name) }
|
73
|
+
else
|
74
|
+
specs
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def load_lockfile
|
79
|
+
@specs = lockfile.specs.each_with_object([]) do |spec, acc|
|
80
|
+
acc << Spec.new(spec.name, spec.dependencies.map(&:name))
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Bundler
|
2
|
+
module Dependencies
|
3
|
+
class Scanner
|
4
|
+
attr_reader :graph
|
5
|
+
|
6
|
+
def initialize(path = Bundler.default_lockfile)
|
7
|
+
@lockfile = LockfileParser.new(Bundler.read_file(path))
|
8
|
+
@graph = Graph.new(lockfile: lockfile)
|
9
|
+
end
|
10
|
+
|
11
|
+
def gem_count
|
12
|
+
gems.count
|
13
|
+
end
|
14
|
+
|
15
|
+
def spec_count
|
16
|
+
specs.count
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
"#{gem_count} gems scanned; #{spec_count} dependencies found"
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :lockfile
|
26
|
+
|
27
|
+
def gems
|
28
|
+
lockfile.dependencies.keys
|
29
|
+
end
|
30
|
+
|
31
|
+
def specs
|
32
|
+
lockfile.specs
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Bundler
|
2
|
+
module Dependencies
|
3
|
+
class Spec
|
4
|
+
SPECS = {} # rubocop:disable Style/MutableConstant
|
5
|
+
|
6
|
+
attr_accessor :name, :dependencies
|
7
|
+
|
8
|
+
def self.new(name, dependencies = [])
|
9
|
+
name = name.to_sym
|
10
|
+
spec = find(name) || super(name)
|
11
|
+
spec.dependencies = Graph.new(specs: dependencies.map { |d| new(d) }) if dependencies.any?
|
12
|
+
spec
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.find(name)
|
16
|
+
SPECS[name.to_sym]
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(name)
|
20
|
+
@name = name
|
21
|
+
@dependencies = Graph.new
|
22
|
+
|
23
|
+
SPECS[name] = self
|
24
|
+
end
|
25
|
+
|
26
|
+
def flatten
|
27
|
+
dependencies.inject([]) do |arr, dependency|
|
28
|
+
arr << dependency
|
29
|
+
arr.concat(dependency.flatten)
|
30
|
+
end.uniq
|
31
|
+
end
|
32
|
+
|
33
|
+
def dependency_count
|
34
|
+
flatten.count
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Bundler
|
2
|
+
module Dependencies
|
3
|
+
module Visitors
|
4
|
+
class ShellTree
|
5
|
+
def walk(graph, shell = nil)
|
6
|
+
Visitor.walk(graph) do |gem, depth|
|
7
|
+
if depth > 0
|
8
|
+
print ' ' * depth
|
9
|
+
print '- '
|
10
|
+
end
|
11
|
+
|
12
|
+
say(shell, gem.name, (:bold if depth == 0))
|
13
|
+
end
|
14
|
+
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def say(shell, message, opts)
|
21
|
+
if shell
|
22
|
+
shell.say(message, opts)
|
23
|
+
else
|
24
|
+
puts message
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bundler-dependencies
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Vandersluis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-11-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.20.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.20.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.12.2
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.12.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.76.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.76.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.36.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.36.0
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- daniel.vandersluis@gmail.com
|
114
|
+
executables:
|
115
|
+
- bundle-dependencies
|
116
|
+
- bundler-dependencies
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- ".gitignore"
|
121
|
+
- ".rspec"
|
122
|
+
- ".rubocop.yml"
|
123
|
+
- ".ruby-version"
|
124
|
+
- ".travis.yml"
|
125
|
+
- CHANGES.md
|
126
|
+
- Gemfile
|
127
|
+
- LICENSE
|
128
|
+
- README.md
|
129
|
+
- Rakefile
|
130
|
+
- bin/bundle-dependencies
|
131
|
+
- bin/bundler-dependencies
|
132
|
+
- bin/console
|
133
|
+
- bin/setup
|
134
|
+
- bundler-dependencies.gemspec
|
135
|
+
- lib/bundler/dependencies.rb
|
136
|
+
- lib/bundler/dependencies/cli.rb
|
137
|
+
- lib/bundler/dependencies/cli/command.rb
|
138
|
+
- lib/bundler/dependencies/cli/count.rb
|
139
|
+
- lib/bundler/dependencies/cli/graph.rb
|
140
|
+
- lib/bundler/dependencies/graph.rb
|
141
|
+
- lib/bundler/dependencies/scanner.rb
|
142
|
+
- lib/bundler/dependencies/spec.rb
|
143
|
+
- lib/bundler/dependencies/version.rb
|
144
|
+
- lib/bundler/dependencies/visitor.rb
|
145
|
+
- lib/bundler/dependencies/visitors/shell_tree.rb
|
146
|
+
homepage: https://github.com/dvandersluis/bundler-dependencies
|
147
|
+
licenses:
|
148
|
+
- MIT
|
149
|
+
metadata:
|
150
|
+
allowed_push_host: https://rubygems.org
|
151
|
+
homepage_uri: https://github.com/dvandersluis/bundler-dependencies
|
152
|
+
source_code_uri: https://github.com/dvandersluis/bundler-dependencies
|
153
|
+
changelog_uri: https://github.com/dvandersluis/bundler-dependencies/CHANGES.md
|
154
|
+
post_install_message:
|
155
|
+
rdoc_options: []
|
156
|
+
require_paths:
|
157
|
+
- lib
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0'
|
163
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
requirements: []
|
169
|
+
rubygems_version: 3.0.3
|
170
|
+
signing_key:
|
171
|
+
specification_version: 4
|
172
|
+
summary: Find gems in your Gemfile with too many dependencies
|
173
|
+
test_files: []
|