lita-markov 1.0.0 → 1.0.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: 627ba42fa0054e9a6cd2d46bbde5cb6510f1b985
4
- data.tar.gz: c53c2b0f565930850bd0a60085d6d02c69128eee
3
+ metadata.gz: 01b2f398d9caec20fbf37702c662684da7146cdc
4
+ data.tar.gz: a748f843fd1d732e87f54172a86c4c6c591cb4fb
5
5
  SHA512:
6
- metadata.gz: b634fa615bb4960166da153db753ea5c8f05f9dece26a856626fbdd8b73be6ee887ce559a55fdfa17d215085e9d61b9e62c40d65a89630ef813fba33a756c7d5
7
- data.tar.gz: 885beb293a6f002273be56e374700e56d2739bd451076ccffc5114d7a261cc9aee76c4e6fabb379dc564d62301fe9ab7c0a15d9c9cf6cf3659ba5fe0c1ea682f
6
+ metadata.gz: 9a0098f7c3791ef925b3c4ca91a9ee27dd241f4dfbae1b98f9c594fb7004a1ef41bb25a44980ba7b1d3fc1cfcb65919df0f2306e9eda5ca8faf98c6b8a3d64c8
7
+ data.tar.gz: aa74aeb55df9ffa5c5ae47b3d009a49ac779778d08071758967e77c70e201154e6b61afbf2e8e7999f1dbefe0fc942fc4d86cae477e884f370aeb1e1d7386691
@@ -10,12 +10,11 @@ class Lita::Handlers::Markov
10
10
  attr_accessor :handler
11
11
  attr_reader :db
12
12
 
13
- def initialize(handler = nil)
13
+ def initialize(database_url = nil)
14
14
  @handler = handler
15
15
  @depth = 2
16
16
 
17
- database_url = DEFAULT_DATABASE_URL
18
- database_url ||= handler.config.database_url if handler
17
+ database_url = database_url || DEFAULT_DATABASE_URL
19
18
 
20
19
  @db = Sequel.connect database_url
21
20
 
@@ -5,9 +5,7 @@ require 'lita/handlers/markov/engine'
5
5
 
6
6
  module Lita::Handlers
7
7
  class Markov
8
- attr_reader :engine
9
-
10
- config :database_url
8
+ config :database_url, type: String, required: true
11
9
 
12
10
  route(/.+/, :ingest, command: false)
13
11
 
@@ -15,10 +13,8 @@ module Lita::Handlers
15
13
  'markov USER' => 'Generate a markov chain from the given user.'
16
14
  })
17
15
 
18
- def initialize(robot)
19
- super(robot)
20
-
21
- @engine = Engine.new self
16
+ def engine
17
+ @engine ||= Engine.new config.database_url
22
18
  end
23
19
 
24
20
  def ingest(chat)
@@ -30,7 +26,7 @@ module Lita::Handlers
30
26
  # Get the mention name (ie. 'dirk') of the user
31
27
  id = chat.user.id
32
28
 
33
- @engine.ingest id, message
29
+ engine.ingest id, message
34
30
  end
35
31
 
36
32
  def generate(chat)
@@ -38,7 +34,7 @@ module Lita::Handlers
38
34
  id = Lita::User.fuzzy_find(name).id
39
35
 
40
36
  begin
41
- sentence = @engine.generate_sentence_for id
37
+ sentence = engine.generate_sentence_for id
42
38
 
43
39
  chat.reply sentence
44
40
  rescue Engine::EmptyDictionaryError
data/lita-markov.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-markov"
3
- spec.version = "1.0.0"
3
+ spec.version = "1.0.1"
4
4
  spec.authors = ["Dirk Gadsden"]
5
5
  spec.email = ["dirk@dirk.to"]
6
6
  spec.description = "Markov chains for Lita."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-markov
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dirk Gadsden