lita-wordnik 0.0.1 → 0.0.2

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: 04e7612f43af97a846b2a720e130cdcdd25475a0
4
- data.tar.gz: fbeeeb8f1d1b2838327bfcab5227ebf5d7fbcdd9
3
+ metadata.gz: 73ca4d2f891a4dad92531c72f86767e84faf75fe
4
+ data.tar.gz: bcb9309635fb442e5c2c482c9019878b5f07ffa0
5
5
  SHA512:
6
- metadata.gz: 4acd1c210978f0042a4a0ae61e0a6305729ce433e3de9641a9da6ea79a2bdbd9dd23e853b8a85b7329a469c4ab17f9a76c5965bc32f443ae85abcad819b350fa
7
- data.tar.gz: dfe0590571736facf54dfc64585b5ee220d64fc9c1be928c898140e62ed42ece62bec2d9187ecca0895b290372d23c91971cd0b17402d268d208d3cc7ba9c5b8
6
+ metadata.gz: 6f3df2c0b86f98c3eb3d88f4a9e91ebc237c81eb8563bf12c49f8c3b6e5a21d6ccceb3565bedecff149eba07421bb49160bc5888d5e94720311b25c6927fdbfa
7
+ data.tar.gz: 11f2f3b04dbfc99c2d3075aadbac970407114c11736b3fab8b6ba5430fcf550fa593a80a632d1e9a56a1f5a116934f1a1b63476edaa2fe13aaa0e47f26abdd16
data/.travis.yml CHANGED
@@ -4,3 +4,7 @@ rvm:
4
4
  script: bundle exec rspec
5
5
  before_install:
6
6
  - gem update --system
7
+ notifications:
8
+ webhooks:
9
+ urls:
10
+ - https://lita-freenode.herokuapp.com/travis
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2013 Jimmy Cuadra
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # lita-wordnik
2
2
 
3
- [![Build Status](https://travis-ci.org/jimmycuadra/lita-wordnik.png)](https://travis-ci.org/jimmycuadra/lita-wordnik)
3
+ [![Build Status](https://travis-ci.org/jimmycuadra/lita-wordnik.png?branch=master)](https://travis-ci.org/jimmycuadra/lita-wordnik)
4
4
  [![Code Climate](https://codeclimate.com/github/jimmycuadra/lita-wordnik.png)](https://codeclimate.com/github/jimmycuadra/lita-wordnik)
5
5
  [![Coverage Status](https://coveralls.io/repos/jimmycuadra/lita-wordnik/badge.png)](https://coveralls.io/r/jimmycuadra/lita-wordnik)
6
6
 
@@ -3,6 +3,8 @@ require "lita"
3
3
  module Lita
4
4
  module Handlers
5
5
  class Wordnik < Handler
6
+ NO_DEFINITIONS = "Wordnik doesn't have any definitions for that."
7
+
6
8
  def self.default_config(config)
7
9
  config.api_key = nil
8
10
  end
@@ -48,10 +50,15 @@ module Lita
48
50
  when 400
49
51
  "Wordnik didn't understand that word."
50
52
  when 404
51
- "Wordnik doesn't have any definitions for that."
53
+ NO_DEFINITIONS
52
54
  when 200
53
55
  data = MultiJson.load(response.body).first
54
- "#{data["word"]} (#{data["partOfSpeech"]}): #{data["text"]}"
56
+
57
+ if data
58
+ "#{data["word"]} (#{data["partOfSpeech"]}): #{data["text"]}"
59
+ else
60
+ NO_DEFINITIONS
61
+ end
55
62
  else
56
63
  Lita.logger.error("Wordnik request failed: #{response.inspect}")
57
64
  "Wordnik request failed. See the Lita logs."
data/lita-wordnik.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-wordnik"
3
- spec.version = "0.0.1"
3
+ spec.version = "0.0.2"
4
4
  spec.authors = ["Jimmy Cuadra"]
5
5
  spec.email = ["jimmy@jimmycuadra.com"]
6
6
  spec.description = %q{A Lita handler for dictionary functionality backed by Wordnik.}
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
14
14
  spec.require_paths = ["lib"]
15
15
 
16
- spec.add_runtime_dependency "lita", "~> 2.1"
16
+ spec.add_runtime_dependency "lita", ">= 2.1"
17
17
 
18
18
  spec.add_development_dependency "bundler", "~> 1.3"
19
19
  spec.add_development_dependency "rake"
@@ -1,6 +1,28 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Lita::Handlers::Wordnik, lita_handler: true do
4
+ let(:body) do
5
+ <<-BODY.chomp
6
+ [
7
+ {
8
+ "word": "computer",
9
+ "text": "A device that computes, especially a programmable electronic \
10
+ machine that performs high-speed mathematical or logical operations or that \
11
+ assembles, stores, correlates, or otherwise processes information.",
12
+ "partOfSpeech": "noun"
13
+ }
14
+ ]
15
+ BODY
16
+ end
17
+
18
+ let(:response) { double("Faraday::Response", status: 200, body: body) }
19
+
20
+ before do
21
+ allow_any_instance_of(
22
+ Faraday::Connection
23
+ ).to receive(:get).and_return(response)
24
+ end
25
+
4
26
  it { routes_command("define computer").to(:define) }
5
27
 
6
28
  it "sets the API key to nil by default" do
@@ -14,27 +36,7 @@ describe Lita::Handlers::Wordnik, lita_handler: true do
14
36
  end
15
37
 
16
38
  context "when the API key is set" do
17
- let(:body) do
18
- <<-BODY.chomp
19
- [
20
- {
21
- "word": "computer",
22
- "text": "A device that computes, especially a programmable electronic \
23
- machine that performs high-speed mathematical or logical operations or that \
24
- assembles, stores, correlates, or otherwise processes information.",
25
- "partOfSpeech": "noun"
26
- }
27
- ]
28
- BODY
29
- end
30
- let(:response) { double("Faraday::Response", status: 200, body: body) }
31
-
32
- before do
33
- Lita.config.handlers.wordnik.api_key = "abc123"
34
- allow_any_instance_of(
35
- Faraday::Connection
36
- ).to receive(:get).and_return(response)
37
- end
39
+ before { Lita.config.handlers.wordnik.api_key = "abc123" }
38
40
 
39
41
  it "replies with the definition" do
40
42
  send_command("define computer")
@@ -64,6 +66,15 @@ BODY
64
66
  send_command("define computer")
65
67
  expect(replies.last).to include("request failed")
66
68
  end
69
+
70
+ context "when the response has no definitions" do
71
+ let(:body) { "[]" }
72
+
73
+ it "replies that Wordnik has no definitions" do
74
+ send_command("define whiskey stone")
75
+ expect(replies.last).to include("doesn't have any definitions")
76
+ end
77
+ end
67
78
  end
68
79
  end
69
80
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-wordnik
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Cuadra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-12 00:00:00.000000000 Z
11
+ date: 2013-10-31 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
19
  version: '2.1'
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
26
  version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
@@ -104,6 +104,7 @@ files:
104
104
  - .gitignore
105
105
  - .travis.yml
106
106
  - Gemfile
107
+ - LICENSE
107
108
  - README.md
108
109
  - Rakefile
109
110
  - lib/lita-wordnik.rb
@@ -131,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
132
  version: '0'
132
133
  requirements: []
133
134
  rubyforge_project:
134
- rubygems_version: 2.0.3
135
+ rubygems_version: 2.1.3
135
136
  signing_key:
136
137
  specification_version: 4
137
138
  summary: A Lita handler for dictionary functionality backed by Wordnik.