Class: FluidCLI::Packager

Inherits:
Object
  • Object
show all
Defined in:
lib/fluid_cli/packager.rb

Constant Summary collapse

PACKAGING_DIR =
File.join(FluidCLI::ROOT, "packaging")
BUILDS_DIR =
File.join(PACKAGING_DIR, "builds", FluidCLI::VERSION)

Instance Method Summary collapse

Constructor Details

#initializePackager

Returns a new instance of Packager.



6
7
8
# File 'lib/fluid_cli/packager.rb', line 6

def initialize
  FileUtils.mkdir_p(BUILDS_DIR)
end

Instance Method Details

#build_homebrewObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fluid_cli/packager.rb', line 10

def build_homebrew
  root_dir = File.join(PACKAGING_DIR, "homebrew")

  build_path = File.join(BUILDS_DIR, "fluid_cli.rb")
  puts "\nBuilding Homebrew package"

  puts "Generating formula…"
  File.delete(build_path) if File.exist?(build_path)

  spec_contents = File.read(File.join(root_dir, "fluid_cli.base.rb"))
  spec_contents = spec_contents.gsub("FLUID_CLI_VERSION", FluidCLI::VERSION)

  puts "Grabbing sha256 checksum from Rubygems.org"
  require "digest/sha2"
  require "open-uri"
  gem_checksum = URI.open("https://rubygems.org/downloads/fluid_cli-#{FluidCLI::VERSION}.gem") do |io|
    Digest::SHA256.new.hexdigest(io.read)
  end

  puts "Got sha256 checksum for gem: #{gem_checksum}"
  spec_contents = spec_contents.gsub("FLUID_CLI_GEM_CHECKSUM", gem_checksum)

  puts "Writing generated formula\n  To: #{build_path}\n\n"
  File.write(build_path, spec_contents)
end