cinch-calculate 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ before_install:
6
+ - sudo apt-get install units
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'cinch-test', :git => 'git://github.com/jayferd/cinch-test'
3
4
  # Specify your gem's dependencies in cinch-calculate.gemspec
4
5
  gemspec
data/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Cinch::Plugins::Calculate
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/cinch-calculate.png)](http://badge.fury.io/rb/cinch-calculate)
4
+ [![Dependency Status](https://gemnasium.com/canonical-hackers/cinch-calculate.png)](https://gemnasium.com/canonical-hackers/cinch-calculate)
5
+ [![Build Status](https://travis-ci.org/canonical-hackers/cinch-calculate.png?branch=master)](https://travis-ci.org/canonical-hackers/cinch-calculate)
6
+ [![Coverage Status](https://coveralls.io/repos/canonical-hackers/cinch-calculate/badge.png?branch=master)](https://coveralls.io/r/canonical-hackers/cinch-calculate?branch=master)
7
+ [![Code Climate](https://codeclimate.com/github/canonical-hackers/cinch-calculate.png)](https://codeclimate.com/github/canonical-hackers/cinch-calculate)
8
+
3
9
  Plugin that alows users to find the answers to math problems.
4
10
 
5
11
  ## Installation
@@ -35,6 +41,12 @@ alternate location.
35
41
 
36
42
  Once that's all done, just use .math in the channel.
37
43
 
44
+ 17:31 <@xentrac> .math 1000 W/m^2 * pi * earthradius^2
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)
47
+ 17:31 < marvin> xentrac: 3814043.9
48
+
49
+
38
50
  ## Contributing
39
51
 
40
52
  1. Fork it
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -6,7 +6,7 @@ require 'cinch/plugins/calculate/version'
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = "cinch-calculate"
8
8
  gem.version = Cinch::Plugins::Calculate::VERSION
9
- gem.authors = ["Brian Haberer"]
9
+ gem.authors = ["Brian Haberer", "Paul Visscher"]
10
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}
@@ -16,4 +16,9 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency 'rake'
21
+ gem.add_development_dependency 'rspec'
22
+ gem.add_development_dependency 'coveralls'
23
+ gem.add_development_dependency 'cinch-test'
19
24
  end
@@ -1,3 +1,5 @@
1
+ require 'cinch'
2
+
1
3
  module Cinch::Plugins
2
4
  class Calculate
3
5
  include Cinch::Plugin
@@ -19,15 +21,9 @@ module Cinch::Plugins
19
21
 
20
22
  def math(problem_string)
21
23
  return 'Sorry, I can\'t do that' unless units_binary_exists?
22
-
23
- units_output = IO.popen([@units_path, "-t", problem_string])
24
-
25
- return units_output.readline.chomp!
24
+ return IO.popen([@units_path, "-t", problem_string]).readline
26
25
  rescue EOFError
27
- # If you don't have GNU Units installed you will get this error.
28
- debug "Your copy of Units did not produce useful output."
29
26
  debug "Make sure you have GNU Units installed and not the BSD Units that ships with OSX."
30
- return 'Sorry, I can\'t do that'
31
27
  end
32
28
 
33
29
  def units_binary_exists?
@@ -1,7 +1,7 @@
1
1
  module Cinch
2
2
  module Plugins
3
3
  class Calculate
4
- VERSION = "0.0.1"
4
+ VERSION = "1.0.0"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cinch::Plugins::Calculate do
4
+
5
+ include Cinch::Test
6
+
7
+ before(:each) do
8
+ @bot = make_bot(Cinch::Plugins::Calculate)
9
+ end
10
+
11
+ describe 'configuration' do
12
+ it 'should handle units binary not existing gracefully' do
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.
17
+ should == 'test: Sorry, I can\'t do that'
18
+ end
19
+ end
20
+
21
+ it 'should allow basic math' do
22
+ msg = make_message(@bot, '!math 2 + 2')
23
+
24
+ get_replies(msg).last.chomp.
25
+ should == 'test: 4'
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+ require 'cinch-calculate'
4
+ require 'cinch/test'
5
+
metadata CHANGED
@@ -1,16 +1,81 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch-calculate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Brian Haberer
9
+ - Paul Visscher
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2013-05-06 00:00:00.000000000 Z
13
- dependencies: []
13
+ date: 2013-06-26 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rake
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: rspec
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: coveralls
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: cinch-test
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
14
79
  description: Cinch Plugin to alow users to pass mathematical problems to the bot for
15
80
  evaluation
16
81
  email:
@@ -20,6 +85,7 @@ extensions: []
20
85
  extra_rdoc_files: []
21
86
  files:
22
87
  - .gitignore
88
+ - .travis.yml
23
89
  - Gemfile
24
90
  - LICENSE.txt
25
91
  - README.md
@@ -28,6 +94,8 @@ files:
28
94
  - lib/cinch-calculate.rb
29
95
  - lib/cinch/plugins/calculate/calculate.rb
30
96
  - lib/cinch/plugins/calculate/version.rb
97
+ - spec/cinch-calculate_spec.rb
98
+ - spec/spec_helper.rb
31
99
  homepage: https://github.com/canonical-hackers/cinch-calculate
32
100
  licenses: []
33
101
  post_install_message:
@@ -52,4 +120,7 @@ rubygems_version: 1.8.24
52
120
  signing_key:
53
121
  specification_version: 3
54
122
  summary: Cinch Plugin for Math
55
- test_files: []
123
+ test_files:
124
+ - spec/cinch-calculate_spec.rb
125
+ - spec/spec_helper.rb
126
+ has_rdoc: