lita 2.6.0 → 2.7.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: e05fe1e0cb321abc7f328ade3580833013f91650
4
- data.tar.gz: 150331c84e76818a44f66f2759a965aed8d8fa75
3
+ metadata.gz: bee2a741d49b87172b517ce6f499112eff3ee14d
4
+ data.tar.gz: ae078494be2d7787bc92851abecc9b9aa1c96881
5
5
  SHA512:
6
- metadata.gz: af679c53aaa2fd86fedfa2c69b984d0961f9d7af73cf371a7c3a8148101dbae94396d078331b19fd2dcddaf1bd12b2bcf8e73dbed00bfbdda0134b3475ce8a2a
7
- data.tar.gz: f61fd270bd693b01bc78ccd5e07062bf4838ca5265c25fa08394cf6b63f25a93fb48e655377b83b1f93a3550a86bd5ded52401d82a269b3d3d28a53261955df0
6
+ metadata.gz: 9a0c5e3efa4af7a3e38f8edf9a10b8c48ceaebdf9cc9227953bb833652abe3c2347375472e5d19e32ff8779c793d4279a887a7d3190c15892b644fbffbea5e8e
7
+ data.tar.gz: 5f517756b1ffc8ae36e6435db1a1b10a8c8ce2336ec06b2c38f88ca1a10b81dd6363668657b390d45659165ba69314839ec2b30acab1b8d1c71740ea515d5483
@@ -4,6 +4,8 @@ rvm:
4
4
  script: bundle exec rake
5
5
  before_install:
6
6
  - gem update --system
7
+ services:
8
+ - redis-server
7
9
  notifications:
8
10
  webhooks:
9
11
  urls:
data/README.md CHANGED
@@ -82,6 +82,7 @@ To configure Lita, edit the file `lita_config.rb` generated by the `lita new` co
82
82
  Lita.configure do |config|
83
83
  config.robot.name = "Sir Bottington"
84
84
  config.robot.mention_name = "bottington"
85
+ config.robot.alias = "/"
85
86
  config.robot.adapter = :example_chat_service
86
87
  config.adapter.username = "bottington"
87
88
  config.adapter.password = "secret"
@@ -96,6 +97,7 @@ The main config objects are:
96
97
  * `robot` - General settings for Lita.
97
98
  * `name` (String) - The display name the bot will use on the chat service. Default: `"Lita"`.
98
99
  * `mention_name` (String) - The name the bot will look for in messages to determine if the message is being addressed to it. Usually this is the same as the display name, but in some cases it may not be. For example, in HipChat, display names are required to be a first and last name, such as "Lita Bot", whereas the mention system would use a name like "LitaBot". Default: `Lita.config.robot.name`.
100
+ * `alias` (String) - The alias the bot will look for in messages to determine if the message is being addressed to it. Useful if you want to use something shorter than the robot's name or mention name, such as a slash, to send it a command. No default.
99
101
  * `adapter` (Symbol, String) - The adapter to load. Default: `:shell`.
100
102
  * `log_level` (Symbol, String) - The severity level of log messages to output. Valid options are, in order of severity: `:debug`, `:info`, `:warn`, `:error`, and `:fatal`. For whichever level you choose, log messages of that severity and greater will be output. Default: `:info`.
101
103
  * `admins` (Array<String>) - An array of string user IDs which tell Lita which users are considered administrators. Only these users will have access to Lita's `auth` command. Default: `nil`.
@@ -145,7 +147,7 @@ To generate a starting template for a new adapter gem, run `lita adapter NAME`,
145
147
 
146
148
  ### Example
147
149
 
148
- Here is a bare bones example of an adapter for the fictious chat service, FancyChat.
150
+ Here is a bare bones example of an adapter for the fictitious chat service, FancyChat.
149
151
 
150
152
  ``` ruby
151
153
  module Lita
@@ -205,7 +207,7 @@ route /^echo\s+(.+)/, :echo
205
207
  Here is an example of a route declaration with all the options:
206
208
 
207
209
  ``` ruby
