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



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rubypack/bundler_controller.rb', line 22

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

#packageObject



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

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