cinch-calculate 1.0.0 → 1.0.5

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/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'cinch-test', :git => 'git://github.com/jayferd/cinch-test'
4
3
  # Specify your gem's dependencies in cinch-calculate.gemspec
5
4
  gemspec
data/README.md CHANGED
@@ -39,11 +39,11 @@ alternate location.
39
39
 
40
40
  c.plugins.options[Cinch::Plugins::Calculate][:units_path] = '/usr/bin/gunits'
41
41
 
42
- Once that's all done, just use .math in the channel.
42
+ Once that's all done, just use !math in the channel.
43
43
 
44
- 17:31 <@xentrac> .math 1000 W/m^2 * pi * earthradius^2
44
+ 17:31 <@xentrac> !math 1000 W/m^2 * pi * earthradius^2
45
45
  17:31 < marvin> xentrac: 1.2751652e+17 kg m^2 / s^3
46
- 17:31 <@xentrac> .math (1000 W/m^2 * pi * earthradius^2) / (quadrillion btu / year)
46
+ 17:31 <@xentrac> !math (1000 W/m^2 * pi * earthradius^2) / (quadrillion btu / year)
47
47
  17:31 < marvin> xentrac: 3814043.9
48
48
 
49
49
 
@@ -4,21 +4,25 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'cinch/plugins/calculate/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
- gem.name = "cinch-calculate"
7
+ gem.name = 'cinch-calculate'
8
8
  gem.version = Cinch::Plugins::Calculate::VERSION
9
- gem.authors = ["Brian Haberer", "Paul Visscher"]
10
- gem.email = ["bhaberer@gmail.com"]
9
+ gem.authors = ['Brian Haberer', 'Paul Visscher']
10
+ gem.email = ['bhaberer@gmail.com']
11
11
  gem.description = %q{Cinch Plugin to alow users to pass mathematical problems to the bot for evaluation}
12
12
  gem.summary = %q{Cinch Plugin for Math}
13
- gem.homepage = "https://github.com/canonical-hackers/cinch-calculate"
13
+ gem.homepage = 'https://github.com/canonical-hackers/cinch-calculate'
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 = ["lib"]
19
+ gem.require_paths = ['lib']
19
20
 
20
21
  gem.add_development_dependency 'rake'
21
22
  gem.add_development_dependency 'rspec'
22
23
  gem.add_development_dependency 'coveralls'
23
24
  gem.add_development_dependency 'cinch-test'
25
+
26
+ gem.add_dependency 'cinch', '~> 2.0.12'
27
+ gem.add_dependency 'cinch-cooldown', '~> 1.1.1'
24
28
  end
@@ -1,2 +1,3 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  require 'cinch/plugins/calculate/version'
2
- require 'cinch/plugins/calculate/calculate'
3
+ require 'cinch/plugins/calculate'
@@ -1,10 +1,16 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  require 'cinch'
3
+ require 'cinch/cooldown'
2
4
 
3
5
  module Cinch::Plugins
6
+ # Cinch plugin to allow complex math calculations to be done.
4
7
  class Calculate
5
8
  include Cinch::Plugin
6
9
 
7
- self.help = "Use .math <problem> to do math computations. (e.g. 5 feet / inches, .math sin(2) + 4)"
10
+ self.help = 'Use .math <problem> to do math computations.' +
11
+ '(e.g. 5 feet / inches, .math sin(2) + 4)'
12
+
13
+ enforce_cooldown
8
14
 
9
15
  match /math (.+)/
10
16
 
@@ -21,14 +27,15 @@ module Cinch::Plugins
21
27
 
22
28
  def math(problem_string)
23
29
  return 'Sorry, I can\'t do that' unless units_binary_exists?
24
- return IO.popen([@units_path, "-t", problem_string]).readline
30
+ return IO.popen([@units_path, "-t", problem_string]).readline.chomp
25
31
  rescue EOFError
26
- debug "Make sure you have GNU Units installed and not the BSD Units that ships with OSX."
32
+ debug 'Make sure you have GNU Units installed ' +
33
+ 'and not the BSD Units that ships with OSX.'
27
34
  end
28
35
 
29
36
  def units_binary_exists?
30
37
  return true if File.exist? @units_path
31
- debug "Cinch can't find the unit conversion binary."
38
+ debug 'Cinch can\'t find the unit conversion binary.'
32
39
  false
33
40
  end
34
41
  end
@@ -1,7 +1,9 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  module Cinch
2
3
  module Plugins
4
+ # Versioning info
3
5
  class Calculate
4
- VERSION = "1.0.0"
6
+ VERSION = '1.0.5'
5
7
  end
6
8
  end
7
9
  end
@@ -11,17 +11,13 @@ describe Cinch::Plugins::Calculate do
11
11
  describe 'configuration' do
12
12
  it 'should handle units binary not existing gracefully' do
13
13
  @bot = make_bot(Cinch::Plugins::Calculate, { :units_path => '/usr/baddir/units' })
14
- msg = make_message(@bot, '!math 2 + 2')
15
-
16
- get_replies(msg).last.chomp.
14
+ get_replies(make_message(@bot, '!math 2 + 2')).last.text.
17
15
  should == 'test: Sorry, I can\'t do that'
18
16
  end
19
17
  end
20
18
 
21
19
  it 'should allow basic math' do
22
- msg = make_message(@bot, '!math 2 + 2')
23
-
24
- get_replies(msg).last.chomp.
20
+ get_replies(make_message(@bot, '!math 2 + 2')).last.text.
25
21
  should == 'test: 4'
26
22
  end
27
23
  end
@@ -1,5 +1,11 @@
1
1
  require 'coveralls'
2
- Coveralls.wear!
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-calculate'
4
11
  require 'cinch/test'
5
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch-calculate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-06-26 00:00:00.000000000 Z
13
+ date: 2014-02-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -76,6 +76,38 @@ dependencies:
76
76
  - - ! '>='
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: cinch
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ~>
85
+ - !ruby/object:Gem::Version
86
+ version: 2.0.12
87
+ type: :runtime
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ version: 2.0.12
95
+ - !ruby/object:Gem::Dependency
96
+ name: cinch-cooldown
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ~>
101
+ - !ruby/object:Gem::Version
102
+ version: 1.1.1
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 1.1.1
79
111
  description: Cinch Plugin to alow users to pass mathematical problems to the bot for
80
112
  evaluation
81
113
  email:
@@ -92,12 +124,13 @@ files:
92
124
  - Rakefile
93
125
  - cinch-calculate.gemspec
94
126
  - lib/cinch-calculate.rb
95
- - lib/cinch/plugins/calculate/calculate.rb
127
+ - lib/cinch/plugins/calculate.rb
96
128
  - lib/cinch/plugins/calculate/version.rb
97
129
  - spec/cinch-calculate_spec.rb
98
130
  - spec/spec_helper.rb
99
131
  homepage: https://github.com/canonical-hackers/cinch-calculate
100
- licenses: []
132
+ licenses:
133
+ - MIT
101
134
  post_install_message:
102
135
  rdoc_options: []
103
136
  require_paths:
@@ -116,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
149
  version: '0'
117
150
  requirements: []
118
151
  rubyforge_project:
119
- rubygems_version: 1.8.24
152
+ rubygems_version: 1.8.25
120
153
  signing_key:
121
154
  specification_version: 3
122
155
  summary: Cinch Plugin for Math