Skip to content

Commit

Permalink
Add sourcedir accessor that holds the path to the extracted source
Browse files Browse the repository at this point in the history
Fixes #142
  • Loading branch information
bernd committed Nov 28, 2015
1 parent 2fa45d3 commit 43a686f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/fpm/cookery/packager.rb
Expand Up @@ -131,7 +131,9 @@ def dispense
extracted_source = recipe.extracted_source
end

recipe.run_lifecycle_hook(:after_source_extraction, recipe.builddir(extracted_source))
# Make the path to the extracted source available in the recipe.
recipe.sourcedir = recipe.builddir(extracted_source)
recipe.run_lifecycle_hook(:after_source_extraction, recipe.sourcedir)

Log.info "Using source directory: #{extracted_source}"

Expand Down
6 changes: 5 additions & 1 deletion lib/fpm/cookery/recipe.rb
Expand Up @@ -184,7 +184,11 @@ def extracted_source
self.class.extracted_source
end

attr_reader :source_handler
def sourcedir=(sourcedir)
@sourcedir = sourcedir
end

attr_reader :source_handler, :sourcedir

extend Forwardable
def_delegator :@source_handler, :local_path
Expand Down
11 changes: 11 additions & 0 deletions spec/recipe_spec.rb
Expand Up @@ -280,6 +280,17 @@ def self.spec_recipe_attribute_list(name, list)
end
end

describe ".sourcedir" do
it "is not set by default" do
expect(recipe.sourcedir).to be_nil
end

it "can be set" do
recipe.sourcedir = '/tmp/foo/bar'
expect(recipe.sourcedir).to eq('/tmp/foo/bar')
end
end

describe "#local_path" do
it "returns the path to the local source file" do
klass.class_eval do
Expand Down

0 comments on commit 43a686f

Please sign in to comment.