Skip to content

Commit

Permalink
Merge pull request #82 from benjaminws/software_dirs
Browse files Browse the repository at this point in the history
Refactor how we handle loading dirs for software files.
  • Loading branch information
schisamo committed Dec 6, 2013
2 parents c947fc8 + 0642f69 commit 7dc4415
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/omnibus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ def self.software_files
ruby_files(File.join(project_root, Config.software_dir))
end

# Return directories to search for {Omnibus::Software} DSL files.
#
# @return [Array<String>]
def self.software_dirs
@software_dirs ||= begin
software_dirs = [File.join(project_root, Config.software_dir)]
software_dirs << File.join(omnibus_software_root, 'config', 'software') if omnibus_software_root
software_dirs
end
end

# Backward compat alias
#
# @todo print a deprecation message
Expand Down Expand Up @@ -288,9 +299,7 @@ def self.recursively_load_dependency(dependency_name, project, overrides, softwa
dep_file = software_map[dependency_name]

unless dep_file
raise MissingProjectDependency.new(dependency_name,
[File.join(project_root, Config.software_dir),
File.join(omnibus_software_root, 'config', 'software')])
raise MissingProjectDependency.new(dependency_name, software_dirs)
end

dep_software = Omnibus::Software.load(dep_file, project, overrides)
Expand Down
34 changes: 34 additions & 0 deletions spec/software_dirs_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require 'omnibus'
require 'spec_helper'

describe Omnibus do

describe '#software_dirs' do

before :each do
# This is probably really silly, but it works
Omnibus.class_eval { @software_dirs = nil }
end

context 'omnibus_software_root not nil' do
before :each do
Omnibus.stub(:omnibus_software_root) { './data' }
end

it 'will include list of software from omnibus-software gem' do
Omnibus.software_dirs.length.should eq 2
end
end

context 'omnibus_software_root nil' do
before :each do
Omnibus.stub(:omnibus_software_root) { nil }
end

it 'will not include list of software from omnibus-software gem' do
Omnibus.software_dirs.length.should eq 1
end
end
end

end

0 comments on commit 7dc4415

Please sign in to comment.