bundleup 0.4.0 → 0.5.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
  SHA1:
3
- metadata.gz: 2042941c3836df1dff0b80b1b85122edb2c9dc6f
4
- data.tar.gz: 4bed7910cd47f5613cd5feaff7cfe133e949ca9e
3
+ metadata.gz: 2cdcf23602e29ab6ba90b1595932e66128998669
4
+ data.tar.gz: 18f6f50cc591ee28556dd02b6d49e17ac59bf1f3
5
5
  SHA512:
6
- metadata.gz: 4edde92228db4dd91b754baa92e9b5719c168fea1536e6922b8c8437c9c75c8090cdecb11afdfda8e06737dffa5f67108a44b814c4e64390508e6d8d45541661
7
- data.tar.gz: 21a13add9532fde6fa8c3c00796300fed0074dd1a597ab98a9fe92893eb9ffd107c2c8d304100541f3fcf1d9795e9a69eaa1edc07f8ed239ec83f46119118844
6
+ metadata.gz: 4aad6eeb2689aa6e4497773eb121a49a4fa0e76b60b74f7b0093b934d6bc078026076c3fbfb351a3364896a101ec108a43bc479e3cf9a8be6ea7bf8642588274
7
+ data.tar.gz: e1858b619e1df3213996abd4da0ad6d27b8ecf8b0ced37bf487baf21412c43ef2d6418d791d7569b0b5ff02e1bdb5e7c2615c86d3d9c94f0536cdf2ade089d5b
data/.rubocop.yml CHANGED
@@ -14,6 +14,9 @@ Metrics/ClassLength:
14
14
  Exclude:
15
15
  - "test/**/*"
16
16
 
17
+ Style/BarePercentLiterals:
18
+ EnforcedStyle: percent_q
19
+
17
20
  Style/ClassAndModuleChildren:
18
21
  Enabled: false
19
22
 
data/CHANGELOG.md CHANGED
@@ -8,6 +8,14 @@ bundleup is in a pre-1.0 state. This means that its APIs and behavior are subjec
8
8
 
9
9
  * Your contribution here!
10
10
 
11
+ ## [0.5.0][] (2016-04-01)
12
+
13
+ * You can now pass command-line arguments to bundleup, which will in turn be
14
+ handed to `bundle update`. For example: `bundleup --group=development`.
15
+ * Improve the console output when a Bundler command fails.
16
+ * Fixed a bug where if a Bundler command failed to run, it would be executed a
17
+ second time.
18
+
11
19
  ## [0.4.0][] (2016-02-19)
12
20
 
13
21
  * **Change the upgrade process to modify the Gemfile.lock in place, with the
@@ -36,7 +44,8 @@ bundleup is in a pre-1.0 state. This means that its APIs and behavior are subjec
36
44
  * Initial release
37
45
 
38
46
  [Semver]: http://semver.org
39
- [Unreleased]: https://github.com/mattbrictson/bundleup/compare/v0.4.0...HEAD
47
+ [Unreleased]: https://github.com/mattbrictson/bundleup/compare/v0.5.0...HEAD
48
+ [0.5.0]: https://github.com/mattbrictson/bundleup/compare/v0.4.0...v0.5.0
40
49
  [0.4.0]: https://github.com/mattbrictson/bundleup/compare/v0.3.0...v0.4.0
41
50
  [0.3.0]: https://github.com/mattbrictson/bundleup/compare/v0.2.0...v0.3.0
42
51
  [0.2.0]: https://github.com/mattbrictson/bundleup/compare/v0.1.0...v0.2.0
data/README.md CHANGED
@@ -34,6 +34,12 @@ bundleup
34
34
 
35
35
  That’s it!
36
36
 
37
+ Protip: Any extra command-line arguments will be passed along to `bundle update`. For example:
38
+
39
+ ```
40
+ # Only upgrade development gems
41
+ bundleup --group=development
42
+ ```
37
43
 
38
44
  ## How it works
39
45
 
@@ -5,25 +5,25 @@ module Bundleup
5
5
  include Console
6
6
 
7
7
  def outdated
8
- run("bundle outdated", true)
8
+ run(%w(bundle outdated), true)
9
9
  end
10
10
 
11
11
  def show
12
- run("bundle show")
12
+ run(%w(bundle show))
13
13
  end
14
14
 
15
- def update
16
- run("bundle update")
15
+ def update(args=[])
16
+ run(%w(bundle update) + args)
17
17
  end
18
18
 
19
19
  private
20
20
 
21
21
  def run(cmd, fail_silently=false)
22
- progress("Running `#{cmd}`") do
23
- out, err, status = Open3.capture3(cmd)
22
+ cmd_line = cmd.join(" ")
23
+ progress("Running `#{cmd_line}`") do
24
+ out, err, status = Open3.capture3(*cmd)
24
25
  next(out) if status.success? || fail_silently
25
-
26
- raise ["Failed to execute: #{cmd}", out, err].compact.join("\n")
26
+ raise ["Failed to execute: #{cmd_line}", out, err].compact.join("\n")
27
27
  end
28
28
  end
29
29
  end
data/lib/bundleup/cli.rb CHANGED
@@ -19,7 +19,7 @@ module Bundleup
19
19
 
20
20
  def review_upgrades
21
21
  if upgrades.any?
22
- puts "\nIt looks like the following gem(s) will be updated:\n\n"
22
+ puts "\nThe following gem(s) will be updated:\n\n"
23
23
  print_upgrades_table
24
24
  else
25
25
  ok("Nothing to update.")
@@ -37,13 +37,14 @@ module Bundleup
37
37
  end
38
38
 
39
39
  def restore_lockfile
40
+ return unless defined?(@upgrade)
40
41
  return unless upgrade.lockfile_changed?
41
42
  upgrade.undo
42
43
  puts "Your original Gemfile.lock has been restored."
43
44
  end
44
45
 
45
46
  def upgrade
46
- @upgrade ||= Upgrade.new
47
+ @upgrade ||= Upgrade.new(ARGV)
47
48
  end
48
49
 
49
50
  def upgrades
@@ -66,7 +67,7 @@ module Bundleup
66
67
  def print_pins_table
67
68
  rows = tableize(pins) do |g|
68
69
  pin_operator, pin_version = g.pin.split(" ", 2)
69
- reason = [":", "pinned at", pin_operator, pin_version]
70
+ reason = [":", "pinned at", pin_operator.rjust(2), pin_version]
70
71
  [g.name, g.new_version, "→", g.newest_version, *reason]
71
72
  end
72
73
  puts rows.join("\n")
@@ -24,19 +24,21 @@ module Bundleup
24
24
 
25
25
  def confirm(question)
26
26
  print question.sub(/\??\z/, " [Yn]? ")
27
- gets =~ /^($|y)/i
27
+ $stdin.gets =~ /^($|y)/i
28
28
  end
29
29
 
30
+ # Runs a block in the background and displays a spinner until it completes.
30
31
  def progress(message, &block)
32
+ spinner = %w(/ - \\ |).cycle
31
33
  print "\e[90m#{message}... \e[0m"
32
- thread = Thread.new(&block)
33
- thread.join(0.5)
34
- %w(/ - \\ |).cycle do |char|
35
- break if thread.join(0.1)
36
- print "\r\e[90m#{message}... #{char} \e[0m"
34
+ result = observing_thread(block, 0.5, 0.1) do
35
+ print "\r\e[90m#{message}... #{spinner.next} \e[0m"
37
36
  end
38
37
  puts "\r\e[90m#{message}... OK\e[0m"
39
- thread.value
38
+ result
39
+ rescue StandardError
40
+ puts "\r\e[90m#{message}...\e[0m \e[31mFAILED\e[0m"
41
+ raise
40
42
  end
41
43
 
42
44
  # Given a two-dimensional Array of strings representing a table of data,
@@ -67,5 +69,28 @@ module Bundleup
67
69
  rows.map { |values| values[i].to_s.length }.max
68
70
  end
69
71
  end
72
+
73
+ # Starts the `callable` in a background thread and waits for it to complete.
74
+ # If the callable fails with an exception, it will be raised here. Otherwise
75
+ # the main thread is paused for an `initial_wait` time in seconds, and
76
+ # subsequently for `periodic_wait` repeatedly until the thread completes.
77
+ # After each wait, `yield` is called to allow a block to execute.
78
+ def observing_thread(callable, initial_wait, periodic_wait)
79
+ thread = Thread.new(&callable)
80
+ wait_for_exit(thread, initial_wait)
81
+ loop do
82
+ break if wait_for_exit(thread, periodic_wait)
83
+ yield
84
+ end
85
+ thread.value
86
+ end
87
+
88
+ def wait_for_exit(thread, seconds)
89
+ thread.join(seconds)
90
+ rescue StandardError
91
+ # Sanity check. If we get an exception, the thread should be dead.
92
+ raise if thread.alive?
93
+ thread
94
+ end
70
95
  end
71
96
  end
@@ -1,6 +1,7 @@
1
1
  module Bundleup
2
2
  class Upgrade
3
- def initialize(commands=BundleCommands.new)
3
+ def initialize(update_args=[], commands=BundleCommands.new)
4
+ @update_args = update_args
4
5
  @commands = commands
5
6
  @gem_statuses = {}
6
7
  @original_lockfile_contents = IO.read(lockfile)
@@ -25,11 +26,11 @@ module Bundleup
25
26
 
26
27
  private
27
28
 
28
- attr_reader :commands, :original_lockfile_contents
29
+ attr_reader :update_args, :commands, :original_lockfile_contents
29
30
 
30
31
  def run
31
32
  find_versions(:old)
32
- commands.update
33
+ commands.update(update_args)
33
34
  find_versions(:new)
34
35
  find_pinned_versions
35
36
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Bundleup
3
- VERSION = "0.4.0".freeze
3
+ VERSION = "0.5.0".freeze
4
4
  end
data/sample.png CHANGED
Binary file
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: 0.4.0
4
+ version: 0.5.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: 2016-02-19 00:00:00.000000000 Z
11
+ date: 2016-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  version: '0'
159
159
  requirements: []
160
160
  rubyforge_project:
161
- rubygems_version: 2.5.1
161
+ rubygems_version: 2.6.2
162
162
  signing_key:
163
163
  specification_version: 4
164
164
  summary: A friendlier command-line interface for Bundler’s `update` and `outdated`