Class: BundlerConservativeUpdate::Hook
- Inherits:
-
Object
- Object
- BundlerConservativeUpdate::Hook
- Defined in:
- lib/bundler_conservative_update.rb
Overview
Decides whether a bundle update invocation should be re-executed with
--conservative. Instantiated with injected argv and env so it can be tested
without a real Bundler run.
Instance Method Summary collapse
-
#conservative_argv ⇒ Object
The original argv with --conservative inserted right after the subcommand, leaving the receiver's argv untouched.
-
#initialize(argv:, env:) ⇒ Hook
constructor
A new instance of Hook.
-
#should_inject? ⇒ Boolean
True when the current command is a
bundle updatethat names a scope to update and has not already stated its own update strategy.
Constructor Details
#initialize(argv:, env:) ⇒ Hook
Returns a new instance of Hook.
43 44 45 46 |
# File 'lib/bundler_conservative_update.rb', line 43 def initialize(argv:, env:) @argv = argv @env = env end |
Instance Method Details
#conservative_argv ⇒ Object
The original argv with --conservative inserted right after the subcommand, leaving the receiver's argv untouched.
67 68 69 70 71 |
# File 'lib/bundler_conservative_update.rb', line 67 def conservative_argv new_argv = @argv.dup new_argv.insert(update_index + 1, "--conservative") new_argv end |
#should_inject? ⇒ Boolean
True when the current command is a bundle update that names a scope to
update and has not already stated its own update strategy.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/bundler_conservative_update.rb', line 50 def should_inject? index = update_index return false if index.nil? return false unless @argv[index] == "update" args = @argv[(index + 1)..] || [] return false if skip_flag?(args) return false unless scope?(args) return false if disabled? true end |