From 240bf536fc2d6ae8a4aa851e09704ffbc92984a2 Mon Sep 17 00:00:00 2001 From: dB Date: Sun, 19 Jul 2015 14:10:02 -0400 Subject: [PATCH] Upgraded to slack-ruby-bot 0.3.0. --- .rubocop_todo.yml | 6 +++++- .travis.yml | 2 +- Gemfile | 4 ++-- Gemfile.lock | 6 +++--- slack-mathbot/commands/about.rb | 4 +++- slack-mathbot/commands/calculate.rb | 5 +++-- slack-mathbot/commands/help.rb | 2 +- 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6f0d38a..e1db15c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,5 +1,5 @@ # This configuration was generated by `rubocop --auto-gen-config` -# on 2015-07-09 16:07:58 -0400 using RuboCop version 0.31.0. +# on 2015-07-19 14:05:31 -0400 using RuboCop version 0.31.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -9,6 +9,10 @@ Lint/RescueException: Enabled: false +# Offense count: 1 +Metrics/AbcSize: + Max: 17 + # Offense count: 11 # Configuration parameters: AllowURI, URISchemes. Metrics/LineLength: diff --git a/.travis.yml b/.travis.yml index e6ba548..491fedc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,3 @@ rvm: - - 2.1.6 + - 2.2.0 diff --git a/Gemfile b/Gemfile index 402184f..706beac 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,8 @@ source 'http://rubygems.org' -ruby '2.1.6' +ruby '2.2.0' -gem 'slack-ruby-bot', '~> 0.2.0' +gem 'slack-ruby-bot', '~> 0.3.0' gem 'puma' gem 'sinatra' gem 'dentaku' diff --git a/Gemfile.lock b/Gemfile.lock index 0bf259c..725d866 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -42,7 +42,7 @@ GEM minitest (5.7.0) multi_json (1.11.2) multipart-post (2.0.0) - oj (2.12.9) + oj (2.12.10) parser (2.3.0.pre.2) ast (>= 1.1, < 3.0) powerpack (0.1.1) @@ -85,7 +85,7 @@ GEM faraday_middleware (~> 0.8) faye-websocket (~> 0.9.2) multi_json (~> 1.0, >= 1.0.3) - slack-ruby-bot (0.2.0) + slack-ruby-bot (0.3.0) activesupport giphy (~> 2.0.2) hashie @@ -116,6 +116,6 @@ DEPENDENCIES rspec rubocop (= 0.31.0) sinatra - slack-ruby-bot (~> 0.2.0) + slack-ruby-bot (~> 0.3.0) vcr webmock diff --git a/slack-mathbot/commands/about.rb b/slack-mathbot/commands/about.rb index f71bdff..7aaed2d 100644 --- a/slack-mathbot/commands/about.rb +++ b/slack-mathbot/commands/about.rb @@ -1,7 +1,9 @@ module SlackMathbot module Commands class Default < SlackRubyBot::Commands::Base - def self.call(data, _command, _arguments) + match(/^(?\w*)$/) + + def self.call(data, _match) send_message_with_gif data.channel, SlackMathbot::ABOUT, 'math' end end diff --git a/slack-mathbot/commands/calculate.rb b/slack-mathbot/commands/calculate.rb index 1a495af..15c7bbc 100644 --- a/slack-mathbot/commands/calculate.rb +++ b/slack-mathbot/commands/calculate.rb @@ -2,9 +2,10 @@ module SlackMathbot module Commands class Calculate < SlackRubyBot::Commands::Base operator '=' + command 'calculate' - def self.call(data, _command, arguments) - result = Dentaku::Calculator.new.evaluate(arguments.join) + def self.call(data, match) + result = Dentaku::Calculator.new.evaluate(match[:expression]) if match.names.include?('expression') result = result.to_s if result if result && result.length > 0 send_message data.channel, result diff --git a/slack-mathbot/commands/help.rb b/slack-mathbot/commands/help.rb index 7ca28d8..26c47d1 100644 --- a/slack-mathbot/commands/help.rb +++ b/slack-mathbot/commands/help.rb @@ -1,7 +1,7 @@ module SlackMathbot module Commands class Help < SlackRubyBot::Commands::Base - def self.call(data, _command, _arguments) + def self.call(data, _match) send_message_with_gif data.channel, 'See https://github.com/dblock/slack-mathbot, please.', 'help' end end