mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
refactor linked file/directories dsl
This commit is contained in:
parent
56b2917730
commit
fe00aa856a
2 changed files with 16 additions and 6 deletions
|
@ -44,19 +44,29 @@ module Capistrano
|
|||
end
|
||||
|
||||
def linked_dirs(parent)
|
||||
fetch(:linked_dirs, []).map { |dir| parent.join(dir) }
|
||||
paths = fetch(:linked_dirs, [])
|
||||
join_paths(parent, paths)
|
||||
end
|
||||
|
||||
def linked_files(parent)
|
||||
fetch(:linked_files, []).map { |file| parent.join(file) }
|
||||
paths = fetch(:linked_files, [])
|
||||
join_paths(parent, paths)
|
||||
end
|
||||
|
||||
def linked_file_dirs(parent)
|
||||
linked_files(parent).map { |file| file.dirname }
|
||||
map_dirnames(linked_files(parent))
|
||||
end
|
||||
|
||||
def linked_dir_parents(parent)
|
||||
linked_dirs(parent).map { |dir| dir.dirname }
|
||||
map_dirnames(linked_dirs(parent))
|
||||
end
|
||||
|
||||
def join_paths(parent, paths)
|
||||
paths.map { |path| parent.join(path) }
|
||||
end
|
||||
|
||||
def map_dirnames(paths)
|
||||
paths.map { |path| path.dirname }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,12 +2,12 @@ require 'spec_helper'
|
|||
|
||||
module Capistrano
|
||||
|
||||
class DummyClass
|
||||
class DummyDSL
|
||||
include DSL
|
||||
end
|
||||
|
||||
describe DSL do
|
||||
let(:dsl) { DummyClass.new }
|
||||
let(:dsl) { DummyDSL.new }
|
||||
|
||||
describe '#t' do
|
||||
before do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue