class RBT::GenerateMachomebrewFormula

Constants

DEFAULT_PROGRAM
#

DEFAULT_PROGRAM

#
NAMESPACE
#

NAMESPACE

#

Public Class Methods

new( for_this_program = ARGV.first, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/generate_machomebrew_formula.rb, line 32
def initialize(
    for_this_program = ARGV.first,
    run_already      = true
  )
  reset
  set_program(
    for_this_program
  )
  run if run_already
end

Public Instance Methods

find_remote_homepage() click to toggle source
#

find_remote_homepage

This method finds the last URL.

#
# File lib/rbt/utility_scripts/generate_machomebrew_formula.rb, line 85
def find_remote_homepage
  @data.remote_homepage?.to_s
end
generate_main_string() click to toggle source
#

generate_main_string

#
# File lib/rbt/utility_scripts/generate_machomebrew_formula.rb, line 92
  def generate_main_string
    short_name        = @data.short_name?.to_s.capitalize
    if short_name.empty?
      short_name = program_name?.to_s.dup.capitalize
    end
    link_to_remote_package = @data.url1?
    dependencies      = @data.required_deps_on?
    configure_options = @data.configure_options?
    program_homepage  = find_remote_homepage
    @_ << "

require 'formula'

class #{short_name.to_s} < Formula

  homepage '"+program_homepage+"'
  url '"+link_to_remote_package+"'
  sha1 '692669243433c55384a54b397a1cc926e582e9f2'

"
  # Next, add the dependencies:
  dependencies.each {|dep|
    @_ << "  depends_on '"+dep+"'"+N
  }

@_ << "

  skip_clean :all

  def options
    [['--disable-etcdir', 'Disable the reading of Zsh rc files in /etc']]
  end

  def install
    args = %w(
"

  # ========================================================================= #
  # Next, add the dependencies:
  # ========================================================================= #
  configure_options.each {|option|
    @_ << option.to_s+N
  } unless configure_options.empty?

@_ << "
    )

    args << '--disable-etcdir' if ARGV.include? '--disable-etcdir'
    system './configure', *args
    system 'make install'
  end

  def caveats; <<-EOS.undent

Bla.

EOS
  end
end
"
  end
program?() click to toggle source
#

program?

#
# File lib/rbt/utility_scripts/generate_machomebrew_formula.rb, line 67
def program?
  @program
end
Also aliased as: program_name?
program_name?()
Alias for: program?
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/generate_machomebrew_formula.rb, line 46
def reset
  super()
  @program = nil
  @_ = ''.dup # This is the string we use to generate a machomebrew formula.
  setup_dataset
  @namespace = NAMESPACE
end
run() click to toggle source
#

run

#
# File lib/rbt/utility_scripts/generate_machomebrew_formula.rb, line 169
def run
  setup_dataset # Set it up anew again.
  generate_main_string
  save_string
end
save_string() click to toggle source
#

save_string

#
# File lib/rbt/utility_scripts/generate_machomebrew_formula.rb, line 157
def save_string
  _ = "#{rbt_log_directory?}homebrew_formulas/#{program?}.rb"
  unless File.directory? File.dirname(_)
    mkdir(File.dirname(_))
  end
  opnn; e "Saving into `#{sfile(_)}`."
  save_what_to(@_, _)
end
set_program( i = DEFAULT_PROGRAM ) click to toggle source
#

set_program

#
# File lib/rbt/utility_scripts/generate_machomebrew_formula.rb, line 57
def set_program(
    i = DEFAULT_PROGRAM
  )
  i = DEFAULT_PROGRAM if i.nil?
  @program = i.to_s.dup
end
setup_dataset(i = program?) click to toggle source
#

setup_dataset

@program must exist before calling this method.

#
# File lib/rbt/utility_scripts/generate_machomebrew_formula.rb, line 76
def setup_dataset(i = program?)
  @data = RBT::Cookbooks::Cookbook.new(i) { :bypass_menu_check }
end