forked from javan/whenever
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move capistrano integration into a module & add tests for it
(cherry picked from commit 40b8035) Conflicts: lib/whenever/capistrano/recipes.rb
- Loading branch information
1 parent
300425e
commit 133d722
Showing
6 changed files
with
315 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module Whenever | ||
module CapistranoSupport | ||
def options | ||
fetch(:whenever_options) | ||
end | ||
|
||
def roles | ||
Array(options[:roles]) | ||
end | ||
|
||
def servers | ||
find_servers(options) | ||
end | ||
|
||
def server_roles | ||
servers.inject({}) do |map, server| | ||
map[server] = role_names_for_host(server) & roles | ||
map | ||
end | ||
end | ||
|
||
def run_whenever_commands(args) | ||
unless [:command, :path, :flags].all? { |a| args.include?(a) } | ||
raise ArgumentError, ":command, :path, & :flags are required" | ||
end | ||
|
||
server_roles.each do |server, roles| | ||
roles_arg = roles.empty? ? "" : " --roles #{roles.join(',')}" | ||
|
||
command = "cd #{args[:path]} && #{args[:command]} #{args[:flags]}#{roles_arg}" | ||
run command, options.merge(:hosts => server.host) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.