lita-quote 0.0.2 → 0.1.1
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 +4 -4
- data/README.md +7 -4
- data/lib/lita/handlers/quote.rb +16 -9
- data/lita-quote.gemspec +2 -2
- data/spec/lita/handlers/quote_spec.rb +26 -12
- data/spec/spec_helper.rb +1 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c424f385330f646630dc26dd84265a23be2de82e
|
4
|
+
data.tar.gz: 6dfe8133b5f307084720a34b733e12e2c8acf748
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9094e78abbe8175f4ec200cee08f3721580dfe4d78ae26aa5b3fe6229ee4e24c3793ca384782366ee39f20fbd08ba7bad1935cd79bd7ab27f723429dd25453e5
|
7
|
+
data.tar.gz: 6d00d48dc76b8f7eceff30af015f5b60c5859e7cb3399d459e3dbe886c04af8c45cde25d7f734ba1a0d63a5f0404a2b74c7f51819cadee93edab3b5b32232b34
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# lita-quote
|
2
2
|
|
3
|
+
[](https://travis-ci.org/josqu4red/lita-quote)
|
4
|
+
[](https://coveralls.io/r/josqu4red/lita-quote)
|
5
|
+
|
3
6
|
**lita-quote** is a handler for [Lita](https://github.com/jimmycuadra/lita) to store and retrieve user quotes.
|
4
7
|
|
5
8
|
## Installation
|
@@ -28,25 +31,25 @@ end
|
|
28
31
|
|
29
32
|
Store a quote:
|
30
33
|
```
|
31
|
-
Lita: qadd content of the quote
|
34
|
+
Lita: qadd content of the quote # or addquote
|
32
35
|
Added quote #42
|
33
36
|
```
|
34
37
|
|
35
38
|
Get a random quote:
|
36
39
|
```
|
37
|
-
Lita: qget
|
40
|
+
Lita: qget # or getquote
|
38
41
|
#36: a random quote [2014-03-21]
|
39
42
|
```
|
40
43
|
|
41
44
|
Get a given quote:
|
42
45
|
```
|
43
|
-
Lita: qget 42
|
46
|
+
Lita: qget 42 # or getquote
|
44
47
|
#42: content of the quote [2014-03-22]
|
45
48
|
```
|
46
49
|
|
47
50
|
Delete a quote:
|
48
51
|
```
|
49
|
-
Lita: qdel 42
|
52
|
+
Lita: qdel 42 # or delquote
|
50
53
|
Deleted quote #42
|
51
54
|
```
|
52
55
|
|
data/lib/lita/handlers/quote.rb
CHANGED
@@ -2,27 +2,28 @@ module Lita
|
|
2
2
|
module Handlers
|
3
3
|
class Quote < Handler
|
4
4
|
|
5
|
-
|
6
|
-
config.date_format = nil
|
7
|
-
end
|
5
|
+
config :date_format
|
8
6
|
|
9
7
|
route /^qadd\s+(.*)$/, :add_quote, command: true,
|
10
8
|
help: { "qadd <text>" => "Store quote following the command" }
|
11
9
|
|
12
|
-
route /^
|
13
|
-
help: { "
|
14
|
-
|
15
|
-
route /^qdel\s+(\d+)$/, :del_quote, command: true, restrict_to: ["admins"],
|
16
|
-
help: { "qdel <id>" => "Delete quote with given #id (admins only)" }
|
10
|
+
route /^addquote\s+(.*)$/, :add_quote, command: true,
|
11
|
+
help: { "addquote <text>" => "Store quote following the command" }
|
17
12
|
|
18
13
|
def add_quote(response)
|
19
14
|
quote_id = redis.incr("last_id")
|
20
15
|
message = "##{quote_id}: #{response.matches.flatten.first}"
|
21
|
-
message += " #{Time.now.strftime(
|
16
|
+
message += " #{Time.now.strftime(config.date_format)}" if Lita.config.handlers.quote.date_format
|
22
17
|
redis.hset("list", quote_id, message)
|
23
18
|
response.reply("Added quote ##{quote_id}")
|
24
19
|
end
|
25
20
|
|
21
|
+
route /^qget(\s*(\d+))?$/, :get_quote, command: true,
|
22
|
+
help: { "qget [id]" => "Retrieve a quote by #id or randomly" }
|
23
|
+
|
24
|
+
route /^getquote(\s*(\d+))?$/, :get_quote, command: true,
|
25
|
+
help: { "getquote [id]" => "Retrieve a quote by #id or randomly" }
|
26
|
+
|
26
27
|
def get_quote(response)
|
27
28
|
if quote_id = response.matches.flatten.last
|
28
29
|
quote = redis.hget("list", quote_id.to_i)
|
@@ -38,6 +39,12 @@ module Lita
|
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
42
|
+
route /^qdel\s+(\d+)$/, :del_quote, command: true, restrict_to: ["quote_admins"],
|
43
|
+
help: { "qdel <id>" => "Delete quote with given #id (quote_admins only)" }
|
44
|
+
|
45
|
+
route /^delquote\s+(\d+)$/, :del_quote, command: true, restrict_to: ["quote_admins"],
|
46
|
+
help: { "delquote <id>" => "Delete quote with given #id (quote_admins only)" }
|
47
|
+
|
41
48
|
def del_quote(response)
|
42
49
|
quote_id = response.matches.flatten.last.to_i
|
43
50
|
if redis.hdel("list", quote_id) == 1
|
data/lita-quote.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-quote"
|
3
|
-
spec.version = "0.
|
3
|
+
spec.version = "0.1.1"
|
4
4
|
spec.authors = ["Jonathan Amiez"]
|
5
5
|
spec.email = ["jonathan.amiez@gmail.com"]
|
6
6
|
spec.description = "Quote handler for Lita"
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
15
|
spec.require_paths = ["lib"]
|
16
16
|
|
17
|
-
spec.add_runtime_dependency "lita", "
|
17
|
+
spec.add_runtime_dependency "lita", "~> 4.0"
|
18
18
|
|
19
19
|
spec.add_development_dependency "bundler", "~> 1.3"
|
20
20
|
spec.add_development_dependency "rake"
|
@@ -8,20 +8,34 @@ describe Lita::Handlers::Quote, lita_handler: true do
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
it {
|
12
|
-
it {
|
13
|
-
it {
|
14
|
-
|
15
|
-
it {
|
16
|
-
it {
|
17
|
-
|
18
|
-
it {
|
19
|
-
|
20
|
-
it {
|
21
|
-
it {
|
22
|
-
it {
|
11
|
+
it { is_expected.to route_command("qadd dat funny guy").to(:add_quote) }
|
12
|
+
it { is_expected.to route_command("addquote dat funny guy").to(:add_quote) }
|
13
|
+
it { is_expected.not_to route_command("qadd").to(:add_quote) }
|
14
|
+
it { is_expected.not_to route_command("addquote").to(:add_quote) }
|
15
|
+
it { is_expected.not_to route_command("yo qadd dat funny guy").to(:add_quote) }
|
16
|
+
it { is_expected.not_to route_command("yo addquote dat funny guy").to(:add_quote) }
|
17
|
+
|
18
|
+
it { is_expected.to route_command("qget").to(:get_quote) }
|
19
|
+
it { is_expected.to route_command("getquote").to(:get_quote) }
|
20
|
+
it { is_expected.to route_command("qget 22").to(:get_quote) }
|
21
|
+
it { is_expected.to route_command("getquote 22").to(:get_quote) }
|
22
|
+
it { is_expected.not_to route_command("yo qget").to(:get_quote) }
|
23
|
+
it { is_expected.not_to route_command("yo getquote").to(:get_quote) }
|
24
|
+
it { is_expected.not_to route_command("qget dat").to(:get_quote) }
|
25
|
+
it { is_expected.not_to route_command("getquote dat").to(:get_quote) }
|
26
|
+
|
27
|
+
it { is_expected.to route_command("qdel 22").with_authorization_for(:quote_admins).to(:del_quote) }
|
28
|
+
it { is_expected.to route_command("delquote 22").with_authorization_for(:quote_admins).to(:del_quote) }
|
29
|
+
it { is_expected.not_to route_command("qdel").to(:del_quote) }
|
30
|
+
it { is_expected.not_to route_command("delquote").to(:del_quote) }
|
31
|
+
it { is_expected.not_to route_command("yo qdel dat").to(:del_quote) }
|
32
|
+
it { is_expected.not_to route_command("yo delquote dat").to(:del_quote) }
|
23
33
|
|
24
34
|
describe "#add_quote" do
|
35
|
+
it "adds a quote to database" do
|
36
|
+
send_command("qadd <+renchap> t'as un user et pas d'accès ? <+josqu4red> nan mais allow")
|
37
|
+
expect(replies.last).to match(/Added quote #\d+/)
|
38
|
+
end
|
25
39
|
end
|
26
40
|
|
27
41
|
describe "#get_quote" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-quote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Amiez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|