del 0.1.14 → 0.1.15

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
  SHA256:
3
- metadata.gz: e85d9b9946bae3f1de83c5b5aa9ca4233f857f709442a1b936db6ec844966407
4
- data.tar.gz: de3491021d7b76d98f1ac3c589333a13853ac11175ce64c08ff1172421b3656f
3
+ metadata.gz: 4c692700ff52b08475986f45fd13437d99d69dfa93123bde4d96021200894cd4
4
+ data.tar.gz: 3343f38e6ae8c7760d5bcee2315abe2c20f972b298beb1a201c34c1001ee26c3
5
5
  SHA512:
6
- metadata.gz: 56f686105ffd29d6e69948cc0c0788ce57c86d562a2433457b41df1562145c8db58becbbabb6c84b9abfa4e3b80c36bd7c222d78f176655d3937317f354240fe
7
- data.tar.gz: 7f5bbcccc027f0a5ada5d7802fe4b2c69aa8991f8a830299687f3477a10b4c29be59f1f705a0dc0e644a23a781e285b5a1576912ed5c14eb80025d69cd27d3e2
6
+ metadata.gz: e68e68bad8620911482ae6a029bd4bab2e41e0ce7c21ee295221e68327a39c5cd8702a256a408751623c09522b63d96ca0f95f92f4f401d4c322b7aa78fb0842
7
+ data.tar.gz: 57f62a3bc023b8003d8c872864e94be4f6a3fc4ad7e6352793846d8deb6ed8b63689cbf4feda04f73bbdbaefae29b31018131eb3df7d769478fe6ead240d5dba
@@ -9,7 +9,6 @@ module Del
9
9
  attr_accessor :muc_domain
10
10
  attr_accessor :name
11
11
  attr_accessor :password
12
- attr_accessor :rooms
13
12
  attr_accessor :router
14
13
  attr_accessor :users
15
14
  attr_accessor :socket_file
@@ -23,7 +22,6 @@ module Del
23
22
  @muc_domain = settings.fetch(:muc_domain, "conf.hipchat.com")
24
23
  @name = settings.fetch(:full_name)
25
24
  @password = settings.fetch(:password)
26
- @rooms = Repository.new
27
25
  @router = DefaultRouter.new
28
26
  @socket_file = settings.fetch(:socket_file, SOCKET_FILE)
29
27
  @users = Repository.new
@@ -1,11 +1,9 @@
1
1
  module Del
2
2
  class Connection
3
- attr_reader :configuration, :rooms, :users
3
+ attr_reader :configuration
4
4
 
5
5
  def initialize(configuration:)
6
6
  @configuration = configuration
7
- @rooms = configuration.rooms
8
- @users = configuration.users
9
7
  @mucs = {}
10
8
  end
11
9
 
@@ -19,7 +17,7 @@ module Del
19
17
  client.auth(configuration.password)
20
18
  roster = Jabber::Roster::Helper.new(client, false)
21
19
  roster.add_update_callback do |old_item, item|
22
- users.upsert(item['jid'], item.attributes) if item
20
+ configuration.users.upsert(item['jid'], item.attributes) if item
23
21
  end
24
22
  roster.get_roster
25
23
  roster.wait_for_roster
@@ -30,7 +28,7 @@ module Del
30
28
  end
31
29
  client.send(Jabber::Presence.new(:chat))
32
30
  configuration.default_rooms.each do |room|
33
- Del.logger.debug("Joining #{room} as #{robot.name}")
31
+ Del.logger.debug("Joining room '#{room}' as '#{robot.name}'")
34
32
  room_jid = jid_for(room, configuration.muc_domain.dup, robot.name)
35
33
  stripped_jid = room_jid.strip.to_s
36
34
  next if @mucs[stripped_jid]
@@ -44,9 +42,9 @@ module Del
44
42
  end
45
43
  muc.join(room_jid)
46
44
  end
47
- list_rooms(configuration.muc_domain).each do |room|
48
- rooms.upsert(room)
49
- end
45
+ #list_rooms(configuration.muc_domain).each do |room|
46
+ #rooms.upsert(room)
47
+ #end
50
48
  end
51
49
 
52
50
  def deliver(jid, message)
@@ -77,14 +75,14 @@ module Del
77
75
  @jid ||= jid_for(configuration.jid, "chat.hipchat.com", "bot")
78
76
  end
79
77
 
80
- def list_rooms(muc_domain)
81
- Jabber::MUC::MUCBrowser.new(client).muc_rooms(muc_domain).map do |jid, name|
82
- jid.to_s
83
- end
84
- end
78
+ #def list_rooms(muc_domain)
79
+ #Jabber::MUC::MUCBrowser.new(client).muc_rooms(muc_domain).map do |jid, name|
80
+ #jid.to_s
81
+ #end
82
+ #end
85
83
 
86
84
  def encode_string(s)
87
- s.encode("UTF-8", invalid: :replace, undef: :replace)
85
+ s.to_s.encode("UTF-8", invalid: :replace, undef: :replace)
88
86
  end
89
87
 
90
88
  def jid_for(jid, domain, resource)
@@ -10,7 +10,9 @@ module Del
10
10
  end
11
11
 
12
12
  def find_by(id)
13
- @lock.synchronize { Del::User.new(id, @storage[id.to_s]) }
13
+ @lock.synchronize do
14
+ Del::User.new(id, @storage[id.to_s])
15
+ end
14
16
  end
15
17
 
16
18
  def find_all
data/lib/del/user.rb CHANGED
@@ -10,5 +10,9 @@ module Del
10
10
  def mention_name
11
11
  attributes[:mention_name]
12
12
  end
13
+
14
+ def to_s
15
+ YAML.dump(attributes)
16
+ end
13
17
  end
14
18
  end
data/lib/del/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Del
2
- VERSION = "0.1.14"
2
+ VERSION = "0.1.15"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: del
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo