syndi 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +12 -0
- data/CHANGELOG.md +0 -0
- data/Gemfile +8 -0
- data/INSTALL.md +86 -0
- data/LICENSE +28 -0
- data/README.md +104 -0
- data/Rakefile +26 -0
- data/WINDOWS.md +64 -0
- data/bin/syndi +102 -0
- data/bin/syndi-conf +47 -0
- data/conf/example.yml +101 -0
- data/docs/Events.md +103 -0
- data/docs/Upgrade.md +16 -0
- data/ext/csyndi/events.c +50 -0
- data/ext/csyndi/extconf.rb +20 -0
- data/ext/csyndi/integer.c +53 -0
- data/ext/csyndi/libauto.c +37 -0
- data/ext/csyndi/logger.c +228 -0
- data/include/syndi/csyndi.h +38 -0
- data/include/syndi/events.h +19 -0
- data/include/syndi/integer.h +17 -0
- data/include/syndi/logger.h +57 -0
- data/include/syndi.h +22 -0
- data/lib/syndi/actress.rb +12 -0
- data/lib/syndi/api/events.rb +170 -0
- data/lib/syndi/api/object.rb +29 -0
- data/lib/syndi/api/plugin.rb +155 -0
- data/lib/syndi/api.rb +7 -0
- data/lib/syndi/bot.rb +270 -0
- data/lib/syndi/config.rb +113 -0
- data/lib/syndi/configure/cli.rb +23 -0
- data/lib/syndi/configure/generator.rb +410 -0
- data/lib/syndi/configure.rb +19 -0
- data/lib/syndi/dsl/base.rb +74 -0
- data/lib/syndi/dsl/irc.rb +13 -0
- data/lib/syndi/events.rb +114 -0
- data/lib/syndi/irc/common.rb +63 -0
- data/lib/syndi/irc/library.rb +89 -0
- data/lib/syndi/irc/object/channel.rb +21 -0
- data/lib/syndi/irc/object/entity.rb +90 -0
- data/lib/syndi/irc/object/message.rb +99 -0
- data/lib/syndi/irc/object/user.rb +139 -0
- data/lib/syndi/irc/protocol/numerics.rb +60 -0
- data/lib/syndi/irc/protocol.rb +164 -0
- data/lib/syndi/irc/sasl/diffie_hellman.rb +36 -0
- data/lib/syndi/irc/sasl/mech/dh_blowfish.rb +83 -0
- data/lib/syndi/irc/sasl/mech/plain.rb +39 -0
- data/lib/syndi/irc/sasl/mech.rb +15 -0
- data/lib/syndi/irc/server.rb +301 -0
- data/lib/syndi/irc/state/channel_manager.rb +6 -0
- data/lib/syndi/irc/state/support.rb +142 -0
- data/lib/syndi/irc/state/user_manager.rb +6 -0
- data/lib/syndi/irc/std/commands.rb +99 -0
- data/lib/syndi/irc/std/numerics.rb +216 -0
- data/lib/syndi/irc.rb +8 -0
- data/lib/syndi/jewel/specification.rb +121 -0
- data/lib/syndi/jewel/util.rb +27 -0
- data/lib/syndi/jewel.rb +5 -0
- data/lib/syndi/rubyext/string.rb +10 -0
- data/lib/syndi/verbosity.rb +10 -0
- data/lib/syndi/version.rb +38 -0
- data/lib/syndi.rb +129 -0
- data/spec/helper.rb +32 -0
- data/spec/syndi/events_spec.rb +43 -0
- data/tasks/compile.rake +15 -0
- data/tasks/install.rake +10 -0
- data/tasks/package.rake +13 -0
- data/tasks/spec.rake +12 -0
- metadata +101 -13
data/lib/syndi.rb
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
# Copyright (c) 2013, Autumn Perrault, et al. All rights reserved.
|
2
|
+
# This free software is distributed under the FreeBSD license (see LICENSE).
|
3
|
+
|
4
|
+
require 'syndi/rubyext/string'
|
5
|
+
require 'syndi/version'
|
6
|
+
|
7
|
+
module Syndi
|
8
|
+
extend self
|
9
|
+
|
10
|
+
# @return [Boolean] Whether we're installed as a gem.
|
11
|
+
def gem?
|
12
|
+
begin
|
13
|
+
# If we already checked, just return the result of that.
|
14
|
+
return @gem if defined? @gem
|
15
|
+
|
16
|
+
# Otherwise, check.
|
17
|
+
result = Gem.path.each do |gempath|
|
18
|
+
break true if __FILE__ =~ /^#{Regexp.escape gempath}/
|
19
|
+
end
|
20
|
+
@gem = (result == true ? true : false)
|
21
|
+
ensure
|
22
|
+
@gem ||= false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [Boolean] Whether we're running on Microsoft Windows.
|
27
|
+
def windows?
|
28
|
+
begin
|
29
|
+
return @windows if defined? @windows
|
30
|
+
if ::RbConfig::CONFIG['host_os'] =~ /bccwin|djgpp|mswin|mingw|cygwin|wince/i
|
31
|
+
@windows = true
|
32
|
+
else
|
33
|
+
@windows = false
|
34
|
+
end
|
35
|
+
ensure
|
36
|
+
@windows ||= false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# This fixes coloring issues on Windows--or at least, the ones with which we
|
41
|
+
# need be concerned.
|
42
|
+
def windows_colored
|
43
|
+
colors = [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white]
|
44
|
+
extras = [:clear, :bold, :underline, :reversed]
|
45
|
+
|
46
|
+
colors.each do |col|
|
47
|
+
String.send(:define_method, col, proc { self })
|
48
|
+
end
|
49
|
+
extras.each do |extr|
|
50
|
+
String.send(:define_method, extr, proc { self })
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
###################
|
55
|
+
# central methods #
|
56
|
+
###################
|
57
|
+
|
58
|
+
# Retrieve the application data directory.
|
59
|
+
#
|
60
|
+
# @return [String]
|
61
|
+
def dir
|
62
|
+
@app_dir ||= File.join ENV['HOME'], '.syndi'
|
63
|
+
end
|
64
|
+
|
65
|
+
# Initiate Syndi with command-line +options+.
|
66
|
+
#
|
67
|
+
# @param [Slop] options The command-line options.
|
68
|
+
def go options
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
# Logger access.
|
73
|
+
#
|
74
|
+
# @return [Syndi::Logger]
|
75
|
+
def log
|
76
|
+
@logger ||= Syndi::Logger.new
|
77
|
+
end
|
78
|
+
|
79
|
+
# Central event system access.
|
80
|
+
#
|
81
|
+
# @return [Syndi::Events]
|
82
|
+
def events
|
83
|
+
@event_manager ||= Syndi::Events.new
|
84
|
+
end
|
85
|
+
|
86
|
+
# Configuration access.
|
87
|
+
#
|
88
|
+
# @return [Syndi::Config]
|
89
|
+
def conf
|
90
|
+
@configuration ||= Syndi::Config.new
|
91
|
+
end
|
92
|
+
|
93
|
+
# Central Syndi Celluloid actor.
|
94
|
+
#
|
95
|
+
# @return [Syndi::Actress] Subclass of {Celluloid::Actor}.
|
96
|
+
def actress
|
97
|
+
@actress ||= Syndi::Actress.new
|
98
|
+
end
|
99
|
+
|
100
|
+
# Execute some code after the given interval.
|
101
|
+
#
|
102
|
+
# @param [Integer] interval
|
103
|
+
#
|
104
|
+
# @return [Celluloid::Timer]
|
105
|
+
def after interval, &prc
|
106
|
+
actress.after interval, &prc
|
107
|
+
end
|
108
|
+
|
109
|
+
# Execute some code every +interval+.
|
110
|
+
#
|
111
|
+
# @param [Integer] interval
|
112
|
+
#
|
113
|
+
# @return [Celluloid::Timer]
|
114
|
+
def every interval, &prc
|
115
|
+
actress.every interval, &prc
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
if Syndi.windows?
|
121
|
+
Syndi.windows_colored
|
122
|
+
else
|
123
|
+
require 'colored'
|
124
|
+
end
|
125
|
+
|
126
|
+
require 'libsyndi'
|
127
|
+
%w[events actress config bot].each { |lib| require "syndi/#{lib}" }
|
128
|
+
|
129
|
+
# vim: set ts=4 sts=2 sw=2 et:
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Copyright (c) 2013, Autumn Perrault, et al. All rights reserved.
|
2
|
+
# This free software is distributed under the FreeBSD license (see LICENSE).
|
3
|
+
|
4
|
+
require 'English'
|
5
|
+
$LOAD_PATH.unshift File.join __dir__, '..', 'lib'
|
6
|
+
|
7
|
+
require 'rspec/core'
|
8
|
+
require 'rspec/expectations'
|
9
|
+
require 'rspec/mocks'
|
10
|
+
require 'fileutils'
|
11
|
+
require 'stringio'
|
12
|
+
|
13
|
+
require 'syndi'
|
14
|
+
|
15
|
+
$temp_dir = Dir.mktmpdir 'syndi-rspec'
|
16
|
+
Syndi.app_dir = $temp_dir
|
17
|
+
$VERBOSITY = Float::INFINITY
|
18
|
+
|
19
|
+
module Helper
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
RSpec.configure do |conf|
|
24
|
+
conf.syntax = :expect
|
25
|
+
conf.include Helper
|
26
|
+
|
27
|
+
conf.after(:all) do
|
28
|
+
FileUtils.remove_entry $temp_dir
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# vim: set ts=4 sts=2 sw=2 et:
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Copyright (c) 2013, Autumn Perrault, et al. All rights reserved.
|
2
|
+
# This free software is distributed under the FreeBSD license (see LICENSE).
|
3
|
+
|
4
|
+
require 'syndi/events'
|
5
|
+
|
6
|
+
describe Syndi::Events do
|
7
|
+
|
8
|
+
before do
|
9
|
+
@events = Syndi::Events.new
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#on' do
|
13
|
+
|
14
|
+
it 'listens for an event' do
|
15
|
+
@events.on(:moo) do |magic|
|
16
|
+
magic = true
|
17
|
+
end
|
18
|
+
|
19
|
+
rawr = false
|
20
|
+
@events.emit :moo, rawr
|
21
|
+
|
22
|
+
expect { rawr }.to be_true
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns a listener' do
|
26
|
+
expect do
|
27
|
+
@events.on(:cows) { nil }
|
28
|
+
end.to be_an_instance_of Syndi::Events::Listener
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#emit'
|
34
|
+
|
35
|
+
describe Syndi::Events::Listener
|
36
|
+
|
37
|
+
describe '#deaf'
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
# vim: set ts=4 sts=2 sw=2 et:
|
data/tasks/compile.rake
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Copyright (c) 2013, Autumn Perrault, et al. All rights reserved.
|
2
|
+
# This free software is distributed under the FreeBSD license (see LICENSE).
|
3
|
+
|
4
|
+
require 'rake/extensiontask'
|
5
|
+
|
6
|
+
desc 'Compile the native extension.'
|
7
|
+
Rake::ExtensionTask.new 'libsyndi', $gemspec do |ext|
|
8
|
+
ext.cross_compile = true
|
9
|
+
|
10
|
+
ext.cross_compiling do |spec|
|
11
|
+
spec.post_install_message << "\r\nNOTICE: You have installed the binary distribution of this gem."
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# vim: set ts=4 sts=2 sw=2 et:
|
data/tasks/install.rake
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Copyright (c) 2013, Autumn Perrault, et al. All rights reserved.
|
2
|
+
# This free software is distributed under the FreeBSD license (see LICENSE).
|
3
|
+
|
4
|
+
desc 'Install the gem.'
|
5
|
+
task :install => :gem do
|
6
|
+
gempkg = Dir["pkg/Syndi-#{$gemspec.version}.gem"].last
|
7
|
+
sh "gem install #{gempkg}"
|
8
|
+
end
|
9
|
+
|
10
|
+
# vim: set ts=4 sts=2 sw=2 et:
|
data/tasks/package.rake
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Copyright (c) 2013, Autumn Perrault, et al. All rights reserved.
|
2
|
+
# This free software is distributed under the FreeBSD license (see LICENSE).
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'rubygems/package_task'
|
6
|
+
|
7
|
+
desc 'Package the gem.'
|
8
|
+
Gem::PackageTask.new($gemspec) do |pkg|
|
9
|
+
pkg.need_zip = true
|
10
|
+
pkg.need_tar = true
|
11
|
+
end
|
12
|
+
|
13
|
+
# vim: set ts=4 sts=2 sw=2 et:
|
data/tasks/spec.rake
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Copyright (c) 2013, Autumn Perrault, et al. All rights reserved.
|
2
|
+
# This free software is distributed under the FreeBSD license (see LICENSE).
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
desc 'Test the application.'
|
7
|
+
RSpec::Core::RakeTask.new do |t|
|
8
|
+
t.pattern = "#{__dir__}/../spec/**/*_spec.rb"
|
9
|
+
t.rspec_opts = ["-I #{__dir__}/../lib", "-r #{__dir__}/../spec/helper.rb"]
|
10
|
+
end
|
11
|
+
|
12
|
+
# vim: set ts=4 sts=2 sw=2 et:
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syndi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Autumn Perrault
|
@@ -9,8 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.2'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.2'
|
14
28
|
- !ruby/object:Gem::Dependency
|
15
29
|
name: celluloid
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,24 +127,95 @@ dependencies:
|
|
113
127
|
name: rspec
|
114
128
|
requirement: !ruby/object:Gem::Requirement
|
115
129
|
requirements:
|
116
|
-
- - "
|
130
|
+
- - ">="
|
117
131
|
- !ruby/object:Gem::Version
|
118
|
-
version: '
|
132
|
+
version: '0'
|
119
133
|
type: :development
|
120
134
|
prerelease: false
|
121
135
|
version_requirements: !ruby/object:Gem::Requirement
|
122
136
|
requirements:
|
123
|
-
- - "
|
137
|
+
- - ">="
|
124
138
|
- !ruby/object:Gem::Version
|
125
|
-
version: '
|
139
|
+
version: '0'
|
126
140
|
description: |2
|
127
|
-
An elegant, modern, multithreaded, event-driven, modular
|
141
|
+
An elegant, modern, multithreaded, event-driven, modular chat bot
|
128
142
|
designed upon a multi-protocol model.
|
129
|
-
email:
|
130
|
-
executables:
|
131
|
-
|
143
|
+
email: syndibot@googlegroups.com
|
144
|
+
executables:
|
145
|
+
- syndi
|
146
|
+
- syndi-conf
|
147
|
+
extensions:
|
148
|
+
- ext/csyndi/extconf.rb
|
132
149
|
extra_rdoc_files: []
|
133
|
-
files:
|
150
|
+
files:
|
151
|
+
- bin/syndi-conf
|
152
|
+
- bin/syndi
|
153
|
+
- lib/syndi/dsl/irc.rb
|
154
|
+
- lib/syndi/dsl/base.rb
|
155
|
+
- lib/syndi/configure.rb
|
156
|
+
- lib/syndi/verbosity.rb
|
157
|
+
- lib/syndi/api.rb
|
158
|
+
- lib/syndi/rubyext/string.rb
|
159
|
+
- lib/syndi/irc.rb
|
160
|
+
- lib/syndi/configure/generator.rb
|
161
|
+
- lib/syndi/configure/cli.rb
|
162
|
+
- lib/syndi/api/plugin.rb
|
163
|
+
- lib/syndi/api/events.rb
|
164
|
+
- lib/syndi/api/object.rb
|
165
|
+
- lib/syndi/config.rb
|
166
|
+
- lib/syndi/version.rb
|
167
|
+
- lib/syndi/actress.rb
|
168
|
+
- lib/syndi/jewel/specification.rb
|
169
|
+
- lib/syndi/jewel/util.rb
|
170
|
+
- lib/syndi/events.rb
|
171
|
+
- lib/syndi/jewel.rb
|
172
|
+
- lib/syndi/irc/protocol.rb
|
173
|
+
- lib/syndi/irc/library.rb
|
174
|
+
- lib/syndi/irc/object/message.rb
|
175
|
+
- lib/syndi/irc/object/entity.rb
|
176
|
+
- lib/syndi/irc/object/user.rb
|
177
|
+
- lib/syndi/irc/object/channel.rb
|
178
|
+
- lib/syndi/irc/sasl/mech.rb
|
179
|
+
- lib/syndi/irc/sasl/diffie_hellman.rb
|
180
|
+
- lib/syndi/irc/sasl/mech/dh_blowfish.rb
|
181
|
+
- lib/syndi/irc/sasl/mech/plain.rb
|
182
|
+
- lib/syndi/irc/protocol/numerics.rb
|
183
|
+
- lib/syndi/irc/state/support.rb
|
184
|
+
- lib/syndi/irc/state/channel_manager.rb
|
185
|
+
- lib/syndi/irc/state/user_manager.rb
|
186
|
+
- lib/syndi/irc/common.rb
|
187
|
+
- lib/syndi/irc/server.rb
|
188
|
+
- lib/syndi/irc/std/numerics.rb
|
189
|
+
- lib/syndi/irc/std/commands.rb
|
190
|
+
- lib/syndi/bot.rb
|
191
|
+
- lib/syndi.rb
|
192
|
+
- ext/csyndi/events.c
|
193
|
+
- ext/csyndi/logger.c
|
194
|
+
- ext/csyndi/extconf.rb
|
195
|
+
- ext/csyndi/integer.c
|
196
|
+
- ext/csyndi/libauto.c
|
197
|
+
- docs/Upgrade.md
|
198
|
+
- docs/Events.md
|
199
|
+
- include/syndi/integer.h
|
200
|
+
- include/syndi/logger.h
|
201
|
+
- include/syndi/csyndi.h
|
202
|
+
- include/syndi/events.h
|
203
|
+
- include/syndi.h
|
204
|
+
- tasks/spec.rake
|
205
|
+
- tasks/compile.rake
|
206
|
+
- tasks/package.rake
|
207
|
+
- tasks/install.rake
|
208
|
+
- README.md
|
209
|
+
- LICENSE
|
210
|
+
- WINDOWS.md
|
211
|
+
- INSTALL.md
|
212
|
+
- CHANGELOG.md
|
213
|
+
- Gemfile
|
214
|
+
- Rakefile
|
215
|
+
- ".yardopts"
|
216
|
+
- conf/example.yml
|
217
|
+
- spec/helper.rb
|
218
|
+
- spec/syndi/events_spec.rb
|
134
219
|
homepage: http://syndibot.com
|
135
220
|
licenses:
|
136
221
|
- FreeBSD
|
@@ -141,7 +226,7 @@ post_install_message: |
|
|
141
226
|
We suggest that, if you're not already consulting it, you read the Syndi Handbook:
|
142
227
|
https://github.com/syndibot/syndi/wiki/Handbook
|
143
228
|
|
144
|
-
Moreover, you should typically now run `
|
229
|
+
Moreover, you should typically now run `syndi-conf` to produce a configuration file.
|
145
230
|
rdoc_options: []
|
146
231
|
require_paths:
|
147
232
|
- lib
|
@@ -161,4 +246,7 @@ rubygems_version: 2.0.0.rc.1
|
|
161
246
|
signing_key:
|
162
247
|
specification_version: 4
|
163
248
|
summary: A modern, elegant, extensible multi-protocol bot.
|
164
|
-
test_files:
|
249
|
+
test_files:
|
250
|
+
- spec/helper.rb
|
251
|
+
- spec/syndi/events_spec.rb
|
252
|
+
- Rakefile
|