cinch 2.0.0.pre.1 → 2.0.0.pre.2

Sign up to get free protection for your applications and to get access to all the features.
data/docs/bot_options.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # @title Bot options
2
+ # @markup kramdown
2
3
 
3
4
  # Options
4
5
  Note: This page describes options of Cinch. It does not describe how
data/docs/changes.md CHANGED
@@ -1,37 +1,30 @@
1
1
  # @title What has changed?
2
+ # @markup kramdown
2
3
 
3
4
  # What has changed in 2.0?
4
- 1. **Added support for SASL**
5
- 1. **Added support for DCC SEND**
6
- 1. **Added a fair scheduler for outgoing messages**
7
- 1. **Added required plugin options**
8
- 1. **Added support for colors/formatting**
9
- 1. **Added network discovery**
10
- 1. **Added match groups**
11
- 1. **Added match options overwriting plugin options**
12
- 1. **Added support for actions (/me)**
13
- 1. **Added support for broken IRC networks**
14
- 1. **Dynamic timers**
15
- 1. **Reworked logging facilities**
16
-
17
- 1. **API improvements**
18
- 1. **Helper changes**
19
- 1. **Added a Cinch::Target Target class**
20
- 1. **Cinch::Constants**
21
- 1. **New methods**
22
- 1. **Cinch::Bot**
23
- 1. **Cinch::Channel**
24
- 1. **Cinch::Helpers**
25
- 1. **Cinch::IRC**
26
- 1. **Cinch::Message**
27
- 1. **Cinch::User**
28
- 1. **Removed/Renamed methods**
29
- 1. **Handlers**
5
+ 1. Added support for SASL
6
+ 1. Added support for DCC SEND
7
+ 1. Added a fair scheduler for outgoing messages
8
+ 1. Added required plugin options
9
+ 1. Added support for colors/formatting
10
+ 1. Added network discovery
11
+ 1. Added match groups
12
+ 1. Added match options overwriting plugin options
13
+ 1. Added support for actions (/me)
14
+ 1. Added support for broken IRC networks
15
+ 1. Dynamic timers
16
+ 1. Reworked logging facilities
17
+ 1. API improvements
18
+ 1. Helper changes
19
+ 1. Added a Cinch::Target Target class
20
+ 1. Cinch::Constants
21
+ 1. New methods
22
+ 1. Removed/Renamed methods
23
+ 1. Handlers
30
24
  1. The Plugin class
31
- 1. **Channel/Target/User implement Comparable**
32
- 1. **Renamed `*Manager` to `*List`**
33
-
34
- 1. **New events**
25
+ 1. Channel/Target/User implement Comparable
26
+ 1. Renamed `*Manager` to `*List`
27
+ 1. New events
35
28
 
36
29
  ## Added support for SASL
37
30
 
@@ -141,7 +134,7 @@ Example:
141
134
 
142
135
  ## Added match options overwriting plugin options
143
136
 
144
- Matchers now have their own `:prefix`, `:suffix` and `:reacting_on`
137
+ Matchers now have their own `:prefix`, `:suffix` and `:react_on`
145
138
  options which overwrite plugin options for single matchers.
146
139
 
147
140
 
@@ -150,7 +143,7 @@ options which overwrite plugin options for single matchers.
150
143
  A new event, {`:action`} has been added and can be used for matching
151
144
  actions as follows:
152
145
 
153
- match "kicks the bot", reacting_on: :action
146
+ match "kicks the bot", react_on: :action
154
147
  def execute(m)
155
148
  m.reply "Ouch!"
156
149
  end
@@ -1,4 +1,5 @@
1
1
  # @title Common mistakes
2
+ # @markup kramdown
2
3
 
3
4
  # I defined an initialize method in my plugin and now it doesn't work properly anymore
4
5
 
data/docs/common_tasks.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # @title Common Tasks
2
+ # @markup kramdown
2
3
 
3
4
  # Checking if a user is online
4
5
 
data/docs/encodings.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # @title Encodings
2
+ # @markup kramdown
3
+
2
4
  # Encodings
3
5
 
4
6
  The IRC protocol doesn't define a specific encoding that should be
data/docs/events.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # @title Events
2
+ # @markup kramdown
2
3
 
3
4
  Cinch provides three kinds of events:
4
5
 
data/docs/logging.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # @title Logging
2
+ # @markup kramdown
2
3
 
3
4
  TODO explain the logging facilities
4
5
 
data/docs/migrating.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # @title Migration Guide
2
+ # @markup kramdown
3
+
2
4
  # Migration Guide
3
5
 
4
6
  This document explains how to migrate between API incompatible
@@ -36,9 +38,8 @@ shouldn't and usually mustn't overwrite:
36
38
  - `::plugin_name`
37
39
  - `::prefix=`
38
40
  - `::prefix`
41
+ - `::react_on=`
39
42
  - `::react_on`
40
- - `::reacting_on=`
41
- - `::reacting_on`
42
43
  - `::required_options=`
43
44
  - `::required_options`
44
45
  - `::set`
data/docs/readme.md CHANGED
@@ -1,18 +1,19 @@
1
1
  # @title README
2
+ # @markup kramdown
2
3
 
3
4
 
4
- - {file:changes.md Changelog}
5
- - {file:migrating.md Migration guides}
5
+ - {file:docs/changes.md Changelog}
6
+ - {file:docs/migrating.md Migration guides}
6
7
 
7
8
  # Important documents
8
9
 
9
10
  The following is a list of important documents to read.
10
11
 
11
- - {file:bot_options.md Bot options}
12
- - {file:common_tasks.md Common Tasks}
13
- - {file:common_mistakes.md Common mistakes}
12
+ - {file:docs/bot_options.md Bot options}
13
+ - {file:docs/common_tasks.md Common Tasks}
14
+ - {file:docs/common_mistakes.md Common mistakes}
14
15
  - {Cinch::DCC DCC}
15
- - {file:encodings.md Encodings}
16
- - {file:logging.md Logging}
16
+ - {file:docs/encodings.md Encodings}
17
+ - {file:docs/logging.md Logging}
17
18
  - {Cinch::SASL SASL}
18
- - {file:events.d Events}
19
+ - {file:docs/events.md Events}
data/lib/cinch/channel.rb CHANGED
@@ -17,7 +17,7 @@ module Cinch
17
17
  # Users are represented by a Hash, mapping individual users to an
18
18
  # array of modes (e.g. "o" for opped).
19
19
  #
20
- # @return [Hash<User => Array<String>>] all users in the channel
20
+ # @return [Hash{User => Array<String}>] all users in the channel
21
21
  # @version 1.1.0
22
22
  attr_reader :users
23
23
  synced_attr_reader :users
@@ -40,7 +40,7 @@ module Cinch
40
40
  # either a value in the case of modes that take an option (e.g.
41
41
  # "k" for the channel key) or true.
42
42
  #
43
- # @return [Hash<String => Object>]
43
+ # @return [Hash{String => Object}]
44
44
  attr_reader :modes
45
45
  synced_attr_reader :modes
46
46
  def initialize(name, bot)
@@ -139,7 +139,7 @@ module Cinch
139
139
  end
140
140
  # @endgroup
141
141
 
142
- # @return [Number] The maximum number of allowed users in the
142
+ # @return [Integer] The maximum number of allowed users in the
143
143
  # channel. 0 if unlimited.
144
144
  def limit
145
145
  @modes["l"].to_i
@@ -9,7 +9,7 @@ module Cinch
9
9
  module DCCableObject
10
10
  # Return the next `number` bytes of the object.
11
11
  #
12
- # @param [Number] number Read `number` bytes at most
12
+ # @param [Integer] number Read `number` bytes at most
13
13
  # @return [String] The read data
14
14
  # @return [nil] If no more data can be read
15
15
  def read(number)
@@ -17,7 +17,7 @@ module Cinch
17
17
 
18
18
  # Seek to a specific position.
19
19
  #
20
- # @param [Number] position The position in bytes to seek to
20
+ # @param [Integer] position The position in bytes to seek to
21
21
  # @return [void]
22
22
  def seek(position)
23
23
  end
@@ -29,7 +29,7 @@ module Cinch
29
29
  def path
30
30
  end
31
31
 
32
- # @return [Number] The total size of the data, in bytes.
32
+ # @return [Integer] The total size of the data, in bytes.
33
33
  def size
34
34
  end
35
35
  end
@@ -60,21 +60,21 @@ module Cinch
60
60
  # @return [String]
61
61
  attr_reader :filename
62
62
 
63
- # @return [Number]
63
+ # @return [Integer]
64
64
  attr_reader :size
65
65
 
66
66
  # @return [String]
67
67
  attr_reader :ip
68
68
 
69
- # @return [Number]
69
+ # @return [Fixnum]
70
70
  attr_reader :port
71
71
 
72
72
  # @param [Hash] opts
73
73
  # @option opts [User] user
74
74
  # @option opts [String] filename
75
- # @option opts [Number] size
75
+ # @option opts [Integer] size
76
76
  # @option opts [String] ip
77
- # @option opts [Number] port
77
+ # @option opts [Fixnum] port
78
78
  # @api private
79
79
  def initialize(opts)
80
80
  @user, @filename, @size, @ip, @port = opts.values_at(:user, :filename, :size, :ip, :port)
@@ -87,14 +87,14 @@ module Cinch
87
87
 
88
88
  # Seek to `pos` in the data.
89
89
  #
90
- # @param [Number] pos
90
+ # @param [Integer] pos
91
91
  # @return [void]
92
92
  # @api private
93
93
  def seek(pos)
94
94
  @io.seek(pos)
95
95
  end
96
96
 
97
- # @return [Number] The port used for the socket
97
+ # @return [Fixnum] The port used for the socket
98
98
  def port
99
99
  @port ||= @socket.addr[1]
100
100
  end
data/lib/cinch/helpers.rb CHANGED
@@ -72,13 +72,13 @@ module Cinch
72
72
  # Timer(5) { puts "timer fired" }
73
73
  # end
74
74
  #
75
- # @param [Number] interval Interval in seconds
75
+ # @param [Numeric] interval Interval in seconds
76
76
  # @param [Proc] block A proc to execute
77
77
  # @option options [Symbol] :method (:timer) Method to call (only
78
78
  # if no proc is provided)
79
79
  # @option options [Boolean] :threaded (true) Call method in a
80
80
  # thread?
81
- # @option options [Number] :shots (Float::INFINITY) How often
81
+ # @option options [Integer] :shots (Float::INFINITY) How often
82
82
  # should the timer fire?
83
83
  # @option options [Boolean] :start_automatically (true) If true,
84
84
  # the timer will automatically start after the bot finished
@@ -1,4 +1,4 @@
1
- require "cinch/logger/logger"
1
+ require "cinch/logger"
2
2
  module Cinch
3
3
  class Logger
4
4
  # This logger logs all incoming messages in the format of zcbot.
data/lib/cinch/logger.rb CHANGED
@@ -101,10 +101,10 @@ module Cinch
101
101
  # Logs a message.
102
102
  #
103
103
  # @param [String, Array] messages The message(s) to log
104
- # @param [Symbol<:debug, :incoming, :outgoing, :info, :warn,
105
- # :exception, :error, :fatal>] event The kind of event that
104
+ # @param [:debug, :incoming, :outgoing, :info, :warn,
105
+ # :exception, :error, :fatal] event The kind of event that
106
106
  # triggered the message
107
- # @param [Symbol<:debug, :info, :warn, :error, :fatal>] level The level of the message
107
+ # @param [:debug, :info, :warn, :error, :fatal] level The level of the message
108
108
  # @return [void]
109
109
  # @version 2.0.0
110
110
  def log(messages, event = :debug, level = event)
@@ -120,7 +120,7 @@ module Cinch
120
120
  end
121
121
  end
122
122
 
123
- # @param [Symbol<:debug, :info, :warn, :error, :fatal>] level
123
+ # @param [:debug, :info, :warn, :error, :fatal] level
124
124
  # @return [Boolean] Whether the currently set logging level will
125
125
  # allow the passed in level to be logged
126
126
  # @since 2.0.0
data/lib/cinch/message.rb CHANGED
@@ -93,7 +93,7 @@ module Cinch
93
93
  @server ||= @prefix[/^(\S+)/, 1]
94
94
  end
95
95
 
96
- # @return [Number, nil] the numeric error code, if any
96
+ # @return [Integer, nil] the numeric error code, if any
97
97
  def error
98
98
  @error ||= (command.to_i if numeric_reply? && command[/[45]\d\d/])
99
99
  end
@@ -4,7 +4,7 @@ module Cinch
4
4
  module ModeParser
5
5
  # @param [String] modes The mode string as sent by the server
6
6
  # @param [Array<String>] params Parameters belonging to the modes
7
- # @param [Hash<:add => Array<String>, :remove => Array<String>] param_modes
7
+ # @param [Hash{:add, :remove => Array<String>}] param_modes
8
8
  # A mapping describing which modes require parameters
9
9
  def self.parse_modes(modes, params, param_modes = {})
10
10
  if modes.size == 0
data/lib/cinch/network.rb CHANGED
@@ -79,7 +79,7 @@ module Cinch
79
79
  # value for when no network/ircd was detected so that MessageQueue
80
80
  # doesn't break.
81
81
 
82
- # @return [Number] The `messages per second` value that best suits
82
+ # @return [Numeric] The `messages per second` value that best suits
83
83
  # the current network
84
84
  def default_messages_per_second
85
85
  case @network
@@ -90,7 +90,7 @@ module Cinch
90
90
  end
91
91
  end
92
92
 
93
- # @return [Number] The `server queue size` value that best suits
93
+ # @return [Integer] The `server queue size` value that best suits
94
94
  # the current network
95
95
  def default_server_queue_size
96
96
  case @network
data/lib/cinch/plugin.rb CHANGED
@@ -24,11 +24,11 @@ module Cinch
24
24
  #
25
25
  # @attr plugin_name
26
26
  module ClassMethods
27
- # @return [Hash<Symbol<:pre, :post> => Array<Hook>>] All hooks
27
+ # @return [Hash{:pre, :post => Array<Hook>}] All hooks
28
28
  attr_reader :hooks
29
29
 
30
- # @return [Array<Symbol<:message, :channel, :private>>] The list of events to react on
31
- attr_accessor :reacting_on
30
+ # @return [Array<:message, :channel, :private>] The list of events to react on
31
+ attr_accessor :react_on
32
32
 
33
33
  # The name of the plugin.
34
34
  # @overload plugin_name
@@ -79,7 +79,7 @@ module Cinch
79
79
  # @attr [Boolean] use_suffix
80
80
  # @attr [Symbol] method
81
81
  # @attr [Symbol] group
82
- Matcher = Struct.new(:pattern, :use_prefix, :use_suffix, :method, :group, :prefix, :suffix, :reacting_on)
82
+ Matcher = Struct.new(:pattern, :use_prefix, :use_suffix, :method, :group, :prefix, :suffix, :react_on)
83
83
 
84
84
  # Represents a Listener as created by {#listen_to}.
85
85
  #
@@ -94,7 +94,7 @@ module Cinch
94
94
  # timers. This class only describes a Timer that still has to
95
95
  # be created.
96
96
  #
97
- # @attr [Number] interval
97
+ # @attr [Numeric] interval
98
98
  # @attr [Symbol] method
99
99
  # @attr [Hash] options
100
100
  # @attr [Boolean] registered
@@ -118,7 +118,7 @@ module Cinch
118
118
  @hooks = Hash.new{|h, k| h[k] = []}
119
119
  @prefix = nil
120
120
  @suffix = nil
121
- @reacting_on = :message
121
+ @react_on = :message
122
122
  @required_options = []
