cinch-convert 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-convert.gemspec +9 -10
- data/lib/cinch/plugins/convert.rb +39 -37
- data/lib/cinch/plugins/convert/version.rb +1 -1
- metadata +27 -34
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: 2cabb397e9f3cbff9787e40b91e2025d76f325d8
|
4
|
+
data.tar.gz: 279498c8d6848f1bf2a1f6e75132c63414d1476e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e5bcc92da5fcbf04ee7edc0f3baca4778d8ccec0f4cac965a3cde9d5220c963c1fa9fd7009a462ffba87ab86b8ed256b915032f767d60a304b035b9da33aae66
|
7
|
+
data.tar.gz: 2841644c826271651b44955f8d64cdd27980b1bf4c117324f7be2318a54ee83ced08ce54a170b70384d2d71eccae10e421b5617b8f46a043d09860d0a89c0183
|
data/.travis.yml
CHANGED
@@ -1,6 +1,25 @@
|
|
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
|
5
24
|
before_install:
|
6
25
|
- sudo apt-get install units
|
data/cinch-convert.gemspec
CHANGED
@@ -8,20 +8,19 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = Cinch::Plugins::Convert::VERSION
|
9
9
|
gem.authors = ['Brian Haberer', 'Paul Visscher']
|
10
10
|
gem.email = ['bhaberer@gmail.com']
|
11
|
-
gem.description = %q
|
12
|
-
gem.summary = %q
|
11
|
+
gem.description = %q(Cinch Plugin for Coverting Units via the units binary)
|
12
|
+
gem.summary = %q(Cinch Plugin for converting units)
|
13
13
|
gem.homepage = 'https://github.com/canonical-hackers/cinch-convert'
|
14
14
|
gem.license = 'MIT'
|
15
15
|
|
16
16
|
gem.files = `git ls-files`.split($/)
|
17
|
-
gem.executables = gem.files.grep(
|
18
|
-
gem.test_files = gem.files.grep(
|
17
|
+
gem.executables = gem.files.grep(/^bin\//).map { |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(/^(test|spec|features)\//)
|
19
19
|
gem.require_paths = ['lib']
|
20
20
|
|
21
|
-
gem.add_development_dependency 'rake'
|
22
|
-
gem.add_development_dependency 'rspec'
|
23
|
-
gem.add_development_dependency 'coveralls'
|
24
|
-
gem.add_development_dependency 'cinch-test'
|
25
|
-
|
26
|
-
gem.add_dependency 'cinch', '~> 2.0.12'
|
21
|
+
gem.add_development_dependency 'rake', '~> 0.9'
|
22
|
+
gem.add_development_dependency 'rspec', '~> 3'
|
23
|
+
gem.add_development_dependency 'coveralls', '~> 0.7'
|
24
|
+
gem.add_development_dependency 'cinch-test', '~> 0.0', '>= 0.0.2'
|
25
|
+
gem.add_dependency 'cinch', '~> 2'
|
27
26
|
end
|
@@ -1,55 +1,57 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require 'cinch'
|
3
3
|
|
4
|
-
module Cinch
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
module Cinch
|
5
|
+
module Plugins
|
6
|
+
# Cinch Plugin to convert units
|
7
|
+
class Convert
|
8
|
+
include Cinch::Plugin
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
self.help = 'Use .convert <thing 1> to <thing 2> to do a unit ' \
|
11
|
+
'conversion. (e.g. .convert 5 feet to meters)'
|
11
12
|
|
12
|
-
|
13
|
+
match(/convert (.+) to (.+)/)
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
def initialize(*args)
|
16
|
+
super
|
17
|
+
@units_path = config[:units_path] || '/usr/bin/units'
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
def execute(m, from, to)
|
21
|
+
m.reply convert(from, to), true
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
+
private
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
def convert(from, to)
|
27
|
+
return "Sorry, there's a configuration issue." unless units_bin_exists?
|
28
|
+
return if from.nil? || to.nil?
|
28
29
|
|
29
|
-
|
30
|
+
units_line = get_units_output(from, to)
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
if units_line.match(/Unknown unit/)
|
33
|
+
"Sorry, #{units_line.downcase}."
|
34
|
+
elsif units_line.match(/conformability error/)
|
35
|
+
'Sorry, there was an error when making that conversion.'
|
36
|
+
else
|
37
|
+
"#{from} is #{units_line} #{to}."
|
38
|
+
end
|
37
39
|
end
|
38
|
-
end
|
39
40
|
|
40
|
-
|
41
|
-
|
41
|
+
def get_units_output(from, to)
|
42
|
+
units_output = IO.popen([@units_path, '-t', from, to])
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
# we only take one line here because the first line of output is
|
45
|
+
# either an error message or the part of the conversion output we
|
46
|
+
# want.
|
47
|
+
units_output.readline.chomp!
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
def units_bin_exists?
|
51
|
+
return true if File.exist? @units_path
|
52
|
+
debug 'Cinch can not find the unit conversion binary.'
|
53
|
+
false
|
54
|
+
end
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch-convert
|
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
|
@@ -10,88 +9,84 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2014-
|
12
|
+
date: 2014-07-30 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: rake
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - ~>
|
21
19
|
- !ruby/object:Gem::Version
|
22
|
-
version: '0'
|
20
|
+
version: '0.9'
|
23
21
|
type: :development
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
|
-
- -
|
25
|
+
- - ~>
|
29
26
|
- !ruby/object:Gem::Version
|
30
|
-
version: '0'
|
27
|
+
version: '0.9'
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
29
|
name: rspec
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
|
-
- -
|
32
|
+
- - ~>
|
37
33
|
- !ruby/object:Gem::Version
|
38
|
-
version: '
|
34
|
+
version: '3'
|
39
35
|
type: :development
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
|
-
- -
|
39
|
+
- - ~>
|
45
40
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
41
|
+
version: '3'
|
47
42
|
- !ruby/object:Gem::Dependency
|
48
43
|
name: coveralls
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
45
|
requirements:
|
52
|
-
- -
|
46
|
+
- - ~>
|
53
47
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
48
|
+
version: '0.7'
|
55
49
|
type: :development
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
52
|
requirements:
|
60
|
-
- -
|
53
|
+
- - ~>
|
61
54
|
- !ruby/object:Gem::Version
|
62
|
-
version: '0'
|
55
|
+
version: '0.7'
|
63
56
|
- !ruby/object:Gem::Dependency
|
64
57
|
name: cinch-test
|
65
58
|
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
59
|
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.0'
|
68
63
|
- - ! '>='
|
69
64
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
65
|
+
version: 0.0.2
|
71
66
|
type: :development
|
72
67
|
prerelease: false
|
73
68
|
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
69
|
requirements:
|
70
|
+
- - ~>
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0.0'
|
76
73
|
- - ! '>='
|
77
74
|
- !ruby/object:Gem::Version
|
78
|
-
version:
|
75
|
+
version: 0.0.2
|
79
76
|
- !ruby/object:Gem::Dependency
|
80
77
|
name: cinch
|
81
78
|
requirement: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
79
|
requirements:
|
84
80
|
- - ~>
|
85
81
|
- !ruby/object:Gem::Version
|
86
|
-
version: 2
|
82
|
+
version: '2'
|
87
83
|
type: :runtime
|
88
84
|
prerelease: false
|
89
85
|
version_requirements: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
86
|
requirements:
|
92
87
|
- - ~>
|
93
88
|
- !ruby/object:Gem::Version
|
94
|
-
version: 2
|
89
|
+
version: '2'
|
95
90
|
description: Cinch Plugin for Coverting Units via the units binary
|
96
91
|
email:
|
97
92
|
- bhaberer@gmail.com
|
@@ -114,29 +109,27 @@ files:
|
|
114
109
|
homepage: https://github.com/canonical-hackers/cinch-convert
|
115
110
|
licenses:
|
116
111
|
- MIT
|
112
|
+
metadata: {}
|
117
113
|
post_install_message:
|
118
114
|
rdoc_options: []
|
119
115
|
require_paths:
|
120
116
|
- lib
|
121
117
|
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
-
none: false
|
123
118
|
requirements:
|
124
119
|
- - ! '>='
|
125
120
|
- !ruby/object:Gem::Version
|
126
121
|
version: '0'
|
127
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
-
none: false
|
129
123
|
requirements:
|
130
124
|
- - ! '>='
|
131
125
|
- !ruby/object:Gem::Version
|
132
126
|
version: '0'
|
133
127
|
requirements: []
|
134
128
|
rubyforge_project:
|
135
|
-
rubygems_version:
|
129
|
+
rubygems_version: 2.2.2
|
136
130
|
signing_key:
|
137
|
-
specification_version:
|
131
|
+
specification_version: 4
|
138
132
|
summary: Cinch Plugin for converting units
|
139
133
|
test_files:
|
140
134
|
- spec/cinch-convert_spec.rb
|
141
135
|
- spec/spec_helper.rb
|
142
|
-
has_rdoc:
|