lita-onewheel-wolfram-alpha 0.2.1 → 0.4.1

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
- SHA1:
3
- metadata.gz: 32f165223ed798c71dafcababc7e61e9121cec19
4
- data.tar.gz: a427b47198e411447fe81f15741dc27eb034192e
2
+ SHA256:
3
+ metadata.gz: ddedf066ed989639187331b05e4c09e2d735238ac2ea1c47d07e26c00478b130
4
+ data.tar.gz: 3e9d754aeb0d48a17cde5b4ad8269fde45bd01df47707087d292007074a91a42
5
5
  SHA512:
6
- metadata.gz: 2431c58259e5c55a4a389a3d1d6ba7c32fc02c32f400a45899d6e589f5a32656f4101a03c89d997ef0d8b7b7bc54df2f50321dc8ae38407a3900dd5ac8d9849f
7
- data.tar.gz: df846985f7afd31f8b8513984bd084b540745d141126ec975722bbe5d48bf7e9c0da1ac5ab52a2f70bbb16a53b6298ff247f95a03a36f8e31a8872763712cd0a
6
+ metadata.gz: 9df98af793616a13235b2a49d1f80f8ca6d10454eea4fb0bc415021dab656014a12ef9170c275f90eff222aeef7c8a0a97a5108fe955126ab145ffd8890817e6
7
+ data.tar.gz: dcd21e22c1f202bb9352feb01db60061c0d819d9b0df4839ceb734e219f2e00e11d552329dd369af2519dceae70713a365b7581b7dcda3544bd3a37340ea108c
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.4
4
3
  - 2.3.0
4
+ - 2.4.2
5
5
  script: bundle exec rake
6
6
  before_install:
7
7
  - gem update --system
@@ -8,6 +8,12 @@ module Lita
8
8
  config :api_uri
9
9
 
10
10
  route(/^alpha\s*(.*)/i, :handle_wolfram_query, command: true)
11
+ route(/^quote\s*(.*)/i, :handle_wolfram_quote, command: true)
12
+
13
+ def handle_wolfram_quote(response)
14
+ response.matches[0][0] = "quote #{response.matches[0][0]}"
15
+ handle_wolfram_query(response)
16
+ end
11
17
 
12
18
  def handle_wolfram_query(response)
13
19
  unless config.app_id and config.api_uri
@@ -19,10 +25,16 @@ module Lita
19
25
  post_script = ''
20
26
 
21
27
  if matches = query.match(/\<(.*)\>/)
22
- query.gsub! /\<#{matches[1]}\>/, ''
28
+ Lita.logger.debug "Megamatch: #{matches[1]}"
29
+ query.gsub! /\<.*\>/, ''
23
30
  post_script = " #{matches[1]}"
24
31
  end
25
32
 
33
+ # fraction hack
34
+ if query.match /\// and !query.match /\./
35
+ query += ".0"
36
+ end
37
+
26
38
  api_response = make_api_call query
27
39
  reply = parse_response api_response, query
28
40
  reply += post_script
@@ -62,8 +74,9 @@ module Lita
62
74
  def make_api_call(query)
63
75
  Lita.logger.debug "lita-onewheel-wolfram-alpha: Making api call for #{query}"
64
76
  uri = build_uri query
77
+ Lita.logger.debug "lita-onewheel-wolfram-alpha: #{uri}"
65
78
  response = RestClient.get(uri)
66
- Lita.logger.debug 'lita-onewheel-wolfram-alpha: ' + response.to_s
79
+ #Lita.logger.debug 'lita-onewheel-wolfram-alpha: ' + response.to_s
67
80
  Nokogiri::XML response.to_s
68
81
  end
69
82
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-onewheel-wolfram-alpha'
3
- spec.version = '0.2.1'
3
+ spec.version = '0.4.1'
4
4
  spec.authors = ['Andrew Kreps']
5
5
  spec.email = ['andrew.kreps@gmail.com']
6
6
  spec.description = %q{Lita interface to Wolfram Alpha.}
@@ -15,12 +15,12 @@ Gem::Specification.new do |spec|
15
15
  spec.require_paths = ['lib']
16
16
 
17
17
  spec.add_runtime_dependency 'lita', '~> 4'
18
- spec.add_runtime_dependency 'rest-client', '~> 1'
18
+ spec.add_runtime_dependency 'rest-client', '~> 2'
19
19
  spec.add_runtime_dependency 'nokogiri', '~> 1'
20
20
 
21
- spec.add_development_dependency 'bundler', '~> 1'
21
+ spec.add_development_dependency 'bundler', '~> 2'
22
22
  # spec.add_development_dependency 'pry-byebug', '~> 3.1'
23
- spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'rake', '~> 12'
24
24
  spec.add_development_dependency 'rack-test', '~> 0'
25
25
  spec.add_development_dependency 'rspec', '~> 3'
26
26
  spec.add_development_dependency 'simplecov', '~> 0'
@@ -18,6 +18,7 @@ describe Lita::Handlers::OnewheelWolframAlpha, :lita_handler => true do
18
18
  end
19
19
 
20
20
  it { is_expected.to route_command('alpha') }
21
+ it { is_expected.to route_command('quote') }
21
22
 
22
23
  it 'will work' do
23
24
  mock_fixture('pi')
@@ -61,4 +62,16 @@ describe Lita::Handlers::OnewheelWolframAlpha, :lita_handler => true do
61
62
  send_command 'alpha x^2 <as a service>'
62
63
  expect(replies.last).to eq('http://www2.wolframalpha.com/Calculate/MSP/MSP8620hdi8ba18h005cd0000268f85ce36b8h331?MSPStoreType=image/gif&s=15 as a service')
63
64
  end
65
+
66
+ it 'will add .0 to a fraction' do
67
+ mock_fixture('oneovertwo')
68
+ send_command 'alpha 1/2'
69
+ expect(replies.last).to eq('0.5')
70
+ end
71
+
72
+ it 'will quote' do
73
+ mock_fixture('quote')
74
+ send_command 'quote amzn'
75
+ expect(replies.last).to eq('x')
76
+ end
64
77
  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.2.1
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kreps
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-14 00:00:00.000000000 Z
11
+ date: 2019-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1'
33
+ version: '2'
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: '2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: nokogiri
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1'
61
+ version: '2'
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: '2'
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: '0'
75
+ version: '12'
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: '0'
82
+ version: '12'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rack-test
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -180,8 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
180
  - !ruby/object:Gem::Version
181
181
  version: '0'
182
182
  requirements: []
183
- rubyforge_project:
184
- rubygems_version: 2.6.11
183
+ rubygems_version: 3.1.2
185
184
  signing_key:
186
185
  specification_version: 4
187
186
  summary: Summarize THIS!