bundler-why 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.ruby-version +1 -0
- data/.travis.yml +6 -0
- data/CONTRIBUTING.md +30 -0
- data/Gemfile +7 -0
- data/LICENSE.md +65 -0
- data/README.md +46 -0
- data/bin/console +14 -0
- data/bin/test +3 -0
- data/bundler-why.gemspec +21 -0
- data/lib/bundler/why.rb +8 -0
- data/lib/bundler/why/command.rb +75 -0
- data/lib/bundler/why/version.rb +7 -0
- data/plugins.rb +1 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ac50c4e539f7928944ee960faba8a98ceb9eb3f5ca06135efd684f385e81b420
|
4
|
+
data.tar.gz: b93ed4b008830ff44fc8138568cf6ec33fe345164eb93e1c765ecfdea6a47553
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6146c6debba323e2325ff5000a99e15dc3434669bfab9a83354928e7cfdf15bc9be50847bda681a3158e73b99d26047b944af78bc71019ce77b7fbe8e1b8377d
|
7
|
+
data.tar.gz: 0561dc31c1f1567c1d806045471f827ff08a55c40d404dc263cc09116e5aef51d38ee9c970817bd18101ba83bb7632b8ad3c77f53e5b3b831c36545804e51659
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.1
|
data/.travis.yml
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
This project does not accept contributions at this time.
|
4
|
+
|
5
|
+
These notes are for my own reference.
|
6
|
+
|
7
|
+
## Local development
|
8
|
+
|
9
|
+
The "Running your plugin locally" section of the
|
10
|
+
[How to write a Bundler plugin][1] instructions seems to be wrong, per
|
11
|
+
https://github.com/rubygems/rubygems/issues/3209#issuecomment-652107633
|
12
|
+
|
13
|
+
However, `--git` seems to work. So, I open two tabs, one in the bundler-why
|
14
|
+
directory, the second in some project `banana` with a meaningful gemfile.
|
15
|
+
|
16
|
+
To test a change, in the first tab I make a WIP commit then in the second tab I
|
17
|
+
|
18
|
+
```
|
19
|
+
rm -rf /Users/jared/git/banana/.bundle/plugin
|
20
|
+
bundler plugin install bundler-why \
|
21
|
+
--git file:///Users/jared/git/bundler-why \
|
22
|
+
--verbose --retry=1
|
23
|
+
bundle why tzinfo
|
24
|
+
```
|
25
|
+
|
26
|
+
Deleting the `plugin` directory is a workaround for the fact that [bundler
|
27
|
+
does not provide a command to uninstall plugins][2].
|
28
|
+
|
29
|
+
[1]: https://bundler.io/v2.0/guides/bundler_plugins.html
|
30
|
+
[2]: https://github.com/rubygems/rubygems/issues/3187
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
Do No Harm License
|
2
|
+
|
3
|
+
**Preamble**
|
4
|
+
|
5
|
+
Most software today is developed with little to no thought of how it will be used, or the consequences for our society and planet.
|
6
|
+
|
7
|
+
As software developers, we engineer the infrastructure of the 21st century. We recognise that our infrastructure has great power to shape the world and the lives of those we share it with, and we choose to consciously take responsibility for the social and environmental impacts of what we build.
|
8
|
+
|
9
|
+
We envisage a world free from injustice, inequality, and the reckless destruction of lives and our planet. We reject slavery in all its forms, whether by force, indebtedness, or by algorithms that hack human vulnerabilities. We seek a world where humankind is at peace with our neighbours, nature, and ourselves. We want our work to enrich the physical, mental and spiritual wellbeing of all society.
|
10
|
+
|
11
|
+
We build software to further this vision of a just world, or at the very least, to not put that vision further from reach.
|
12
|
+
|
13
|
+
**Terms**
|
14
|
+
|
15
|
+
*Copyright* (c) *(year)* *(owner)*. All rights reserved.
|
16
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
17
|
+
|
18
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
19
|
+
|
20
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
21
|
+
|
22
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
23
|
+
|
24
|
+
4. This software must not be used by any organisation, website, product or service that:
|
25
|
+
|
26
|
+
a) lobbies for, promotes, or derives a majority of income from actions that support or contribute to:
|
27
|
+
* sex trafficking
|
28
|
+
* human trafficking
|
29
|
+
* slavery
|
30
|
+
* indentured servitude
|
31
|
+
* gambling
|
32
|
+
* tobacco
|
33
|
+
* adversely addictive behaviours
|
34
|
+
* nuclear energy
|
35
|
+
* warfare
|
36
|
+
* weapons manufacturing
|
37
|
+
* war crimes
|
38
|
+
* violence (except when required to protect public safety)
|
39
|
+
* burning of forests
|
40
|
+
* deforestation
|
41
|
+
* hate speech or discrimination based on age, gender, gender identity, race, sexuality, religion, nationality
|
42
|
+
|
43
|
+
b) lobbies against, or derives a majority of income from actions that discourage or frustrate:
|
44
|
+
* peace
|
45
|
+
* access to the rights set out in the Universal Declaration of Human Rights and the Convention on the Rights of the Child
|
46
|
+
* peaceful assembly and association (including worker associations)
|
47
|
+
* a safe environment or action to curtail the use of fossil fuels or prevent climate change
|
48
|
+
* democratic processes
|
49
|
+
|
50
|
+
5. All redistribution of source code or binary form, including any modifications must be under these terms. You must inform recipients that the code is governed by these conditions, and how they can obtain a copy of this license. You may not attempt to alter the conditions of who may/may not use this software.
|
51
|
+
|
52
|
+
We define:
|
53
|
+
|
54
|
+
**Forests** to be 0.5 or more hectares of trees that were either planted more than 50 years ago or were not planted by humans or human made equipment.
|
55
|
+
|
56
|
+
**Deforestation** to be the clearing, burning or destruction of 0.5 or more hectares of forests within a 1 year period.
|
57
|
+
|
58
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
59
|
+
|
60
|
+
**Attribution**
|
61
|
+
|
62
|
+
Do No Harm License [Contributor Covenant][homepage], (pre 1.0),
|
63
|
+
available at https://github.com/raisely/NoHarm
|
64
|
+
|
65
|
+
[homepage]: https://github.com/raisely/NoHarm
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Bundler::Why
|
2
|
+
|
3
|
+
Explains the presence of a dependency.
|
4
|
+
|
5
|
+
```bash
|
6
|
+
bundle why tzinfo
|
7
|
+
ransack -> activesupport -> tzinfo
|
8
|
+
rspec-rails -> activesupport -> tzinfo
|
9
|
+
business_time -> tzinfo
|
10
|
+
...
|
11
|
+
```
|
12
|
+
|
13
|
+
## License
|
14
|
+
|
15
|
+
[Do No Harm License][LICENSE.md]
|
16
|
+
|
17
|
+
By using this software you accept the terms of the license.
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
```bash
|
22
|
+
bundler plugin install bundler-why
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Specify the name of one gem. There are no options.
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
This project does not accept contributions at this time.
|
32
|
+
|
33
|
+
## Graphs are the coolest
|
34
|
+
|
35
|
+
If you like [graphs][1], you'll enjoy knowing that Bundler uses a [directed
|
36
|
+
acyclic graph][2] and `why` is printing all [directed paths][3] to the specified
|
37
|
+
gem.
|
38
|
+
|
39
|
+
## Inspired by
|
40
|
+
|
41
|
+
[`yarn why`][4]
|
42
|
+
|
43
|
+
[1]: https://en.wikipedia.org/wiki/Graph_(discrete_mathematics)
|
44
|
+
[2]: https://en.wikipedia.org/wiki/Directed_acyclic_graph
|
45
|
+
[3]: https://en.wikipedia.org/wiki/Path_(graph_theory)
|
46
|
+
[4]: https://classic.yarnpkg.com/en/docs/cli/why
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bundler/why"
|
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/test
ADDED
data/bundler-why.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'lib/bundler/why/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "bundler-why"
|
5
|
+
spec.licenses = ['Nonstandard']
|
6
|
+
spec.version = ::Bundler::Why.gem_version.to_s
|
7
|
+
spec.authors = ["Jared Beck"]
|
8
|
+
spec.email = ["jared@jaredbeck.com"]
|
9
|
+
spec.summary = 'Explains the presence of a dependency.'
|
10
|
+
spec.homepage = 'https://github.com/jaredbeck/bundler-why'
|
11
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
12
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
13
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
14
|
+
spec.metadata["changelog_uri"] = spec.homepage
|
15
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
16
|
+
`git ls-files -z`.
|
17
|
+
split("\x0").
|
18
|
+
reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
end
|
data/lib/bundler/why.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'byebug'
|
2
|
+
$stdout.sync = true
|
3
|
+
|
4
|
+
module Bundler
|
5
|
+
module Why
|
6
|
+
class Command < ::Bundler::Plugin::API
|
7
|
+
command "why"
|
8
|
+
|
9
|
+
def exec(command, args)
|
10
|
+
if args.length == 1
|
11
|
+
why(args.first)
|
12
|
+
else
|
13
|
+
warn 'Usage: bundle why gemname'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
# `Bundler.load` is a memoized method, so it's OK if we call it a few
|
20
|
+
# times.
|
21
|
+
# @return Bundler::Runtime
|
22
|
+
def runtime
|
23
|
+
Bundler.load
|
24
|
+
end
|
25
|
+
|
26
|
+
# @param spec_set Bundler::SpecSet
|
27
|
+
# @param gem_name String
|
28
|
+
# @return Bundler::StubSpecification
|
29
|
+
def find_one_spec_in_set(spec_set, gem_name)
|
30
|
+
specs = runtime.specs[gem_name]
|
31
|
+
if specs.length == 1
|
32
|
+
specs.first
|
33
|
+
else
|
34
|
+
raise Error, format(
|
35
|
+
'Expected gem name to match exactly 1 spec, got %d',
|
36
|
+
specs.length
|
37
|
+
)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# @param path Array[Bundler::StubSpecification]
|
42
|
+
# @void
|
43
|
+
def print_path(path)
|
44
|
+
puts path.map(&:name).join(' -> ')
|
45
|
+
end
|
46
|
+
|
47
|
+
# @param gem_name String
|
48
|
+
# @void
|
49
|
+
def why(gem_name)
|
50
|
+
spec_set = runtime.specs
|
51
|
+
spec = find_one_spec_in_set(spec_set, gem_name)
|
52
|
+
traverse(spec_set, spec)
|
53
|
+
end
|
54
|
+
|
55
|
+
# @param spec_set Bundler::SpecSet
|
56
|
+
# @param parent Bundler::StubSpecification
|
57
|
+
# @param path Array[Bundler::StubSpecification]
|
58
|
+
# @void
|
59
|
+
def traverse(spec_set, parent, path = [parent])
|
60
|
+
children = spec_set.select { |s|
|
61
|
+
s.dependencies.any? { |d|
|
62
|
+
d.type == :runtime && d.name == parent.name
|
63
|
+
}
|
64
|
+
}
|
65
|
+
if children.empty?
|
66
|
+
print_path(path)
|
67
|
+
else
|
68
|
+
children.each do |child|
|
69
|
+
traverse(spec_set, child, [child].concat(path))
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/plugins.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/why"
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bundler-why
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jared Beck
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- jared@jaredbeck.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".gitignore"
|
21
|
+
- ".ruby-version"
|
22
|
+
- ".travis.yml"
|
23
|
+
- CONTRIBUTING.md
|
24
|
+
- Gemfile
|
25
|
+
- LICENSE.md
|
26
|
+
- README.md
|
27
|
+
- bin/console
|
28
|
+
- bin/test
|
29
|
+
- bundler-why.gemspec
|
30
|
+
- lib/bundler/why.rb
|
31
|
+
- lib/bundler/why/command.rb
|
32
|
+
- lib/bundler/why/version.rb
|
33
|
+
- plugins.rb
|
34
|
+
homepage: https://github.com/jaredbeck/bundler-why
|
35
|
+
licenses:
|
36
|
+
- Nonstandard
|
37
|
+
metadata:
|
38
|
+
homepage_uri: https://github.com/jaredbeck/bundler-why
|
39
|
+
source_code_uri: https://github.com/jaredbeck/bundler-why
|
40
|
+
changelog_uri: https://github.com/jaredbeck/bundler-why
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 2.6.0
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubygems_version: 3.1.3
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: Explains the presence of a dependency.
|
60
|
+
test_files: []
|