Class: EY::Serverside::Task
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#servers ⇒ Object
readonly
Returns the value of attribute servers.
-
#shell ⇒ Object
readonly
Returns the value of attribute shell.
Instance Method Summary collapse
-
#c ⇒ Object
deprecated, please don’t use.
-
#initialize(servers, conf, shell) ⇒ Task
constructor
A new instance of Task.
- #load_ey_yml ⇒ Object
- #paths ⇒ Object
- #require_custom_tasks ⇒ Object
- #roles(*task_roles) ⇒ Object
- #run(cmd, &block) ⇒ Object
- #sudo(cmd, &block) ⇒ Object
Constructor Details
#initialize(servers, conf, shell) ⇒ Task
Returns a new instance of Task.
14 15 16 17 18 19 |
# File 'lib/engineyard-serverside/task.rb', line 14 def initialize(servers, conf, shell) @servers = servers @config = conf @shell = shell @roles = :all end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/engineyard-serverside/task.rb', line 6 def config @config end |
#servers ⇒ Object (readonly)
Returns the value of attribute servers.
6 7 8 |
# File 'lib/engineyard-serverside/task.rb', line 6 def servers @servers end |
#shell ⇒ Object (readonly)
Returns the value of attribute shell.
6 7 8 |
# File 'lib/engineyard-serverside/task.rb', line 6 def shell @shell end |
Instance Method Details
#c ⇒ Object
deprecated, please don’t use
9 10 11 12 |
# File 'lib/engineyard-serverside/task.rb', line 9 def c EY::Serverside.deprecation_warning("The method 'c' is deprecated in favor of 'config' for better clarity.") config end |
#load_ey_yml ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/engineyard-serverside/task.rb', line 44 def load_ey_yml ey_yml = ["config/ey.yml", "ey.yml"].map do |short_file| paths.repository_cache.join(short_file) end.detect do |file| file.exist? end if ey_yml shell.status "Loading deploy configuration in #{ey_yml}" data = YAML.load_file(ey_yml.to_s) config.load_ey_yml_data(data, shell) end rescue Exception shell.error "Error loading YAML in #{ey_yml}" raise end |
#paths ⇒ Object
21 22 23 |
# File 'lib/engineyard-serverside/task.rb', line 21 def paths config.paths end |
#require_custom_tasks ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/engineyard-serverside/task.rb', line 25 def require_custom_tasks deploy_file = ["config/eydeploy.rb", "eydeploy.rb"].map do |short_file| paths.repository_cache.join(short_file) end.detect do |file| file.exist? end if deploy_file shell.status "Loading deployment task overrides from #{deploy_file}" begin instance_eval(deploy_file.read) rescue Exception => e shell.fatal "Exception while loading #{deploy_file}" shell.fatal [e.to_s, e.backtrace].join("\n") raise end end end |
#roles(*task_roles) ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/engineyard-serverside/task.rb', line 61 def roles(*task_roles) raise "Roles must be passed a block" unless block_given? begin @roles = task_roles yield ensure @roles = :all end end |
#run(cmd, &block) ⇒ Object
72 73 74 |
# File 'lib/engineyard-serverside/task.rb', line 72 def run(cmd, &block) servers.roles(@roles).run(shell, cmd, &block) end |
#sudo(cmd, &block) ⇒ Object
76 77 78 |
# File 'lib/engineyard-serverside/task.rb', line 76 def sudo(cmd, &block) servers.roles(@roles).sudo(shell, cmd, &block) end |