cinch-simplecalc 1.0.0 → 1.0.1
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.
data/cinch-simplecalc.gemspec
CHANGED
@@ -4,18 +4,19 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'cinch/plugins/simplecalc/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
|
-
gem.name =
|
7
|
+
gem.name = 'cinch-simplecalc'
|
8
8
|
gem.version = Cinch::Plugins::Simplecalc::VERSION
|
9
|
-
gem.authors = [
|
10
|
-
gem.email = [
|
9
|
+
gem.authors = ['Brian Haberer']
|
10
|
+
gem.email = ['bhaberer@gmail.com']
|
11
11
|
gem.description = %q{Cinch Plugin that passes simple numeric math propblems to the Calc gem}
|
12
12
|
gem.summary = %q{Cinch Plugin to do simple math}
|
13
|
-
gem.homepage =
|
13
|
+
gem.homepage = 'https://github.com/bhaberer/cinch-simplecalc'
|
14
|
+
gem.license = 'MIT'
|
14
15
|
|
15
16
|
gem.files = `git ls-files`.split($/)
|
16
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
-
gem.require_paths = [
|
19
|
+
gem.require_paths = ['lib']
|
19
20
|
|
20
21
|
gem.add_development_dependency 'rake'
|
21
22
|
gem.add_development_dependency 'rspec'
|
@@ -24,6 +25,6 @@ Gem::Specification.new do |gem|
|
|
24
25
|
gem.add_dependency 'cinch', '~> 2.0.5'
|
25
26
|
gem.add_dependency 'cinch-test', '~> 0.0.3'
|
26
27
|
gem.add_dependency 'cinch-toolbox', '~> 1.0.0'
|
27
|
-
gem.add_dependency 'cinch-cooldown', '~> 1.
|
28
|
+
gem.add_dependency 'cinch-cooldown', '~> 1.1.1'
|
28
29
|
gem.add_dependency 'calc', '~> 1.0.0'
|
29
30
|
end
|
data/lib/cinch-simplecalc.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
require 'calc'
|
2
3
|
require 'cinch'
|
3
|
-
require 'cinch
|
4
|
+
require 'cinch/cooldown'
|
4
5
|
|
5
6
|
module Cinch::Plugins
|
7
|
+
# Simple Plugin to do quick math
|
6
8
|
class SimpleCalc
|
7
9
|
include Cinch::Plugin
|
8
10
|
|
9
11
|
enforce_cooldown
|
10
12
|
|
11
|
-
self.help =
|
13
|
+
self.help = 'Use .math <problem> to do math. (i.e. .math 2 + 2)'
|
12
14
|
|
13
15
|
match /math (.+)/
|
14
16
|
|
@@ -20,9 +22,10 @@ module Cinch::Plugins
|
|
20
22
|
|
21
23
|
def calc(problem)
|
22
24
|
answer = Calc.evaluate(problem)
|
23
|
-
|
25
|
+
answer unless answer == problem
|
24
26
|
rescue ZeroDivisionError
|
25
|
-
|
27
|
+
# Rescue against people being cute.
|
28
|
+
"I'm sorry, Dave, I'm afraid I can't do that."
|
26
29
|
end
|
27
30
|
end
|
28
31
|
end
|
@@ -10,19 +10,19 @@ describe Cinch::Plugins::SimpleCalc do
|
|
10
10
|
|
11
11
|
it 'should allow users to perform simple math' do
|
12
12
|
msg = make_message(@bot, '!math 2 + 2')
|
13
|
-
get_replies(msg).last.
|
14
|
-
should == 'test: 4'
|
13
|
+
get_replies(msg).last.text
|
14
|
+
.should == 'test: 4'
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should strip all non numeric information from the string' do
|
18
18
|
msg = make_message(@bot, '!math cos 2')
|
19
|
-
get_replies(msg).last.
|
20
|
-
should == 'test: 2'
|
19
|
+
get_replies(msg).last.text
|
20
|
+
.should == 'test: 2'
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'should crack wise if asked to do the impossible' do
|
24
24
|
msg = make_message(@bot, '!math 1 / 0')
|
25
|
-
get_replies(msg).last.
|
26
|
-
should == 'test:
|
25
|
+
get_replies(msg).last.text
|
26
|
+
.should == 'test: I\'m sorry, Dave, I\'m afraid I can\'t do that.'
|
27
27
|
end
|
28
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch-simplecalc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -114,7 +114,7 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.
|
117
|
+
version: 1.1.1
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
requirements:
|
123
123
|
- - ~>
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 1.
|
125
|
+
version: 1.1.1
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: calc
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,12 +154,13 @@ files:
|
|
154
154
|
- Rakefile
|
155
155
|
- cinch-simplecalc.gemspec
|
156
156
|
- lib/cinch-simplecalc.rb
|
157
|
-
- lib/cinch/plugins/simplecalc
|
157
|
+
- lib/cinch/plugins/simplecalc.rb
|
158
158
|
- lib/cinch/plugins/simplecalc/version.rb
|
159
159
|
- spec/cinch-simplecalc_spec.rb
|
160
160
|
- spec/spec_helper.rb
|
161
161
|
homepage: https://github.com/bhaberer/cinch-simplecalc
|
162
|
-
licenses:
|
162
|
+
licenses:
|
163
|
+
- MIT
|
163
164
|
post_install_message:
|
164
165
|
rdoc_options: []
|
165
166
|
require_paths:
|
@@ -178,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
179
|
version: '0'
|
179
180
|
requirements: []
|
180
181
|
rubyforge_project:
|
181
|
-
rubygems_version: 1.8.
|
182
|
+
rubygems_version: 1.8.25
|
182
183
|
signing_key:
|
183
184
|
specification_version: 3
|
184
185
|
summary: Cinch Plugin to do simple math
|