123
123
  self.plugin_name = nil
124
124
  end
@@ -131,7 +131,7 @@ module Cinch
131
131
  # - {#help}
132
132
  # - {#plugin_name}
133
133
  # - {#prefix}
134
- # - {#reacting_on}
134
+ # - {#react_on}
135
135
  # - {#required_options}
136
136
  # - {#suffix}
137
137
  #
@@ -140,7 +140,7 @@ module Cinch
140
140
  # @param [Object] value
141
141
  # @return [void]
142
142
  # @overload set(options)
143
- # @param [Hash<Symbol => Object>] options The options, as key => value associations
143
+ # @param [Hash{Symbol => Object}] options The options, as key => value associations
144
144
  # @return [void]
145
145
  # @example
146
146
  # set(:help => "the help message",
@@ -177,8 +177,8 @@ module Cinch
177
177
  # @todo Document match/listener grouping
178
178
  # @todo document new options
179
179
  def match(pattern, options = {})
180
- options = {:use_prefix => true, :use_suffix => true, :method => :execute, :group => nil, :prefix => nil, :suffix => nil, :reacting_on => nil}.merge(options)
181
- matcher = Matcher.new(pattern, *options.values_at(:use_prefix, :use_suffix, :method, :group, :prefix, :suffix, :reacting_on))
180
+ options = {:use_prefix => true, :use_suffix => true, :method => :execute, :group => nil, :prefix => nil, :suffix => nil, :react_on => nil}.merge(options)
181
+ matcher = Matcher.new(pattern, *options.values_at(:use_prefix, :use_suffix, :method, :group, :prefix, :suffix, :react_on))
182
182
  @matchers << matcher
183
183
 
184
184
  matcher
@@ -200,7 +200,7 @@ module Cinch
200
200
  # @param [Hash] options
201
201
  # @option options [Symbol] :method (:listen) The method to
202
202
  # execute
203
- # @return [Array<Listener]
203
+ # @return [Array<Listener>]
204
204
  def listen_to(*types)
205
205
  options = {:method => :listen}
206
206
  if types.last.is_a?(Hash)
@@ -218,23 +218,16 @@ module Cinch
218
218
  @ctcps << command.to_s.upcase
219
219
  end
220
220
 
221
- # Set which kind of messages to react on for matchers.
222
- # @param [Symbol<:message, :channel, :private>] event Which event to react on
223
- # @return [void]
224
- def react_on(event)
225
- self.reacting_on = event
226
- end
227
-
228
221
  # @example
229
222
  # timer 5, method: :some_method
230
223
  # def some_method
231
224
  # Channel("#cinch-bots").send(Time.now.to_s)
232
225
  # end
233
226
  #
234
- # @param [Number] interval Interval in seconds
227
+ # @param [Numeric] interval Interval in seconds
235
228
  # @option options [Symbol] :method (:timer) Method to call (only
236
229
  # if no proc is provided)
237
- # @option options [Number] :shots (Float::INFINITY) How often
230
+ # @option options [Integer] :shots (Float::INFINITY) How often
238
231
  # should the timer fire?
239
232
  # @option options [Boolean] :threaded (true) Call method in a
240
233
  # thread?
@@ -256,7 +249,7 @@ module Cinch
256
249
  # Defines a hook which will be run before or after a handler is
257
250
  # executed, depending on the value of `type`.
258
251
  #
259
- # @param [Symbol<:pre, :post>] type Run the hook before or after
252
+ # @param [:pre, :post] type Run the hook before or after
260
253
  # a handler?
261
254
  # @option options [Array<:match, :listen_to, :ctcp>] :for ([:match, :listen_to, :ctcp])
262
255
  # Which kinds of events to run the hook for.
@@ -369,7 +362,7 @@ module Cinch
369
362
  _suffix = matcher.use_suffix ? matcher.suffix || suffix : nil
370
363
 
371
364
  pattern_to_register = Pattern.new(_prefix, matcher.pattern, _suffix)
