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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50952bb8fc939112456f6b7a025624803324f07c
4
- data.tar.gz: 5c5aa687530e808caf1ffaa62b776bc686f88b48
3
+ metadata.gz: e781b13a53b4d3414cc609af1a3d62067fd9e856
4
+ data.tar.gz: edcc847c1a15f5ed98e798d13188bf26c33e2d16
5
5
  SHA512:
6
- metadata.gz: 7dc53348875a94b9256aff973f5cfaa453bad08aeceef11f11f6a165beac6d139a6714acf8dd2a53f9faa906ee7ba9eb21c08ffaba0aedc67ba620a1b4becf97
7
- data.tar.gz: e810f236eb31fb95c2fe9f6126ec65622d013ade71d0a366fd45ac293f5738abaf7f631ff0610dff716892bfd9a61241bd8356c227f88b70e14f198e06eb9212
6
+ metadata.gz: 706177df5ef41cc12f60b323957a9f326846fda200b87b28d1f319632250550f9c3621776e308830e0f8c30e98dd91d58516a55d6352021adafaebfb3a8fb0a9
7
+ data.tar.gz: ec5bb99466af9ba981f931d59cf15af1d6d2cf857b97ff749293be80d26afffcb357e37a7e747b745290907effd7a889c01ecfc550e1d8cf91ee702ccfc72d3b
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ spec/reports
16
16
  test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
+ lita_config.rb
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
@@ -1,3 +1,3 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
@@ -5,13 +5,13 @@ module Lita
5
5
  @robot = robot
6
6
  end
7
7
 
8
- def actions(source)
8
+ def actions(_source)
9
9
  {
10
- :error => -> (session_id, context, error) {
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
@@ -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
- :say => -> (session_id, context, msg) {
8
- @robot.send_message(source, msg)
9
- },
10
- :merge => -> (session_id, context, entities, msg) {
11
- Utils::ContextPiper.pipe(context, entities, 'intent', 'intent')
12
- Utils::ContextPiper.pipe(context, entities, 'location', 'loc')
13
- context
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
@@ -7,4 +7,4 @@ module Lita
7
7
  end
8
8
  end
9
9
  end
10
- end
10
+ end
@@ -6,4 +6,4 @@ module Lita
6
6
  end
7
7
  end
8
8
  end
9
- end
9
+ end
@@ -1,7 +1,6 @@
1
1
  module Lita
2
2
  module Utils
3
3
  class Bickle
4
-
5
4
  def initialize(robot)
6
5
  @robot = robot
7
6
  end
@@ -7,4 +7,4 @@ module Lita
7
7
  end
8
8
  end
9
9
  end
10
- end
10
+ end
@@ -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.has_key? entity
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.2'
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', '>= 3.3.1'
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'
@@ -1,7 +1,7 @@
1
+ # frozen_string_literal: false
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Lita::Handlers::Wit, lita_handler: true do
4
-
5
5
  describe 'handling unhandled_message' do
6
6
  let(:source) { double(:source) }
7
7
 
data/spec/spec_helper.rb CHANGED
@@ -13,7 +13,6 @@ SimpleCov.start 'rails' do
13
13
  end
14
14
 
15
15
  require 'lita-wit'
16
- Wit.logger.level = Logger::WARN
17
16
 
18
17
  require 'lita/rspec'
19
18
  require 'lita_config'
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.2
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: 2016-05-05 00:00:00.000000000 Z
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: 3.3.1
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: 3.3.1
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.5.1
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