bundleup 2.3.0 → 2.4.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: cc1297e37c324c0e1a7211bbd56afdb0112e926f2f36e57497ac4f82a485b429
4
- data.tar.gz: fdd2d8e71d312d5bb0a5d3f4f73c8b072fecf8c94bebe67098c6584c18d5c402
3
+ metadata.gz: 2dfa7a68f9a4f6cb80f944a05711bc3baf21d7d4771b1fe517eaa1e87ccf5879
4
+ data.tar.gz: ec24af12b0c552fd3649461559681141d681f4eb922b978701203e0c3c4e9235
5
5
  SHA512:
6
- metadata.gz: b8d980c979d30a1a016a21acf8a82bd0f809ce589d676e328e27adaf2b913f582ee4a879fb5a9485a7535ea80485dc4391d86c345249e654b3807cdf2e8d1e1a
7
- data.tar.gz: 3f9302208de8f051fd829dc438498f8802bf9660e80e90fa79c4ee496e4c867b7b86cabd6f9ef45ab60f8fd6bce16ac147294779cf9a049f02878845a6f1dd54
6
+ metadata.gz: 6622f460ab1d5bfde0f40ca4f2a4c9332556c4bcaf345e3d3be59c19565138acec061665c976e15db5f9419989122bf1e37d3efe0a6080e28c948b9964987869
7
+ data.tar.gz: d857ee33151444717cbc58d7d3af5d8650e7f906022c70d20f18ffdf91d803b53d0ea810df797f9961c56c19c5d012781cfed733f4bfc167bfcbb7b62a5817e6
data/README.md CHANGED
@@ -75,6 +75,38 @@ Note that `--update-gemfile` will _not_ modify Gemfile entries that contain a co
75
75
  gem 'sidekiq', '~> 5.2' # our monkey patch doesn't work on 6.0+
76
76
  ```
77
77
 
78
+ ### Integrate bundlup in a script
79
+
80
+ `Bundleup::CLI` gives you two methods to track updated and pinned gems:
81
+
82
+ ```ruby
83
+ cli = Bundleup::CLI.new([])
84
+ cli.run
85
+ cli.updated_gems
86
+ # > ["rubocop"]
87
+
88
+ cli.pinned_gems
89
+ # > ["rake"]
90
+ ```
91
+
92
+ You can then easily create scripts to perform any actions such as running tests, running rubocop, or commit changes.
93
+
94
+ ```ruby
95
+ cli = Bundleup::CLI.new([])
96
+ cli.run
97
+
98
+ if cli.updated_gems.any?
99
+ system "bundle exec rspec"
100
+ elsif cli.updated_gems.include?("rubocop")
101
+ system "bundle exec rubocop"
102
+ end
103
+
104
+ if cli.updated_gems.any?
105
+ system "git commit -m \"Update gems dependencies\" -- Gemfile.lock"
106
+ end
107
+ ```
108
+
109
+
78
110
  ## How bundleup works
79
111
 
80
112
  bundleup starts by making a backup copy of your Gemfile.lock. Next it runs `bundle check` (and `bundle install` if any gems are missing in your local environment), `bundle list`, then `bundle update` and `bundle list` again to find what gems versions are being used before and after Bundler does its updating magic. (Since gems are actually being installed into your Ruby environment during these steps, the process may take a few moments to complete, especially if gems with native extensions need to be compiled.)
data/lib/bundleup/cli.rb CHANGED
@@ -8,14 +8,21 @@ module Bundleup
8
8
  extend Forwardable
9
9
  def_delegators :Bundleup, :commands, :logger
10
10
 
11
+ attr_reader :updated_gems, :pinned_gems
12
+
11
13
  def initialize(args)
12
14
  @args = args.dup
13
15
  @update_gemfile = @args.delete("--update-gemfile")
16
+ @updated_gems = []
17
+ @pinned_gems = []
14
18
  end
15
19
 
16
20
  def run # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
17
21
  print_usage && return if (args & %w[-h --help]).any?
18
22
 
23
+ @updated_gems = []
24
+ @pinned_gems = []
25
+
19
26
  assert_gemfile_and_lock_exist!
20
27
 
21
28
  logger.puts "Please wait a moment while I upgrade your Gemfile.lock..."
@@ -32,6 +39,9 @@ module Bundleup
32
39
  logger.puts pin_report unless pin_report.empty?
33
40
 
34
41
  if logger.confirm?("Do you want to apply these changes?")
42
+ @updated_gems = update_report.updated_gems
43
+ @pinned_gems = pin_report.pinned_gems
44
+
35
45
  logger.ok "Done!"
36
46
  else
37
47
  backup.restore
@@ -24,6 +24,10 @@ module Bundleup
24
24
  end
25
25
  end
26
26
 
27
+ def pinned_gems
28
+ outdated_gems.keys.sort
29
+ end
30
+
27
31
  private
28
32
 
29
33
  attr_reader :gem_versions, :outdated_gems, :gem_comments
@@ -25,6 +25,12 @@ module Bundleup
25
25
  end
26
26
  end
27
27
 
28
+ def updated_gems
29
+ gem_names.reject do |gem|
30
+ old_versions[gem] == new_versions[gem]
31
+ end
32
+ end
33
+
28
34
  private
29
35
 
30
36
  attr_reader :old_versions, :new_versions
@@ -1,3 +1,3 @@
1
1
  module Bundleup
2
- VERSION = "2.3.0".freeze
2
+ VERSION = "2.4.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundleup
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brictson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-15 00:00:00.000000000 Z
11
+ date: 2023-08-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Use `bundleup` whenever you want to update the locked Gemfile dependencies
14
14
  of a Ruby project. It shows exactly what gems will be updated with color output
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0'
65
65
  requirements: []
66
- rubygems_version: 3.4.15
66
+ rubygems_version: 3.4.18
67
67
  signing_key:
68
68
  specification_version: 4
69
69
  summary: A friendlier command-line interface for Bundler’s `update` and `outdated`