bundler-stats 2.0.1 → 2.3.0

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: effbf5fc1dcb265737923b548467df2b831f444638f673e37622a2efd564cb54
4
- data.tar.gz: 23cae592f904d2cdaef97b5597f953b0a927f24368d5f6e1b8763224391d4884
3
+ metadata.gz: 38f866872f6ba724ee82db46ba1715c05bcf8f22272f0ae6a23a96b1760232ce
4
+ data.tar.gz: ee9b4655d4c8faa1da7f23d3602820ab70eeaf10aad836f4bc7c544cd10bf795
5
5
  SHA512:
6
- metadata.gz: de70cf8fedea1260329b24fea38e1f564215ae7f6bf67d5d0d87d6aa1b639cad39ced3625069ea6ecb38e315a3fec7de561cde0a331e951d550234f90e6ed0c7
7
- data.tar.gz: 606dc092473b823593dc2baec837c91956a6554c31f66990afc1f89052dac95f9c0209324b7e643429e04fe922025bcb090264f9730a7b6d900706bf6138ccfd
6
+ metadata.gz: e31cce716bfae8bdc92e525d1047678b96c4ea18f80aee2875718f84c690a8a76dbd34ee923b445724716f45eb0e9cdbeab69e13b0d6479284cb4a1185beeecf
7
+ data.tar.gz: 2644320effea69f6e117a92154e3ddf0e0a3327a23d8141262dc4138fefa8a8a84eab049e68686ded2f778d2b271cbf8a00c43a6eb2b9fa06c09d01b11ce694d
@@ -0,0 +1,27 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+ strategy:
12
+ matrix:
13
+ os: [ubuntu-latest, macos-latest]
14
+ ruby-version: [3.1, 3.0, 2.7, 2.6, 2.5, 2.4, 2.3]
15
+ runs-on: ${{ matrix.os }}
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - name: Set up Ruby ${{ matrix.ruby-version }}
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ bundler-cache: true
24
+ - name: Install dependencies
25
+ run: bundle install
26
+ - name: Run tests
27
+ run: bundle exec rspec
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  Gemfile.lock
2
+ bundler-stats-*.gem
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.3
data/CHANGELOG.md CHANGED
@@ -1,19 +1,112 @@
1
1
  Changelog
2
2
  =============
3
3
 
4
- ## [1.1.0] - 2018-03-16
4
+ ## [2.3.0] - 2022-02-12
5
+
6
+ ### Added
7
+ - Skiplist now correctly removes dependencies from 1st and onward levels
8
+ - Wildcard ability for specifying gems for skiplist
9
+ - Document `versions` in README
10
+
11
+ ## [2.2.0] - 2022-02-09
12
+
13
+ ### Added
14
+ - Support for gems.rb and gems.locked files.
15
+ - Proper exit codes from thor when errors occur
16
+ - Looser dependency on thor
17
+
18
+ ## [2.1.1] - 2021-11-30
19
+
20
+ ### Changed
21
+ - Symlink isn't the recommended way to alias a command. Patterned current
22
+ solution after bundle-audit. Boy that naming convention was unfortunate.
23
+ - Pin down dependencies a bit.
24
+
25
+ ### Added
26
+ - Moved to Github test workflow, by @etagwerker.
27
+ - New default ruby version to be most current non-3 ruby.
28
+ - Build artifacts now ignored.
29
+ - Moved to a real spec_helper so tests can be filtered during runs if desired.
30
+
5
31
  ### Fixed
32
+ - Failing test from previous version.
6
33
 
7
- - Remove unintentional inclusion of pry outside of dev environment
34
+ ## [2.1.0] - 2021-11-29
35
+
36
+ ### Changed
37
+ - Add Travis targets for more modern rubies, by @etagwerker.
38
+ - Make sorting predictable across platforms, by @etagwerker.
39
+
40
+ ### Fixed
41
+ - Fix error in CI when `tput` isn't available, by @etagwerker.
42
+
43
+ ## [2.0.1] - 2018-05-04
8
44
 
9
- ## [1.1.0] - 2018-03-15
10
45
  ### Added
