Module: Spoom::Context::Bundle
Overview
Bundle features for a context
Instance Method Summary collapse
- #bundle(command, version: nil, capture_err: true) ⇒ Object
- #bundle_exec(command, version: nil, capture_err: true) ⇒ Object
- #bundle_install!(version: nil, capture_err: true) ⇒ Object
- #gem_version_from_gemfile_lock(gem) ⇒ Object
- #gemfile_lock_specs ⇒ Object
- #read_gemfile ⇒ Object
- #read_gemfile_lock ⇒ Object
- #write_gemfile!(contents, append: false) ⇒ Object
Instance Method Details
#bundle(command, version: nil, capture_err: true) ⇒ Object
33 34 35 36 |
# File 'lib/spoom/context/bundle.rb', line 33 def bundle(command, version: nil, capture_err: true) command = "_#{version}_ #{command}" if version exec("bundle #{command}", capture_err: capture_err) end |
#bundle_exec(command, version: nil, capture_err: true) ⇒ Object
46 47 48 |
# File 'lib/spoom/context/bundle.rb', line 46 def bundle_exec(command, version: nil, capture_err: true) bundle("exec #{command}", version: version, capture_err: capture_err) end |
#bundle_install!(version: nil, capture_err: true) ⇒ Object
40 41 42 |
# File 'lib/spoom/context/bundle.rb', line 40 def bundle_install!(version: nil, capture_err: true) bundle("install", version: version, capture_err: capture_err) end |
#gem_version_from_gemfile_lock(gem) ⇒ Object
62 63 64 |
# File 'lib/spoom/context/bundle.rb', line 62 def gem_version_from_gemfile_lock(gem) gemfile_lock_specs[gem]&.version&.to_s end |
#gemfile_lock_specs ⇒ Object
51 52 53 54 55 56 |
# File 'lib/spoom/context/bundle.rb', line 51 def gemfile_lock_specs return {} unless file?("Gemfile.lock") parser = Bundler::LockfileParser.new(read_gemfile_lock) parser.specs.map { |spec| [spec.name, spec] }.to_h end |
#read_gemfile ⇒ Object
15 16 17 |
# File 'lib/spoom/context/bundle.rb', line 15 def read_gemfile read("Gemfile") end |
#read_gemfile_lock ⇒ Object
21 22 23 |
# File 'lib/spoom/context/bundle.rb', line 21 def read_gemfile_lock read("Gemfile.lock") end |
#write_gemfile!(contents, append: false) ⇒ Object
27 28 29 |
# File 'lib/spoom/context/bundle.rb', line 27 def write_gemfile!(contents, append: false) write!("Gemfile", contents, append: append) end |