sandofsky-kirby 4.2.1 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/kirby.gemspec +1 -1
  2. data/lib/kirby.rb +32 -14
  3. metadata +1 -1
data/kirby.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{kirby}
3
- s.version = "4.2.1"
3
+ s.version = "5.0.0"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Patched by Ben Sandofsky"]
data/lib/kirby.rb CHANGED
@@ -22,6 +22,7 @@ class Kirby
22
22
  nick = opts[:nick] || config[:nick] || "kirby-dev"
23
23
 
24
24
  @config ||= {
25
+ :hooks => "#{path}/#{nick}.rb",
25
26
  :svns => "#{path}/#{nick}.svns",
26
27
  :atoms => "#{path}/#{nick}.atoms",
27
28
  :pidfile => "#{path}/#{nick}.pid",
@@ -41,6 +42,10 @@ class Kirby
41
42
  opts.each do |key, value|
42
43
  config[key] = value if value
43
44
  end
45
+ if File.exist?(@config[:hooks])
46
+ require @config[:hooks]
47
+ extend Hooks
48
+ end
44
49
  end
45
50
 
46
51
  # Connect and reconnect to the server
@@ -88,23 +93,32 @@ class Kirby
88
93
  when /:(.+?)!.* PRIVMSG ##{config[:channel]} \:\001ACTION (.+)\001/
89
94
  log "* #{$1} #{$2}"
90
95
  when /:(.+?)!.* PRIVMSG ##{config[:channel]} \:(.+)/
91
- nick, msg = $1, $2
92
- log "<#{nick}> #{msg}"
93
- if !config[:silent]
94
- case msg
95
- when /^>>\s*(.+)/ then try $1
96
- when /^#{config[:nick]}:/
97
- ["Usage:", " '>> CODE': evaluate code in IRB", " 'reset_irb': get a clean IRB session", " 'add_svn [repository_url]': watch an SVN repository", " 'add_atom [atom_feed_url]': watch an atom feed, such as a Git repository"].each {|s| say s}
98
- when /^reset_irb/ then reset_irb
99
- when /^add_svn (.+?)(\s|\r|\n|$)/ then @svns[$1] = 0 and say @svns.inspect
100
- when /^add_atom (.+?)(\s|\r|\n|$)/ then @atoms[$1] = '' and say @atoms.inspect
101
- when /(http:\/\/.*?)(\s|\r|\n|$)/ then post($1) if config[:delicious_pass]
102
- end
103
- end
96
+ nick, msg = $1, $2
97
+ channel_handler(nick, msg)
104
98
  end
105
99
  end
106
100
  end
107
101
 
102
+ def channel_handler(nick, msg)
103
+ log "<#{nick}> #{msg}"
104
+ if !config[:silent]
105
+ case msg
106
+ when /^>>\s*(.+)/ then try $1
107
+ when /^#{config[:nick]}:/
108
+ ["Usage:", " '>> CODE': evaluate code in IRB", " 'reset_irb': get a clean IRB session", " 'add_svn [repository_url]': watch an SVN repository", " 'add_atom [atom_feed_url]': watch an atom feed, such as a Git repository"].each {|s| say s}
109
+ when /^reset_irb/ then reset_irb
110
+ when /^add_svn (.+?)(\s|\r|\n|$)/ then @svns[$1] = 0 and say @svns.inspect
111
+ when /^add_atom (.+?)(\s|\r|\n|$)/ then @atoms[$1] = '' and say @atoms.inspect
112
+ when /(http:\/\/.*?)(\s|\r|\n|$)/ then post($1) if config[:delicious_pass]
113
+ else
114
+ after_message(nick, msg)
115
+ end
116
+ end
117
+ end
118
+
119
+ def after_message(nick, message)
120
+ end
121
+
108
122
  # Send a raw string to the server.
109
123
  def write s
110
124
  raise RuntimeError, "No socket" unless @socket
@@ -150,6 +164,10 @@ class Kirby
150
164
  result[/^Your session has been closed/] ? (reset_irb and try_eval s) : result.split("\n")
151
165
  end
152
166
 
167
+ def after_commit(rev, project, author, message)
168
+ say "Commit #{rev} to #{project} by #{author}: #{message}"
169
+ end
170
+
153
171
  # Look for SVN changes. Note that Rubyforge polls much better if you use the http:// protocol instead of the svn:// protocol for your repository.
154
172
  def poll
155
173
  return unless (Time.now - $last_poll > 60 rescue true)
@@ -161,7 +179,7 @@ class Kirby
161
179
  project = repo.split(/\.|\//).reject do |path|
162
180
  ['trunk', 'rubyforge', 'svn', 'org', 'com', 'net', 'http:', nil].include? path
163
181
  end.last
164
- say "Commit #{rev} to #{project || repo} by #{(ci/:author).text}: #{(ci/:msg).text}"
182
+ after_commit(rev, (project || repo), (ci/:author).text, (ci/:msg).text)
165
183
  end rescue nil
166
184
  end
167
185
  File.open(config[:svns], 'w') {|f| f.puts YAML.dump(@svns)}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sandofsky-kirby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.1
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patched by Ben Sandofsky