46
+ - Complete custom table printer for some nicer output.
47
+
48
+ ## [2.0.0] - 2018-05-04
49
+ Broken as hell.
50
+
51
+ ## [1.3.4] - 2019-04-18
52
+
53
+ ### Changed
54
+ - Allow use of either `bundle-stats` or `bundler-stats` since the gem name was
55
+ a confusing choice. Live and learn.
56
+
57
+ ### Added
58
+ - Display resolved version of a gem when using `bundler-stats show`.
59
+
60
+ ## [1.3.3] - 2019-04-18
61
+
62
+ ### Changed
63
+ - Only print missing system dependency warning once per target gem, rather than
64
+ blowing up the console when a complicated gem is affected.
11
65
 
66
+ ## [1.3.2] - 2019-04-17
67
+
68
+ ### Fixed
69
+ - Fix issue when testing removability and a system gem from another platform
70
+ is "required", thx @rwojnarowski.
71
+
72
+ ## [1.3.1] - 2019-04-05
73
+
74
+ ### Changed
75
+ - Nicer table printing, still committed to not adding a table printing gem.
76
+
77
+ ## [1.3.0] - 2019-04-05
78
+
79
+ ### Changed
80
+ - Reversed the order in which gems are printed to worst-offenders-first.
81
+
82
+ ## [1.2.1] - 2019-04-05
83
+
84
+ ### Fixed
85
+ - When a system gem is missing from the lockfile (but is depended upon), warn
86
+ the user rather than exploding.
87
+
88
+ ## [1.2.0] - 2019-04-05
89
+
90
+ ### Fixed
91
+ - Loosen dependency on thor gem, by localhostdotdev.
92
+
93
+ ## [1.1.2] - 2018-03-16
94
+ Wonkiness w/ versioning. Apparently I was bad at this.
95
+
96
+ ## [1.1.0] - 2018-03-16
97
+ Eventually superseded by 1.1.2 for reasons.
98
+
99
+ ### Fixed
100
+ - Remove unintentional inclusion of pry outside of dev environment, per @Tuxified
101
+
102
+ ## [1.1.0] - 2018-03-15
103
+
104
+ ### Added
12
105
  - Adds a way to view dependency version restrictions for a given gem, by @olivierlacan
13
106
 
14
107
  ## [1.0.0] - 2016-04-13
15
- ### Added
16
108
 
109
+ ### Added
17
110
  - Base library, woo!
18
111
  - List all transitive dependencies and how many other deps rely on them
19
112
  - View list of Github-specified dependencies
data/README.md CHANGED
@@ -34,8 +34,10 @@ Usage
34
34
  bundle-stats version # Prints the bundler-stats version
35
35
  bundle-stats versions TARGET # Shows versions requirements for target in other dependencies
36
36
 
37
+ ### Auditing Your Gemfile
38
+
37
39
  The most obvious thing to do is run the command by itself, which should help
38
- identify problem areas:
40
+ identify problem areas.
39
41
 
40
42
  > bundle-stats
41
43
 
@@ -62,7 +64,7 @@ identify problem areas:
62
64
  Unpinned Versions 54
63
65
  Github Refs 0
64
66
 
65
- It looks like rails_admin is a huge problem. Use `show` to investigate:
67
+ It looks like rails_admin is a huge problem. Use `show` to investigate.
66
68
 
67
69
  > bundle-stats show rails_admin
68
70
  bundle-stats for rails_admin
@@ -98,22 +100,117 @@ It looks like rails_admin is a huge problem. Use `show` to investigate:
98
100
  | | bundler |
99
101
  +--------------------------------|----------------------------------------+
100
102
 
