capistrano / capistrano/capistrano-features

Change the behavior of remote_file

Open
#2 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
2
Forks
0
PR merge metrics
No merged PRs in 30d

Description

I like to suggest to Introduce first a RoleTask. With this in place you can do this (only a thought not tested):

``` ruby

role :web

remote_file 'my/path/text.txt' => ['local/file.txt', :web, :all] do |task|
roles = t.prerequisites.find_all{ Rake::Task[name].class == RoleTask}
on roles do
.... upload the file
end
end

```

And with a RemoteFileTask

``` ruby
class RemoteFileTask < FileTask
# pseudo code
def needed?
! File.exist_on_every_remote_host?(name) || out_of_date?(timestamp) || @application.options.build_all
end

# Time stamp for file task.
def timestamp
if File.exist_remote_on_all_roles?(name)
sanatize_time(File.earliest_mtime_remote(name.to_s))
else
Rake::EARLY
end
end

def sanatize_time(time)
if option_trust_time
time
else
get_earliest_time_on_remote_hosts_diff_to_local_time(time)
end
end

private

# has to be changed
def out_of_date?(stamp)
@prerequisites.any? { |n| application[n, @scope].timestamp > stamp }
end
end
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.