Module: Buildpack::Packager

Defined in:
lib/buildpack/packager.rb,
lib/buildpack/packager/package.rb,
lib/buildpack/packager/version.rb,
lib/buildpack/packager/zip_file_excluder.rb,
lib/buildpack/packager/table_presentation.rb,
lib/buildpack/packager/dependencies_presenter.rb,
lib/buildpack/packager/default_versions_presenter.rb

Defined Under Namespace

Modules: TablePresentation Classes: CheckSumError, DefaultVersionsPresenter, DependenciesPresenter, Package, ZipFileExcluder

Constant Summary collapse

VERSION =
'2.3.4'.freeze

Class Method Summary collapse

Class Method Details

.check_for_zipObject



47
48
49
50
51
52
53
# File 'lib/buildpack/packager.rb', line 47

def self.check_for_zip
  _, _, status = Open3.capture3('which zip')

  if status.to_s.include?('exit 1')
    raise "Zip is not installed\nTry: apt-get install zip\nAnd then rerun"
  end
end

.defaults(options) ⇒ Object



42
43
44
45
# File 'lib/buildpack/packager.rb', line 42

def self.defaults(options)
  package = Package.new(options)
  package.defaults
end

.list(options) ⇒ Object



37
38
39
40
# File 'lib/buildpack/packager.rb', line 37

def self.list(options)
  package = Package.new(options)
  package.list
end

.package(options) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/buildpack/packager.rb', line 17

def self.package(options)
  check_for_zip

  package = Package.new(options)

  Dir.mktmpdir do |temp_dir|
    package.copy_buildpack_to_temp_dir(temp_dir)

    package.build_dependencies(temp_dir) if options[:mode] == :cached

    package.build_zip_file(temp_dir)
  end

  buildpack_type = options[:mode] == :cached ? "Cached" : "Uncached"
  human_readable_size = `du -h #{package.zip_file_path} | cut -f1`
  puts "#{buildpack_type} buildpack created and saved as #{package.zip_file_path} with a size of #{human_readable_size.strip}"

  package
end