lita-onewheel-wolfram-alpha 0.1.6 → 0.2.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30dba7ff15623575ec9f9f9b0a74d2255a94c840
|
4
|
+
data.tar.gz: 578a393409a27068c6df60a22bc5137c43d95f40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b2920c124e0e59ad4a883f58186a86d04b92b32fc2dd7375b3e56a7069a6b299b27378488e2e9eacf20eedc29e4d510183856be0a0a8554146b73cfe213f165
|
7
|
+
data.tar.gz: 6ae413064714bb920e2ba97c21cbbeef3a6bd9b549015d6956b31f195b6780c0aa5331482df35dde690d2f67009131345ec8ad5b5c3559e3f512a35625c6dfa2
|
@@ -15,8 +15,16 @@ module Lita
|
|
15
15
|
return
|
16
16
|
end
|
17
17
|
query = response.matches[0][0]
|
18
|
+
|
19
|
+
post_script = ''
|
20
|
+
|
21
|
+
if matches = query.match(/\<(.*)\>/)
|
22
|
+
post_script = " #{matches[1]}"
|
23
|
+
end
|
24
|
+
|
18
25
|
api_response = make_api_call query
|
19
26
|
reply = parse_response api_response, query
|
27
|
+
reply += post_script
|
20
28
|
Lita.logger.debug "lita-onewheel-wolfram-alpha: Replying with #{reply}"
|
21
29
|
response.reply reply
|
22
30
|
end
|
@@ -24,12 +32,17 @@ module Lita
|
|
24
32
|
def parse_response(noko_doc, query)
|
25
33
|
success_node = noko_doc.xpath('queryresult').attribute('success')
|
26
34
|
Lita.logger.debug "lita-onewheel-wolfram-alpha: Success attr: #{success_node.to_s}"
|
35
|
+
|
36
|
+
# No sense parsing if we didn't have success.
|
27
37
|
if success_node.to_s == 'true'
|
38
|
+
|
28
39
|
pods = noko_doc.xpath('//pod')
|
29
40
|
Lita.logger.debug "lita-onewheel-wolfram-alpha: Pod title: #{pods[1].attribute('title').to_s}"
|
30
|
-
|
41
|
+
|
42
|
+
title = pods[1].attribute('title').to_s
|
43
|
+
if title == 'Plot' # Plot is a graph, grab the image.
|
31
44
|
pods[1].xpath('//img')[1].attribute('src').to_s
|
32
|
-
else
|
45
|
+
else # Plaintext seems to work well for, say, Definition.
|
33
46
|
rid_thee_of_extras pods[1].xpath('//plaintext')[1].child.to_s
|
34
47
|
end
|
35
48
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'lita-onewheel-wolfram-alpha'
|
3
|
-
spec.version = '0.
|
3
|
+
spec.version = '0.2.0'
|
4
4
|
spec.authors = ['Andrew Kreps']
|
5
5
|
spec.email = ['andrew.kreps@gmail.com']
|
6
6
|
spec.description = %q{Lita interface to Wolfram Alpha.}
|
@@ -14,15 +14,15 @@ 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', '~> 4
|
18
|
-
spec.add_runtime_dependency 'rest-client', '~> 1
|
19
|
-
spec.add_runtime_dependency 'nokogiri', '~> 1
|
17
|
+
spec.add_runtime_dependency 'lita', '~> 4'
|
18
|
+
spec.add_runtime_dependency 'rest-client', '~> 1'
|
19
|
+
spec.add_runtime_dependency 'nokogiri', '~> 1'
|
20
20
|
|
21
|
-
spec.add_development_dependency 'bundler', '~> 1
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1'
|
22
22
|
# spec.add_development_dependency 'pry-byebug', '~> 3.1'
|
23
|
-
spec.add_development_dependency 'rake'
|
24
|
-
spec.add_development_dependency 'rack-test', '~> 0
|
25
|
-
spec.add_development_dependency 'rspec', '~> 3
|
26
|
-
spec.add_development_dependency 'simplecov', '~> 0
|
27
|
-
spec.add_development_dependency 'coveralls', '~> 0
|
23
|
+
spec.add_development_dependency 'rake'
|
24
|
+
spec.add_development_dependency 'rack-test', '~> 0'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3'
|
26
|
+
spec.add_development_dependency 'simplecov', '~> 0'
|
27
|
+
spec.add_development_dependency 'coveralls', '~> 0'
|
28
28
|
end
|
@@ -28,7 +28,11 @@ describe Lita::Handlers::OnewheelWolframAlpha, :lita_handler => true do
|
|
28
28
|
it 'will fail gracefully' do
|
29
29
|
mock_fixture('boopadoop')
|
30
30
|
send_command 'alpha boopadoop'
|
31
|
-
expect(replies.last).to
|
31
|
+
expect(replies.last).to satisfy { |v|
|
32
|
+
['Nope, no boopadoop to see here.',
|
33
|
+
'What\'s that, now?',
|
34
|
+
'boopadoop?'].include? v
|
35
|
+
}
|
32
36
|
end
|
33
37
|
|
34
38
|
it 'will print plot for mathy things' do
|
@@ -51,4 +55,10 @@ describe Lita::Handlers::OnewheelWolframAlpha, :lita_handler => true do
|
|
51
55
|
send_command 'alpha light years'
|
52
56
|
expect(replies.last).to eq('1 ly | 0.3066 pc (parsecs) | 63241 au (astronomical units) | 9.461×10^12 km (kilometers) | 9.461×10^15 meters | 5.879 trillion miles')
|
53
57
|
end
|
58
|
+
|
59
|
+
it 'will add desired text to the end' do
|
60
|
+
mock_fixture('x^2')
|
61
|
+
send_command 'alpha x^2 <as a service>'
|
62
|
+
expect(replies.last).to eq('http://www2.wolframalpha.com/Calculate/MSP/MSP8620hdi8ba18h005cd0000268f85ce36b8h331?MSPStoreType=image/gif&s=15 as a service')
|
63
|
+
end
|
54
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-onewheel-wolfram-alpha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kreps
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -16,126 +16,126 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '4
|
19
|
+
version: '4'
|
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: '4
|
26
|
+
version: '4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rest-client
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1
|
33
|
+
version: '1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1
|
40
|
+
version: '1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: nokogiri
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1
|
47
|
+
version: '1'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1
|
54
|
+
version: '1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1
|
61
|
+
version: '1'
|
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: '1
|
68
|
+
version: '1'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rack-test
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '3
|
103
|
+
version: '3'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '3
|
110
|
+
version: '3'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: simplecov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0
|
117
|
+
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0
|
124
|
+
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: coveralls
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '0
|
131
|
+
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '0
|
138
|
+
version: '0'
|
139
139
|
description: Lita interface to Wolfram Alpha.
|
140
140
|
email:
|
141
141
|
- andrew.kreps@gmail.com
|
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
181
|
version: '0'
|
182
182
|
requirements: []
|
183
183
|
rubyforge_project:
|
184
|
-
rubygems_version: 2.
|
184
|
+
rubygems_version: 2.6.11
|
185
185
|
signing_key:
|
186
186
|
specification_version: 4
|
187
187
|
summary: Summarize THIS!
|