forked from TalkingQuickly/capistrano-3-rails-template
-
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.
Adds a simple string templating system for fetch vars not yet set
- Loading branch information
1 parent
1b672e6
commit 649979d
Showing
3 changed files
with
20 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# we often want to refer to variables which | ||
# are defined in subsequent stage files. This | ||
# let's us use the {{var}} to represent fetch(:var) | ||
# in strings which are only evaluated at runtime. | ||
|
||
def sub_strings(input_string) | ||
output_string = input_string | ||
input_string.scan(/{{(\w*)}}/).each do |var| | ||
output_string.gsub!("{{#{var[0]}}}", fetch(var[0].to_sym)) | ||
end | ||
output_string | ||
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