Class: ConfigFor::Capistrano::Task
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- ConfigFor::Capistrano::Task
- Includes:
- Capistrano::DSL
- Defined in:
- lib/config_for/capistrano.rb
Overview
Rake Task generator for generating and uploading config files through Capistrano.
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#folder ⇒ String
Folder to upload the generated config.
-
#name ⇒ String
The name of the task and subtasks namespace.
Instance Method Summary collapse
-
#initialize(name, options = {}) {|task| ... } ⇒ Task
constructor
Generates new tasks with for uploading #name.
-
#path ⇒ Object
Is a join of #folder and #file.
-
#run_task(_task, _args) ⇒ Object
Invokes the task to do the upload.
-
#yaml ⇒ String
Generated YAML content Gets the configuration from #variable, deep stringifies keys and returns YAML.
Constructor Details
#initialize(name, options = {}) {|task| ... } ⇒ Task
Generates new tasks with for uploading #name
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/config_for/capistrano.rb', line 112 def initialize(name, = {}, &block) @name = name @folder = 'config' @file = "#{name}.yml" @variable = "#{name}_yml".to_sym @roles = .fetch(:roles, :all) @override = .fetch(:override, false) yield(self) if block_given? @config = ConfigFor::Capistrano::UploadFileTask.new(path, roles: @roles, override: @override, &method(:generate)) desc "Generate #{name} uploader" unless ::Rake.application.last_description define end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
97 98 99 |
# File 'lib/config_for/capistrano.rb', line 97 def config @config end |
#folder ⇒ String
Returns folder to upload the generated config.
105 106 107 |
# File 'lib/config_for/capistrano.rb', line 105 def folder @folder end |
#name ⇒ String
Returns the name of the task and subtasks namespace.
101 102 103 |
# File 'lib/config_for/capistrano.rb', line 101 def name @name end |
Instance Method Details
#path ⇒ Object
Is a join of #folder and #file
130 131 132 |
# File 'lib/config_for/capistrano.rb', line 130 def path ::File.join(@folder, @file) end |
#run_task(_task, _args) ⇒ Object
Invokes the task to do the upload
135 136 137 |
# File 'lib/config_for/capistrano.rb', line 135 def run_task(_task, _args) invoke("#{name}:upload") end |
#yaml ⇒ String
Generated YAML content Gets the configuration from #variable, deep stringifies keys and returns YAML
142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/config_for/capistrano.rb', line 142 def yaml config = fetch(@variable, {}) stringified = if config.respond_to?(:deep_stringify_keys) config.deep_stringify_keys else # TODO: remove when dropping rails 3 support # two level stringify for rails 3 compatibility config.stringify_keys.each_value(&:stringify_keys!) end stringified.to_yaml end |