Skip to content

Commit

Permalink
Support a new basename parameter for the install method.
Browse files Browse the repository at this point in the history
  • Loading branch information
bernd committed Aug 5, 2012
1 parent 3616e71 commit 6c0337e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/fpm/cookery/path.rb
Expand Up @@ -25,14 +25,14 @@ def mkdir
FileUtils.mkdir_p(self.to_s) FileUtils.mkdir_p(self.to_s)
end end


def install(src) def install(src, new_basename = nil)
case src case src
when Array when Array
src.collect {|src| install_p(src) } src.collect {|src| install_p(src) }
when Hash when Hash
src.collect {|src, new_basename| install_p(src, new_basename) } src.collect {|src, new_basename| install_p(src, new_basename) }
else else
install_p(src) install_p(src, new_basename)
end end
end end


Expand Down
11 changes: 11 additions & 0 deletions spec/path_spec.rb
Expand Up @@ -119,5 +119,16 @@
end end
end end
end end

describe "with a new basename argument" do
it "installs the file with a new basename" do
Dir.mktmpdir do |dir|
path = FPM::Cookery::Path.new(dir)
path.install(File.expand_path('../spec_helper.rb', __FILE__), 'foo.rb')

File.exist?(path/'foo.rb').must_equal true
end
end
end
end end
end end

0 comments on commit 6c0337e

Please sign in to comment.