Class: Capfire
- Inherits:
-
Object
- Object
- Capfire
- Defined in:
- lib/capfire.rb
Class Method Summary collapse
-
.account ⇒ Object
Campfire account.
-
.bin_installed?(bin_name) ⇒ Boolean
Quick and irty way to check for installed bins Ideally this should also check if it’s in the users path etc.
-
.broach_room ⇒ Object
Initializes a broach campfire room.
- .config ⇒ Object
- .config_file_exists? ⇒ Boolean
-
.cowsay? ⇒ Boolean
‘brew install cowsay && cowsay “capfire”` _ < capfire > ——— \ ^__^ \ (oo)___ (__)\ )/\ ||—-w | || ||.
- .default_idiot_message ⇒ Object
-
.deploy_message(args, compare_url, application) ⇒ Object
Message to post to campfire on deploy.
-
.deployer ⇒ Object
Who is deploying.
-
.github_compare_url(repo_url, first_commit, last_commit) ⇒ Object
Link to github’s excellent Compare View.
-
.idiot_message(application) ⇒ Object
Message to post on deploying without pushing.
-
.room ⇒ Object
Campfire room.
-
.speak(message) ⇒ Object
Posts to campfire.
-
.token ⇒ Object
Campfire token.
- .valid_config? ⇒ Boolean
Class Method Details
.account ⇒ Object
Campfire account
29 30 31 |
# File 'lib/capfire.rb', line 29 def account self.config["account"] end |
.bin_installed?(bin_name) ⇒ Boolean
Quick and irty way to check for installed bins Ideally this should also check if it’s in the users path etc. Skipping for now.
90 91 92 |
# File 'lib/capfire.rb', line 90 def bin_installed?(bin_name) !`which #{bin_name}`.empty? end |
.broach_room ⇒ Object
Initializes a broach campfire room
95 96 97 98 99 100 101 102 |
# File 'lib/capfire.rb', line 95 def broach_room Broach.settings = { 'account' => self.account, 'token' => self.token, 'use_ssl' => true } Broach::Room.find_by_name(self.room) end |
.config ⇒ Object
19 20 21 |
# File 'lib/capfire.rb', line 19 def config YAML::load(File.open(File.join(ENV['HOME'],'.campfire')))["campfire"] end |
.config_file_exists? ⇒ Boolean
10 11 12 |
# File 'lib/capfire.rb', line 10 def config_file_exists? File.exists?(File.join(ENV['HOME'],'.campfire')) end |
.cowsay? ⇒ Boolean
‘brew install cowsay && cowsay “capfire”`
_________
< capfire >
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
47 48 49 |
# File 'lib/capfire.rb', line 47 def cowsay? config["cowsay"] && self.bin_installed?("cowsay") end |
.default_idiot_message ⇒ Object
64 65 66 |
# File 'lib/capfire.rb', line 64 def "LATFH: #deployer# wanted to deploy #application#, but forgot to push first." end |
.deploy_message(args, compare_url, application) ⇒ Object
Message to post to campfire on deploy
78 79 80 81 82 83 84 85 |
# File 'lib/capfire.rb', line 78 def (args,compare_url, application) = self.config["message"] .gsub!(/#deployer#/, deployer) .gsub!(/#application#/, application) .gsub!(/#args#/, args) .gsub!(/#compare_url#/, compare_url) end |
.deployer ⇒ Object
Who is deploying
52 53 54 |
# File 'lib/capfire.rb', line 52 def deployer Etc.getlogin end |
.github_compare_url(repo_url, first_commit, last_commit) ⇒ Object
Link to github’s excellent Compare View
57 58 59 60 61 62 |
# File 'lib/capfire.rb', line 57 def github_compare_url(repo_url, first_commit, last_commit) repo_url.gsub!(/git@/, 'http://') repo_url.gsub!(/\.com:/,'.com/') repo_url.gsub!(/\.git/, '') "#{repo_url}/compare/#{first_commit}...#{last_commit}" end |
.idiot_message(application) ⇒ Object
Message to post on deploying without pushing
69 70 71 72 73 74 75 |
# File 'lib/capfire.rb', line 69 def (application) = self.config["idiot_message"] = unless .gsub!(/#deployer#/, self.deployer) .gsub!(/#application#/, application) end |
.room ⇒ Object
Campfire room
24 25 26 |
# File 'lib/capfire.rb', line 24 def room self.config["room"] end |
.speak(message) ⇒ Object
Posts to campfire
105 106 107 |
# File 'lib/capfire.rb', line 105 def speak() self.broach_room.speak() end |
.token ⇒ Object
Campfire token
34 35 36 |
# File 'lib/capfire.rb', line 34 def token self.config["token"] end |
.valid_config? ⇒ Boolean
14 15 16 17 |
# File 'lib/capfire.rb', line 14 def valid_config? config = self.config config["message"] && config["room"] && config ["token"] && config["account"] end |