lita-quote 0.0.2 → 0.1.1

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: 54c00850248244df1aea3553cde8489441d1b09c
4
- data.tar.gz: 1b3245e1737533291f5ce0c24c5819c7b6a6e5d0
3
+ metadata.gz: c424f385330f646630dc26dd84265a23be2de82e
4
+ data.tar.gz: 6dfe8133b5f307084720a34b733e12e2c8acf748
5
5
  SHA512:
6
- metadata.gz: fd2fe43d19aa5a94fe2719df4e506f656e42aa1a6389b57012bbb8cdff65634f368bd0be8ae8a213eb6425a3a38c109ccde0e03b756e0362dd0ace47e2c12c5e
7
- data.tar.gz: e18b972b1405ac78e68e6ed995552d6e473ba8e0f5279f8ab2098f9d1c733bb5909bc44f3e81ec33f9e686305b0f1af7cfddcda69149fbdb28c2efa27ca2f811
6
+ metadata.gz: 9094e78abbe8175f4ec200cee08f3721580dfe4d78ae26aa5b3fe6229ee4e24c3793ca384782366ee39f20fbd08ba7bad1935cd79bd7ab27f723429dd25453e5
7
+ data.tar.gz: 6d00d48dc76b8f7eceff30af015f5b60c5859e7cb3399d459e3dbe886c04af8c45cde25d7f734ba1a0d63a5f0404a2b74c7f51819cadee93edab3b5b32232b34
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # lita-quote
2
2
 
3
+ [![Build Status](https://travis-ci.org/josqu4red/lita-quote.png?branch=master)](https://travis-ci.org/josqu4red/lita-quote)
4
+ [![Coverage Status](https://coveralls.io/repos/josqu4red/lita-quote/badge.png)](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
 
@@ -2,27 +2,28 @@ module Lita
2
2
  module Handlers
3
3
  class Quote < Handler
4
4
 
5
- def self.default_config(config)
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 /^qget(\s*(\d+))?$/, :get_quote, command: true,
13
- help: { "qget [id]" => "Retrieve a quote by #id or randomly" }
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(Lita.config.handlers.quote.date_format)}" if Lita.config.handlers.quote.date_format
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-quote"
3
- spec.version = "0.0.2"
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", ">= 3.0"
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 { routes_command("qadd dat funny guy").to(:add_quote) }
12
- it { doesnt_route("qadd").to(:add_quote) }
13
- it { doesnt_route("yo qadd dat funny guy").to(:add_quote) }
14
-
15
- it { routes_command("qget").to(:get_quote) }
16
- it { routes_command("qget 22").to(:get_quote) }
17
- it { doesnt_route("yo qget").to(:get_quote) }
18
- it { doesnt_route("qget dat").to(:get_quote) }
19
-
20
- it { routes_command("qdel 22").to(:del_quote) }
21
- it { doesnt_route("qdel").to(:del_quote) }
22
- it { doesnt_route("yo qdel dat").to(:del_quote) }
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
@@ -8,3 +8,4 @@ SimpleCov.start { add_filter "/spec/" }
8
8
 
9
9
  require "lita-quote"
10
10
  require "lita/rspec"
11
+ Lita.version_3_compatibility_mode = false
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.0.2
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-03-22 00:00:00.000000000 Z
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: '3.0'
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: '3.0'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement