slack-ruby-bot 0.5.1 → 0.5.2

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: 692c967d9fd9953f4279e4596fb01bd43b280914
4
- data.tar.gz: 8c24ae4ccdee5c0667e97094ac527d3f28c75a25
3
+ metadata.gz: 798363fd87ec36b9a8e488f9e19f1c327e247056
4
+ data.tar.gz: 2cbd2241442997ef069af02f665b673d8e946696
5
5
  SHA512:
6
- metadata.gz: 25b5ad5e407f6cb817dae5e9f6516cec650d0feb34397d17e05b2ec2ed6291d7321968dad1b44f330efb1ddc47f4e995d7bb5100be6f5acd4713055e507963c6
7
- data.tar.gz: 2e545f8960023ae2b79874a400083eb3601bcbea361776177da09ebdd16acf2281e831fa64ac3610e14a577eafab11fa1f790a57ade80b5fb5d62c04e1b133ca
6
+ metadata.gz: aaf11fa6bbc8f93ccb702fade2c9b49c28d90dde8e60db35e00bb17e3318ce7174d9033f2a9cc7794ca6f21a7aa03c820ad26ede18d583db6b43759df1475f28
7
+ data.tar.gz: a234a8651084ee3d140f1876adefcf30465cc2ba285bc7b81969fa42ecce1bca2c1828724bc3dbeb2f92cc4d5c26e340ce70645ad6de1aeaa4cf84b28fee664b
@@ -1,5 +1,5 @@
1
1
  # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2015-11-26 14:43:46 +0900 using RuboCop version 0.32.1.
2
+ # on 2015-12-26 16:43:10 -0500 using RuboCop version 0.32.1.
3
3
  # The point is for the user to remove these configuration records
4
4
  # one by one as the offenses are removed from the code base.
5
5
  # Note that changes in the inspected code, or installation of new
@@ -15,7 +15,7 @@ Lint/UselessAccessModifier:
15
15
 
16
16
  # Offense count: 8
17
17
  Metrics/AbcSize:
18
- Max: 27
18
+ Max: 28
19
19
 
20
20
  # Offense count: 1
21
21
  # Configuration parameters: CountComments.
@@ -26,12 +26,12 @@ Metrics/ClassLength:
26
26
  Metrics/CyclomaticComplexity:
27
27
  Max: 8
28
28
 
29
- # Offense count: 96
29
+ # Offense count: 102
30
30
  # Configuration parameters: AllowURI, URISchemes.
31
31
  Metrics/LineLength:
32
32
  Max: 145
33
33
 
34
- # Offense count: 5
34
+ # Offense count: 6
35
35
  # Configuration parameters: CountComments.
36
36
  Metrics/MethodLength:
37
37
  Max: 22