101
- Removing the dep will only actually remove 9 gems. The rest are shared
102
- dependencies with other gems like rails. We can also omit trees we aren't going
103
- to remove (hi rails) by not following them:
103
+ ### Skipping Common Dependencies
104
+
105
+ Let's take a look at another common gem to rails codebases. In this case,
106
+ we have some unique dependencies, but also many dependencies on rails, and on
107
+ its constituent gems.
108
+
109
+ > bundle-stats show compass-rails
110
+ bundle-stats for compass-rails
111
+
112
+ +--------------------------------|----------------------------------------+
113
+ | Depended Upon By (0) | |
114
+ | Depends On (35) | compass, sass-rails, sprockets |
115
+ | | chunky_png, compass-core |
116
+ | | compass-import-once, rb-fsevent |
117
+ | | rb-inotify, sass, multi_json, ffi |
118
+ | | railties, sprockets-rails, tilt |
119
+ | | actionpack, activesupport, method_source |
120
+ | | rake, thor, actionview, rack, rack-test |
121
+ | | rails-dom-testing, rails-html-sanitizer |
122
+ | | builder, erubi, concurrent-ruby, i18n |
123
+ | | minitest, tzinfo, thread_safe, nokogiri |
124
+ | | mini_portile2, loofah, crass |
125
+ | Unique to This (3) | compass, compass-core |
126
+ | | compass-import-once |
127
+ +--------------------------------|----------------------------------------+
128
+
129
+ We're not looking to remove rails, so there's not much point in including it
130
+ within this output. Instead, we can use the `nofollow` flag to skip it in all
131
+ output lists.
104
132
 
105
- > bundle-stats show sass-rails --nofollow="railties,activesupport,actionpack"
106
- bundle-stats for sass-rails
133
+ > bundle-stats show compass-rails --nofollow="railties,activeupport,actionview,actionpack"
134
+ bundle-stats for compass-rails
107
135
 
108
136
  +--------------------------------|----------------------------------------+
109
- | Depended Upon By (2) | compass-rails, rails_admin |
110
- | Depends On (9) | railties, sass, sprockets |
137
+ | Depended Upon By (0) | |
138
+ | Depends On (20) | compass, sass-rails, sprockets |
139
+ | | chunky_png, compass-core |
140
+ | | compass-import-once, rb-fsevent |
141
+ | | rb-inotify, sass, multi_json, ffi |
111
142
  | | sprockets-rails, tilt, concurrent-ruby |
112
- | | rack, actionpack, activesupport |
113
- | Unique to This (0) | |
143
+ | | rack, activesupport, i18n, minitest |
144
+ | | tzinfo, thread_safe |
145
+ | Unique to This (3) | compass, compass-core |
146
+ | | compass-import-once |
114
147
  +--------------------------------|----------------------------------------+
115
148
 
116
- To consume information with a build job or somesuch, all commands can emit JSON:
149
+ This is better, but for other codebases it's common for gems to depend on each
150
+ of the _many many_ child gems of rails individually. Rather than specifying each
151
+ by itself, we can use wildcards to remove them in bulk.
152
+
153
+ > bundle-stats show compass-rails --nofollow="rail*,action*,active*"
154
+ bundle-stats for compass-rails
155
+
156
+ +--------------------------------|----------------------------------------+
157
+ | Depended Upon By (0) | |
158
+ | Depends On (15) | compass, sass-rails, sprockets |
159
+ | | chunky_png, compass-core |
160
+ | | compass-import-once, rb-fsevent |
161
+ | | rb-inotify, sass, multi_json, ffi |
162
+ | | sprockets-rails, tilt, concurrent-ruby |
163
+ | | rack |
164
+ | Unique to This (3) | compass, compass-core |
165
+ | | compass-import-once |
166
+ +--------------------------------|----------------------------------------+
167
+
168
+ ### Showing Required Versions
169
+
170
+ Sometimes you try to upgrade a gem, you ask bundler _very nicely_, but you
171
+ find that the version hasn't changed. When that happens, sometimes it's not
172
+ clear why the gem version isn't changing.
173
+
174
+ In that case, use `versions` to list all required dependencies on your gem.
175
+
176
+ > bundle-stats versions actionpack
177
+ version dependencies for actionpack
178
+
179
+ Depended Upon By 24
180
+ Resolved Version 5.2.0
181
+
182
+ +----------------------------|------------------+
183
+ | Name | Required Version |
184
+ +----------------------------|------------------+
185
+ | webpacker | = 5.2.0 |
186
+ | actionmailer | = 5.2.0 |
187
+ | activestorage | = 5.2.0 |
188
+ | coffee-rails | = 5.2.0 |
189
+ | compass-rails | = 5.2.0 |
190
+ | devise | = 5.2.0 |
191
+ | factory_bot_rails | = 5.2.0 |
192
+ | font-awesome-rails | = 5.2.0 |
193
+ | rails_admin | = 5.2.0 |
194
+ | railties | = 5.2.0 |
195
+ | sass-rails | = 5.2.0 |
196
+ | scenic | = 5.2.0 |
197
+ | versionist | = 5.2.0 |
198
+ | actioncable | = 5.2.0 |
199
+ | jquery-rails | = 5.2.0 |
200
+ | jquery-ui-rails | = 5.2.0 |
201
+ | jquery_file_download-rails | = 5.2.0 |
202
+ | rails | = 5.2.0 |
203
+ | rspec-rails | >= 3.0 |
204
+ | sprockets-rails | >= 4.0 |
205
+ | haml-rails | >= 4.0.1 |
206
+ | responders | >= 4.2.0, < 5.3 |
207
+ | simple_form | >= 5.0 |
208
+ | rails-controller-testing | ~> 5.x, >= 5.0.1 |
209
+ +----------------------------|------------------+
210
+
211
+ ### Output Formats
212
+
213
+ To consume information with a build job or somesuch, all commands can emit JSON.
117
214
 
118
215
  > bundle-stats show sass-rails --nofollow="railties,activesupport,actionpack" -f json
119
216
  {
@@ -154,7 +251,7 @@ Credits
154
251
  Thanks to the many kind people at [RailsCamp East
155
252
  2016](http://east.railscamp.com) for the help, the ideas, and the support.
156
253
 
157
- Thanks to Isaac Bowen for being pedantic about speeling.
254
+ Also, many other folks for their feature / fix contributions. ❤️
158
255
 
159
256
  License
160
257
  -------
data/bin/bundle-stats CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
-
4
3
  require 'rubygems'
5
4
 
6
5
  lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
data/bin/bundler-stats ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ load File.expand_path('../bundle-stats', __FILE__)
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.licenses = "MIT"
16
16
  gem.authors = "Joseph Mastey"
17
17
  gem.email = "jmmastey@gmail.com"
18
- gem.homepage = ""
18
+ gem.homepage = "http://github.com/jmmastey/bundler-stats"
19
19
 
20
20
  gem.metadata = {
21
21
  "homepage_uri" => "http://github.com/jmmastey/bundler-stats",
@@ -35,12 +35,12 @@ 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"
39
- gem.add_dependency "thor", "~> 0.19"
38
+ gem.add_dependency "bundler", ">= 1.9", "< 3"
39
+ gem.add_dependency "thor", ">= 0.19.0", "< 2.0"
40
40
 
41
41
  gem.add_development_dependency "rspec", "~> 3.4"
42
42
  gem.add_development_dependency "guard", "~> 2.13"
43
- gem.add_development_dependency "guard-rspec"
43
+ gem.add_development_dependency "guard-rspec", "< 5"
44
44
  gem.add_development_dependency "pry", "~> 0.10"
45
- gem.add_development_dependency "rb-readline"
45
+ gem.add_development_dependency "rb-readline", "< 1"
46
46
  end
@@ -5,7 +5,7 @@ module Bundler
5
5
  class Calculator
6
6
  attr_reader :parser, :tree, :gemfile, :remover
7
7
 
8
- def initialize(gemfile_path, lockfile_path, options = {})
8
+ def initialize(gemfile_path, lockfile_path, skiplist = nil)
9
9
  raise ArgumentError unless File.readable?(lockfile_path)
10
10
  raise ArgumentError unless File.readable?(gemfile_path)
11
11
 
@@ -17,9 +17,7 @@ module Bundler
17
17
  lock_contents = File.read(lockfile_path)
18
18
  @parser = Bundler::LockfileParser.new(lock_contents)
19
19
 
20
- skiplist = options.fetch(:skiplist, [])
21
20
  @tree = Bundler::Stats::Tree.new(@parser, skiplist: skiplist)
22
-
23
21
  @remover = Bundler::Stats::Remover.new(@tree, @gemfile)
24
22
  end
25
23
 
@@ -64,7 +62,7 @@ module Bundler
64
62
  stats = @gemfile.map do |gem|
65
63
  @tree.summarize(gem.name)
66
64
  end
67
- stats.sort_by { |row| row[:total_dependencies] }.reverse
65
+ stats.sort_by { |row| [row[:total_dependencies] * -1, row[:name]] }
68
66
  end
69
67
  end
70
68
  end
@@ -59,6 +59,10 @@ module Bundler
59
59
 
60
60
  private
61
61
 
62
+ def self.exit_on_failure?
63
+ true
64
+ end
65
+
62
66
  def draw_stats(gem_stats, summary)
63
67
  max_name_length = gem_stats.map { |gem| gem[:name].length }.max
64
68
 
@@ -95,7 +99,7 @@ module Bundler
95
99
 
96
100
  def draw_versions(stats, target)
97
101
  dependers = stats[:top_level_dependencies] # they do the depending
98
- say "bundle-stats for #{target}"
102
+ say "version dependencies for #{target}"
99
103
  say Printer.new(
100
104
  headers: nil,
101
105
  borders: false,
@@ -117,31 +121,30 @@ module Bundler
117
121
  end
118
122
 
119
123
  def build_calculator(options)
120
- if !options[:nofollow].nil?
121
- skiplist = options[:nofollow].gsub(/\s+/, '').split(",")
122
- else
123
- skiplist = []
124
- end
125
-
126
- @calculator ||= Bundler::Stats::Calculator.new(gemfile_path, lockfile_path, skiplist: skiplist)
124
+ skiplist = Bundler::Stats::Skiplist.new(options[:nofollow])
125
+ @calculator ||= Bundler::Stats::Calculator.new(gemfile_path, lockfile_path, skiplist)
127
126
  end
128
127
 
129
128
  def gemfile_path
130
129
  cwd = Pathname.new("./")
131
130
  until cwd.realdirpath.root? do
132
- return (cwd + "Gemfile") if File.exist?(cwd + "Gemfile")
131
+ %w(gems.rb Gemfile).each do |gemfile|
132
+ return (cwd + gemfile) if File.exist?(cwd + gemfile)
133
+ end
133
134
  cwd = cwd.parent
134
135
  end
135
- raise ArgumentError, "Couldn't find Gemfile in this directory or parents"
136
+ raise ArgumentError, "Couldn't find gems.rb nor Gemfile in this directory or parents"
136
137
  end
137
138
 
138
139
  def lockfile_path
139
140
  cwd = Pathname.new(".")
140
141
  until cwd.realdirpath.root? do
141
- return (cwd + "Gemfile.lock") if File.exist?(cwd + "Gemfile.lock")
142
+ %w(gems.locked Gemfile.lock).each do |lockfile|
143
+ return (cwd + lockfile) if File.exist?(cwd + lockfile)
144
+ end
142
145
  cwd = cwd.parent
143
146
  end
144
- raise ArgumentError, "Couldn't find Gemfile in this directory or parents"
147
+ raise ArgumentError, "Couldn't find gems.locked nor Gemfile.lock in this directory or parents"
145
148
  end
146
149
  end
147
150
  end
@@ -38,7 +38,7 @@ class Bundler::Stats::Printer
38
38
 
39
39
  def terminal_width
40
40
  Integer(Kernel.send(:"`", "tput cols"))
41
- rescue Errno::ENOENT, TypeError, Errno::ENOENT
41
+ rescue StandardError
42
42
  80
43
43
  end
44
44
 
@@ -0,0 +1,32 @@
1
+ class Bundler::Stats::Skiplist
2
+ attr_reader :regex_list
3
+
4
+ def initialize(list = '')
5
+ @regex_list = if list.respond_to?(:regex_list)
6
+ list.regex_list
7
+ elsif list.respond_to?(:split)
8
+ list
9
+ .gsub(/\s+/, '')
10
+ .split(",")
11
+ .map { |str| glob_to_regex(str) }
12
+ else
13
+ (list || []).map { |str| glob_to_regex(str) }
14
+ end
15
+ end
16
+
17
+ def filter(gem_list)
18
+ gem_list.reject { |gem| self.include?(gem) }
19
+ end
20
+
21
+ def include?(target)
22
+ @regex_list.any? { |pattern| pattern =~ target.name }
23
+ end
24
+
25
+ private
26
+
27
+ def glob_to_regex(str)
28
+ str.gsub!('*','.*') # weird globbish behavior
29
+
30
+ /^#{str}$/
31
+ end
32
+ end
@@ -1,20 +1,21 @@
1
1
  class Bundler::Stats::Tree
2
- attr_accessor :tree
2
+ attr_accessor :tree, :skiplist
3
3
 
4
4
  ERR_MESSAGE = "The dependency `%s` wasn't found. It may not be present in " \
5
5
  "your Gemfile.lock. This often happens when a dependency isn't " \
6
6
  "installed on your platform."
7
7
 
8
- def initialize(parser, skiplist: [])
8
+ def initialize(parser, skiplist: '')
9
9
  raise ArgumentError unless parser.respond_to?(:specs)
10
10
 
11
11
  @parser = parser
12
12
  @tree = specs_as_tree(@parser.specs)
13
- @skiplist = skiplist
13
+ @skiplist = Bundler::Stats::Skiplist.new(skiplist)
14
14
  end
15
15
 
16
16
  def summarize(target)
17
17
  transitive_dependencies = transitive_dependencies(target)
18
+
18
19
  { name: target,
19
20
  total_dependencies: transitive_dependencies.count,
20
21
  first_level_dependencies: first_level_dependencies(target).count,
@@ -51,12 +52,12 @@ class Bundler::Stats::Tree
51
52
  return []
52
53
  end
53
54
 
54
- top_level = @tree[target].dependencies
55
+ top_level = skiplist.filter(@tree[target].dependencies)
55
56
  all_level = top_level + top_level.inject([]) do |arr, dep|
56
57
  # turns out bundler refuses to include itself in the dependency tree,
57
58
  # which is sneaky
58
59
  next arr if dep.name == "bundler"
59
- next arr if @skiplist.include? dep.name
60
+ next arr if skiplist.include? dep
60
61
 
61
62
  arr += transitive_dependencies(dep.name)
62
63
  end
@@ -1,5 +1,5 @@
1
1
  module Bundler
2
2
  module Stats
3
- VERSION = '2.0.1'
3
+ VERSION = '2.3.0'
4
4
  end
5
5
  end
data/lib/bundler/stats.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require_relative 'stats/calculator'
2
2
  require_relative 'stats/printer'
3
3
  require_relative 'stats/remover'
4
+ require_relative 'stats/skiplist'
4
5
  require_relative 'stats/tree'
5
6
  require_relative 'stats/version'
@@ -1,5 +1,4 @@
1
- require 'bundler'
2
- require 'bundler/stats'
1
+ require 'spec_helper'
3
2
 
4
3
  describe Bundler::Stats::Calculator do
5
4
  subject { described_class }
@@ -39,9 +38,9 @@ describe Bundler::Stats::Calculator do
39
38
  # this sucks. break this dependency further
40
39
  allow(Bundler::LockfileParser).to receive(:new) { "parser" }
41
40
 
42
- target = subject.new(gemfile_path, lockfile_path, skiplist: "abc")
41
+ target = subject.new(gemfile_path, lockfile_path, "skiplist")
43
42
 
44
- expect(Bundler::Stats::Tree).to have_received(:new).with("parser", skiplist: "abc")
43
+ expect(Bundler::Stats::Tree).to have_received(:new).with("parser", skiplist: "skiplist")
45
44
  end
46
45
  end
47
46
 
@@ -77,6 +76,16 @@ describe Bundler::Stats::Calculator do
77
76
  end
78
77
 
79
78
  context "#gem_stats" do
79
+ let(:partial_sorted_result) do
80
+ [
81
+ ["rolify", 0],
82
+ ["rubocop-rspec", 0],
83
+ ["spring", 0],
84
+ ["state_machine", 0],
85
+ ["will_paginate", 0]
86
+ ]
87
+ end
88
+
80
89
  it "includes entries for each gem" do
81
90
  calculator = subject.new(gemfile_path, lockfile_path)
82
91
 
@@ -85,6 +94,14 @@ describe Bundler::Stats::Calculator do
85
94
  expect(target).to be_a(Array)
86
95
  expect(target.length).to eq(calculator.gemfile.length)
87
96
  end
97
+
98
+ it "sorts entries by total dependencies descending and name ascending" do
99
+ calculator = subject.new(gemfile_path, lockfile_path)
100
+
101
+ target = calculator.gem_stats
102
+ tuple = target.map {|x| [x[:name], x[:total_dependencies]] }
103
+ expect(tuple).to end_with(*partial_sorted_result)
104
+ end
88
105
  end
89
106
 
90
107
  context "#summary" do
@@ -1,5 +1,4 @@
1
- require 'bundler'
2
- require 'bundler/stats'
1
+ require 'spec_helper'
3
2
 
4
3
  describe Bundler::Stats::Printer do
5
4
  subject { described_class }
@@ -30,6 +29,17 @@ describe Bundler::Stats::Printer do
30
29
  expect(response).to eq(80)
31
30
  end
32
31
  end
32
+
33
+ context "tput returns an error" do
34
+ it "returns the default value" do
35
+ allow(Kernel).to receive(:send).and_return("tput: No value for $TERM and no -T specified")
36
+
37
+ printer = subject.new
38
+ response = printer.terminal_width
39
+
40
+ expect(response).to eq(80)
41
+ end
42
+ end
33
43
  end
34
44
 
35
45
  describe "#column_widths" do
@@ -1,5 +1,4 @@
1
- require 'bundler'
2
- require 'bundler/stats'
1
+ require 'spec_helper'
3
2
 
4
3
  LazyLazySpec = Struct.new(:name, :dependencies)
5
4
  FakeLockfileParser = Struct.new(:specs)
@@ -1,5 +1,4 @@
1
- require 'bundler'
2
- require 'bundler/stats'
1
+ require 'spec_helper'
3
2
 
4
3
  describe Bundler::Stats::Tree do
5
4
  subject { described_class }
@@ -141,20 +140,24 @@ describe Bundler::Stats::Tree do
141
140
  end
142
141
 
143
142
  context "skip lists" do
144
- it "still includes the skipped entry" do
143
+ it "skips processing the requested entry, plus children of skipped entries" do
145
144
  tree = subject.new(parser, skiplist: ["depth-three"])
146
145
 
147
146
  target = tree.transitive_dependencies("depth-one")
148
147
 
149
- expect(target.map(&:name)).to include("depth-three")
148
+ expect(target.map(&:name)).to include("depth-two")
149
+ expect(target.map(&:name)).not_to include("depth-three")
150
+ expect(target.map(&:name)).not_to include("depth-four")
150
151
  end
151
152
 
152
- it "stops processing the children of skipped entries" do
153
- tree = subject.new(parser, skiplist: ["depth-three"])
153
+ it "allows skiplist wildcards" do
154
+ tree = subject.new(parser, skiplist: ["depth-t*"])
154
155
 
155
156
  target = tree.transitive_dependencies("depth-one")
156
157
 
157
- expect(target.map(&:name)).not_to include("depth-four")
158
+ expect(target.map(&:name)).not_to include("depth-two")
159
+ expect(target.map(&:name)).not_to include("depth-three")
160
+ expect(target.map(&:name)).not_to include("depth-four") # because transitive
158
161
  end
159
162
  end
160
163
  end
@@ -0,0 +1,11 @@
1
+ require 'bundler'
2
+ require 'bundler/stats'
3
+
4
+ RSpec.configure do |config|
5
+ config.filter_run :focus
6
+ config.run_all_when_everything_filtered = true
7
+
8
+ config.expect_with :rspec do |expectations|
9
+ expectations.syntax = :expect
10
+ end
11
+ 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.0.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Mastey
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-05 00:00:00.000000000 Z
11
+ date: 2022-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.9'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,20 +27,29 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '1.9'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '3'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: thor
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - "~>"
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 0.19.0
40
+ - - "<"
32
41
  - !ruby/object:Gem::Version
33
- version: '0.19'
42
+ version: '2.0'
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
- - - "~>"
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.19.0
50
+ - - "<"
39
51
  - !ruby/object:Gem::Version
40
- version: '0.19'
52
+ version: '2.0'
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: rspec
43
55
  requirement: !ruby/object:Gem::Requirement
@@ -70,16 +82,16 @@ dependencies:
70
82
  name: guard-rspec
71
83
  requirement: !ruby/object:Gem::Requirement
72
84
  requirements:
73
- - - ">="
85
+ - - "<"
74
86
  - !ruby/object:Gem::Version
75
- version: '0'
87
+ version: '5'
76
88
  type: :development
77
89
  prerelease: false
78
90
  version_requirements: !ruby/object:Gem::Requirement
79
91
  requirements:
80
- - - ">="
92
+ - - "<"
81
93
  - !ruby/object:Gem::Version
82
- version: '0'
94
+ version: '5'
83
95
  - !ruby/object:Gem::Dependency
84
96
  name: pry
85
97
  requirement: !ruby/object:Gem::Requirement
@@ -98,16 +110,16 @@ dependencies:
98
110
  name: rb-readline
99
111
  requirement: !ruby/object:Gem::Requirement
100
112
  requirements:
101
- - - ">="
113
+ - - "<"
102
114
  - !ruby/object:Gem::Version
103
- version: '0'
115
+ version: '1'
104
116
  type: :development
105
117
  prerelease: false
106
118
  version_requirements: !ruby/object:Gem::Requirement
107
119
  requirements:
108
- - - ">="
120
+ - - "<"
109
121
  - !ruby/object:Gem::Version
110
- version: '0'
122
+ version: '1'
111
123
  description: Looks through your lockfile and tries to identify problematic use of
112
124
  dependencies
113
125
  email: jmmastey@gmail.com
@@ -120,9 +132,10 @@ extra_rdoc_files:
120
132
  - CODE_OF_CONDUCT.md
121
133
  - README.md
122
134
  files:
135
+ - ".github/workflows/main.yml"
123
136
  - ".gitignore"
124
137
  - ".rspec"
125
- - ".travis.yml"
138
+ - ".ruby-version"
126
139
  - CHANGELOG.md
127
140
  - CODE_OF_CONDUCT.md
128
141
  - Gemfile
@@ -137,22 +150,24 @@ files:
137
150
  - lib/bundler/stats/cli.rb
138
151
  - lib/bundler/stats/printer.rb
139
152
  - lib/bundler/stats/remover.rb
153
+ - lib/bundler/stats/skiplist.rb
140
154
  - lib/bundler/stats/tree.rb
141
155
  - lib/bundler/stats/version.rb
142
156
  - spec/lib/bundler/stats/calculator_spec.rb
143
157
  - spec/lib/bundler/stats/printer_spec.rb
144
158
  - spec/lib/bundler/stats/remover_spec.rb
145
159
  - spec/lib/bundler/stats/tree_spec.rb
160
+ - spec/spec_helper.rb
146
161
  - spec/test_gemfile
147
162
  - spec/test_gemfile.lock
148
- homepage: ''
163
+ homepage: http://github.com/jmmastey/bundler-stats
149
164
  licenses:
150
165
  - MIT
151
166
  metadata:
152
167
  homepage_uri: http://github.com/jmmastey/bundler-stats
153
168
  changelog_uri: https://github.com/jmmastey/bundler-stats/blob/master/CHANGELOG.md
154
169
  source_code_uri: http://github.com/jmmastey/bundler-stats
155
- post_install_message:
170
+ post_install_message:
156
171
  rdoc_options: []
157
172
  require_paths:
158
173
  - lib
@@ -167,9 +182,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
182
  - !ruby/object:Gem::Version
168
183
  version: '0'
169
184
  requirements: []
170
- rubyforge_project:
171
- rubygems_version: 2.7.3
172
- signing_key:
185
+ rubygems_version: 3.1.6
186
+ signing_key:
173
187
  specification_version: 4
174
188
  summary: Dependency investigation for Bundler
175
189
  test_files: []
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- script: bundle exec rspec
3
- rvm:
4
- - 2.3
5
- - 2.4
6
- - 2.5
data/bin/bundler-stats DELETED
@@ -1 +0,0 @@
1
- bin/bundle-stats