balotelli 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +3 -1
- data/Gemfile +1 -4
- data/Gemfile.lock +10 -0
- data/README.md +2 -0
- data/lib/balotelli/base.rb +6 -3
- data/lib/balotelli/version.rb +1 -1
- data/test/lib/balotelli/asdf.rb +6 -0
- data/test/lib/balotelli/base_test.rb +11 -27
- data/test/lib/balotelli/special_one.rb +5 -0
- data/test/lib/balotelli/xyz.rb +6 -0
- data/test/test_helper.rb +1 -5
- metadata +10 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef5944b434681720612e6b79a001c885b928a50b
|
4
|
+
data.tar.gz: ec61338aa00b866af4c6e5cade4520e35c785645
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d64ae0e8f82f218a71f8e1ae876baa8ce54b15a6f88dd90adb0bd13de188ebdafb7bbe774622e2b1efe0aa34da4cfa8fb6a38bb433c0419dca80502543f80bc7
|
7
|
+
data.tar.gz: babff7f3371a6a7838f9d3c28ae21b1e9399b6acf1dcdbd279871982407789b430ad7c49b76cc8921d6bc5cbb6e8f6b3a02f7fc005e999a1e73f4394be7bdd3e
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
balotelli (0.3.0)
|
5
|
+
|
1
6
|
GEM
|
2
7
|
remote: https://rubygems.org/
|
3
8
|
specs:
|
@@ -9,5 +14,10 @@ PLATFORMS
|
|
9
14
|
ruby
|
10
15
|
|
11
16
|
DEPENDENCIES
|
17
|
+
balotelli!
|
18
|
+
bundler
|
12
19
|
minitest (~> 5.8.0)
|
13
20
|
rake (~> 10.4.2)
|
21
|
+
|
22
|
+
BUNDLED WITH
|
23
|
+
1.11.2
|
data/README.md
CHANGED
data/lib/balotelli/base.rb
CHANGED
@@ -33,8 +33,9 @@ module Balotelli
|
|
33
33
|
|
34
34
|
def get_user_list(channel)
|
35
35
|
self.class.instance_variable_set(:@to_process, :user_list)
|
36
|
+
cv = self.class.instance_variable_set(:@condition_variable, ConditionVariable.new)
|
36
37
|
self.class.names(channel)
|
37
|
-
|
38
|
+
__MUTEX__.synchronize { cv.wait(__MUTEX__) }
|
38
39
|
__CACHE__[:user_list][channel]
|
39
40
|
end
|
40
41
|
|
@@ -55,6 +56,7 @@ module Balotelli
|
|
55
56
|
|
56
57
|
@modules = {}
|
57
58
|
@cache = Hash.new { |hash, key| hash[key] = {} }
|
59
|
+
@mutex = Mutex.new
|
58
60
|
end
|
59
61
|
|
60
62
|
def inherited(subclass)
|
@@ -133,8 +135,8 @@ module Balotelli
|
|
133
135
|
|
134
136
|
def new_response(str, match, metadata, klass, priv = nil)
|
135
137
|
route, block, mod, command = match.flatten
|
136
|
-
|
137
|
-
new(str, route, block,
|
138
|
+
message = klass.new(*[metadata, priv].compact)
|
139
|
+
new(str, route, block, message, command).tap do |response|
|
138
140
|
response.extend(mod) if mod.class.to_s == 'Module'
|
139
141
|
end.send(:execute)
|
140
142
|
end
|
@@ -147,6 +149,7 @@ module Balotelli
|
|
147
149
|
users << " #{str.match(regex).captures.first}"
|
148
150
|
end
|
149
151
|
@cache[@to_process][metadata[:channel]] = users.split(' ')
|
152
|
+
@condition_variable.signal
|
150
153
|
@to_process = false
|
151
154
|
end
|
152
155
|
end
|
data/lib/balotelli/version.rb
CHANGED
@@ -3,30 +3,14 @@ require 'test_helper'
|
|
3
3
|
class TestBot < Balotelli::Base
|
4
4
|
end
|
5
5
|
|
6
|
-
module Balotelli::Module::Asdf
|
7
|
-
extend Balotelli::Module::Base
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
module Balotelli::Module::Xyz
|
15
|
-
extend Balotelli::Module::Base
|
16
|
-
|
17
|
-
on %r{si}i do
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
module Balotelli::Module::SpecialOne
|
23
|
-
extend Balotelli::Module::Base
|
24
|
-
on "asdfg" do
|
25
|
-
puts "n"
|
7
|
+
class BaseTest < Minitest::Test
|
8
|
+
def setup
|
9
|
+
require_relative 'xyz'
|
10
|
+
require_relative 'asdf'
|
11
|
+
require_relative 'special_one'
|
26
12
|
end
|
27
|
-
end
|
28
13
|
|
29
|
-
class BaseTest < Minitest::Test
|
30
14
|
def test_it_sets_up
|
31
15
|
assert TestBot.instance_variable_get(:@routes)
|
32
16
|
assert TestBot.instance_variable_get(:@modules)
|
@@ -51,10 +35,10 @@ class BaseTest < Minitest::Test
|
|
51
35
|
assert TestBot.match("asdfg")
|
52
36
|
end
|
53
37
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
38
|
+
def test_it_matches_module_routes
|
39
|
+
TestBot.register(Balotelli::Module::Asdf)
|
40
|
+
assert_equal TestBot.mod_match("asdf Yes, sir")[0], /yes/i
|
41
|
+
TestBot.register(Balotelli::Module::Xyz, "hoh")
|
42
|
+
assert_equal TestBot.mod_match("!hoh Si si")[0], /si/i
|
43
|
+
end
|
60
44
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: balotelli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Henryk Bartkowiak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,11 +80,14 @@ files:
|
|
80
80
|
- lib/balotelli/core/utils.rb
|
81
81
|
- lib/balotelli/module/base.rb
|
82
82
|
- lib/balotelli/version.rb
|
83
|
+
- test/lib/balotelli/asdf.rb
|
83
84
|
- test/lib/balotelli/balotelli_helper_test.rb
|
84
85
|
- test/lib/balotelli/base_test.rb
|
85
86
|
- test/lib/balotelli/config_test.rb
|
86
87
|
- test/lib/balotelli/core/irc_test.rb
|
87
88
|
- test/lib/balotelli/core/router_test.rb
|
89
|
+
- test/lib/balotelli/special_one.rb
|
90
|
+
- test/lib/balotelli/xyz.rb
|
88
91
|
- test/test_helper.rb
|
89
92
|
homepage: https://github.com/mhib/balotelli
|
90
93
|
licenses:
|
@@ -106,14 +109,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
109
|
version: '0'
|
107
110
|
requirements: []
|
108
111
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.5.1
|
110
113
|
signing_key:
|
111
114
|
specification_version: 4
|
112
115
|
summary: Simple IRC bot framework
|
113
116
|
test_files:
|
117
|
+
- test/lib/balotelli/asdf.rb
|
114
118
|
- test/lib/balotelli/balotelli_helper_test.rb
|
115
119
|
- test/lib/balotelli/base_test.rb
|
116
120
|
- test/lib/balotelli/config_test.rb
|
117
121
|
- test/lib/balotelli/core/irc_test.rb
|
118
122
|
- test/lib/balotelli/core/router_test.rb
|
123
|
+
- test/lib/balotelli/special_one.rb
|
124
|
+
- test/lib/balotelli/xyz.rb
|
119
125
|
- test/test_helper.rb
|
126
|
+
has_rdoc:
|