lita-key-value 0.2.0 → 1.0.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: a43f1b3fe82b602f02b2c5fd9959cc344cc2018c
4
- data.tar.gz: aa56665e4927ba12e2b48d5aecd53d14af705ff3
3
+ metadata.gz: 82f0ee31ca473fd0e97adc6c3a9248150d584f53
4
+ data.tar.gz: 5c09b282b317d394cac58e5a112cd842714c330e
5
5
  SHA512:
6
- metadata.gz: e6e6e7caf234a9a3eec575fd35fd7259f49121658a7ad8ba9b273ad2a2915cd0b0928d828aa6bebc5a3ffa2e4b68744000e4017fd42bba4605692a65ad4edceb
7
- data.tar.gz: 55b0926c7e3742e0169366daca6420316ade6dee47b60534dc2aab916899fb024c37879d2074188c49fbf86bab0645c56e085420f3c9f3ea9062a69a09798f68
6
+ metadata.gz: 4b2022a3c3defc7bd663ba3469a45f1a498eeafe5f3d653a585ad935067afa82424c4c09b9802dee949146bb127244b5431399e626346054115d6e7f7a9d4b77
7
+ data.tar.gz: 30d563ea31295ec8364c863d7219ad270cb99fbff56ca4306536f9140f88dd058115f52cc30cb1bc193e29906a442ee12999ff8f60feee2abc307cf330395acc
@@ -4,11 +4,12 @@ module Lita
4
4
  module Handlers
5
5
  class KeyValue < Handler
6
6
  REDIS_KEY = "kv"
7
- KEY_PATTERN = /[\w\._]+/
8
7
 
9
- def self.default_config(config)
10
- config.key_pattern = nil
11
- config.key_normalizer = nil
8
+ config :key_pattern, type: Regexp, default: /[\w\._]+/
9
+ config :key_normalizer do
10
+ validate do |value|
11
+ "must be a callable object" unless value.respond_to?(:call)
12
+ end
12
13
  end
13
14
 
14
15
  def self.define_routes(pattern)
@@ -36,8 +37,7 @@ module Lita
36
37
  on :loaded, :define_routes
37
38
 
38
39
  def define_routes(payload)
39
- pattern = config.key_pattern || KEY_PATTERN
40
- self.class.define_routes(pattern.source)
40
+ self.class.define_routes(config.key_pattern.source)
41
41
  end
42
42
 
43
43
  def set(response)
@@ -100,7 +100,7 @@ module Lita
100
100
  def normalize_key(key)
101
101
  normalizer = config.key_normalizer
102
102
 
103
- if normalizer.respond_to?(:call)
103
+ if normalizer
104
104
  normalizer.call(key)
105
105
  else
106
106
  key.to_s.downcase.strip
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-key-value"
3
- spec.version = "0.2.0"
3
+ spec.version = "1.0.0"
4
4
  spec.authors = ["Jimmy Cuadra"]
5
5
  spec.email = ["jimmy@jimmycuadra.com"]
6
6
  spec.description = %q{A Lita handler for storing snippets of text.}
@@ -14,11 +14,11 @@ 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", ">= 2.7"
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"
21
- spec.add_development_dependency "rspec", ">= 3.0.0.beta2"
21
+ spec.add_development_dependency "rspec", ">= 3.0.0"
22
22
  spec.add_development_dependency "simplecov"
23
23
  spec.add_development_dependency "coveralls"
24
24
  end
@@ -1,11 +1,11 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Lita::Handlers::KeyValue, lita_handler: true do
4
- it { routes_command("kv set foo bar").to(:set) }
5
- it { routes_command("kv get foo").to(:get) }
6
- it { routes_command("kv delete foo").to(:delete) }
7
- it { routes_command("kv list").to(:list) }
8
- it { routes_command("kv search foo").to(:search) }
4
+ it { is_expected.to route_command("kv set foo bar").to(:set) }
5
+ it { is_expected.to route_command("kv get foo").to(:get) }
6
+ it { is_expected.to route_command("kv delete foo").to(:delete) }
7
+ it { is_expected.to route_command("kv list").to(:list) }
8
+ it { is_expected.to route_command("kv search foo").to(:search) }
9
9
 
10
10
  it "sets and gets keys" do
11
11
  send_command("kv set foo bar")
data/spec/spec_helper.rb CHANGED
@@ -8,3 +8,5 @@ SimpleCov.start { add_filter "/spec/" }
8
8
 
9
9
  require "lita-key-value"
10
10
  require "lita/rspec"
11
+
12
+ Lita.version_3_compatibility_mode = false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-key-value
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.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: 2014-04-02 00:00:00.000000000 Z
11
+ date: 2014-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.7'
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: '2.7'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 3.0.0.beta2
61
+ version: 3.0.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 3.0.0.beta2
68
+ version: 3.0.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement