Class: BundleUpdateInteractive::Latest::GemfileEditor
- Inherits:
-
Object
- Object
- BundleUpdateInteractive::Latest::GemfileEditor
- Defined in:
- lib/bundle_update_interactive/latest/gemfile_editor.rb
Instance Method Summary collapse
-
#initialize(gemfile_path: "Gemfile", lockfile_path: "Gemfile.lock") ⇒ GemfileEditor
constructor
A new instance of GemfileEditor.
- #shift_gemfile ⇒ Object
- #with_relaxed_gemfile ⇒ Object
Constructor Details
#initialize(gemfile_path: "Gemfile", lockfile_path: "Gemfile.lock") ⇒ GemfileEditor
Returns a new instance of GemfileEditor.
6 7 8 9 |
# File 'lib/bundle_update_interactive/latest/gemfile_editor.rb', line 6 def initialize(gemfile_path: "Gemfile", lockfile_path: "Gemfile.lock") @gemfile_path = gemfile_path @lockfile_path = lockfile_path end |
Instance Method Details
#shift_gemfile ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/bundle_update_interactive/latest/gemfile_editor.rb', line 18 def shift_gemfile lockfile = Lockfile.parse(File.read(lockfile_path)) original, modified = modify_gemfile do |name, requirement| lockfile_entry = lockfile[name] requirement.shift(lockfile_entry.version.to_s) if lockfile_entry end original != modified end |
#with_relaxed_gemfile ⇒ Object
11 12 13 14 15 16 |
# File 'lib/bundle_update_interactive/latest/gemfile_editor.rb', line 11 def with_relaxed_gemfile original, modified = modify_gemfile { |_, requirement| requirement.relax } yield ensure File.write(gemfile_path, original) if original && original != modified end |