Skip to content

Commit

Permalink
Integrate MacPkg with Project
Browse files Browse the repository at this point in the history
* Add delegation for configuration needed by packagers in Project
* Update mac_pkg functional tests to verify MacPkg uses Project API
  correctly
* Update test fixtures to match correct project layout
  • Loading branch information
danielsdeleo committed Feb 14, 2014
1 parent b82edd1 commit afbf41b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 15 deletions.
20 changes: 12 additions & 8 deletions functional/packagers/mac_pkg_spec.rb
Expand Up @@ -32,15 +32,19 @@
let(:package_dir) { Dir.pwd }

let(:project) do
double(Omnibus::Project,
:name => "functional-test-project",
:version => "23.4.2",
:install_path => "/opt/functional-test-project",
:package_scripts_path => scripts_path,
:files_path => files_path,
:package_dir => package_dir,
:mac_pkg_identifier => mac_pkg_identifier)

Omnibus.stub(:project_root).and_return(omnibus_root)
Omnibus.config.stub(:package_dir).and_return(package_dir)

project_file=<<-P
name "functional-test-project"
maintainer "YOU"
homepage "http://www.theonion.com/articles/drunken-man-careens-wildly-across-internet,35249/"
build_version "23.4.2"
install_path "/opt/functional-test-project"
mac_pkg_identifier "#{mac_pkg_identifier}"
P
Omnibus::Project.new(project_file, __FILE__)
end


Expand Down
4 changes: 2 additions & 2 deletions lib/omnibus/packagers/mac_pkg.rb
Expand Up @@ -45,8 +45,8 @@ class MacPkg
def_delegator :@project, :name

# !@method version
# @return (see Project#version)
def_delegator :@project, :version
# @return (see Project#build_version)
def_delegator :@project, :build_version, :version

# !@method identifier
# @return (see Project#mac_pkg_identifier)
Expand Down
32 changes: 29 additions & 3 deletions lib/omnibus/project.rb
Expand Up @@ -54,8 +54,6 @@ def self.load(filename)
# @param filename [String] unused!
#
# @see Omnibus::Project#load
#
# @todo Remove filename parameter, as it is unused.
def initialize(io, filename)
@output_package = nil
@name = nil
Expand All @@ -64,13 +62,14 @@ def initialize(io, filename)
@homepage = nil
@description = nil
@replaces = nil
@mac_pkg_identifier = nil

@exclusions = Array.new
@conflicts = Array.new
@config_files = Array.new
@dependencies = Array.new
@runtime_dependencies = Array.new
instance_eval(io)
instance_eval(io, filename)
validate

@library = Omnibus::Library.new(self)
Expand Down Expand Up @@ -243,6 +242,11 @@ def build_iteration(val=NULL_ARG)
@build_iteration || 1
end

def mac_pkg_identifier(val=NULL_ARG)
@mac_pkg_identifier = val unless val.equal?(NULL_ARG)
@mac_pkg_identifier
end

# Set or retrieve the {deb/rpm/solaris}-user fpm argument.
#
# @param val [String]
Expand Down Expand Up @@ -392,6 +396,28 @@ def package_scripts_path
"#{Omnibus.project_root}/package-scripts/#{name}"
end

# Path to the /files directory in the omnibus project. This directory can
# contain assets used for creating packages (e.g., Mac .pkg files and
# Windows MSIs can be installed by GUI which can optionally be customized
# with background images, license agreements, etc.)
#
# This method delegates to the Omnibus.project_root module function so that
# Packagers classes rely only on the Project object for their inputs.
#
# @return [String] path to the files directory.
def files_path
"#{Omnibus.project_root}/files"
end

# The directory where packages are written when created. Delegates to
# #config. The delegation allows Packagers (like Packagers::MacPkg) to
# define the implementation rather than using the global config everywhere.
#
# @return [String] path to the package directory
def package_dir
config.package_dir
end

# Determine the package type(s) to be built, based on the platform
# family for which the package is being built.
#
Expand Down
4 changes: 2 additions & 2 deletions spec/packagers/mac_pkg_spec.rb
Expand Up @@ -95,7 +95,7 @@
let(:project) do
double(Omnibus::Project,
:name => "myproject",
:version => "23.4.2",
:build_version => "23.4.2",
:install_path => "/opt/myproject",
:package_scripts_path => scripts_path,
:files_path => files_path,
Expand All @@ -110,7 +110,7 @@
end

it "uses the project's version" do
expect(packager.version).to eq(project.version)
expect(packager.version).to eq(project.build_version)
end

it "uses the project's name" do
Expand Down

0 comments on commit afbf41b

Please sign in to comment.