gem_bench 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +16 -0
- data/CONTRIBUTING.md +42 -26
- data/README.md +165 -27
- data/lib/gem_bench/jersey.rb +150 -0
- data/lib/gem_bench/player.rb +20 -18
- data/lib/gem_bench/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +51 -24
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b054d58ceb273738cbb17694960de3fb3a5c8646eeed7f41c77e9b4177e3a52c
|
4
|
+
data.tar.gz: a5565712bc1ae7423890b8b7615a048850962e6a403f6ed76828804f60fa8840
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ba5c0b8243072eec99db4ccd0d7efd6aab41d6d592bfddecf359259777a9be5c578f7ef8c3cf02b01117369c0f777db594cbf22ec5663d6dbaf06c700e87d96
|
7
|
+
data.tar.gz: 25e0360cd1200ecdc0d7a65de318c02270492c255dc66f9bf46cd4359a5fe37ff6b67307c351b20657ada7a3ec04584221bbe8bafce5f29e8d2373671042a941
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -11,6 +11,22 @@ and this project adheres to [Semantic Versioning v2](https://semver.org/spec/v2.
|
|
11
11
|
### Fixed
|
12
12
|
### Removed
|
13
13
|
|
14
|
+
[2.0.1] SEP.17.2024
|
15
|
+
COVERAGE: 82.15% -- 382/465 lines in 9 files
|
16
|
+
BRANCH COVERAGE: 58.08% -- 97/167 branches in 9 files
|
17
|
+
51.72% documented
|
18
|
+
### Added
|
19
|
+
* Ability to re-namespace and load copy of a gem alongside vanilla version for benchmarking via `GemBench::Jersey`
|
20
|
+
* See: https://github.com/panorama-ed/memo_wise/pull/339
|
21
|
+
* Many more tests
|
22
|
+
* `kettle-soup-cover` for test coverage enforcement
|
23
|
+
* Better documentation
|
24
|
+
* Improved instructions for contributing
|
25
|
+
### Changed
|
26
|
+
* Improved `bin/checksums`
|
27
|
+
### Fixed
|
28
|
+
* Stopped swallowing `ArgumentError` in certain exceptional cases
|
29
|
+
|
14
30
|
[2.0.0] SEP.25.2023
|
15
31
|
### Added
|
16
32
|
* Compatible with Bundler 2+
|
data/CONTRIBUTING.md
CHANGED
@@ -1,46 +1,62 @@
|
|
1
1
|
## Contributing
|
2
2
|
|
3
|
-
Bug reports and pull requests are welcome on
|
4
|
-
|
5
|
-
the [code of conduct][conduct].
|
3
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/pboling/gem_bench][🚎src-main].
|
4
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to
|
5
|
+
the [code of conduct][🤝conduct].
|
6
6
|
|
7
7
|
To submit a patch, please fork the project and create a patch with tests. Once you're happy with it send a pull request
|
8
|
-
and post a message to the [gitter chat][🏘chat].
|
8
|
+
and you might also post a message to the [gitter chat][🏘chat].
|
9
9
|
|
10
10
|
## Development
|
11
11
|
|
12
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
12
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
13
|
+
Then, run `bin/rake` to run the default rake tasks, which include specs.
|
14
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
13
15
|
|
14
16
|
## Release
|
15
17
|
|
16
|
-
|
18
|
+
### One-time, Per-developer, Setup
|
19
|
+
|
20
|
+
**IMPORTANT**: Your public key for signing gems will need to be picked up by the line in the
|
21
|
+
`gemspec` defining the `spec.cert_chain` (check the relevant ENV variables there),
|
22
|
+
in order to sign the new release.
|
23
|
+
See: [RubyGems Security Guide][🔒️rubygems-security-guide]
|
24
|
+
|
25
|
+
### To release a new version:
|
17
26
|
|
18
27
|
1. Run `bin/setup && bin/rake` as a tests, coverage, & linting sanity check
|
19
|
-
2.
|
28
|
+
2. Update the version number in `version.rb`
|
20
29
|
3. Run `bin/setup && bin/rake` again as a secondary check, and to update `Gemfile.lock`
|
21
|
-
4.
|
22
|
-
5.
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
`
|
32
|
-
|
30
|
+
4. Run `git commit -am "🔖 Prepare release v<VERSION>"` to commit the changes
|
31
|
+
5. Run `git push` to trigger the final CI pipeline before release, & merge PRs
|
32
|
+
- NOTE: Remember to [check the build][🧪build]!
|
33
|
+
6. Run `export GIT_TRUNK_BRANCH_NAME="$(git remote show origin | grep 'HEAD branch' | cut -d ' ' -f5)" && echo $GIT_TRUNK_BRANCH_NAME`
|
34
|
+
7. Run `git checkout $GIT_TRUNK_BRANCH_NAME`
|
35
|
+
8. Run `git pull origin $GIT_TRUNK_BRANCH_NAME` to ensure you will release the latest trunk code
|
36
|
+
9. Set `SOURCE_DATE_EPOCH` so `rake build` and `rake release` use same timestamp, and generate same checksums
|
37
|
+
- Run `export SOURCE_DATE_EPOCH=$EPOCHSECONDS && echo $SOURCE_DATE_EPOCH`
|
38
|
+
- If the echo above has no output, then it didn't work.
|
39
|
+
- Note that you'll need the `zsh/datetime` module, if running `zsh`.
|
40
|
+
- In `bash` you can use `date +%s` instead, i.e. `export SOURCE_DATE_EPOCH=$(date +%s) && echo $SOURCE_DATE_EPOCH`
|
41
|
+
10. Run `bundle exec rake build`
|
42
|
+
11. Run `bin/checksums` (more [context][🔒️rubygems-checksums-pr]) to create SHA-256 and SHA-512 checksums
|
43
|
+
- Checksums will be committed automatically by the script, but not pushed
|
44
|
+
12. Run `bundle exec rake release` which will create a git tag for the version,
|
45
|
+
push git commits and tags, and push the `.gem` file to [rubygems.org][💎rubygems]
|
33
46
|
|
34
47
|
## Contributors
|
35
48
|
|
36
|
-
[![Contributors]
|
49
|
+
[![Contributors][🖐contributors-img]][🖐contributors]
|
37
50
|
|
38
|
-
Made with [contributors-img][contrib-rocks].
|
51
|
+
Made with [contributors-img][🖐contrib-rocks].
|
39
52
|
|
53
|
+
[🧪build]: https://github.com/pboling/gem_bench/actions
|
54
|
+
[🤝conduct]: https://github.com/pboling/gem_bench/blob/main/CODE_OF_CONDUCT.md
|
55
|
+
[🖐contrib-rocks]: https://contrib.rocks
|
40
56
|
[🖐contributors]: https://github.com/pboling/gem_bench/graphs/contributors
|
41
|
-
[
|
42
|
-
[
|
43
|
-
[
|
57
|
+
[🖐contributors-img]: https://contrib.rocks/image?repo=pboling/gem_bench
|
58
|
+
[💎rubygems]: https://rubygems.org
|
59
|
+
[🔒️rubygems-security-guide]: https://guides.rubygems.org/security/#building-gems
|
60
|
+
[🔒️rubygems-checksums-pr]: https://github.com/rubygems/guides/pull/325
|
61
|
+
[🚎src-main]: https://github.com/pboling/gem_bench
|
44
62
|
[🏘chat]: https://matrix.to/#/%23pboling_gem_bench:gitter.im
|
45
|
-
[rubygems-security-guide]: https://guides.rubygems.org/security/#building-gems
|
46
|
-
[rubygems]: https://rubygems.org
|
data/README.md
CHANGED
@@ -1,43 +1,143 @@
|
|
1
1
|
# GemBench
|
2
2
|
|
3
|
+
<div id="badges">
|
4
|
+
|
5
|
+
<div align="center">
|
6
|
+
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
8
|
+
[](https://rubygems.org/gems/gem_bench)
|
9
|
+
[](https://github.com/pboling/gem_bench)
|
10
|
+
[](https://depfu.com/github/pboling/gem_bench?project_id=2688)
|
11
|
+
[](https://codeclimate.com/github/pboling/gem_bench/test_coverage)
|
12
|
+
[](https://codeclimate.com/github/pboling/gem_bench/maintainability)
|
13
|
+
[![CI Supported Build][🚎s-wfi]][🚎s-wf]
|
14
|
+
[![CI Unsupported Build][🚎us-wfi]][🚎us-wf]
|
15
|
+
[![CI Style Build][🚎st-wfi]][🚎st-wf]
|
16
|
+
[![CI Coverage Build][🚎cov-wfi]][🚎cov-wf]
|
17
|
+
[![CI Heads Build][🚎hd-wfi]][🚎hd-wf]
|
18
|
+
|
19
|
+
[🚎s-wf]: https://github.com/pboling/gem_bench/actions/workflows/supported.yml
|
20
|
+
[🚎s-wfi]: https://github.com/pboling/gem_bench/actions/workflows/supported.yml/badge.svg
|
21
|
+
[🚎us-wf]: https://github.com/pboling/gem_bench/actions/workflows/unsupported.yml
|
22
|
+
[🚎us-wfi]: https://github.com/pboling/gem_bench/actions/workflows/unsupported.yml/badge.svg
|
23
|
+
[🚎st-wf]: https://github.com/pboling/gem_bench/actions/workflows/style.yml
|
24
|
+
[🚎st-wfi]: https://github.com/pboling/gem_bench/actions/workflows/style.yml/badge.svg
|
25
|
+
[🚎cov-wf]: https://github.com/pboling/gem_bench/actions/workflows/coverage.yml
|
26
|
+
[🚎cov-wfi]: https://github.com/pboling/gem_bench/actions/workflows/coverage.yml/badge.svg
|
27
|
+
[🚎hd-wf]: https://github.com/pboling/gem_bench/actions/workflows/heads.yml
|
28
|
+
[🚎hd-wfi]: https://github.com/pboling/gem_bench/actions/workflows/heads.yml/badge.svg
|
29
|
+
|
30
|
+
</div>
|
31
|
+
|
32
|
+
-----
|
33
|
+
|
34
|
+
<div align="center">
|
35
|
+
|
36
|
+
[![Liberapay Patrons][⛳liberapay-img]][⛳liberapay]
|
37
|
+
[![Sponsor Me on Github][🖇sponsor-img]][🖇sponsor]
|
38
|
+
[![Polar Shield][🖇polar-img]][🖇polar]
|
39
|
+
[![Donate to my FLOSS or refugee efforts at ko-fi.com][🖇kofi-img]][🖇kofi]
|
40
|
+
[![Donate to my FLOSS or refugee efforts using Patreon][🖇patreon-img]][🖇patreon]
|
41
|
+
|
42
|
+
[⛳liberapay-img]: https://img.shields.io/liberapay/patrons/pboling.svg?logo=liberapay
|
43
|
+
[⛳liberapay]: https://liberapay.com/pboling/donate
|
44
|
+
[🖇sponsor-img]: https://img.shields.io/badge/Sponsor_Me!-pboling.svg?style=social&logo=github
|
45
|
+
[🖇sponsor]: https://github.com/sponsors/pboling
|
46
|
+
[🖇polar-img]: https://polar.sh/embed/seeks-funding-shield.svg?org=pboling
|
47
|
+
[🖇polar]: https://polar.sh/pboling
|
48
|
+
[🖇kofi-img]: https://img.shields.io/badge/buy%20me%20coffee-donate-yellow.svg
|
49
|
+
[🖇kofi]: https://ko-fi.com/O5O86SNP4
|
50
|
+
[🖇patreon-img]: https://img.shields.io/badge/patreon-donate-yellow.svg
|
51
|
+
[🖇patreon]: https://patreon.com/galtzo
|
52
|
+
|
53
|
+
<span class="badge-buymealatte">
|
54
|
+
<a href="https://www.buymeacoffee.com/pboling"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a latte&emoji=&slug=pboling&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff" /></a>
|
55
|
+
</span>
|
56
|
+
|
57
|
+
</div>
|
58
|
+
</div>
|
59
|
+
|
60
|
+
Scene: You are a spectator at a game of Ruby Sports Gem Ball.
|
61
|
+
|
62
|
+
Gem wearing jersey namespace **#23**:
|
63
|
+
|
64
|
+
> "Put me in coach!"
|
65
|
+
|
66
|
+
Other Gem, also wearing jersey namespace **#23**:
|
67
|
+
|
68
|
+
> "Put me in coach!"
|
69
|
+
|
70
|
+
Coach:
|
71
|
+
|
72
|
+
> ❨╯°□°❩╯︵┻━┻ fine, but one of you change your jersey first!
|
73
|
+
|
74
|
+
## What's it do?
|
75
|
+
|
3
76
|
`gem_bench` is for static Gemfile and installed gem library source code analysis.
|
4
77
|
|
5
|
-
`gem_bench` can
|
78
|
+
`gem_bench` can be used to re-namespace a gem at run-time so that you can run simultaneously:
|
79
|
+
|
80
|
+
- two versions of the same library, or
|
81
|
+
- two different things that happen to have a namespace collision,
|
6
82
|
|
7
|
-
|
8
|
-
|
83
|
+
for benchmarking or other purposes.
|
84
|
+
|
85
|
+
`gem_bench` can also be used to trim down app load times by keeping your worst players on the bench.
|
9
86
|
|
10
87
|
| Project | GemBench |
|
11
88
|
|------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
12
89
|
| gem name | [gem_bench](https://rubygems.org/gems/gem_bench) |
|
13
|
-
| license | [](https://opensource.org/licenses/MIT) |
|
14
|
-
| download rank | [](https://github.com/pboling/gem_bench) |
|
15
|
-
| version | [](https://rubygems.org/gems/gem_bench) |
|
16
|
-
| dependencies | [](https://depfu.com/github/pboling/gem_bench?project_id=5613) |
|
17
|
-
| continuous integration | [![Current][🚎cwfi]][🚎cwf] [![Heads][🖐hwfi]][🖐hwf] [![Style][🧮swfi]][🧮swf] [![Coverage][📗cov-wfi]][📗cov-wf] |
|
18
|
-
| test coverage | [](https://codeclimate.com/github/pboling/gem_bench/test_coverage) |
|
19
|
-
| maintainability | [](https://codeclimate.com/github/pboling/gem_bench/maintainability) |
|
20
90
|
| code triage | [](https://www.codetriage.com/pboling/gem_bench) |
|
21
91
|
| homepage | [on Github.com][homepage] |
|
22
92
|
| documentation | [on Rdoc.info][documentation] |
|
23
93
|
| live chat | [![Join the chat][🏘chati]][🏘chat] |
|
24
94
|
| expert support | [](https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github) |
|
25
|
-
| Spread ~♡ⓛⓞⓥⓔ♡~ | [🌏](https://about.me/peter.boling)
|
26
|
-
|
27
|
-
[🚎cwf]: https://github.com/rubocop-lts/rubocop-lts/actions/workflows/current.yml
|
28
|
-
[🚎cwfi]: https://github.com/rubocop-lts/rubocop-lts/actions/workflows/current.yml/badge.svg
|
29
|
-
[🖐hwf]: https://github.com/rubocop-lts/rubocop-lts/actions/workflows/heads.yml
|
30
|
-
[🖐hwfi]: https://github.com/rubocop-lts/rubocop-lts/actions/workflows/heads.yml/badge.svg
|
31
|
-
[🧮swf]: https://github.com/rubocop-lts/rubocop-lts/actions/workflows/style.yml
|
32
|
-
[🧮swfi]: https://github.com/rubocop-lts/rubocop-lts/actions/workflows/style.yml/badge.svg
|
33
|
-
[📗cov-wf]: https://github.com/rubocop-lts/rubocop-lts/actions/workflows/coverage.yml
|
34
|
-
[📗cov-wfi]: https://github.com/rubocop-lts/rubocop-lts/actions/workflows/coverage.yml/badge.svg
|
95
|
+
| Spread ~♡ⓛⓞⓥⓔ♡~ | [🌏](https://about.me/peter.boling) [👼](https://angel.co/peter-boling) [](http://twitter.com/galtzo) |
|
96
|
+
|
35
97
|
[🏘chat]: https://matrix.to/#/%23pboling_gem_bench:gitter.im
|
36
98
|
[🏘chati]: https://badges.gitter.im/Join%20Chat.svg
|
37
99
|
|
100
|
+
### New for 2.0.1 - `GemBench::Jersey`
|
101
|
+
|
102
|
+
Allows you to re-namespace any gem.
|
103
|
+
You can, for example, benchmark a gem against another version of itself.
|
104
|
+
|
105
|
+
The gem `alt_memery` uses a namespace, `Memery`, that does not match the gem name.
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
require "gem_bench/jersey"
|
109
|
+
|
110
|
+
jersey = GemBench::Jersey.new(
|
111
|
+
gem_name: "alt_memery",
|
112
|
+
trades: {"Memery" => "AltMemery"},
|
113
|
+
metadata: { # optional, mostly used for benchmarking report output
|
114
|
+
something: "a value here",
|
115
|
+
something_else: :obviously,
|
116
|
+
},
|
117
|
+
)
|
118
|
+
jersey.doff_and_don
|
119
|
+
# The re-namespaced constant is now available!
|
120
|
+
AltMemery # => AltMemery
|
121
|
+
jersey.as_klass # => AltMemery
|
122
|
+
|
123
|
+
# The original, unmodified, gem is still there!
|
124
|
+
require "alt_memery"
|
125
|
+
|
126
|
+
Memery # => Memery
|
127
|
+
# So you can use both!
|
128
|
+
```
|
129
|
+
|
130
|
+
NOTE: It is not required by default, so you do need to require the Jersey if you want to use it!
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
require "gem_bench/jersey"
|
134
|
+
```
|
135
|
+
|
136
|
+
For a real example, see: https://github.com/panorama-ed/memo_wise/pull/339
|
137
|
+
|
38
138
|
### New for 2.0.0 - Dropped Support for Ruby 2.0, 2.1, 2.2
|
39
139
|
|
40
|
-
|
140
|
+
- Required Ruby is now 2.3+
|
41
141
|
- `VERSION` is now namespaced at `GemBench::Version::VERSION` and is enhanced by `version_gem`.
|
42
142
|
|
43
143
|
### New for 1.0.2 - Gemfile specs
|
@@ -45,6 +145,7 @@ You: ❨╯°□°❩╯︵┻━┻
|
|
45
145
|
Version constraints are important. Give the Gemfile some love in your CI build
|
46
146
|
|
47
147
|
Create a `spec/gemfile_spec.rb` like:
|
148
|
+
|
48
149
|
```ruby
|
49
150
|
Rspec.describe("Gemfile") do
|
50
151
|
it("has version constraint on every gem") do
|
@@ -76,8 +177,13 @@ For string version constraints anything is allowed (e.g. `'~> 1.0'`), as it assu
|
|
76
177
|
|
77
178
|
Search the Ruby source code of all the gems loaded by your Gemfile for a specified regex, to find out which gems have wat DRAGONS.
|
78
179
|
|
79
|
-
Gem:
|
80
|
-
|
180
|
+
Gem:
|
181
|
+
|
182
|
+
> "I have no wat DRAGONS!"`
|
183
|
+
|
184
|
+
You:
|
185
|
+
|
186
|
+
> ❨╯°□°❩╯︵┻━┻ Yes you do!
|
81
187
|
|
82
188
|
```
|
83
189
|
>> puts GemBench.find(look_for_regex: /wat/).starters.map {|gem| "#{gem.name} has wat DRAGONS at #{gem.stats}" }.join("\n")
|
@@ -145,6 +251,7 @@ irb: warn: can't alias context from irb_context.
|
|
145
251
|
```
|
146
252
|
|
147
253
|
Find out what gems may be causing it by defining `context`!
|
254
|
+
|
148
255
|
```
|
149
256
|
>> require 'gem_bench'
|
150
257
|
=> true
|
@@ -153,12 +260,42 @@ Find out what gems may be causing it by defining `context`!
|
|
153
260
|
[GemBench] Detected 11 loaded gems + 2 loaded gems which GemBench is configured to ignore.
|
154
261
|
=> [byebug, diff-lcs]
|
155
262
|
```
|
263
|
+
|
156
264
|
Then find the file with the first occurrence of the regex in each:
|
265
|
+
|
157
266
|
```
|
158
267
|
>> bad_context_maybes.map { |bcm| bcm.stats.map(&:first) }
|
159
268
|
=> [["/Users/pboling/.rvm/gems/ruby-2.4.0@foss/gems/byebug-9.0.6/lib/byebug/command.rb"], ["/Users/pboling/.rvm/gems/ruby-2.4.0@foss/gems/diff-lcs-1.3/lib/diff/lcs/hunk.rb"]]
|
160
269
|
```
|
161
270
|
|
271
|
+
### Find what gems have `RAILS_ENV` specific code!
|
272
|
+
|
273
|
+
Let's try to find what libraries might be using a conditional guard to alter their behavior in a specific Rails environment.
|
274
|
+
|
275
|
+
```
|
276
|
+
# Not a perfect regex, but pretty good: https://rubular.com/r/b7tdIoYOVQM2RR
|
277
|
+
# RAILS_ENV == "development"
|
278
|
+
# Rails.env.development?
|
279
|
+
# Rails.env == "development"
|
280
|
+
# ENV["RAILS_ENV"] == "development"
|
281
|
+
# ENV.fetch("RAILS_ENV") == "development"
|
282
|
+
>> require "gem_bench"
|
283
|
+
=> true
|
284
|
+
>> conditional_rails_behavior_regex = /(ENV(\["|\.fetch\("))?rails(_|\.)env("\]|"\))?( == "|\.)development/i
|
285
|
+
>> conditional_rails_behavior = GemBench.find(look_for_regex: conditional_rails_behavior_regex).starters
|
286
|
+
=> [rack, actionpack, actioncable, actionmailer, rubocop, railties, rubocop-ruby2_7, sass, sass-rails]
|
287
|
+
>> print conditional_rails_behavior.map {|gem| "#{gem.name} has Rails.env condition in #{gem.stats}" }.join("\n")
|
288
|
+
rack has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rack-mini-profiler-3.1.0/lib/mini_profiler_rails/railtie.rb", 1154]]
|
289
|
+
actionpack has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/actionpack-3.2.22.5/lib/action_controller/metal/force_ssl.rb", 1377]]
|
290
|
+
actioncable has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/actioncable-5.2.8.1/lib/action_cable/engine.rb", 886]]
|
291
|
+
actionmailer has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/actionmailer-7.0.5/lib/action_mailer/railtie.rb", 807]]
|
292
|
+
rubocop has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rubocop-ruby2_2-2.0.5/lib/rubocop/ruby2_2/railtie.rb", 131]]
|
293
|
+
railties has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/railties-3.2.22.5/lib/rails.rb", 2478]]
|
294
|
+
rubocop-ruby2_7 has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rubocop-ruby2_7-2.0.5/lib/rubocop/ruby2_7/railtie.rb", 131]]
|
295
|
+
sass has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/sass-rails-5.1.0/lib/sass/rails/railtie.rb", 3349]]
|
296
|
+
sass-rails has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/sass-rails-5.1.0/lib/sass/rails/railtie.rb", 3349]]
|
297
|
+
```
|
298
|
+
|
162
299
|
### More Different Example!
|
163
300
|
|
164
301
|
Fire up an `irb` session or a `rails console` and then:
|
@@ -222,7 +359,7 @@ In order to *also* see list gems may *not* be required at boot time you need to:
|
|
222
359
|
1. Make sure you are in the root of a project with a Gemfile
|
223
360
|
2. Make sure the gem is actually a dependency in the Gemfile
|
224
361
|
|
225
|
-
So here's a [
|
362
|
+
So here's a [fat Gemfile][bundle-group-pattern] weighing in at 265 gem dependencies. We'll use it for this example:
|
226
363
|
|
227
364
|
∴ bundle exec rails console
|
228
365
|
Welcome to RAILS. You are using ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.2.1]. Have fun ;)
|
@@ -382,12 +519,13 @@ A future version will also look for initializers, because gems which have code t
|
|
382
519
|
|
383
520
|
## Contributors
|
384
521
|
|
385
|
-
[![Contributors]
|
522
|
+
[![Contributors][🖐contributors-img]][🖐contributors]
|
386
523
|
|
387
|
-
Made with [contributors-img][contrib-rocks].
|
524
|
+
Made with [contributors-img][🖐contrib-rocks].
|
388
525
|
|
526
|
+
[🖐contrib-rocks]: https://contrib.rocks
|
389
527
|
[🖐contributors]: https://github.com/pboling/gem_bench/graphs/contributors
|
390
|
-
[
|
528
|
+
[🖐contributors-img]: https://contrib.rocks/image?repo=pboling/gem_bench
|
391
529
|
|
392
530
|
## Contributing
|
393
531
|
|
@@ -0,0 +1,150 @@
|
|
1
|
+
# Std Libs Dependencies
|
2
|
+
require "tmpdir"
|
3
|
+
|
4
|
+
# Re-write a gem to a temp directory, re-namespace the primary namespace of that gem module, and load it.
|
5
|
+
# If the original gem defines multiple top-level namespaces, they can all be renamed by providing more key value pairs.
|
6
|
+
# If the original gem monkey patches other libraries, that behavior can't be isolated, so YMMV.
|
7
|
+
#
|
8
|
+
# NOTE: Non-top-level namespaces do not need to be renamed, as they are isolated within their parent namespace.
|
9
|
+
#
|
10
|
+
# Usage
|
11
|
+
#
|
12
|
+
# jersey = GemBench::Jersey.new(
|
13
|
+
# gem_name: "alt_memery"
|
14
|
+
# trades: {
|
15
|
+
# "Memery" => "AltMemery"
|
16
|
+
# },
|
17
|
+
# metadata: {
|
18
|
+
# something: "a value here",
|
19
|
+
# something_else: :obviously,
|
20
|
+
# },
|
21
|
+
# )
|
22
|
+
# jersey.doff_and_don
|
23
|
+
# # The re-namespaced constant is now available!
|
24
|
+
# AltMemery # => AltMemery
|
25
|
+
#
|
26
|
+
module GemBench
|
27
|
+
class Jersey
|
28
|
+
attr_reader :gem_name
|
29
|
+
attr_reader :gem_path
|
30
|
+
attr_reader :trades
|
31
|
+
attr_reader :metadata
|
32
|
+
attr_reader :files
|
33
|
+
attr_reader :verbose
|
34
|
+
|
35
|
+
def initialize(gem_name:, trades:, metadata: {}, verbose: false)
|
36
|
+
@gem_name = gem_name
|
37
|
+
@gem_path = Gem.loaded_specs[gem_name]&.full_gem_path
|
38
|
+
@gem_lib_dir = Gem
|
39
|
+
@trades = trades
|
40
|
+
@metadata = metadata
|
41
|
+
@verbose = verbose
|
42
|
+
end
|
43
|
+
|
44
|
+
def required?
|
45
|
+
gem_path && trades.values.all? { |new_namespace| Object.const_defined?(new_namespace) }
|
46
|
+
end
|
47
|
+
|
48
|
+
# Generates tempfiles and requires them, resulting
|
49
|
+
# in a loaded gem that will not have namespace
|
50
|
+
# collisions when alongside the original-namespaced gem.
|
51
|
+
# If a block is provided the contents of each file will be yielded to the block,
|
52
|
+
# after all namespace substitutions are complete, but before the contents
|
53
|
+
# are written to the re-namespaced gem. The return value of the block will be
|
54
|
+
# written to the file in this scenario.
|
55
|
+
#
|
56
|
+
# @return void
|
57
|
+
def doff_and_don(&block)
|
58
|
+
return puts "Skipping #{gem_name} (not loaded on #{RUBY_VERSION})" unless gem_path
|
59
|
+
|
60
|
+
puts "Doffing #{gem_path}" if verbose
|
61
|
+
Dir.mktmpdir do |directory|
|
62
|
+
files = []
|
63
|
+
Dir[File.join(gem_path, "lib", "**", "*.rb")].map do |file|
|
64
|
+
if verbose
|
65
|
+
puts file
|
66
|
+
puts File.basename(file)
|
67
|
+
puts "--------------------------------"
|
68
|
+
end
|
69
|
+
dirname = File.dirname(file)
|
70
|
+
puts "dirname: #{dirname}" if verbose
|
71
|
+
is_at_gem_root = dirname[(-4)..(-1)] == "/lib"
|
72
|
+
puts "is_at_gem_root: #{is_at_gem_root}" if verbose
|
73
|
+
lib_split = dirname.split("/lib/")[-1]
|
74
|
+
puts "lib_split: #{lib_split}" if verbose
|
75
|
+
# lib_split could be like:
|
76
|
+
# - "ruby/gems/3.2.0/gems/method_source-1.1.0/lib"
|
77
|
+
# - "method_source"
|
78
|
+
# Se we check to make sure it is actually a subdir of the gem's lib directory
|
79
|
+
full_path = File.join(gem_path, "lib", lib_split)
|
80
|
+
relative_path = !is_at_gem_root && Dir.exist?(full_path) && lib_split
|
81
|
+
puts "relative_path: #{relative_path}" if verbose
|
82
|
+
filename = File.basename(file)[0..-4]
|
83
|
+
puts "filename: #{filename}" if verbose
|
84
|
+
|
85
|
+
if relative_path
|
86
|
+
dir_path = File.join(directory, relative_path)
|
87
|
+
Dir.mkdir(dir_path) unless Dir.exist?(dir_path)
|
88
|
+
puts "creating #{filename} in #{dir_path}" if verbose
|
89
|
+
files << create_tempfile_copy(file, filename, dir_path, :dd1, &block)
|
90
|
+
else
|
91
|
+
puts "directory not relative (#{directory}) for file #{filename}" if verbose
|
92
|
+
files << create_tempfile_copy(file, filename, directory, :dd2, &block)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
load_gem_copy(files)
|
96
|
+
end
|
97
|
+
|
98
|
+
nil
|
99
|
+
end
|
100
|
+
|
101
|
+
def primary_namespace
|
102
|
+
trades.values.first
|
103
|
+
end
|
104
|
+
|
105
|
+
# Will raise NameError if called before #doff_and_don
|
106
|
+
def as_klass
|
107
|
+
Object.const_get(primary_namespace) if gem_path
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def load_gem_copy(files)
|
113
|
+
files.each do |filepath|
|
114
|
+
# begin
|
115
|
+
require filepath
|
116
|
+
# rescue LoadError => e
|
117
|
+
# puts file.to_s
|
118
|
+
# puts tempfile.path
|
119
|
+
# puts e.class
|
120
|
+
# puts e.message
|
121
|
+
# end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# @return [String] the file path of the new copy of the original file
|
126
|
+
def create_tempfile_copy(file, filename, directory, from, &block)
|
127
|
+
# Value of block is returned from File.open
|
128
|
+
File.open(File.join(directory, "#{filename}.rb"), "w") do |file_copy|
|
129
|
+
new_jersey(file, file_copy, from, &block)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# @return [String] the file path of the new copy of the original file
|
134
|
+
def new_jersey(file, file_copy, from)
|
135
|
+
nj = File.read(file)
|
136
|
+
trades.each do |old_namespace, new_namespace|
|
137
|
+
nj.gsub!(old_namespace, new_namespace)
|
138
|
+
end
|
139
|
+
if verbose
|
140
|
+
puts "new_jersey has from: #{from}"
|
141
|
+
puts "new_jersey has file: #{file}"
|
142
|
+
puts "new_jersey file_copy path: #{file_copy.path}"
|
143
|
+
end
|
144
|
+
nj = yield nj if block_given?
|
145
|
+
file_copy.write(nj)
|
146
|
+
file_copy.close
|
147
|
+
file_copy.path
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
data/lib/gem_bench/player.rb
CHANGED
@@ -27,24 +27,7 @@ module GemBench
|
|
27
27
|
# gems got checked, and which had nothing to check
|
28
28
|
@checked = true
|
29
29
|
line_match ||= GemBench::RAILTIE_REGEX
|
30
|
-
scan =
|
31
|
-
false
|
32
|
-
else
|
33
|
-
begin
|
34
|
-
File.read(file_path).encode(
|
35
|
-
"utf-8",
|
36
|
-
invalid: :replace,
|
37
|
-
undef: :replace,
|
38
|
-
replace: "_",
|
39
|
-
) =~ line_match
|
40
|
-
rescue ArgumentError => e
|
41
|
-
if e.message =~ /invalid byte sequence/
|
42
|
-
puts "[GemBench] checking #{file_path} failed due to unparseable file content"
|
43
|
-
false # Assume the likelihood of files with encoding issues that also contain railtie to be low, so: false.
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
30
|
+
scan = !GemBench::DO_NOT_SCAN.include?(name) && check_line(file_path, line_match)
|
48
31
|
stats << [file_path, scan] if scan
|
49
32
|
self.state = if !!scan
|
50
33
|
GemBench::PLAYER_STATES[:starter]
|
@@ -53,6 +36,23 @@ module GemBench
|
|
53
36
|
end
|
54
37
|
end
|
55
38
|
|
39
|
+
def check_line(file_path, line_match)
|
40
|
+
File.read(file_path).encode(
|
41
|
+
"utf-8",
|
42
|
+
invalid: :replace,
|
43
|
+
undef: :replace,
|
44
|
+
replace: "_",
|
45
|
+
) =~ line_match
|
46
|
+
rescue ArgumentError => e
|
47
|
+
if e.message =~ /invalid byte sequence/
|
48
|
+
puts "[GemBench] checking #{file_path} failed due to unparseable file content"
|
49
|
+
false # Assume the likelihood of files with encoding issues that also contain railtie to be low, so: false.
|
50
|
+
else
|
51
|
+
puts "[GemBench] checking #{file_path} failed. Please report a bug to https://github.com/pboling/gembench/issues"
|
52
|
+
raise e
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
56
|
def starter?
|
57
57
|
state == GemBench::PLAYER_STATES[:starter]
|
58
58
|
end
|
@@ -71,6 +71,8 @@ module GemBench
|
|
71
71
|
"gem '#{name}', '~> #{version}'"
|
72
72
|
when :upgrade # when upgrading, and testing gem compatibility you want to try anything newer
|
73
73
|
"gem '#{name}', '>= #{version}'"
|
74
|
+
else
|
75
|
+
raise ArgumentError, "Unknown format for #{self.class.name}#to_s"
|
74
76
|
end
|
75
77
|
end
|
76
78
|
|
data/lib/gem_bench/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem_bench
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Boling
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
KuxrfYrN+9HvMdm+nZ6TypmKftHY3Gj+/uu+g8Icm/zrvTWAEE0mcJOkfrIoNPJb
|
37
37
|
pF8dMA==
|
38
38
|
-----END CERTIFICATE-----
|
39
|
-
date:
|
39
|
+
date: 2024-09-17 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
@@ -61,7 +61,7 @@ dependencies:
|
|
61
61
|
version: '1.1'
|
62
62
|
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: 1.1.
|
64
|
+
version: 1.1.4
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -71,49 +71,61 @@ dependencies:
|
|
71
71
|
version: '1.1'
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 1.1.
|
74
|
+
version: 1.1.4
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
76
|
+
name: yard
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0.9'
|
79
82
|
- - ">="
|
80
83
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
84
|
+
version: 0.9.34
|
82
85
|
type: :development
|
83
86
|
prerelease: false
|
84
87
|
version_requirements: !ruby/object:Gem::Requirement
|
85
88
|
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0.9'
|
86
92
|
- - ">="
|
87
93
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
94
|
+
version: 0.9.34
|
89
95
|
- !ruby/object:Gem::Dependency
|
90
|
-
name: yard
|
96
|
+
name: yard-junk
|
91
97
|
requirement: !ruby/object:Gem::Requirement
|
92
98
|
requirements:
|
93
|
-
- - "
|
99
|
+
- - "~>"
|
94
100
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
101
|
+
version: 0.0.10
|
96
102
|
type: :development
|
97
103
|
prerelease: false
|
98
104
|
version_requirements: !ruby/object:Gem::Requirement
|
99
105
|
requirements:
|
100
|
-
- - "
|
106
|
+
- - "~>"
|
101
107
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
108
|
+
version: 0.0.10
|
103
109
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
110
|
+
name: kettle-soup-cover
|
105
111
|
requirement: !ruby/object:Gem::Requirement
|
106
112
|
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '1.0'
|
107
116
|
- - ">="
|
108
117
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
118
|
+
version: 1.0.2
|
110
119
|
type: :development
|
111
120
|
prerelease: false
|
112
121
|
version_requirements: !ruby/object:Gem::Requirement
|
113
122
|
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '1.0'
|
114
126
|
- - ">="
|
115
127
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
128
|
+
version: 1.0.2
|
117
129
|
- !ruby/object:Gem::Dependency
|
118
130
|
name: awesome_print
|
119
131
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,19 +141,19 @@ dependencies:
|
|
129
141
|
- !ruby/object:Gem::Version
|
130
142
|
version: '0'
|
131
143
|
- !ruby/object:Gem::Dependency
|
132
|
-
name:
|
144
|
+
name: method_source
|
133
145
|
requirement: !ruby/object:Gem::Requirement
|
134
146
|
requirements:
|
135
|
-
- - "
|
147
|
+
- - ">="
|
136
148
|
- !ruby/object:Gem::Version
|
137
|
-
version:
|
149
|
+
version: 1.1.0
|
138
150
|
type: :development
|
139
151
|
prerelease: false
|
140
152
|
version_requirements: !ruby/object:Gem::Requirement
|
141
153
|
requirements:
|
142
|
-
- - "
|
154
|
+
- - ">="
|
143
155
|
- !ruby/object:Gem::Version
|
144
|
-
version:
|
156
|
+
version: 1.1.0
|
145
157
|
- !ruby/object:Gem::Dependency
|
146
158
|
name: rake
|
147
159
|
requirement: !ruby/object:Gem::Requirement
|
@@ -246,6 +258,20 @@ dependencies:
|
|
246
258
|
- - ">="
|
247
259
|
- !ruby/object:Gem::Version
|
248
260
|
version: '0'
|
261
|
+
- !ruby/object:Gem::Dependency
|
262
|
+
name: standard
|
263
|
+
requirement: !ruby/object:Gem::Requirement
|
264
|
+
requirements:
|
265
|
+
- - ">="
|
266
|
+
- !ruby/object:Gem::Version
|
267
|
+
version: 1.35.1
|
268
|
+
type: :development
|
269
|
+
prerelease: false
|
270
|
+
version_requirements: !ruby/object:Gem::Requirement
|
271
|
+
requirements:
|
272
|
+
- - ">="
|
273
|
+
- !ruby/object:Gem::Version
|
274
|
+
version: 1.35.1
|
249
275
|
description: |-
|
250
276
|
Enforce Gemfile version constraints
|
251
277
|
Regex search across all installed gem's source code to find issues quickly
|
@@ -264,6 +290,7 @@ files:
|
|
264
290
|
- SECURITY.md
|
265
291
|
- lib/gem_bench.rb
|
266
292
|
- lib/gem_bench/gemfile_line_tokenizer.rb
|
293
|
+
- lib/gem_bench/jersey.rb
|
267
294
|
- lib/gem_bench/player.rb
|
268
295
|
- lib/gem_bench/scout.rb
|
269
296
|
- lib/gem_bench/strict_version_gem.rb
|
@@ -275,10 +302,10 @@ licenses:
|
|
275
302
|
- MIT
|
276
303
|
metadata:
|
277
304
|
homepage_uri: https://railsbling.com/tags/gem_bench/
|
278
|
-
source_code_uri: http://github.com/pboling/gem_bench/tree/v2.0.
|
279
|
-
changelog_uri: http://github.com/pboling/gem_bench/blob/v2.0.
|
305
|
+
source_code_uri: http://github.com/pboling/gem_bench/tree/v2.0.1
|
306
|
+
changelog_uri: http://github.com/pboling/gem_bench/blob/v2.0.1/CHANGELOG.md
|
280
307
|
bug_tracker_uri: http://github.com/pboling/gem_bench/issues
|
281
|
-
documentation_uri: https://www.rubydoc.info/gems/gem_bench/2.0.
|
308
|
+
documentation_uri: https://www.rubydoc.info/gems/gem_bench/2.0.1
|
282
309
|
wiki_uri: http://github.com/pboling/gem_bench/wiki
|
283
310
|
funding_uri: https://liberapay.com/pboling
|
284
311
|
rubygems_mfa_required: 'true'
|
@@ -297,7 +324,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
297
324
|
- !ruby/object:Gem::Version
|
298
325
|
version: '0'
|
299
326
|
requirements: []
|
300
|
-
rubygems_version: 3.4.
|
327
|
+
rubygems_version: 3.4.22
|
301
328
|
signing_key:
|
302
329
|
specification_version: 4
|
303
330
|
summary: Static Gemfile and installed gem library source code analysis
|
metadata.gz.sig
CHANGED
Binary file
|