Class: Rubypack::BundlerController

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypack/bundler_controller.rb

Instance Method Summary collapse

Constructor Details

#initialize(path:) ⇒ BundlerController

Returns a new instance of BundlerController.



4
5
6
# File 'lib/rubypack/bundler_controller.rb', line 4

def initialize(path:)
  @path = path
end

Instance Method Details

#installObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rubypack/bundler_controller.rb', line 24

def install
  begin
    old_pwd = Dir.pwd
    Dir.chdir(@path)
    IO.popen(['bundle', 'install', '--local', '--deployment', err: [:child, :out]]) do |out|
      yield(out)
    end
    fail("bundle install failed: #{$?.exitstatus}") unless $?.exitstatus == 0
    true
  rescue => error
    fail("Error executing bundle install: #{error.message}")
  ensure
    Dir.chdir(old_pwd)
  end
end

#packageObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rubypack/bundler_controller.rb', line 8

def package
  begin
    old_pwd = Dir.pwd
    Dir.chdir(@path)
    IO.popen(['bundle', 'package', '--all-platforms', '--all', err: [:child, :out]]) do |out|
      yield(out)
    end
    fail("bundle package failed: #{$?.exitstatus}") unless $?.exitstatus == 0
    true
  rescue => error
    fail("Error executing bundle package: #{error.message}")
  ensure
    Dir.chdir(old_pwd)
  end
end