bundler-stats 2.3.0 → 2.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38f866872f6ba724ee82db46ba1715c05bcf8f22272f0ae6a23a96b1760232ce
4
- data.tar.gz: ee9b4655d4c8faa1da7f23d3602820ab70eeaf10aad836f4bc7c544cd10bf795
3
+ metadata.gz: ec7e2660f5dde8efca56ba43dafc36f3484f2487bcb9d8f0d676ea2e78bdfdb1
4
+ data.tar.gz: 6a23fe317d194924cacec0d789f981efcddea0e6a4a897ab391bf214eb9a20be
5
5
  SHA512:
6
- metadata.gz: e31cce716bfae8bdc92e525d1047678b96c4ea18f80aee2875718f84c690a8a76dbd34ee923b445724716f45eb0e9cdbeab69e13b0d6479284cb4a1185beeecf
7
- data.tar.gz: 2644320effea69f6e117a92154e3ddf0e0a3327a23d8141262dc4138fefa8a8a84eab049e68686ded2f778d2b271cbf8a00c43a6eb2b9fa06c09d01b11ce694d
6
+ metadata.gz: c7f99f7537f5942b8fbb9ad64fa63027dbefde792226b961d88e320ff2c806fe8256b9008d3b00ef2f840d4fd0efaadab6fc9281ff2eaf99f078a27020b60c57
7
+ data.tar.gz: c4381e6e31ebd4d5708ceeb45d697c0ef17840b54ef80212152b01d7a9241878a62f11f945d01adca8885c411b7037d4425112b77cde84896131552297703ecd
@@ -11,7 +11,7 @@ jobs:
11
11
  strategy:
12
12
  matrix:
13
13
  os: [ubuntu-latest, macos-latest]
14
- ruby-version: [3.1, 3.0, 2.7, 2.6, 2.5, 2.4, 2.3]
14
+ ruby-version: [4.0, 3.4, 3.3, 3.2]
15
15
  runs-on: ${{ matrix.os }}
16
16
 
17
17
  steps:
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  Gemfile.lock
2
2
  bundler-stats-*.gem
3
+ .tool-versions
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.3
1
+ 4.0.5
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  Changelog
2
2
  =============
3
3
 
4
+ ## Unreleased
5
+
6
+ - Relax Bundler dependency to work with Bundler 4.x
7
+
4
8
  ## [2.3.0] - 2022-02-12
5
9
 
6
10
  ### Added
data/README.md CHANGED
@@ -237,10 +237,24 @@ To consume information with a build job or somesuch, all commands can emit JSON.
237
237
  ]
238
238
  }
239
239
 
240
+ ### Custom Gemfile path
241
+
242
+ This gem by default attempts to locate the Gemfile and Gemfile.lock files in parent directories. If you want to specify a specific location for your Gemfile/gems.rb file, you can use the `--gemfile_path` option.
243
+
244
+ > bundle-stats show sass-rails --gemfile_path=/Users/user/project/Gemfile
245
+
246
+ Keep in mind that the location of the Gemfile.lock/gems.locked file will be inferred from the location of the Gemfile/gems.rb file.
247
+
240
248
  Contributing
241
249
  ------------
242
250
 
243
- Contributions are very welcome. Fork, fix, submit pulls.
251
+ Contributions are very welcome. Fork, fix, submit pull requests.
252
+
253
+ Before you submit your pull request, make sure that the test suite passes:
254
+
255
+ ```
256
+ bundle exec rspec spec
257
+ ```
244
258
 
245
259
  Contribution is expected to conform to the [Contributor Covenant](https://github.com/jmmastey/bundler-stats/blob/master/CODE_OF_CONDUCT.md).
246
260
 
@@ -35,8 +35,8 @@ Gem::Specification.new do |gem|
35
35
 
36
36
  gem.require_paths = %w[ext lib].select { |dir| File.directory?(dir) }
37
37
 
38
- gem.add_dependency "bundler", ">= 1.9", "< 3"
39
- gem.add_dependency "thor", ">= 0.19.0", "< 2.0"
38
+ gem.add_dependency "bundler", ">= 2.4", "< 5"
39
+ gem.add_dependency "thor", "~> 1.5"
40
40
 
41
41
  gem.add_development_dependency "rspec", "~> 3.4"
42
42
  gem.add_development_dependency "guard", "~> 2.13"
@@ -13,6 +13,7 @@ module Bundler
13
13
  desc 'stats', 'Displays basic stats about the gems in your Gemfile'
14
14
  method_option :format, aliases: "-f", description: "Output format, either JSON or text"
15
15
  method_option :nofollow, description: "A comma delimited list of dependencies not to follow."
16
+ method_option :gemfile_path, description: "Custom path for Gemfile/gems.rb and Gemfile.lock/gems.locked"
16
17
  def stats
17
18
  calculator = build_calculator(options)
18
19
  stats = calculator.stats
@@ -27,6 +28,7 @@ module Bundler
27
28
  desc 'show TARGET', 'Prints the dependency tree for a single gem in your Gemfile'
28
29
  method_option :format, aliases: "-f", description: "Output format, either JSON or text"
29
30
  method_option :nofollow, description: "A comma delimited list of dependencies not to follow."
31
+ method_option :gemfile_path, description: "Custom path for Gemfile/gems.rb and Gemfile.lock/gems.locked"
30
32
  def show(target)
31
33
  calculator = build_calculator(options)
32
34
  stats = calculator.summarize(target)
@@ -41,6 +43,7 @@ module Bundler
41
43
  desc 'versions TARGET', 'Shows versions requirements for target in other dependencies'
42
44
  method_option :format, aliases: "-f", description: "Output format, either JSON or text"
43
45
  method_option :nofollow, description: "A comma delimited list of dependencies not to follow."
46
+ method_option :gemfile_path, description: "Custom path for Gemfile/gems.rb and Gemfile.lock/gems.locked"
44
47
  def versions(target)
45
48
  calculator = build_calculator(options)
46
49
  stats = calculator.versions(target)
@@ -122,29 +125,15 @@ module Bundler
122
125
 
123
126
  def build_calculator(options)
124
127
  skiplist = Bundler::Stats::Skiplist.new(options[:nofollow])
125
- @calculator ||= Bundler::Stats::Calculator.new(gemfile_path, lockfile_path, skiplist)
128
+ @calculator ||= Bundler::Stats::Calculator.new(
129
+ file_path_resolver.gemfile_path,
130
+ file_path_resolver.lockfile_path,
131
+ skiplist
132
+ )
126
133
  end
127
134
 
128
- def gemfile_path
129
- cwd = Pathname.new("./")
130
- until cwd.realdirpath.root? do
131
- %w(gems.rb Gemfile).each do |gemfile|
132
- return (cwd + gemfile) if File.exist?(cwd + gemfile)
133
- end
134
- cwd = cwd.parent
135
- end
136
- raise ArgumentError, "Couldn't find gems.rb nor Gemfile in this directory or parents"
137
- end
138
-
139
- def lockfile_path
140
- cwd = Pathname.new(".")
141
- until cwd.realdirpath.root? do
142
- %w(gems.locked Gemfile.lock).each do |lockfile|
143
- return (cwd + lockfile) if File.exist?(cwd + lockfile)
144
- end
145
- cwd = cwd.parent
146
- end
147
- raise ArgumentError, "Couldn't find gems.locked nor Gemfile.lock in this directory or parents"
135
+ def file_path_resolver
136
+ @file_path_resolver ||= Bundler::Stats::FilePathResolver.new(options[:gemfile_path])
148
137
  end
149
138
  end
150
139
  end
@@ -0,0 +1,56 @@
1
+ module Bundler
2
+ module Stats
3
+ class FilePathResolver
4
+ FILES_MAP = {
5
+ "gems.rb" => "gems.locked",
6
+ "Gemfile" => "Gemfile.lock"
7
+ }
8
+
9
+ def initialize(specific_gemfile_path = nil)
10
+ @specific_gemfile_path = specific_gemfile_path
11
+ end
12
+
13
+ def gemfile_path
14
+ resolve_file_path(FILES_MAP.keys, specific_gemfile_path)
15
+ end
16
+
17
+ def lockfile_path
18
+ resolve_file_path(FILES_MAP.values, resolve_lockfile_path)
19
+ end
20
+
21
+ private
22
+
23
+ attr_reader :specific_gemfile_path
24
+
25
+ def resolve_lockfile_path
26
+ return unless specific_gemfile_path
27
+
28
+ file_path = Pathname.new(specific_gemfile_path)
29
+ file_name = file_path.basename.to_s
30
+ locked_file_name = FILES_MAP[file_name]
31
+ raise ArgumentError, "Invalid file name: #{file_name}" if locked_file_name.nil?
32
+ file_path.dirname.join(locked_file_name).to_s
33
+ end
34
+
35
+ def resolve_file_path(file_names, custom_path)
36
+ if custom_path
37
+ raise ArgumentError, "Couldn't find #{custom_path} file path" unless File.exist?(custom_path)
38
+ return custom_path
39
+ end
40
+
41
+ find_file_path(file_names)
42
+ end
43
+
44
+ def find_file_path(file_names)
45
+ cwd = Pathname.new(".")
46
+ until cwd.realdirpath.root? do
47
+ file_names.each do |file|
48
+ return (cwd + file).to_s if File.exist?(cwd + file)
49
+ end
50
+ cwd = cwd.parent
51
+ end
52
+ raise ArgumentError, "Couldn't find #{file_names.join(" nor ")} in this directory or parents"
53
+ end
54
+ end
55
+ end
56
+ end
@@ -1,5 +1,5 @@
1
1
  module Bundler
2
2
  module Stats
3
- VERSION = '2.3.0'
3
+ VERSION = '2.4.1'
4
4
  end
5
5
  end
data/lib/bundler/stats.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require_relative 'stats/calculator'
2
+ require_relative 'stats/file_path_resolver'
2
3
  require_relative 'stats/printer'
3
4
  require_relative 'stats/remover'
4
5
  require_relative 'stats/skiplist'
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bundler::Stats::FilePathResolver do
4
+ let(:file_path_resolver) { described_class.new(specific_gemfile_path) }
5
+
6
+ context "with undefined specific gemfile path" do
7
+ let(:specific_gemfile_path) { nil }
8
+
9
+ before do
10
+ allow(File).to receive(:exist?).and_return(false)
11
+ end
12
+
13
+ context "without files found" do
14
+ it do
15
+ expect { file_path_resolver.gemfile_path }.to raise_error(
16
+ ArgumentError, "Couldn't find gems.rb nor Gemfile in this directory or parents"
17
+ )
18
+ end
19
+
20
+ it do
21
+ expect { file_path_resolver.lockfile_path }.to raise_error(
22
+ ArgumentError, "Couldn't find gems.locked nor Gemfile.lock in this directory or parents"
23
+ )
24
+ end
25
+ end
26
+
27
+ context "with files found" do
28
+ before do
29
+ allow(File).to receive(:exist?).with(Pathname.new("../Gemfile")).and_return(true)
30
+ allow(File).to receive(:exist?).with(Pathname.new("../../gems.locked")).and_return(true)
31
+ end
32
+
33
+ it { expect(file_path_resolver.gemfile_path).to eq("../Gemfile") }
34
+ it { expect(file_path_resolver.lockfile_path).to eq("../../gems.locked") }
35
+ end
36
+ end
37
+
38
+ context "with specific gemfile path" do
39
+ let(:specific_gemfile_path) { "some-project/Gemfile" }
40
+
41
+ context "with valid file path" do
42
+ before do
43
+ allow(File).to receive(:exist?).and_return(true)
44
+ end
45
+
46
+ it { expect(file_path_resolver.gemfile_path).to eq("some-project/Gemfile") }
47
+ it { expect(file_path_resolver.lockfile_path).to eq("some-project/Gemfile.lock") }
48
+
49
+ context "with gems.rb file" do
50
+ let(:specific_gemfile_path) { "some-project/gems.rb" }
51
+
52
+ it { expect(file_path_resolver.gemfile_path).to eq("some-project/gems.rb") }
53
+ it { expect(file_path_resolver.lockfile_path).to eq("some-project/gems.locked") }
54
+ end
55
+
56
+ context "with invalid file name" do
57
+ let(:specific_gemfile_path) { "some-project/yeimfile" }
58
+
59
+ it do
60
+ expect { file_path_resolver.lockfile_path }.to raise_error(
61
+ ArgumentError, "Invalid file name: yeimfile"
62
+ )
63
+ end
64
+ end
65
+ end
66
+
67
+ context "with invalid file path" do
68
+ before do
69
+ allow(File).to receive(:exist?).and_return(false)
70
+ end
71
+
72
+ it do
73
+ expect { file_path_resolver.gemfile_path }.to raise_error(
74
+ ArgumentError, "Couldn't find some-project/Gemfile file path"
75
+ )
76
+ end
77
+
78
+ it do
79
+ expect { file_path_resolver.lockfile_path }.to raise_error(
80
+ ArgumentError, "Couldn't find some-project/Gemfile.lock file path"
81
+ )
82
+ end
83
+ end
84
+ end
85
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler-stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Mastey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-13 00:00:00.000000000 Z
11
+ date: 2026-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,40 +16,34 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.9'
19
+ version: '2.4'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '3'
22
+ version: '5'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '1.9'
29
+ version: '2.4'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '3'
32
+ version: '5'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: thor
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: 0.19.0
40
- - - "<"
37
+ - - "~>"
41
38
  - !ruby/object:Gem::Version
42
- version: '2.0'
39
+ version: '1.5'
43
40
  type: :runtime
44
41
  prerelease: false
45
42
  version_requirements: !ruby/object:Gem::Requirement
46
43
  requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 0.19.0
50
- - - "<"
44
+ - - "~>"
51
45
  - !ruby/object:Gem::Version
52
- version: '2.0'
46
+ version: '1.5'
53
47
  - !ruby/object:Gem::Dependency
54
48
  name: rspec
55
49
  requirement: !ruby/object:Gem::Requirement
@@ -148,12 +142,14 @@ files:
148
142
  - lib/bundler/stats.rb
149
143
  - lib/bundler/stats/calculator.rb
150
144
  - lib/bundler/stats/cli.rb
145
+ - lib/bundler/stats/file_path_resolver.rb
151
146
  - lib/bundler/stats/printer.rb
152
147
  - lib/bundler/stats/remover.rb
153
148
  - lib/bundler/stats/skiplist.rb
154
149
  - lib/bundler/stats/tree.rb
155
150
  - lib/bundler/stats/version.rb
156
151
  - spec/lib/bundler/stats/calculator_spec.rb
152
+ - spec/lib/bundler/stats/file_path_resolver_spec.rb
157
153
  - spec/lib/bundler/stats/printer_spec.rb
158
154
  - spec/lib/bundler/stats/remover_spec.rb
159
155
  - spec/lib/bundler/stats/tree_spec.rb
@@ -182,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
178
  - !ruby/object:Gem::Version
183
179
  version: '0'
184
180
  requirements: []
185
- rubygems_version: 3.1.6
181
+ rubygems_version: 3.4.19
186
182
  signing_key:
187
183
  specification_version: 4
188
184
  summary: Dependency investigation for Bundler