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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 027c995c67a45827bb5fb5731af28403436b9f5e
4
- data.tar.gz: 53c56b031e08f5ce6c2dbd263483b7abc69b5878
3
+ metadata.gz: ef5944b434681720612e6b79a001c885b928a50b
4
+ data.tar.gz: ec61338aa00b866af4c6e5cade4520e35c785645
5
5
  SHA512:
6
- metadata.gz: 4e351562adaa6329654db9a343873a0ec729681c798139bfe3bf85eec150986fcc4444103efe71099159b62c01690195dde6477a78bf25bed5332909df6406d0
7
- data.tar.gz: 748bc1811d9fee418dd31c965e4180bed4d0da28dfd1df7c986fc8adc0529d91697f0802021c675cb74820409f45b73911bea3f0152162943bbf69119653a4a0
6
+ metadata.gz: d64ae0e8f82f218a71f8e1ae876baa8ce54b15a6f88dd90adb0bd13de188ebdafb7bbe774622e2b1efe0aa34da4cfa8fb6a38bb433c0419dca80502543f80bc7
7
+ data.tar.gz: babff7f3371a6a7838f9d3c28ae21b1e9399b6acf1dcdbd279871982407789b430ad7c49b76cc8921d6bc5cbb6e8f6b3a02f7fc005e999a1e73f4394be7bdd3e
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  *.log
3
3
  tmp
4
4
  *.gem
5
+ coverage
data/.travis.yml CHANGED
@@ -1,7 +1,9 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
4
+ - 2.3.0
3
5
  - 2.2
4
6
  - 2.1
5
7
  - 2.0
6
- - jruby-9.0.0.0
8
+ - jruby-9
7
9
  - rbx
data/Gemfile CHANGED
@@ -1,6 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- group :development do
4
- gem 'minitest', '~> 5.8.0'
5
- gem 'rake', '~> 10.4.2'
6
- end
3
+ gemspec
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
@@ -1 +1,3 @@
1
1
  # Balotelli [![Build Status](https://travis-ci.org/mhib/balotelli.svg)](https://travis-ci.org/mhib/balotelli)
2
+
3
+ Code samples in examples/ directory.
@@ -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
- sleep 0.05 while __TO_PROCESS__
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
- responder = klass.new(*[metadata, priv].compact)
137
- new(str, route, block, responder, command).tap do |response|
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
@@ -1,3 +1,3 @@
1
1
  module Balotelli
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
@@ -0,0 +1,6 @@
1
+ module Balotelli::Module::Asdf
2
+ extend Balotelli::Module::Base
3
+
4
+ on %r{yes}i do
5
+ end
6
+ end
@@ -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
- on %r{yes}i do
10
-
11
- end
12
- end
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
- #def test_it_matches_module_routes
55
- #TestBot.register(Balotelli::Module::Asdf)
56
- #assert_equal TestBot.mod_match("asdf Yes, sir")[0], /yes/i
57
- #TestBot.register(Balotelli::Module::Xyz, "hoh")
58
- #assert_equal TestBot.mod_match("!hoh Si si")[0], /si/i
59
- #end
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
@@ -0,0 +1,5 @@
1
+ module Balotelli::Module::SpecialOne
2
+ extend Balotelli::Module::Base
3
+ on "asdfg" do
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module Balotelli::Module::Xyz
2
+ extend Balotelli::Module::Base
3
+
4
+ on %r{si}i do
5
+ end
6
+ end
data/test/test_helper.rb CHANGED
@@ -1,8 +1,4 @@
1
- unless Object.const_defined? 'Balotelli'
2
- $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
3
- require 'balotelli'
4
- end
5
-
1
+ require 'balotelli'
6
2
 
7
3
  alias :test_puts :puts
8
4
  def puts(*args); end
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.1.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: 2015-09-12 00:00:00.000000000 Z
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.4.8
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: