Skip to content

Commit

Permalink
Adding ability to add post script
Browse files Browse the repository at this point in the history
  • Loading branch information
onewheelskyward committed Sep 14, 2017
1 parent 9fee526 commit d3f06d6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
4 changes: 0 additions & 4 deletions lib/lita-onewheel-wolfram-alpha.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
require 'lita'

Lita.load_locales Dir[File.expand_path(
File.join('..', '..', 'locales', '*.yml'), __FILE__
)]

require 'lita/handlers/onewheel_wolfram_alpha'
8 changes: 8 additions & 0 deletions lib/lita/handlers/onewheel_wolfram_alpha.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ def handle_wolfram_query(response)
return
end
query = response.matches[0][0]

post_script = ''

if matches = query.match(/\<(.*)\>/)
post_script = " #{matches[1]}"
end

api_response = make_api_call query
reply = parse_response api_response, query
reply += post_script
Lita.logger.debug "lita-onewheel-wolfram-alpha: Replying with #{reply}"
response.reply reply
end
Expand Down
18 changes: 9 additions & 9 deletions lita-onewheel-wolfram-alpha.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = 'lita-onewheel-wolfram-alpha'
spec.version = '0.1.7'
spec.version = '0.2.0'
spec.authors = ['Andrew Kreps']
spec.email = ['andrew.kreps@gmail.com']
spec.description = %q{Lita interface to Wolfram Alpha.}
Expand All @@ -15,14 +15,14 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']

spec.add_runtime_dependency 'lita', '~> 4'
spec.add_runtime_dependency 'rest-client', '~> 1.8'
spec.add_runtime_dependency 'nokogiri', '~> 1.6'
spec.add_runtime_dependency 'rest-client', '~> 1'
spec.add_runtime_dependency 'nokogiri', '~> 1'

spec.add_development_dependency 'bundler', '~> 1.3'
spec.add_development_dependency 'bundler', '~> 1'
# spec.add_development_dependency 'pry-byebug', '~> 3.1'
spec.add_development_dependency 'rake', '~> 10.4'
spec.add_development_dependency 'rack-test', '~> 0.6'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'simplecov', '~> 0.10'
spec.add_development_dependency 'coveralls', '~> 0.8'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rack-test', '~> 0'
spec.add_development_dependency 'rspec', '~> 3'
spec.add_development_dependency 'simplecov', '~> 0'
spec.add_development_dependency 'coveralls', '~> 0'
end
6 changes: 6 additions & 0 deletions spec/lita/handlers/onewheel_wolfram_alpha_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ def mock_fixture(fixture)
send_command 'alpha light years'
expect(replies.last).to eq('1 ly | 0.3066 pc (parsecs) | 63241 au (astronomical units) | 9.461&#xD7;10^12 km (kilometers) | 9.461&#xD7;10^15 meters | 5.879 trillion miles')
end

it 'will add desired text to the end' do
mock_fixture('x^2')
send_command 'alpha x^2 <as a service>'
expect(replies.last).to eq('http://www2.wolframalpha.com/Calculate/MSP/MSP8620hdi8ba18h005cd0000268f85ce36b8h331?MSPStoreType=image/gif&s=15 as a service')
end
end

0 comments on commit d3f06d6

Please sign in to comment.