208
- route /^echo\s+(.+)/, to: :echo, command: true, restrict_to: [:testers, :committers], help => {
210
+ route /^echo\s+(.+)/, :echo, command: true, restrict_to: [:testers, :committers], help => {
209
211
  "echo FOO" => "Replies back with FOO."
210
212
  }
211
213
  ```
@@ -36,7 +36,7 @@ FATAL
36
36
 
37
37
  # Call the appropriate method depending on kill mode.
38
38
  def handle_existing_process
39
- if @kill_existing
39
+ if @kill_existing && File.exists?(@pid_path)
40
40
  kill_existing_process
41
41
  else
42
42
  ensure_not_running
@@ -25,7 +25,13 @@ module Lita
25
25
  @body = body
26
26
  @source = source
27
27
 
28
- @command = !!@body.sub!(/^\s*@?#{@robot.mention_name}[:,]?\s*/i, "")
28
+ name_pattern = Regexp.escape(@robot.mention_name)
29
+
30
+ if @robot.alias
31
+ name_pattern = "#{name_pattern}|#{Regexp.escape(@robot.alias)}"
32
+ end
33
+
34
+ @command = !!@body.sub!(/^\s*@?(?:#{name_pattern})[:,]?\s*/i, "")
29
35
  end
30
36
 
31
37
  # An array of arguments created by shellsplitting the message body, as if
@@ -13,6 +13,11 @@ module Lita
13
13
  # @return [String] The mention name.
14
14
  attr_accessor :mention_name
15
15
 
16
+ # An alias the robot will look for in incoming messages to determine if it's
17
+ # being addressed.
18
+ # @return [String, Nil] The alias, if one was set.
19
+ attr_accessor :alias
20
+
16
21
  # The name of the robot as it will appear in the chat.
17
22
  # @return [String] The robot's name.
18
23
  attr_reader :name
@@ -20,6 +25,7 @@ module Lita
20
25
  def initialize
21
26
  @name = Lita.config.robot.name
22
27
  @mention_name = Lita.config.robot.mention_name || @name
28
+ @alias = Lita.config.robot.alias
23
29
  @app = RackApp.new(self).to_app
24
30
  load_adapter
25
31
  trigger(:loaded)
@@ -1,4 +1,4 @@
1
1
  module Lita
2
2
  # The current version of Lita.
3
- VERSION = "2.6.0"
3
+ VERSION = "2.7.0"
4
4
  end
@@ -1,5 +1,7 @@
1
1
  describe Lita::Adapters::Shell do
2
- let(:robot) { double("Lita::Robot", name: "Lita", mention_name: "LitaBot") }
2
+ let(:robot) do
3
+ double("Lita::Robot", name: "Lita", mention_name: "LitaBot", alias: "/")
4
+ end
3
5
 
4
6
  subject { described_class.new(robot) }
5
7
 
@@ -1,7 +1,9 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Lita::Message do
4
- let(:robot) { double("Lita::Robot", name: "Lita", mention_name: "LitaBot") }
4
+ let(:robot) do
5
+ double("Lita::Robot", name: "Lita", mention_name: "LitaBot", alias: ".")
6
+ end
5
7
 
6
8
  subject do
7
9
  described_class.new(robot, "Hello", "Carl")
@@ -53,6 +55,15 @@ describe Lita::Message do
53
55
  expect(subject).to be_a_command
54
56
  end
55
57
 
58
+ it "is true when the Robot's alias is used" do
59
+ subject = described_class.new(
60
+ robot,
61
+ "#{robot.alias}hello",
62
+ "Carl"
63
+ )
64
+ expect(subject).to be_a_command
65
+ end
66
+
56
67
  it "is false when the message is not addressed to the Robot" do
57
68
  expect(subject).not_to be_a_command
58
69
  end
@@ -4,3 +4,5 @@ rvm:
4
4
  script: bundle exec rake
5
5
  before_install:
6
6
  - gem update --system
7
+ services:
8
+ - redis-server
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Cuadra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-29 00:00:00.000000000 Z
11
+ date: 2013-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -283,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
283
283
  version: '0'
284
284
  requirements: []
285
285
  rubyforge_project:
286
- rubygems_version: 2.1.3
286
+ rubygems_version: 2.1.11
287
287
  signing_key:
288
288
  specification_version: 4
289
289
  summary: A multi-service chat bot with extendable behavior.
@@ -306,4 +306,3 @@ test_files:
306
306
  - spec/lita/util_spec.rb
307
307
  - spec/lita_spec.rb
308
308
  - spec/spec_helper.rb
309
- has_rdoc: