cinch-simplecalc 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +20 -1
- data/cinch-simplecalc.gemspec +12 -14
- data/lib/cinch/plugins/simplecalc.rb +19 -17
- data/lib/cinch/plugins/simplecalc/version.rb +1 -1
- data/spec/cinch-simplecalc_spec.rb +4 -6
- data/spec/spec_helper.rb +8 -2
- metadata +41 -48
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: d5b91f1195aeb4e77f9e4a92faa722fd31b88b9b
|
4
|
+
data.tar.gz: 9eb65e6fd52ee726ab40749fb8bfbb94a477a391
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 576309d61a78dd87f01ce88917809eb8aaca6901d5846c8c7dd453994b71a052dc023441466e9b8a7efae60dd0f68d09b83f8671910f9482bd0d91be98a0c815
|
7
|
+
data.tar.gz: ca0d4386a4d3f3e013de2ac64a3c468e9a9056f7900a1e59a13618a8ae7adcff40867e4f86d8426e1f9350c4ba6e422ef81eb4f53f6e25ef08cbb7ad93ea4ea1
|
data/.travis.yml
CHANGED
@@ -1,4 +1,23 @@
|
|
1
1
|
language: ruby
|
2
|
+
env:
|
3
|
+
global:
|
4
|
+
- "JRUBY_OPTS=-Xcext.enabled=true"
|
2
5
|
rvm:
|
3
|
-
- 1.
|
6
|
+
- 2.1.0
|
7
|
+
- 2.0.0
|
4
8
|
- 1.9.3
|
9
|
+
- 1.9.2
|
10
|
+
- 1.8.7
|
11
|
+
- jruby-18mode
|
12
|
+
- jruby-19mode
|
13
|
+
- ruby-head
|
14
|
+
- jruby-head
|
15
|
+
- ree
|
16
|
+
matrix:
|
17
|
+
allow_failures:
|
18
|
+
- rvm: 1.8.7
|
19
|
+
- rvm: ree
|
20
|
+
- rvm: jruby-18mode
|
21
|
+
- rvm: jruby-19mode
|
22
|
+
- rvm: jruby-head
|
23
|
+
fast_finish: true
|
data/cinch-simplecalc.gemspec
CHANGED
@@ -8,23 +8,21 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = Cinch::Plugins::Simplecalc::VERSION
|
9
9
|
gem.authors = ['Brian Haberer']
|
10
10
|
gem.email = ['bhaberer@gmail.com']
|
11
|
-
gem.description = %q
|
12
|
-
gem.summary = %q
|
11
|
+
gem.description = %q(Cinch Plugin that passes simple numeric math propblems to the Calc gem)
|
12
|
+
gem.summary = %q(Cinch Plugin to do simple math)
|
13
13
|
gem.homepage = 'https://github.com/bhaberer/cinch-simplecalc'
|
14
14
|
gem.license = 'MIT'
|
15
|
-
|
16
15
|
gem.files = `git ls-files`.split($/)
|
17
|
-
gem.executables = gem.files.grep(
|
18
|
-
gem.test_files = gem.files.grep(
|
16
|
+
gem.executables = gem.files.grep(/^bin\//).map { |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(/^(test|spec|features)\//)
|
19
18
|
gem.require_paths = ['lib']
|
20
19
|
|
21
|
-
gem.add_development_dependency
|
22
|
-
gem.add_development_dependency
|
23
|
-
gem.add_development_dependency
|
24
|
-
gem.add_development_dependency
|
25
|
-
|
26
|
-
gem.add_dependency
|
27
|
-
gem.add_dependency
|
28
|
-
gem.add_dependency
|
29
|
-
gem.add_dependency 'calc', '~> 1.0.0'
|
20
|
+
gem.add_development_dependency 'rake', '~> 10'
|
21
|
+
gem.add_development_dependency 'rspec', '~> 3'
|
22
|
+
gem.add_development_dependency 'coveralls', '~> 0.7'
|
23
|
+
gem.add_development_dependency 'cinch-test', '~> 0.1', '>= 0.1.0'
|
24
|
+
gem.add_dependency 'cinch', '~> 2'
|
25
|
+
gem.add_dependency 'cinch-cooldown', '~> 1.1', '>= 1.1.1'
|
26
|
+
gem.add_dependency 'cinch-toolbox', '~> 1.1'
|
27
|
+
gem.add_dependency 'calc', '~> 1'
|
30
28
|
end
|
@@ -3,29 +3,31 @@ require 'calc'
|
|
3
3
|
require 'cinch'
|
4
4
|
require 'cinch/cooldown'
|
5
5
|
|
6
|
-
module Cinch
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
module Cinch
|
7
|
+
module Plugins
|
8
|
+
# Simple Plugin to do quick math
|
9
|
+
class SimpleCalc
|
10
|
+
include Cinch::Plugin
|
10
11
|
|
11
|
-
|
12
|
+
enforce_cooldown
|
12
13
|
|
13
|
-
|
14
|
+
self.help = 'Use .math <problem> to do math. (i.e. .math 2 + 2)'
|
14
15
|
|
15
|
-
|
16
|
+
match(/math (.+)/)
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def execute(m, problem)
|
19
|
+
m.reply calc(problem), true
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
+
private
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
def calc(problem)
|
25
|
+
answer = Calc.evaluate(problem)
|
26
|
+
answer unless answer == problem
|
27
|
+
rescue ZeroDivisionError
|
28
|
+
# Rescue against people being cute.
|
29
|
+
"I'm sorry, Dave, I'm afraid I can't do that."
|
30
|
+
end
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -10,19 +10,17 @@ 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.text
|
14
|
-
.should == 'test: 4'
|
13
|
+
expect(get_replies(msg).last.text).to eq('test: 4')
|
15
14
|
end
|
16
15
|
|
17
16
|
it 'should strip all non numeric information from the string' do
|
18
17
|
msg = make_message(@bot, '!math cos 2')
|
19
|
-
get_replies(msg).last.text
|
20
|
-
.should == 'test: 2'
|
18
|
+
expect(get_replies(msg).last.text).to eq('test: 2')
|
21
19
|
end
|
22
20
|
|
23
21
|
it 'should crack wise if asked to do the impossible' do
|
24
22
|
msg = make_message(@bot, '!math 1 / 0')
|
25
|
-
get_replies(msg).last.text
|
26
|
-
.
|
23
|
+
expect(get_replies(msg).last.text)
|
24
|
+
.to eq('test: I\'m sorry, Dave, I\'m afraid I can\'t do that.')
|
27
25
|
end
|
28
26
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
require 'coveralls'
|
2
|
-
|
2
|
+
require 'simplecov'
|
3
|
+
|
4
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
+
SimpleCov::Formatter::HTMLFormatter,
|
6
|
+
Coveralls::SimpleCov::Formatter
|
7
|
+
]
|
8
|
+
SimpleCov.start
|
9
|
+
|
3
10
|
require 'cinch-simplecalc'
|
4
11
|
require 'cinch/test'
|
5
|
-
|
metadata
CHANGED
@@ -1,144 +1,139 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch-simplecalc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Brian Haberer
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
19
|
+
version: '10'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
26
|
+
version: '10'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
33
|
+
version: '3'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version: '
|
40
|
+
version: '3'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: coveralls
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
47
|
+
version: '0.7'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
54
|
+
version: '0.7'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: cinch-test
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.1'
|
67
62
|
- - ! '>='
|
68
63
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
64
|
+
version: 0.1.0
|
70
65
|
type: :development
|
71
66
|
prerelease: false
|
72
67
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
68
|
requirements:
|
69
|
+
- - ~>
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0.1'
|
75
72
|
- - ! '>='
|
76
73
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
74
|
+
version: 0.1.0
|
78
75
|
- !ruby/object:Gem::Dependency
|
79
76
|
name: cinch
|
80
77
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
78
|
requirements:
|
83
79
|
- - ~>
|
84
80
|
- !ruby/object:Gem::Version
|
85
|
-
version: 2
|
81
|
+
version: '2'
|
86
82
|
type: :runtime
|
87
83
|
prerelease: false
|
88
84
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
85
|
requirements:
|
91
86
|
- - ~>
|
92
87
|
- !ruby/object:Gem::Version
|
93
|
-
version: 2
|
88
|
+
version: '2'
|
94
89
|
- !ruby/object:Gem::Dependency
|
95
|
-
name: cinch-
|
90
|
+
name: cinch-cooldown
|
96
91
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
92
|
requirements:
|
99
93
|
- - ~>
|
100
94
|
- !ruby/object:Gem::Version
|
101
|
-
version: 1.1
|
95
|
+
version: '1.1'
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 1.1.1
|
102
99
|
type: :runtime
|
103
100
|
prerelease: false
|
104
101
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
102
|
requirements:
|
107
103
|
- - ~>
|
108
104
|
- !ruby/object:Gem::Version
|
109
|
-
version: 1.1
|
105
|
+
version: '1.1'
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: 1.1.1
|
110
109
|
- !ruby/object:Gem::Dependency
|
111
|
-
name: cinch-
|
110
|
+
name: cinch-toolbox
|
112
111
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
112
|
requirements:
|
115
113
|
- - ~>
|
116
114
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.1
|
115
|
+
version: '1.1'
|
118
116
|
type: :runtime
|
119
117
|
prerelease: false
|
120
118
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
119
|
requirements:
|
123
120
|
- - ~>
|
124
121
|
- !ruby/object:Gem::Version
|
125
|
-
version: 1.1
|
122
|
+
version: '1.1'
|
126
123
|
- !ruby/object:Gem::Dependency
|
127
124
|
name: calc
|
128
125
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
126
|
requirements:
|
131
127
|
- - ~>
|
132
128
|
- !ruby/object:Gem::Version
|
133
|
-
version: 1
|
129
|
+
version: '1'
|
134
130
|
type: :runtime
|
135
131
|
prerelease: false
|
136
132
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
133
|
requirements:
|
139
134
|
- - ~>
|
140
135
|
- !ruby/object:Gem::Version
|
141
|
-
version: 1
|
136
|
+
version: '1'
|
142
137
|
description: Cinch Plugin that passes simple numeric math propblems to the Calc gem
|
143
138
|
email:
|
144
139
|
- bhaberer@gmail.com
|
@@ -161,29 +156,27 @@ files:
|
|
161
156
|
homepage: https://github.com/bhaberer/cinch-simplecalc
|
162
157
|
licenses:
|
163
158
|
- MIT
|
159
|
+
metadata: {}
|
164
160
|
post_install_message:
|
165
161
|
rdoc_options: []
|
166
162
|
require_paths:
|
167
163
|
- lib
|
168
164
|
required_ruby_version: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
165
|
requirements:
|
171
166
|
- - ! '>='
|
172
167
|
- !ruby/object:Gem::Version
|
173
168
|
version: '0'
|
174
169
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
-
none: false
|
176
170
|
requirements:
|
177
171
|
- - ! '>='
|
178
172
|
- !ruby/object:Gem::Version
|
179
173
|
version: '0'
|
180
174
|
requirements: []
|
181
175
|
rubyforge_project:
|
182
|
-
rubygems_version:
|
176
|
+
rubygems_version: 2.2.2
|
183
177
|
signing_key:
|
184
|
-
specification_version:
|
178
|
+
specification_version: 4
|
185
179
|
summary: Cinch Plugin to do simple math
|
186
180
|
test_files:
|
187
181
|
- spec/cinch-simplecalc_spec.rb
|
188
182
|
- spec/spec_helper.rb
|
189
|
-
has_rdoc:
|