protonbot 0.2.1 → 0.2.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f65457868bd780dfd1b7d8b15dcb48d2a5ab8a0
4
- data.tar.gz: 1cd97f1b5a0d40282a8377c2e7fccdfb51c542b9
3
+ metadata.gz: 73dd9e0f7a84a103a38624b2ee05ddf53df67060
4
+ data.tar.gz: 9822ccc4e683567a88cb93b5a5b48c9f59591baa
5
5
  SHA512:
6
- metadata.gz: becffdbdd3fc6f0ca4aef5e14ac6e978c849f99b28fdc877bcf71025f22d4d7e8e840814052e073a61c23a7115d03b691156723dc19c12e4524199714b4d7ff1
7
- data.tar.gz: 361b120ccb0963977fae44b744b3408119b4288a1f43ca7210a1ea3bcb24579fbcce12ace69d45f828ab6558633b604351f70607228a9ca3a9ff47907bcb3182
6
+ metadata.gz: bc1ed5e2db7662129cb6b7b00577a18d08887fa992c1eb9fe65f1d917be291675d42fcbbdb590be93697e37c9ba9a26a7103577fb663c8e03bd486366de2a43e
7
+ data.tar.gz: ca800b7b34fbfa5d85a2352ebff17fe13af14911da4037ab80e23b2c1f2ce1e3fa40d49b391b7029a0934dbf20f46d3f66c6268d6542ee1879c2c5c5f69a81dd
data/Gemfile CHANGED
@@ -1,7 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- ruby '2.4.0'
4
-
5
3
  # Specify your gem's dependencies in protonbot.gemspec
6
4
  gem 'protonbot-chanop', '~> 0.1.0'
7
5
  gemspec
data/lib/protonbot/bot.rb CHANGED
@@ -26,14 +26,16 @@ class ProtonBot::Bot
26
26
  @conf['servers'].each do |k_, v_|
27
27
  k = k_.clone
28
28
  v = v_.clone
29
- @plugthrs[k] = Thread.new do
30
- @dbs[k] = Heliodor::DB.new("dbs/#{k}.db", true) unless k.nil?
31
- @plugs[k] = ProtonBot::Plug.new(self, k.clone, v.clone)
32
- begin
33
- @plugs[k].connect! if v['enabled'] || v['enabled'].nil?
34
- rescue => e
35
- @plugs[k].log_err(e)
29
+ @dbs[k] = Heliodor::DB.new("dbs/#{k}.db", true) unless k.nil?
30
+ @plugs[k] = ProtonBot::Plug.new(self, k.clone, v.clone)
31
+ begin
32
+ if v['enabled'] || v['enabled'].nil?
33
+ Thread.new do
34
+ @plugs[k].connect!
35
+ end
36
36
  end
37
+ rescue => e
38
+ @plugs[k].log_err(e)
37
39
  end
38
40
  end
39
41
 
@@ -47,8 +49,8 @@ class ProtonBot::Bot
47
49
  exit
48
50
  end
49
51
 
50
- @plugthrs.each do |_k, v|
51
- v.join
52
+ @plugs.each do |_, p|
53
+ p.thrjoin
52
54
  end
53
55
 
54
56
  @_log.stop
@@ -77,6 +77,7 @@ class ProtonBot::Bot
77
77
  # @return [Bot] self
78
78
  def gem(gemname)
79
79
  if Gem.loaded_specs[gemname]
80
+ require gemname.gsub(/-/, '/')
80
81
  path = "#{Gem.loaded_specs[gemname].lib_dirs_glob.split(':')[0]}/" \
81
82
  "#{gemname.gsub(/-/, '/')}/plugin.rb"
82
83
  if File.exist? path
@@ -98,8 +98,6 @@ class ProtonBot::Plug
98
98
 
99
99
  introduce
100
100
 
101
- @rloop.join
102
- @wloop.join
103
101
  self
104
102
  end
105
103
 
@@ -120,4 +118,17 @@ class ProtonBot::Plug
120
118
  def inspect
121
119
  %(<#ProtonBot::Plug:#{object_id.to_s(16)} @name=#{name} @bot=#{bot}>)
122
120
  end
121
+
122
+ # @!api private
123
+ def thrjoin
124
+ until @rloop && @rloop.status == 'run'
125
+ sleep(0.1)
126
+ end
127
+ until @wloop && @wloop.status == 'run'
128
+ sleep(0.1)
129
+ end
130
+ @bot.plugthrs[@name].join
131
+ @rloop.join
132
+ @wloop.join
133
+ end
123
134
  end
@@ -1,4 +1,4 @@
1
1
  module ProtonBot
2
2
  # ProtonBot's version
3
- VERSION = '0.2.1'.freeze
3
+ VERSION = '0.2.2'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protonbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nickolay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-30 00:00:00.000000000 Z
11
+ date: 2017-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler