lita-onewheel-wolfram-alpha 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/lita/handlers/onewheel_wolfram_alpha.rb +16 -7
- data/lita-onewheel-wolfram-alpha.gemspec +1 -1
- data/spec/fixtures/pi.xml +0 -1
- data/spec/fixtures/whackadoo.xml +0 -1
- data/spec/fixtures/x^2.xml +205 -0
- data/spec/lita/handlers/onewheel_wolfram_alpha_spec.rb +6 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dc26896fc54e84763529a3888cc5075695333f4
|
4
|
+
data.tar.gz: 9d7b2cebfccf3eb2a0e277cc1ede433f3ec92f12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42a6f190f6473c29b4c989647f79205ff42daa28e8df11b31e5e930786e8cce1a89aa7ebff68900a528820db275b565115ea78628adf999351739f8b6e8b03e9
|
7
|
+
data.tar.gz: 490cfd4c1b57e4adaf79d45a7ac0b55e1f25bcbc6ad36bcc09e07aa8266b30f12c1551bfdae271859043b1ba466d73532eb7f11a4ba5d751944a1f7592dae201
|
@@ -16,22 +16,31 @@ module Lita
|
|
16
16
|
end
|
17
17
|
query = response.matches[0][0]
|
18
18
|
api_response = make_api_call query
|
19
|
-
|
19
|
+
reply = parse_response api_response, query
|
20
|
+
response.reply reply
|
20
21
|
end
|
21
22
|
|
22
|
-
def
|
23
|
-
uri = build_uri query
|
24
|
-
response = RestClient.get(uri)
|
25
|
-
noko_doc = Nokogiri::XML response.to_s
|
23
|
+
def parse_response(noko_doc, query)
|
26
24
|
success_node = noko_doc.xpath('queryresult').attribute('success')
|
27
25
|
if success_node.to_s == 'true'
|
28
|
-
|
29
|
-
|
26
|
+
pods = noko_doc.xpath('//pod')
|
27
|
+
if pods[1].attribute('title').to_s == 'Plot'
|
28
|
+
pods[1].xpath('//img')[1].attribute('src').to_s
|
29
|
+
else
|
30
|
+
pods[1].xpath('//plaintext')[1].child.to_s
|
31
|
+
end
|
32
|
+
|
30
33
|
else
|
31
34
|
"Wolfram couldn't parse #{query}."
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
38
|
+
def make_api_call(query)
|
39
|
+
uri = build_uri query
|
40
|
+
response = RestClient.get(uri)
|
41
|
+
Nokogiri::XML response.to_s
|
42
|
+
end
|
43
|
+
|
35
44
|
def build_uri(query)
|
36
45
|
uri = config.api_uri.sub '[query]', CGI::escape(query)
|
37
46
|
uri = uri.sub '[appid]', config.app_id
|
data/spec/fixtures/pi.xml
CHANGED
data/spec/fixtures/whackadoo.xml
CHANGED
@@ -0,0 +1,205 @@
|
|
1
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
2
|
+
<queryresult success='true'
|
3
|
+
error='false'
|
4
|
+
numpods='9'
|
5
|
+
datatypes='Geometry'
|
6
|
+
timedout=''
|
7
|
+
timedoutpods=''
|
8
|
+
timing='1.657'
|
9
|
+
parsetiming='0.15'
|
10
|
+
parsetimedout='false'
|
11
|
+
recalculate=''
|
12
|
+
id='MSPa8320hdi8ba18h005cd0000476562i1a2hd704a'
|
13
|
+
host='http://www2.wolframalpha.com'
|
14
|
+
server='15'
|
15
|
+
related='http://www2.wolframalpha.com/api/v2/relatedQueries.jsp?id=MSPa8420hdi8ba18h005cd00003hf14ed530f75ebh&s=15'
|
16
|
+
version='2.6'>
|
17
|
+
<pod title='Input'
|
18
|
+
scanner='Identity'
|
19
|
+
id='Input'
|
20
|
+
position='100'
|
21
|
+
error='false'
|
22
|
+
numsubpods='1'>
|
23
|
+
<subpod title=''>
|
24
|
+
<img src='http://www2.wolframalpha.com/Calculate/MSP/MSP8520hdi8ba18h005cd00002ii64bc919d4eiah?MSPStoreType=image/gif&s=15'
|
25
|
+
alt='x^2'
|
26
|
+
title='x^2'
|
27
|
+
width='15'
|
28
|
+
height='18' />
|
29
|
+
<plaintext>x^2</plaintext>
|
30
|
+
</subpod>
|
31
|
+
</pod>
|
32
|
+
<pod title='Plot'
|
33
|
+
scanner='Plotter'
|
34
|
+
id='Plot'
|
35
|
+
position='200'
|
36
|
+
error='false'
|
37
|
+
numsubpods='1'>
|
38
|
+
<subpod title=''>
|
39
|
+
<img src='http://www2.wolframalpha.com/Calculate/MSP/MSP8620hdi8ba18h005cd0000268f85ce36b8h331?MSPStoreType=image/gif&s=15'
|
40
|
+
alt=''
|
41
|
+
title=''
|
42
|
+
width='333'
|
43
|
+
height='157' />
|
44
|
+
<plaintext></plaintext>
|
45
|
+
</subpod>
|
46
|
+
</pod>
|
47
|
+
<pod title='Geometric figure'
|
48
|
+
scanner='Geometry'
|
49
|
+
id='GeometricFigure (ofBoundary)'
|
50
|
+
position='300'
|
51
|
+
error='false'
|
52
|
+
numsubpods='1'>
|
53
|
+
<subpod title=''>
|
54
|
+
<img src='http://www2.wolframalpha.com/Calculate/MSP/MSP8720hdi8ba18h005cd00003dcdh5156707h635?MSPStoreType=image/gif&s=15'
|
55
|
+
alt='parabola'
|
56
|
+
title='parabola'
|
57
|
+
width='59'
|
58
|
+
height='18' />
|
59
|
+
<plaintext>parabola</plaintext>
|
60
|
+
</subpod>
|
61
|
+
<states count='1'>
|
62
|
+
<state name='Properties'
|
63
|
+
input='GeometricFigure (ofBoundary)__Properties' />
|
64
|
+
</states>
|
65
|
+
</pod>
|
66
|
+
<pod title='Root'
|
67
|
+
scanner='Reduce'
|
68
|
+
id='Root'
|
69
|
+
position='400'
|
70
|
+
error='false'
|
71
|
+
numsubpods='1'
|
72
|
+
primary='true'>
|
73
|
+
<subpod title=''>
|
74
|
+
<img src='http://www2.wolframalpha.com/Calculate/MSP/MSP8820hdi8ba18h005cd00000d566b84f54h8dg5?MSPStoreType=image/gif&s=15'
|
75
|
+
alt='x = 0'
|
76
|
+
title='x = 0'
|
77
|
+
width='36'
|
78
|
+
height='18' />
|
79
|
+
<plaintext>x = 0</plaintext>
|
80
|
+
</subpod>
|
81
|
+
<states count='1'>
|
82
|
+
<state name='Step-by-step solution'
|
83
|
+
input='Root__Step-by-step solution' />
|
84
|
+
</states>
|
85
|
+
</pod>
|
86
|
+
<pod title='Polynomial discriminant'
|
87
|
+
scanner='Expression'
|
88
|
+
id='PolynomialDiscriminant'
|
89
|
+
position='500'
|
90
|
+
error='false'
|
91
|
+
numsubpods='1'>
|
92
|
+
<subpod title=''>
|
93
|
+
<img src='http://www2.wolframalpha.com/Calculate/MSP/MSP8920hdi8ba18h005cd000022f85hh1873dc931?MSPStoreType=image/gif&s=15'
|
94
|
+
alt='Delta = 0'
|
95
|
+
title='Delta = 0'
|
96
|
+
width='38'
|
97
|
+
height='18' />
|
98
|
+
<plaintext>Delta = 0</plaintext>
|
99
|
+
</subpod>
|
100
|
+
<states count='1'>
|
101
|
+
<state name='Show class number'
|
102
|
+
input='PolynomialDiscriminant__Show class number' />
|
103
|
+
</states>
|
104
|
+
</pod>
|
105
|
+
<pod title='Properties as a real function'
|
106
|
+
scanner='FunctionProperties'
|
107
|
+
id='PropertiesAsARealFunction'
|
108
|
+
position='600'
|
109
|
+
error='false'
|
110
|
+
numsubpods='3'>
|
111
|
+
<subpod title='Domain'>
|
112
|
+
<img src='http://www2.wolframalpha.com/Calculate/MSP/MSP9020hdi8ba18h005cd00002f81538eeddh95hb?MSPStoreType=image/gif&s=15'
|
113
|
+
alt='R (all real numbers)'
|
114
|
+
title='R (all real numbers)'
|
115
|
+
width='138'
|
116
|
+
height='18' />
|
117
|
+
<plaintext>R (all real numbers)</plaintext>
|
118
|
+
</subpod>
|
119
|
+
<subpod title='Range'>
|
120
|
+
<img src='http://www2.wolframalpha.com/Calculate/MSP/MSP9120hdi8ba18h005cd00003efe8f3290b61743?MSPStoreType=image/gif&s=15'
|
121
|
+
alt='{y element R : y>=0} (all non-negative real numbers)'
|
122
|
+
title='{y element R : y>=0} (all non-negative real numbers)'
|
123
|
+
width='312'
|
124
|
+
height='18' />
|
125
|
+
<plaintext>{y element R : y>=0} (all non-negative real numbers)</plaintext>
|
126
|
+
</subpod>
|
127
|
+
<subpod title='Parity'>
|
128
|
+
<img src='http://www2.wolframalpha.com/Calculate/MSP/MSP9220hdi8ba18h005cd00001i3728gb1b1cdb26?MSPStoreType=image/gif&s=15'
|
129
|
+
alt='even'
|
130
|
+
title='even'
|
131
|
+
width='30'
|
132
|
+
height='18' />
|
133
|
+
<plaintext>even</plaintext>
|
134
|
+
</subpod>
|
135
|
+
<infos count='1'>
|
136
|
+
<info text=' is the set of real numbers'>
|
137
|
+
<img src='http://www2.wolframalpha.com/Calculate/MSP/MSP9320hdi8ba18h005cd000047bc2d64ah9g1b58?MSPStoreType=image/gif&s=15'
|
138
|
+
alt=' is the set of real numbers'
|
139
|
+
title=' is the set of real numbers'
|
140
|
+
width='181'
|
141
|
+
height='18' />
|
142
|
+
<link url='http://reference.wolfram.com/mathematica/ref/Reals.html'
|
143
|
+
text='Documentation'
|
144
|
+
title='Documentation' />
|
145
|
+
<link url='http://mathworld.wolfram.com/R.html'
|
146
|
+
text='Definition'
|
147
|
+
title='MathWorld' />
|
148
|
+
</info>
|
149
|
+
</infos>
|
150
|
+
</pod>
|
151
|
+
<pod title='Derivative'
|
152
|
+
scanner='Derivative'
|
153
|
+
id='Derivative'
|
154
|
+
position='700'
|
155
|
+
error='false'
|
156
|
+
numsubpods='1'>
|
157
|
+
<subpod title=''>
|
158
|
+
<img src='http://www2.wolframalpha.com/Calculate/MSP/MSP9420hdi8ba18h005cd00000da6bbhh93292gfg?MSPStoreType=image/gif&s=15'
|
159
|
+
alt='d/dx(x^2) = 2 x'
|
160
|
+
title='d/dx(x^2) = 2 x'
|
161
|
+
width='86'
|
162
|
+
height='36' />
|
163
|
+
<plaintext>d/dx(x^2) = 2 x</plaintext>
|
164
|
+
</subpod>
|
165
|
+
<states count='1'>
|
166
|
+
<state name='Step-by-step solution'
|
167
|
+
input='Derivative__Step-by-step solution' />
|
168
|
+
</states>
|
169
|
+
</pod>
|
170
|
+
<pod title='Indefinite integral'
|
171
|
+
scanner='Integral'
|
172
|
+
id='IndefiniteIntegral'
|
173
|
+
position='800'
|
174
|
+
error='false'
|
175
|
+
numsubpods='1'
|
176
|
+
primary='true'>
|
177
|
+
<subpod title=''>
|
178
|
+
<img src='http://www2.wolframalpha.com/Calculate/MSP/MSP9520hdi8ba18h005cd00001i7gfg66abec9hhe?MSPStoreType=image/gif&s=15'
|
179
|
+
alt=' integral x^2 dx = x^3/3+constant'
|
180
|
+
title=' integral x^2 dx = x^3/3+constant'
|
181
|
+
width='166'
|
182
|
+
height='39' />
|
183
|
+
<plaintext> integral x^2 dx = x^3/3+constant</plaintext>
|
184
|
+
</subpod>
|
185
|
+
<states count='1'>
|
186
|
+
<state name='Step-by-step solution'
|
187
|
+
input='IndefiniteIntegral__Step-by-step solution' />
|
188
|
+
</states>
|
189
|
+
</pod>
|
190
|
+
<pod title='Global minimum'
|
191
|
+
scanner='GlobalExtrema'
|
192
|
+
id='GlobalMinimum'
|
193
|
+
position='900'
|
194
|
+
error='false'
|
195
|
+
numsubpods='1'>
|
196
|
+
<subpod title=''>
|
197
|
+
<img src='http://www2.wolframalpha.com/Calculate/MSP/MSP9620hdi8ba18h005cd000026056i7ifhai8972?MSPStoreType=image/gif&s=15'
|
198
|
+
alt='min{x^2} = 0 at x = 0'
|
199
|
+
title='min{x^2} = 0 at x = 0'
|
200
|
+
width='140'
|
201
|
+
height='22' />
|
202
|
+
<plaintext>min{x^2} = 0 at x = 0</plaintext>
|
203
|
+
</subpod>
|
204
|
+
</pod>
|
205
|
+
</queryresult>
|
@@ -31,6 +31,12 @@ describe Lita::Handlers::OnewheelWolframAlpha, :lita_handler => true do
|
|
31
31
|
expect(replies.last).to eq('Wolfram couldn\'t parse boopadoop.')
|
32
32
|
end
|
33
33
|
|
34
|
+
it 'will print plot for mathy things' do
|
35
|
+
mock_fixture('x^2')
|
36
|
+
send_command 'alpha x^2'
|
37
|
+
expect(replies.last).to eq('http://www2.wolframalpha.com/Calculate/MSP/MSP8620hdi8ba18h005cd0000268f85ce36b8h331?MSPStoreType=image/gif&s=15')
|
38
|
+
end
|
39
|
+
|
34
40
|
it 'will error missing config' do
|
35
41
|
registry.configure do |config|
|
36
42
|
config.handlers.onewheel_wolfram_alpha.api_uri = 'http://api.wolframalpha.com/v2/query?input=[query]&appid=[appid]'
|
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.1.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: 2016-01-
|
11
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- spec/fixtures/boopadoop.xml
|
157
157
|
- spec/fixtures/pi.xml
|
158
158
|
- spec/fixtures/whackadoo.xml
|
159
|
+
- spec/fixtures/x^2.xml
|
159
160
|
- spec/lita/handlers/onewheel_wolfram_alpha_spec.rb
|
160
161
|
- spec/spec_helper.rb
|
161
162
|
homepage: https://github.com/onewheelskyward/lita-onewheel-wolfram-alpha
|
@@ -187,5 +188,6 @@ test_files:
|
|
187
188
|
- spec/fixtures/boopadoop.xml
|
188
189
|
- spec/fixtures/pi.xml
|
189
190
|
- spec/fixtures/whackadoo.xml
|
191
|
+
- spec/fixtures/x^2.xml
|
190
192
|
- spec/lita/handlers/onewheel_wolfram_alpha_spec.rb
|
191
193
|
- spec/spec_helper.rb
|