Class: Capistrano::Campout::Core
- Inherits:
-
Object
- Object
- Capistrano::Campout::Core
- Defined in:
- lib/capistrano-campout/core.rb
Instance Attribute Summary collapse
-
#campfire ⇒ Object
Returns the value of attribute campfire.
-
#room ⇒ Object
Returns the value of attribute room.
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #campout_deployer ⇒ Object
- #find_campfire_room(room_id) ⇒ Object
- #git_deployer ⇒ Object
- #gitutils ⇒ Object
-
#initialize ⇒ Core
constructor
A new instance of Core.
- #local_deployer ⇒ Object
- #paste(text) ⇒ Object
- #play(sound) ⇒ Object
- #post_announce_failure(options = {}) ⇒ Object
- #post_announce_success(options = {}) ⇒ Object
- #pre_announce(options = {}) ⇒ Object
- #speak(msg) ⇒ Object
- #whereto(capistrano_namespace) ⇒ Object
- #will_do(options = {}) ⇒ Object
Constructor Details
Instance Attribute Details
#campfire ⇒ Object
Returns the value of attribute campfire.
11 12 13 |
# File 'lib/capistrano-campout/core.rb', line 11 def campfire @campfire end |
#room ⇒ Object
Returns the value of attribute room.
11 12 13 |
# File 'lib/capistrano-campout/core.rb', line 11 def room @room end |
#settings ⇒ Object
Returns the value of attribute settings.
11 12 13 |
# File 'lib/capistrano-campout/core.rb', line 11 def settings @settings end |
Instance Method Details
#campout_deployer ⇒ Object
34 35 36 37 38 39 |
# File 'lib/capistrano-campout/core.rb', line 34 def campout_deployer if(!(deployer = git_deployer)) deployer = local_deployer end deployer end |
#find_campfire_room(room_id) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/capistrano-campout/core.rb', line 57 def find_campfire_room(room_id) broach_settings = { 'account' => settings.campfire.domain, 'token' => settings.campfire.token } if(!settings.campfire.ssl.nil?) broach_settings['use_ssl'] = settings.campfire.ssl else broach_settings['use_ssl'] = true end Broach.settings = broach_settings Broach::Room.find(room_id) end |
#git_deployer ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/capistrano-campout/core.rb', line 22 def git_deployer if(gitutils) gitutils.user_name else nil end end |
#gitutils ⇒ Object
30 31 32 |
# File 'lib/capistrano-campout/core.rb', line 30 def gitutils @gitutils ||= GitUtils.new('.') end |
#local_deployer ⇒ Object
18 19 20 |
# File 'lib/capistrano-campout/core.rb', line 18 def local_deployer ENV['USER'] end |
#paste(text) ⇒ Object
49 50 51 |
# File 'lib/capistrano-campout/core.rb', line 49 def paste(text) room.paste(text) end |
#play(sound) ⇒ Object
45 46 47 |
# File 'lib/capistrano-campout/core.rb', line 45 def play(sound) room.sound(sound) end |
#post_announce_failure(options = {}) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/capistrano-campout/core.rb', line 126 def post_announce_failure( = {}) = erberize(settings.post_deploy_failure.,'post_deploy_failure message',[:binding]) self.speak() if(!settings.suppress_sounds and settings.post_deploy_failure.play) self.play(settings.post_deploy_failure.play) end if(!settings.suppress_deploy_log_paste) logger = Capistrano::CampoutLogger log_output = File.open(logger.log_file_path).read self.paste(log_output) end @pre_announce_time = nil end |
#post_announce_success(options = {}) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/capistrano-campout/core.rb', line 86 def post_announce_success( = {}) = erberize(settings.post_deploy_success.,'post_deploy_success message',[:binding]) if(!settings.suppress_deploy_time and @pre_announce_time) += " (#{time_period_to_s(Time.now - @pre_announce_time)})" end if(!settings.suppress_github_compare and gitutils) github_compare = true repository = [:repository] || github_compare = false gitutils.repository = repository previous = [:previous_revision] || github_compare = false latest = [:latest_revision] || github_compare = false else github_compare = false end if(gitutils) gitutils.user_name else nil end if(github_compare and gitutils.repository_is_github?) += " #{gitutils.github_compare_url(previous,latest)}" end self.speak() if(!settings.suppress_sounds and settings.post_deploy_success.play) self.play(settings.post_deploy_success.play) end if(!settings.suppress_deploy_log_paste) logger = Capistrano::CampoutLogger log_output = File.open(logger.log_file_path).read self.paste(log_output) end @pre_announce_time = nil end |
#pre_announce(options = {}) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/capistrano-campout/core.rb', line 78 def pre_announce( = {}) self.speak(erberize(settings.pre_deploy.,'pre_deploy message',[:binding])) if(!settings.suppress_sounds and settings.pre_deploy.play) self.play(settings.pre_deploy.play) end @pre_announce_time = Time.now end |
#speak(msg) ⇒ Object
41 42 43 |
# File 'lib/capistrano-campout/core.rb', line 41 def speak(msg) room.speak(msg) end |
#whereto(capistrano_namespace) ⇒ Object
183 184 185 186 |
# File 'lib/capistrano-campout/core.rb', line 183 def whereto(capistrano_namespace) default_value = ENV['SERVER'] || 'production' capistrano_namespace.fetch(:stage,default_value) end |
#will_do(options = {}) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/capistrano-campout/core.rb', line 144 def will_do( = {}) puts "Before Deployment:" puts "Message: #{erberize(settings.pre_deploy.,'pre_deploy message',[:binding])}" if(!settings.suppress_sounds and settings.pre_deploy.play) puts "Will play sound: #{settings.pre_deploy.play}" else puts "Will not play sound" end puts "\n" puts "After Successful Deployment:" puts "Message: #{erberize(settings.post_deploy_success.,'post_deploy_success message',[:binding])}" if(!settings.suppress_sounds and settings.post_deploy_success.play) puts "Will play sound: #{settings.post_deploy_success.play}" else puts "Will not play sound" end if(!settings.suppress_deploy_log_paste) puts "Will paste deployment log" else puts "Will not paste deployment log" end puts "\n" puts "After Failed Deployment:" puts "Message: #{erberize(settings.post_deploy_failure.,'post_deploy_failure message',[:binding])}" if(!settings.suppress_sounds and settings.post_deploy_failure.play) puts "Will play sound: #{settings.post_deploy_failure.play}" else puts "Will not play sound" end if(!settings.suppress_deploy_log_paste) puts "Will paste deployment log" else puts "Will not paste deployment log" end end |