Permalink
Browse files

move to reading configuration file

  • Loading branch information...
1 parent 36b165e commit 8583415188b1f0d56ced5be04d4216b20e07f045 @mpapis mpapis committed Mar 19, 2012
Showing with 44 additions and 16 deletions.
  1. +11 −10 README.md
  2. 0 bin/eployday
  3. +8 −0 example.yml
  4. +8 −2 lib/eployday/cli.rb
  5. +14 −0 lib/eployday/configuration.rb
  6. +2 −3 lib/eployday/deploy.rb
  7. +1 −1 lib/eployday/permission_checker.rb
View
@@ -7,17 +7,18 @@ IRC boot for automatic triggerring `sm deploy`.
On server:
gem install eployday
- eployday example # will generate example.yml
-Edit settings in example.yml
+Example for auto deploy on travis-ci tests passed `rvm-site.yml`:
-Start server with:
-
- nohup eployday example.yml &
+ ---
+ nick: rvm-site-deploy
+ channels:
+ - "#rvm-test"
+ trigger_text: "The build passed."
+ allowed_users:
+ - travis-ci
+ command: "echo bdsm deploy"
-Example for autodeploy on travis tests passed:
+Start server with:
- ---
- users: travis-ci
- triger: The build passed.
- channel: #rvm-test
+ nohup eployday rvm-site.yml &
View
0 bin/eployday 100644 → 100755
No changes.
View
@@ -0,0 +1,8 @@
+---
+nick: rvm-site-deploy
+channels:
+ - "#rvm-test"
+trigger_text: "The build passed."
+allowed_users:
+ - travis-ci
+ - mpapis
View
@@ -1,14 +1,20 @@
require 'cinch'
+require 'eployday/configuration'
require 'eployday/deploy'
module Eployday
class CLI
+ def initialize args
+ raise "configuration file name required" if args.empty?
+ Eployday::Configuration.new args.first
+ end
+
def run
bot = Cinch::Bot.new do
configure do |c|
- c.nick = "eployday"
+ c.nick = Eployday::Configuration[:nick]
c.server = "irc.freenode.net"
- c.channels = ["#rstatus"]
+ c.channels = Eployday::Configuration[:channels]
c.plugins.plugins = [Deploy]
end
end
@@ -0,0 +1,14 @@
+require 'yaml'
+
+module Eployday
+ class Configuration
+ def initialize args
+ @@configuration = YAML.load_file args
+ end
+ def self.[] key
+ @@configuration ||= {}
+ puts "-- reading #{key} => #{@@configuration[key.to_s]}"
+ @@configuration[key.to_s]
+ end
+ end
+end
View
@@ -5,15 +5,14 @@ module Eployday
class Deploy
include Cinch::Plugin
- match "deploy"
+ match Eployday::Configuration[:trigger_text]
def execute(m)
if PermissionChecker.allowed?(m.user)
m.reply "#{m.user.nick}: beginning deploy."
- Kernel.system "sm deploy"
+ Kernel.system Eployday::Configuration[:command]
m.reply "#{m.user.nick}: deploy finished."
end
end
end
end
-
@@ -6,7 +6,7 @@ def allowed?(user, list=load_whitelist)
end
def load_whitelist
- @whitelist = %w[steveklabnik carols10cents wilkie cl0ckw0rk ddagradi]
+ @whitelist = Eployday::Configuration[:allowed_users]
end
end
end

0 comments on commit 8583415

Please sign in to comment.