lita-wit 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +30 -0
- data/Gemfile +1 -1
- data/Rakefile +2 -2
- data/lib/lita/actions/base.rb +4 -4
- data/lib/lita/actions/weather.rb +9 -12
- data/lib/lita/services/wit_client.rb +3 -4
- data/lib/lita/utils/alias_stripper.rb +1 -1
- data/lib/lita/utils/aliases.rb +1 -1
- data/lib/lita/utils/bickle.rb +0 -1
- data/lib/lita/utils/context_piper.rb +1 -1
- data/lib/lita/utils/entities_navigator.rb +2 -2
- data/lita-wit.gemspec +4 -4
- data/spec/lita/handlers/wit_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- metadata +12 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e781b13a53b4d3414cc609af1a3d62067fd9e856
|
4
|
+
data.tar.gz: edcc847c1a15f5ed98e798d13188bf26c33e2d16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 706177df5ef41cc12f60b323957a9f326846fda200b87b28d1f319632250550f9c3621776e308830e0f8c30e98dd91d58516a55d6352021adafaebfb3a8fb0a9
|
7
|
+
data.tar.gz: ec5bb99466af9ba981f931d59cf15af1d6d2cf857b97ff749293be80d26afffcb357e37a7e747b745290907effd7a889c01ecfc550e1d8cf91ee702ccfc72d3b
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# This is the configuration used to check the rubocop source code.
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
Exclude:
|
5
|
+
- 'vendor/**/*'
|
6
|
+
- 'spec/fixtures/**/*'
|
7
|
+
- 'tmp/**/*'
|
8
|
+
TargetRubyVersion: 2.1
|
9
|
+
|
10
|
+
Style/Encoding:
|
11
|
+
EnforcedStyle: when_needed
|
12
|
+
Enabled: true
|
13
|
+
|
14
|
+
Style/Documentation:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Style/FileName:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Style/FrozenStringLiteralComment:
|
21
|
+
EnforcedStyle: always
|
22
|
+
|
23
|
+
Metrics/BlockLength:
|
24
|
+
Exclude:
|
25
|
+
- 'Rakefile'
|
26
|
+
- '**/*.rake'
|
27
|
+
- 'spec/**/*.rb'
|
28
|
+
|
29
|
+
Metrics/LineLength:
|
30
|
+
Enabled: false
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/lib/lita/actions/base.rb
CHANGED
@@ -5,13 +5,13 @@ module Lita
|
|
5
5
|
@robot = robot
|
6
6
|
end
|
7
7
|
|
8
|
-
def actions(
|
8
|
+
def actions(_source)
|
9
9
|
{
|
10
|
-
:
|
10
|
+
error: lambda do |request|
|
11
11
|
# Required, but is never ever called
|
12
|
-
|
12
|
+
end
|
13
13
|
}
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
17
|
-
end
|
17
|
+
end
|
data/lib/lita/actions/weather.rb
CHANGED
@@ -1,19 +1,16 @@
|
|
1
1
|
module Lita
|
2
2
|
module Actions
|
3
3
|
class Weather < Base
|
4
|
-
|
5
4
|
def actions(source)
|
6
|
-
super.merge(
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
Utils::ContextPiper.pipe(context, entities, '
|
12
|
-
|
13
|
-
|
14
|
-
}
|
15
|
-
})
|
5
|
+
super.merge(send: lambda do |_context, msg|
|
6
|
+
@robot.send_message(source, msg['text'])
|
7
|
+
end,
|
8
|
+
merge: lambda do |r|
|
9
|
+
Utils::ContextPiper.pipe(r['context'], r['entities'], 'intent', 'intent')
|
10
|
+
Utils::ContextPiper.pipe(r['context'], r['entities'], 'location', 'loc')
|
11
|
+
r['context']
|
12
|
+
end)
|
16
13
|
end
|
17
14
|
end
|
18
15
|
end
|
19
|
-
end
|
16
|
+
end
|
@@ -1,19 +1,18 @@
|
|
1
1
|
module Lita
|
2
2
|
module Services
|
3
3
|
class WitClient
|
4
|
-
|
5
4
|
def initialize(robot)
|
6
5
|
@robot = robot
|
7
6
|
@token = robot.config.handlers.wit.server_access_token
|
8
7
|
@actions_class = robot.config.handlers.wit.actions_class
|
9
8
|
end
|
10
9
|
|
11
|
-
def run_actions(session_id, message, context={}, max_steps=DEFAULT_MAX_STEPS)
|
10
|
+
def run_actions(session_id, message, context = {}, max_steps = DEFAULT_MAX_STEPS)
|
12
11
|
actions = @actions_class.new(@robot).actions(message.source)
|
13
|
-
@wit = ::Wit.new(@token, actions)
|
12
|
+
@wit = ::Wit.new(access_token: @token, actions: actions)
|
14
13
|
stripped = Utils::AliasStripper.strip(@robot, message)
|
15
14
|
@wit.run_actions(session_id, stripped.body, context, max_steps)
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
19
|
-
end
|
18
|
+
end
|
data/lib/lita/utils/aliases.rb
CHANGED
data/lib/lita/utils/bickle.rb
CHANGED
@@ -2,11 +2,11 @@ module Lita
|
|
2
2
|
module Utils
|
3
3
|
class EntitiesNavigator
|
4
4
|
def self.first_value(entities, entity)
|
5
|
-
return nil unless entities.
|
5
|
+
return nil unless entities.key? entity
|
6
6
|
val = entities[entity][0]['value']
|
7
7
|
return nil if val.nil?
|
8
8
|
val.is_a?(Hash) ? val['value'] : val
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
12
|
-
end
|
12
|
+
end
|
data/lita-wit.gemspec
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'lita-wit'
|
3
|
-
spec.version = '0.1.
|
3
|
+
spec.version = '0.1.3'
|
4
4
|
spec.authors = ['Damien Bastin']
|
5
5
|
spec.email = ['damien.bastin@gmail.com']
|
6
6
|
spec.description = 'A Lita handler for Wit.'
|
7
7
|
spec.summary = 'Receive structured intentions from unstructured sentences using a Lita bot and Wit.'
|
8
8
|
spec.homepage = 'https://github.com/dbastin/lita-wit'
|
9
9
|
spec.license = 'MIT'
|
10
|
-
spec.metadata = { 'lita_plugin_type' => 'handler'}
|
10
|
+
spec.metadata = { 'lita_plugin_type' => 'handler' }
|
11
11
|
|
12
|
-
spec.files = `git ls-files`.split(
|
12
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
13
13
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
14
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
15
|
spec.require_paths = ['lib']
|
16
16
|
|
17
17
|
spec.add_runtime_dependency 'lita', '>= 4.7'
|
18
|
-
spec.add_runtime_dependency 'wit', '>=
|
18
|
+
spec.add_runtime_dependency 'wit', '>= 4.0.0', '< 5.0.0'
|
19
19
|
|
20
20
|
spec.add_development_dependency 'bundler', '>= 1.3'
|
21
21
|
spec.add_development_dependency 'pry-byebug'
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-wit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damien Bastin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -30,14 +30,20 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 4.0.0
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 5.0.0
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
41
|
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
43
|
+
version: 4.0.0
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 5.0.0
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: bundler
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,6 +178,7 @@ extensions: []
|
|
172
178
|
extra_rdoc_files: []
|
173
179
|
files:
|
174
180
|
- ".gitignore"
|
181
|
+
- ".rubocop.yml"
|
175
182
|
- ".travis.yml"
|
176
183
|
- Gemfile
|
177
184
|
- LICENSE
|
@@ -217,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
224
|
version: '0'
|
218
225
|
requirements: []
|
219
226
|
rubyforge_project:
|
220
|
-
rubygems_version: 2.
|
227
|
+
rubygems_version: 2.6.8
|
221
228
|
signing_key:
|
222
229
|
specification_version: 4
|
223
230
|
summary: Receive structured intentions from unstructured sentences using a Lita bot
|