@@ -1,3 +1,7 @@
1
+ ### 0.5.2 (12/26/2015)
2
+
3
+ * Enable setting bot aliases per instance of `SlackRubyBot::Server` - [@dblock](https://github.com/dblock).
4
+
1
5
  ### 0.5.1 (12/23/2015)
2
6
 
3
7
  * Fix: restart sync vs. async - [@dblock](https://github.com/dblock).
data/README.md CHANGED
@@ -17,7 +17,7 @@ A generic Slack bot framework written in Ruby on top of [slack-ruby-client](http
17
17
 
18
18
  ## Stable Release
19
19
 
20
- You're reading the documentation for the **stable** release of slack-ruby-bot 0.5.1.
20
+ You're reading the documentation for the **stable** release of slack-ruby-bot, 0.5.2.
21
21
 
22
22
  ## Usage
23
23
 
@@ -66,7 +66,7 @@ The following examples of bots based on slack-ruby-bot are listed in growing ord
66
66
  * [slack-mathbot](https://github.com/dblock/slack-mathbot): Slack integration with math.
67
67
  * [slack-google-bot](https://github.com/dblock/slack-google-bot): A Slack bot that searches Google, including CSE.
68
68
  * [slack-aws](https://github.com/dblock/slack-aws): Slack integration with Amazon Web Services.
69
- * [slack-gamebot](https://github.com/dblock/slack-gamebot): A generic game bot for ping-pong, chess, etc.
69
+ * [slack-gamebot](https://github.com/dblock/slack-gamebot): A game bot service for ping pong, chess, etc, hosted at [playplay.io](http://playplay.io).
70
70
 
71
71
  ### Commands and Operators
72
72
 
@@ -1,11 +1,18 @@
1
1
  module SlackRubyBot
2
2
  class Client < Slack::RealTime::Client
3
3
  attr_accessor :auth
4
+ attr_accessor :aliases
5
+
6
+ def initialize(attrs = {})
7
+ super(attrs)
8
+ @aliases = attrs[:aliases]
9
+ end
4
10
 
5
11
  def names
6
12
  [
7
13
  SlackRubyBot::Config.user,
8
14
  auth ? auth['user'] : nil,
15
+ aliases,
9
16
  SlackRubyBot::Config.aliases,
10
17
  auth ? "<@#{auth['user_id'].downcase}>" : nil,
11
18
  SlackRubyBot::Config.user_id ? "<@#{SlackRubyBot::Config.user_id.downcase}>" : nil,
@@ -2,12 +2,14 @@ module SlackRubyBot
2
2
  class Server
3
3
  cattr_accessor :hooks
4
4
  attr_accessor :token
5
+ attr_accessor :aliases
5
6
 
6
7
  include SlackRubyBot::Hooks::Hello
7
8
  include SlackRubyBot::Hooks::Message
8
9
 
9
10
  def initialize(options = {})
10
11
  @token = options[:token]
12
+ @aliases = options[:aliases]
11
13
  end
12
14
 
13
15
  def run
@@ -81,7 +83,7 @@ module SlackRubyBot
81
83
 
82
84
  def client
83
85
  @client ||= begin
84
- client = SlackRubyBot::Client.new(token: token)
86
+ client = SlackRubyBot::Client.new(aliases: aliases, token: token)
85
87
  client.on :close do |_data|
86
88
  @client = nil
87
89
  restart! unless @stopping
@@ -1,3 +1,3 @@
1
1
  module SlackRubyBot
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2'
3
3
  end
@@ -1,28 +1,32 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SlackRubyBot::Server do
4
- context 'with a token' do
4
+ context 'with a token and aliases' do
5
5
  let(:client) { Slack::RealTime::Client.new }
6
6
  let(:logger) { subject.send :logger }
7
7
  subject do
8
- SlackRubyBot::Server.new(token: 'token')
8
+ SlackRubyBot::Server.new(token: 'token', aliases: %w(foo bar))
9
9
  end
10
10
  before do
11
11
  allow(subject).to receive(:sleep)
12
12
  allow(logger).to receive(:error)
13
13
  end
14
+ it 'sets aliases' do
15
+ expect(subject.send(:client).aliases).to eq %w(foo bar)
16
+ expect(subject.send(:client).names).to include 'foo'
17
+ end
14
18
  it 'creates a client with a token' do
15
19
  expect(client).to receive(:start!) { fail 'expected' }
16
- expect(Slack::RealTime::Client).to receive(:new).with(token: 'token').and_return(client)
20
+ expect(Slack::RealTime::Client).to receive(:new).with(token: 'token', aliases: %w(foo bar)).and_return(client)
17
21
  expect { subject.start! }.to raise_error RuntimeError, 'expected'
18
22
  end
19
23
  it 'asynchronously creates a client with a token' do
20
24
  expect(client).to receive(:start_async) { fail 'expected' }
21
- expect(Slack::RealTime::Client).to receive(:new).with(token: 'token').and_return(client)
25
+ expect(Slack::RealTime::Client).to receive(:new).with(token: 'token', aliases: %w(foo bar)).and_return(client)
22
26
  expect { subject.start_async }.to raise_error RuntimeError, 'expected'
23
27
  end
24
28
  it 'stops client' do
25
- expect(Slack::RealTime::Client).to receive(:new).with(token: 'token').and_return(client)
29
+ expect(Slack::RealTime::Client).to receive(:new).with(token: 'token', aliases: %w(foo bar)).and_return(client)
26
30
  expect(subject.send(:client)).to_not be nil
27
31
  expect(client).to receive(:started?).and_return(true)
28
32
  subject.stop!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-ruby-bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-24 00:00:00.000000000 Z
11
+ date: 2015-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie