class Omnibus::Generator

Public Class Methods

source_root() click to toggle source

Set the source root for Thor

# File lib/omnibus/generator.rb, line 75
def source_root
  File.expand_path("generator_files", __dir__)
end

Public Instance Methods

create_appx_assets() click to toggle source
# File lib/omnibus/generator.rb, line 112
def create_appx_assets
  return unless options[:appx_assets]

  copy_file(resource_path("appx/AppxManifest.xml.erb"), "#{target}/resources/#{name}/appx/AppxManifest.xml.erb")
  copy_file(resource_path("appx/assets/clear.png"), "#{target}/resources/#{name}/appx/assets/clear.png")
end
create_bff_assets() click to toggle source
# File lib/omnibus/generator.rb, line 119
def create_bff_assets
  return unless options[:bff_assets]

  copy_file(resource_path("bff/gen.template.erb"), "#{target}/resources/#{name}/bff/gen.template.erb")
end
create_deb_assets() click to toggle source
# File lib/omnibus/generator.rb, line 125
def create_deb_assets
  return unless options[:deb_assets]

  copy_file(resource_path("deb/conffiles.erb"), "#{target}/resources/#{name}/deb/conffiles.erb")
  copy_file(resource_path("deb/control.erb"), "#{target}/resources/#{name}/deb/control.erb")
  copy_file(resource_path("deb/md5sums.erb"), "#{target}/resources/#{name}/deb/md5sums.erb")
end
create_dmg_assets() click to toggle source
# File lib/omnibus/generator.rb, line 133
def create_dmg_assets
  return unless options[:dmg_assets]

  copy_file(resource_path("dmg/background.png"), "#{target}/resources/#{name}/dmg/background.png")
  copy_file(resource_path("dmg/icon.png"), "#{target}/resources/#{name}/dmg/icon.png")
end
create_example_software_definitions() click to toggle source
# File lib/omnibus/generator.rb, line 91
def create_example_software_definitions
  template("config/software/zlib.rb.erb", "#{target}/config/software/#{name}-zlib.rb", template_options)
  template("config/software/preparation.rb.erb", "#{target}/config/software/preparation.rb", template_options)
end
create_kitchen_files() click to toggle source
# File lib/omnibus/generator.rb, line 96
def create_kitchen_files
  template(".kitchen.local.yml.erb", "#{target}/.kitchen.local.yml", template_options)
  template(".kitchen.yml.erb", "#{target}/.kitchen.yml", template_options)
  template("Berksfile.erb", "#{target}/Berksfile", template_options)
end
create_msi_assets() click to toggle source
# File lib/omnibus/generator.rb, line 140
def create_msi_assets
  return unless options[:msi_assets]

  copy_file(resource_path("msi/localization-en-us.wxl.erb"), "#{target}/resources/#{name}/msi/localization-en-us.wxl.erb")
  copy_file(resource_path("msi/parameters.wxi.erb"), "#{target}/resources/#{name}/msi/parameters.wxi.erb")
  copy_file(resource_path("msi/source.wxs.erb"), "#{target}/resources/#{name}/msi/source.wxs.erb")

  copy_file(resource_path("msi/assets/LICENSE.rtf"), "#{target}/resources/#{name}/msi/assets/LICENSE.rtf")
  copy_file(resource_path("msi/assets/banner_background.bmp"), "#{target}/resources/#{name}/msi/assets/banner_background.bmp")
  copy_file(resource_path("msi/assets/dialog_background.bmp"), "#{target}/resources/#{name}/msi/assets/dialog_background.bmp")
  copy_file(resource_path("msi/assets/project.ico"), "#{target}/resources/#{name}/msi/assets/project.ico")
  copy_file(resource_path("msi/assets/project_16x16.ico"), "#{target}/resources/#{name}/msi/assets/project_16x16.ico")
  copy_file(resource_path("msi/assets/project_32x32.ico"), "#{target}/resources/#{name}/msi/assets/project_32x32.ico")
end
create_package_scripts() click to toggle source
# File lib/omnibus/generator.rb, line 102
def create_package_scripts
  %w{preinst prerm postinst postrm}.each do |package_script|
    script_path = "#{target}/package-scripts/#{name}/#{package_script}"
    template("package_scripts/#{package_script}.erb", script_path, template_options)

    # Ensure the package script is executable
    chmod(script_path, 0755)
  end
end
create_pkg_assets() click to toggle source
# File lib/omnibus/generator.rb, line 155
def create_pkg_assets
  return unless options[:pkg_assets]

  copy_file(resource_path("pkg/background.png"), "#{target}/resources/#{name}/pkg/background.png")
  copy_file(resource_path("pkg/license.html.erb"), "#{target}/resources/#{name}/pkg/license.html.erb")
  copy_file(resource_path("pkg/welcome.html.erb"), "#{target}/resources/#{name}/pkg/welcome.html.erb")
  copy_file(resource_path("pkg/distribution.xml.erb"), "#{target}/resources/#{name}/pkg/distribution.xml.erb")
end
create_project_definition() click to toggle source
# File lib/omnibus/generator.rb, line 87
def create_project_definition
  template("config/projects/project.rb.erb", "#{target}/config/projects/#{name}.rb", template_options)
end
create_project_files() click to toggle source
# File lib/omnibus/generator.rb, line 80
def create_project_files
  template("Gemfile.erb", "#{target}/Gemfile", template_options)
  template("gitignore.erb", "#{target}/.gitignore", template_options)
  template("README.md.erb", "#{target}/README.md", template_options)
  template("omnibus.rb.erb", "#{target}/omnibus.rb", template_options)
end
create_rpm_assets() click to toggle source
# File lib/omnibus/generator.rb, line 164
def create_rpm_assets
  return unless options[:rpm_assets]

  copy_file(resource_path("rpm/rpmmacros.erb"), "#{target}/resources/#{name}/rpm/rpmmacros.erb")
  copy_file(resource_path("rpm/signing.erb"), "#{target}/resources/#{name}/rpm/signing.erb")
  copy_file(resource_path("rpm/spec.erb"), "#{target}/resources/#{name}/rpm/spec.erb")
end

Private Instance Methods

resource_path(*args) click to toggle source

The path to a vendored resource within Omnibus.

@param [String, Array<String>] args

the sub-path to get

@return [String]

# File lib/omnibus/generator.rb, line 200
def resource_path(*args)
  Omnibus.source_root.join("resources", *args).to_s
end
target() click to toggle source

The target path to create the Omnibus project.

@return [String]

# File lib/omnibus/generator.rb, line 179
def target
  @target ||= File.join(File.expand_path(@options[:path]), "omnibus-#{name}")
end
template_options() click to toggle source

The list of options to pass to the template generators.

@return [Hash]

# File lib/omnibus/generator.rb, line 188
def template_options
  @template_options ||= { name: name }
end