percy 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (6) hide show
  1. data/README.md +33 -25
  2. data/VERSION +1 -1
  3. data/lib/percy/irc.rb +22 -11
  4. data/lib/percy.rb +3 -2
  5. data/percy.gemspec +2 -2
  6. metadata +3 -3
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
- # Percy 1.4.0
1
+ # Percy 1.4.1
2
+
3
+ ## Installing Percy
4
+ `sudo gem install percy`
2
5
 
3
6
  ## Configuring and starting the bot
4
7
 
@@ -24,7 +27,7 @@ Start it with `ruby mybot.rb`.
24
27
 
25
28
  ## Handling Events
26
29
 
27
- - You can also call all methods with `Percy::IRC`, like `Percy::IRC.join('#that_cool_channel')`.
30
+ You can also call all methods with `Percy::IRC`, like `Percy::IRC.join('#that_cool_channel')`.
28
31
 
29
32
  ### Connect
30
33
  on :connect do
@@ -181,38 +184,43 @@ There are constants for formatting your messages. They are all availabe through
181
184
 
182
185
  Availabe formatting constants:
183
186
 
184
- `PLAIN`
185
- `BOLD`
186
- `ITALIC`
187
- `UNDERLINE`
188
- `COLOR_CODE`
189
- `UNCOLOR`
187
+ `PLAIN`
188
+ `BOLD`
189
+ `ITALIC`
190
+ `UNDERLINE`
191
+ `COLOR_CODE`
192
+ `UNCOLOR`
190
193
  `COLORS`
191
194
 
192
195
  Availabe colors through the `COLORS` hash:
193
196
 
194
- `:white`
195
- `:black`
196
- `:blue`
197
- `:green`
198
- `:red`
199
- `:brown`
200
- `:purple`
201
- `:orange`
202
- `:yellow`
203
- `:lime`
204
- `:teal`
205
- `:cyan`
206
- `:royal`
207
- `:pink`
208
- `:gray`
197
+ `:white`
198
+ `:black`
199
+ `:blue`
200
+ `:green`
201
+ `:red`
202
+ `:brown`
203
+ `:purple`
204
+ `:orange`
205
+ `:yellow`
206
+ `:lime`
207
+ `:teal`
208
+ `:cyan`
209
+ `:royal`
210
+ `:pink`
211
+ `:gray`
209
212
  `:silver`
210
213
 
211
214
  ### Example:
212
- message '#that_cool_channel', "#{Percy::Formatting::COLOR_CODE}#{Percy::Formatting::COLORS[:red]}This is red text.#{Percy::Formatting::UNCOLOR} This is not."
215
+ message '#that_cool_channel',
216
+ "#{Percy::Formatting::COLOR_CODE}#{Percy::Formatting::COLORS[:red]}This is red text.#{Percy::Formatting::UNCOLOR} This is not."
213
217
 
214
218
  ### Example with included Percy::Formatting module:
215
- message '#that_cool_channel', "#{COLOR_CODE}#{COLORS[:red]}This is red text.#{UNCOLOR} This is not."
219
+ message '#that_cool_channel',
220
+ "#{COLOR_CODE}#{COLORS[:red]}This is red text.#{UNCOLOR} This is not."
221
+
222
+ ## Reloading
223
+ You can reload your source files with `Percy::IRC.reload` (or just `reload`) without restarting the bot. It is a simple `load $0` where all events are erased and added from the sources again.
216
224
 
217
225
  ## License
218
226
  Copyright (c) 2009, 2010 Tobias Bühlmann
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.0
1
+ 1.4.1
data/lib/percy/irc.rb CHANGED
@@ -34,12 +34,14 @@ module Percy
34
34
  @mutex_observer = Mutex.new
35
35
 
36
36
  def self.configure(&block)
37
- block.call(@config)
38
-
39
- # logger
40
- if @config.logging
41
- @traffic_logger = PercyLogger.new(Pathname.new(PERCY_ROOT).join('logs').expand_path, 'traffic.log')
42
- @error_logger = PercyLogger.new(Pathname.new(PERCY_ROOT).join('logs').expand_path, 'error.log')
37
+ unless @reloading
38
+ block.call(@config)
39
+
40
+ # logger
41
+ if @config.logging
42
+ @traffic_logger = PercyLogger.new(Pathname.new(PERCY_ROOT).join('logs').expand_path, 'traffic.log')
43
+ @error_logger = PercyLogger.new(Pathname.new(PERCY_ROOT).join('logs').expand_path, 'error.log')
44
+ end
43
45
  end
44
46
  end
45
47
 
@@ -264,14 +266,23 @@ module Percy
264
266
 
265
267
  # connect!
266
268
  def self.connect
267
- @traffic_logger.info('-- Starting Percy') if @traffic_logger
268
- puts "#{Time.now.strftime('%d.%m.%Y %H:%M:%S')} -- Starting Percy"
269
-
270
- EventMachine::run do
271
- @connection = EventMachine::connect(@config.server, @config.port, Connection)
269
+ unless @reloading
270
+ @traffic_logger.info('-- Starting Percy') if @traffic_logger
271
+ puts "#{Time.now.strftime('%d.%m.%Y %H:%M:%S')} -- Starting Percy"
272
+
273
+ EventMachine::run do
274
+ @connection = EventMachine::connect(@config.server, @config.port, Connection)
275
+ end
272
276
  end
273
277
  end
274
278
 
279
+ def self.reload
280
+ @reloading = true
281
+ @events = Hash.new []
282
+ load $0
283
+ @reloading = false
284
+ end
285
+
275
286
  private
276
287
 
277
288
  # add observer
data/lib/percy.rb CHANGED
@@ -5,7 +5,7 @@ require 'percy/formatting'
5
5
  Thread.abort_on_exception = true
6
6
 
7
7
  module Percy
8
- VERSION = 'Percy 1.4.0 (http://github.com/tbuehlmann/percy)'
8
+ VERSION = 'Percy 1.4.1 (http://github.com/tbuehlmann/percy)'
9
9
 
10
10
  # set the percy root directory
11
11
  Object::const_set(:PERCY_ROOT, Pathname.new($0).dirname.expand_path)
@@ -22,4 +22,5 @@ def delegate(*methods)
22
22
  end
23
23
 
24
24
  delegate :action, :channel_limit, :configure, :connect, :is_online, :join, :kick, :message,
25
- :mode, :nick, :notice, :on, :part, :quit, :raw, :topic, :users_on, :users_with_status_on
25
+ :mode, :nick, :notice, :on, :part, :quit, :raw, :topic, :users_on, :users_with_status_on,
26
+ :reload
data/percy.gemspec CHANGED
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'percy'
3
- s.version = '1.4.0'
3
+ s.version = '1.4.1'
4
4
  s.summary = '(DSL, EventMachine) IRC Bot Framework inspired by isaac'
5
5
  s.description = 'Percy is an IRC Bot framework inspired by isaac with various changes.'
6
6
  s.homepage = 'http://github.com/tbuehlmann/percy'
7
- s.date = '10.03.2010'
7
+ s.date = '17.03.2010'
8
8
 
9
9
  s.author = 'Tobias Bühlmann'
10
10
  s.email = 'tobias.buehlmann@gmx.de'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 4
8
- - 0
9
- version: 1.4.0
8
+ - 1
9
+ version: 1.4.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Tobias B\xC3\xBChlmann"
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-10 00:00:00 +01:00
17
+ date: 2010-03-17 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency