Class: BundleManager
- Inherits:
-
Object
- Object
- BundleManager
- Defined in:
- lib/bundle_manager.rb
Instance Attribute Summary collapse
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#shell ⇒ Object
Returns the value of attribute shell.
Instance Method Summary collapse
- #bundle(gemfile_directory) ⇒ Object
- #bundle_where_necessary ⇒ Object
- #directory_of(file_path) ⇒ Object
- #find(file_name) ⇒ Object
-
#initialize(repo: raise, shell: raise) ⇒ BundleManager
constructor
A new instance of BundleManager.
Constructor Details
#initialize(repo: raise, shell: raise) ⇒ BundleManager
Returns a new instance of BundleManager.
4 5 6 7 |
# File 'lib/bundle_manager.rb', line 4 def initialize(repo: raise, shell: raise) @shell = shell @repo = repo end |
Instance Attribute Details
#repo ⇒ Object
Returns the value of attribute repo.
2 3 4 |
# File 'lib/bundle_manager.rb', line 2 def repo @repo end |
#shell ⇒ Object
Returns the value of attribute shell.
2 3 4 |
# File 'lib/bundle_manager.rb', line 2 def shell @shell end |
Instance Method Details
#bundle(gemfile_directory) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/bundle_manager.rb', line 17 def bundle(gemfile_directory) begin shell.run "bundle install --local", dir: gemfile_directory rescue ShellRunner::CommandFailureError puts 'trying without --local' shell.run "bundle install", dir: gemfile_directory end end |
#bundle_where_necessary ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/bundle_manager.rb', line 9 def bundle_where_necessary find("Gemfile.lock").each do |gemfile_lock| if repo.changed?(gemfile_lock) bundle(directory_of(gemfile_lock)) end end end |
#directory_of(file_path) ⇒ Object
30 31 32 |
# File 'lib/bundle_manager.rb', line 30 def directory_of(file_path) File.dirname(file_path) end |
#find(file_name) ⇒ Object
26 27 28 |
# File 'lib/bundle_manager.rb', line 26 def find(file_name) Dir.glob("**/#{file_name}") end |