gem_bench 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47591b1b5f1880cbb2c40be1199aa7fa65a25d2c32ca52131ba54e0e89d8b6b7
4
- data.tar.gz: 93aad6d4e020398b93ffdaa2e8fddfce5b5e5cc4fa08854f22850dcccee9f0ee
3
+ metadata.gz: 26701ac598126aaa38d326332e6f826c62bc7e69b6ac1e34fde7f1568269143c
4
+ data.tar.gz: e75766ba0541b15924fce9a1703632a115f09b4226bc90970c98ff49e2bd423a
5
5
  SHA512:
6
- metadata.gz: 47827b59b13ee527cecfc8db349437c0fc416aa53fa83b4138a6c1884652d857ce9be708ec534e099b8a41f47914b831d8f73e09e430134f4deb050714a1925a
7
- data.tar.gz: 9ae3067637e3293209bde40127e55ad42882b075ca71fc65e7b025ec5dd4e160f5669767e6990a8a0db915ff6031f1555e432cc6a110e32b09346a710fd304bf
6
+ metadata.gz: d505382f0219e9ddb9a80418529ecdd35afa34f4f04be0d548bd07876f7b8f3b95ff0c71941e4880d69d5cb6e4f9550db25a0cf43723a7fd720620b580e38c90
7
+ data.tar.gz: 808ca57545b51ec424234c50714e82e528aa9897e432edf8b40074488143fd0730879180e26d3cfdaa06992393e61bc20e8a10578bbed38ec9dab34f281af7f0
checksums.yaml.gz.sig CHANGED
@@ -1 +1,3 @@
1
- dBR���*1x w�{�\�>��zgq}��1rS�(m`��x��<Rk� �5.g,�ŧ��I% Q�M��`�_�����^���lڐ� Vq�=��/q����,0'rD��恶|�y7G�=�{�z�a7�̳6��<��= ��oP7�h�f+����Y��
1
+ 2?5��?�ng�`�QB��T��Wrl:��5��q�o(���P*z��1Y���@u%���B��(��?��q��W��3�/�uhE�#��T_��\�h����Kw5�%i [�@��ڡ��,q*���j��េ��i��4�?��Gq�<Z��d$���>��hi��{:
2
+ A]��a�v�YȴCp�2[���t�E��ϱ�kE�����E�+C�ݒ� �<w�(=L���s�u�݄�)�#扸�$�Z��FDp3�Aʢ�3V�T�
3
+ �gu��/�s6�aa�� ���_g
data/CHANGELOG.md CHANGED
@@ -11,15 +11,28 @@ and this project adheres to [Semantic Versioning v2](https://semver.org/spec/v2.
11
11
  ### Fixed
12
12
  ### Removed
13
13
 
14
+ ## [2.0.5] SEP.21.2024
15
+ - COVERAGE: 99.80% -- 495/496 lines in 9 files
16
+ - BRANCH COVERAGE: 94.35% -- 167/177 branches in 9 files
17
+ - 58.87% documented
18
+ ### Added
19
+ - More specs
20
+ - More documentation
21
+ - 0.2% remaining to 100% test coverage (line)
22
+ ### Fixed
23
+ - Documentation errors
24
+ - Minor improvements to logic and performance (a bit more idiomatic Ruby)
25
+
14
26
  ## [2.0.4] SEP.20.2024
15
27
  - COVERAGE: 98.19% -- 488/497 lines in 9 files
16
28
  - BRANCH COVERAGE: 88.95% -- 161/181 branches in 9 files
17
29
  - 58.06% documented
18
30
  ### Added
19
- - More Documentation
20
- - Almost 100% test coverage
21
- - Thread Safety (removed `GemBench.roster`, which was effectively never used internally)
31
+ - More documentation
32
+ - 1.81% remaining to 100% test coverage (line)
33
+ - Thread safety (removed `GemBench.roster`, which was effectively never used internally)
22
34
  - Performance improvements
35
+ - Support for specifying arbitrary `:gemfile_path` in most class initializers
23
36
  ### Fixed
24
37
  - Can now handle more variations of Ruby syntax in the Gemfile analyzer
25
38
  - `require_relative` > `require` for internal files (except for `spec` => `lib`)
@@ -136,10 +136,10 @@ module GemBench
136
136
  end
137
137
  files.each do |filepath|
138
138
  # But files required here may not load their own internal files properly if they are still using `require`.
139
- # Since Ruby 2.2, best practice for ruby libraries is to use require_relative for internal files,
140
- # and require for external files and dependencies.
141
- # Ref: https://github.com/panorama-ed/memo_wise/issues/349
142
- # We *can* use `require` *here*, because filepath here is an absolute paths
139
+ # Since Ruby 1.9.2, best practice for ruby libraries is to use require_relative for internal files,
140
+ # and require for external files and dependencies, generally, and oversimplified.
141
+ # Ref: https://github.com/rubocop/rubocop/issues/8748#issuecomment-2363327346
142
+ # However, We *can* use `require` *here*, because filepath here is an absolute paths
143
143
  require filepath
144
144
  end
145
145
 
@@ -6,6 +6,13 @@ module GemBench
6
6
  # - if you are in a rails console, and want to evaluate the Gemfile of the Rails app, that's great!
7
7
  # - if you are in a context with no Gemfile loaded, or a different Gemfile loaded than the one you want to evaluate,
8
8
  # this class may not give sensible results. This is because it checks loaded gems via RubyGems and Bundler.
9
+ #
10
+ # Terminology:
11
+ #
12
+ # starter: a gem that needs to be loaded when bundler normally loads gems
13
+ #
14
+ # bencher: a gem that can, or should, have require: false to delay loading until after bootstrap
15
+ #
9
16
  class Team
10
17
  EXCLUDE = %w[
11
18
  bundler
@@ -53,8 +60,8 @@ module GemBench
53
60
  )
54
61
  @exclude_file_pattern_regex_proc = options[:exclude_file_pattern_regex_proc].respond_to?(:call) ? options[:exclude_file_pattern_regex_proc] : GemBench::EXCLUDE_FILE_PATTERN_REGEX_PROC
55
62
  # Among the loaded gems there may be some that did not need to be.
56
- @excluded, @all = @scout.loaded_gems.partition { |x| EXCLUDE.include?(x[0]) }
57
- exclusions = " + #{excluded.length} loaded gems which GemBench is configured to ignore.\n" if @excluded.length > 0
63
+ exclude!
64
+ exclusions = " + #{excluded.length} loaded gems which GemBench is configured to ignore.\n" if excluded.any?
58
65
  @starters = []
59
66
  @benchers = []
60
67
  @current_gemfile_suggestions = []
@@ -70,11 +77,11 @@ module GemBench
70
77
  false
71
78
  end
72
79
  puts "[GemBench] Will search for gems in #{gem_paths.inspect}\n#{if benching?
73
- @scout.check_gemfile? ? "[GemBench] Will check Gemfile at #{gemfile_path}.\n" : "[GemBench] No Gemfile found.\n"
80
+ check_gemfile? ? "[GemBench] Will check Gemfile at #{gemfile_path}.\n" : "[GemBench] No Gemfile found.\n"
74
81
  else
75
82
  ""
76
83
  end}#{bad_ideas ? "[GemBench] Will show bad ideas. Be Careful.\n" : ""}[GemBench] Detected #{all.length} loaded gems#{exclusions}"
77
- compare_gemfile if benching? && @scout.check_gemfile?
84
+ compare_gemfile if benching? && check_gemfile?
78
85
  self.print if verbose
79
86
  end
80
87
 
@@ -82,6 +89,7 @@ module GemBench
82
89
  starters.map { |starter| starter.to_s(format) }
83
90
  end
84
91
 
92
+ # @return void
85
93
  def print
86
94
  string = ""
87
95
  if all.empty?
@@ -92,7 +100,7 @@ module GemBench
92
100
  else
93
101
  "[GemBench] Found no gems containing #{look_for_regex} in Ruby code.\n"
94
102
  end
95
- elsif starters.length > 0
103
+ else
96
104
  string << "\n#{GemBench::USAGE}" unless check_gemfile?
97
105
  string << if benching?
98
106
  "[GemBench] We found a Rails::Railtie or Rails::Engine in the following files. However, it is possible that there are false positives, so you may want to verify that this is the case.\n\n"
@@ -116,18 +124,15 @@ module GemBench
116
124
  starters.each_with_index do |starter, index|
117
125
  string << "#{starter.info(index + 1)}\n"
118
126
  end
119
- if extra_verbose? && !benching? && benchers.length > 0
127
+ if extra_verbose? && !benching? && benchers.any?
120
128
  string << "[GemBench] #{benchers.length} out of #{all.length} evaluated gems did not contain #{look_for_regex}. They are:\n"
121
129
  benchers.each_with_index do |bencher, index|
122
130
  string << "#{bencher.info(index + 1)}\n"
123
131
  end
124
132
  end
125
- else
126
- string << "[GemBench] Congrats! All gems appear clean.\n"
127
- string << "\n#{GemBench::USAGE}" unless check_gemfile?
128
133
  end
129
134
  if check_gemfile? && benching?
130
- if current_gemfile_suggestions.length > 0
135
+ if current_gemfile_suggestions.any?
131
136
  string << "[GemBench] Evaluated #{all.length} gems and Gemfile at #{gemfile_path}.\n[GemBench] Here are #{current_gemfile_suggestions.length} suggestions for improvement:\n"
132
137
  current_gemfile_suggestions.each_with_index do |player, index|
133
138
  string << "#{player.suggest(index + 1)}\n"
@@ -159,7 +164,7 @@ module GemBench
159
164
 
160
165
  def prepare_bad_ideas
161
166
  string = ""
162
- if benchers.length > 0
167
+ if benchers.any?
163
168
  gemfile_instruction = check_gemfile? ? "" : "To safely evaluate a Gemfile:\n\t1. Make sure you are in the root of a project with a Gemfile\n\t2. Make sure the gem is actually a dependency in the Gemfile\n"
164
169
  string << "[GemBench] Evaluated #{all.length} loaded gems and found #{benchers.length} which may be able to skip boot loading (require: false).\n*** => WARNING <= ***: Be careful adding non-primary dependencies to your Gemfile as it is generally a bad idea.\n#{gemfile_instruction}"
165
170
  benchers.each_with_index do |player, index|
@@ -223,6 +228,10 @@ module GemBench
223
228
 
224
229
  private
225
230
 
231
+ def exclude!
232
+ self.excluded, self.all = loaded_gems.partition { |x| EXCLUDE.include?(x[0]) }
233
+ end
234
+
226
235
  def extra_verbose?
227
236
  verbose == "extra"
228
237
  end
@@ -1,6 +1,6 @@
1
1
  module GemBench
2
2
  # Version is enhanced by VersionGem::Basic once the gem is loaded.
3
3
  module Version
4
- VERSION = "2.0.4"
4
+ VERSION = "2.0.5"
5
5
  end
6
6
  end
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
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling
@@ -36,7 +36,7 @@ cert_chain:
36
36
  I5o+DRfXQHqKucx1ldFHvI2rE/kSCWqGTHN2eyu1sqCPeOoIMxrltJhaejKPkxqj
37
37
  zaF9Og==
38
38
  -----END CERTIFICATE-----
39
- date: 2024-09-20 00:00:00.000000000 Z
39
+ date: 2024-09-22 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
@@ -126,20 +126,6 @@ dependencies:
126
126
  - - ">="
127
127
  - !ruby/object:Gem::Version
128
128
  version: 1.0.2
129
- - !ruby/object:Gem::Dependency
130
- name: awesome_print
131
- requirement: !ruby/object:Gem::Requirement
132
- requirements:
133
- - - "~>"
134
- - !ruby/object:Gem::Version
135
- version: '1.9'
136
- type: :development
137
- prerelease: false
138
- version_requirements: !ruby/object:Gem::Requirement
139
- requirements:
140
- - - "~>"
141
- - !ruby/object:Gem::Version
142
- version: '1.9'
143
129
  - !ruby/object:Gem::Dependency
144
130
  name: method_source
145
131
  requirement: !ruby/object:Gem::Requirement
@@ -296,10 +282,10 @@ licenses:
296
282
  - MIT
297
283
  metadata:
298
284
  homepage_uri: https://railsbling.com/tags/gem_bench/
299
- source_code_uri: http://github.com/pboling/gem_bench/tree/v2.0.4
300
- changelog_uri: http://github.com/pboling/gem_bench/blob/v2.0.4/CHANGELOG.md
285
+ source_code_uri: http://github.com/pboling/gem_bench/tree/v2.0.5
286
+ changelog_uri: http://github.com/pboling/gem_bench/blob/v2.0.5/CHANGELOG.md
301
287
  bug_tracker_uri: http://github.com/pboling/gem_bench/issues
302
- documentation_uri: https://www.rubydoc.info/gems/gem_bench/2.0.4
288
+ documentation_uri: https://www.rubydoc.info/gems/gem_bench/2.0.5
303
289
  wiki_uri: http://github.com/pboling/gem_bench/wiki
304
290
  funding_uri: https://liberapay.com/pboling
305
291
  rubygems_mfa_required: 'true'
metadata.gz.sig CHANGED
Binary file