Class: HomebrewAutomation::Bottle

Inherits:
Object
  • Object
show all
Defined in:
lib/homebrew_automation/bottle.rb

Overview

Metadata for building a Bottle for a Homebrew package

Defined Under Namespace

Classes: Error

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tap_name, tap_url, formula_name, os_name, keep_tmp: false, brew: Brew, bottle_finder: Bottle) ⇒ Bottle

Returns a new instance of Bottle.

Parameters:

  • tap_name (String)

    For use with brew tap

  • tap_url (String)

    Something suitable for git clone, e.g. [email protected]:easoncxz/homebrew-tap.git or /some/path/to/my-git-repo

  • formula_name (String)

    As known by Homebrew

  • os_name (String)

    As known by Homebrew, e.g. el_capitan

  • keep_tmp (Boolean) (defaults to: false)

    pass --keep-tmp to brew

  • brew (Brew) (defaults to: Brew)

    Homebrew effects

  • bottle_finder (Bottle) (defaults to: Bottle)

    Bottle-related filesystem effects



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/homebrew_automation/bottle.rb', line 29

def initialize(
    tap_name,
    tap_url,
    formula_name,
    os_name,
    keep_tmp: false,
    brew: Brew,
    bottle_finder: Bottle)
  @tap_name = tap_name
  @tap_url = tap_url
  @formula_name = formula_name
  @os_name = os_name
  @keep_tmp = keep_tmp
  @brew = brew
  @bottle_finder = bottle_finder
end

Class Method Details

.read_json!Object



67
68
69
70
# File 'lib/homebrew_automation/bottle.rb', line 67

def self.read_json!
  json_filename = Dir['*.bottle.json'].first
  File.read(json_filename)
end

.read_tarball!(minus_minus) ⇒ Object



72
73
74
# File 'lib/homebrew_automation/bottle.rb', line 72

def self.read_tarball!(minus_minus)
  File.read(minus_minus)
end

Instance Method Details

#build! {|filename, contents| ... } ⇒ NilClass

Build the bottle and get a binary tarball suitable for upload to Bintray

Unless you’ve already run brew install –build-bottle on that Formula on your system before, the returned effect would take ages to run (looking at about 30-60 minutes).

Yield Parameters:

  • filename (String)

    A filename to tell Bintray which Homebrew can recognise

  • contents (String)

    The data of the binary Bottle tarball, as if read via File#read

Returns:

  • (NilClass)

Raises:

  • (StandardError)


57
58
59
60
61
62
63
64
65
# File 'lib/homebrew_automation/bottle.rb', line 57

def build!(&block)
  raise StandardError, "Bottle#build! expects a block" unless block
  call_brew! do
    json_str = @bottle_finder.read_json!
    (minus_minus, filename) = parse_for_tarball_path(json_str)
    contents = @bottle_finder.read_tarball! minus_minus
    block.call(filename, contents)
  end
end