372
- react_on = matcher.reacting_on || self.class.reacting_on || :message
365
+ react_on = matcher.react_on || self.class.react_on || :message
373
366
 
374
367
  @bot.loggers.debug "[plugin] #{self.class.plugin_name}: Registering executor with pattern `#{pattern_to_register.inspect}`, reacting on `#{react_on}`"
375
368
 
@@ -2,7 +2,7 @@
2
2
  class String
3
3
  # Like `String#downcase`, but respecting different IRC casemaps.
4
4
  #
5
- # @param [Symbol<:rfc1459, :strict-rfc1459, :ascii>] mapping
5
+ # @param [:rfc1459, :"strict-rfc1459", :ascii] mapping
6
6
  # @return [String]
7
7
  def irc_downcase(mapping)
8
8
  case mapping
@@ -18,7 +18,7 @@ class String
18
18
 
19
19
  # Like `String#upcase`, but respecting different IRC casemaps.
20
20
  #
21
- # @param [Symbol<:rfc1459, :strict-rfc1459, :ascii>] mapping
21
+ # @param [:rfc1459, :"strict-rfc1459", :ascii] mapping
22
22
  # @return [String]
23
23
  def irc_upcase(mapping)
24
24
  case mapping
@@ -15,7 +15,7 @@ module Cinch
15
15
  "DH-BLOWFISH"
16
16
  end
17
17
 
18
- # @return [Array<Number, Number, Number>] p, g and y for DH
18
+ # @return [Array(Numeric, Numeric, Numeric)] p, g and y for DH
19
19
  def unpack_payload(payload)
20
20
  pgy = []
21
21
  payload = payload.dup
data/lib/cinch/timer.rb CHANGED
@@ -24,7 +24,7 @@ module Cinch
24
24
  # @return [Bot]
25
25
  attr_reader :bot
26
26
 
27
- # @return [Number] The interval (in seconds) of the timer
27
+ # @return [Numeric] The interval (in seconds) of the timer
28
28
  attr_accessor :interval
29
29
 
30
30
  # @return [Boolean] If true, each invocation will be
@@ -37,7 +37,7 @@ module Cinch
37
37
  # @return [Boolean]
38
38
  attr_reader :started
39
39
 
40
- # @return [Number] The remaining number of shots before this timer
40
+ # @return [Integer] The remaining number of shots before this timer
41
41
  # will stop. This value will automatically reset after
42
42
  # restarting the timer.
43
43
  attr_accessor :shots
@@ -50,9 +50,9 @@ module Cinch
50
50
 
51
51
  # @param [Bot] bot The instance of {Bot} the timer is associated
52
52
  # with
53
- # @option options [Number] :interval The interval (in seconds) of
53
+ # @option options [Numeric] :interval The interval (in seconds) of
54
54
  # the timer
55
- # @option options [Number] :shots (Float::INFINITY) How often should the
55
+ # @option options [Integer] :shots (Float::INFINITY) How often should the
56
56
  # timer fire?
57
57
  # @option options [Boolean] :threaded (true) If true, each invocation will be
58
58
  # executed in a thread of its own.
data/lib/cinch/user.rb CHANGED
@@ -7,7 +7,7 @@ module Cinch
7
7
  # @attr_reader [String] host
8
8
  # @attr_reader [String] realname
9
9
  # @attr_reader [String] authname
10
- # @attr_reader [Number] idle How long this user has been idle, in seconds.
10
+ # @attr_reader [Integer] idle How long this user has been idle, in seconds.
11
11
  # This is a snapshot of the last WHOIS.
12
12
  # @attr_reader [Time] signed_on_at
13
13
  # @attr_reader [Array<Channel>] channels All channels the user is in.
data/lib/cinch/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Cinch
2
2
  # Version of the library
3
- VERSION = '2.0.0-pre.1'
3
+ VERSION = '2.0.0-pre.2'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.1
4
+ version: 2.0.0.pre.2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-03 00:00:00.000000000 Z
12
+ date: 2012-03-05 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A simple, friendly DSL for creating IRC bots
15
15
  email: