lita-diabetter 1.1.0 → 1.2.1.alpha.58

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97677d8e1b43e3224acf0bdee3ad83212b7ad09a
4
- data.tar.gz: 845fef57839b4451b7c2a8304bfbe6ce66dd1534
3
+ metadata.gz: bdeb7db7d9704cbf24e0b9c6177778d691d6b103
4
+ data.tar.gz: 14246499c343713f219fdd2dc346a130bcf4c3e3
5
5
  SHA512:
6
- metadata.gz: dd41b88d9e8b029575e70050372566de65514a3424068ed5d6344d0ba5b671eee7c169874e1922690ebab05cc71669471b4ed98d6c888f9acc9dd32b8dd62270
7
- data.tar.gz: 1c725f41e09e6b597c7d45c46ab972fc7d9b5f31de81c1b5ec078f9d1d3a20d420f280604e1554215ff3bd1eb57528d1cda519c4a150147070a6f13405a1d1a2
6
+ metadata.gz: 91d2f288c2b217d49cb52debde5cf1e4453fefea541216f4d0ebc0f2e6173667c5d1bede6c35aedb15a088df4f972c297ac008399cd86d12c71ffb45239f2341
7
+ data.tar.gz: ac03b31bc1bf4b3cbc43409d6948dc0d7e04ad79571b2e8b6be519d69eed03cdb966b53dab121a47f5d74c29e0902e606e22fb4827158330e9f31fc03c9f3ae1
data/.gitignore CHANGED
@@ -1,17 +1,18 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- InstalledFiles
7
- _yardoc
8
- coverage
9
- doc/
10
- lib/bundler/man
11
- pkg
12
- rdoc
13
- spec/reports
14
- test/tmp
15
- test/version_tmp
16
- tmp
17
- .idea
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
17
+ .idea
18
+ vendor
data/.travis.yml CHANGED
@@ -1,21 +1,21 @@
1
- language: ruby
2
- rvm:
3
- - 2.3.0
4
- notifications:
5
- email:
6
- recipients:
7
- - cas.eliens@gmail.com
8
- on_success: change
9
- on_failure: change
10
- script: bundle exec rake
11
- before_install:
12
- - gem update --system
13
- services:
14
- - redis-server
15
- deploy:
16
- provider: rubygems
17
- api_key:
18
- secure: "xEC9fzPXl1/la7ONuPipqXpbOEpA3GhIm+Dc74OPl20+RbOjHGmhRWOQWi4DCX/zNnWFKnIPxp0NMT2mW28hqRZBaUPKj9jN3AnrJ6EgWOaaWkAkwhXBou16+5Xgz2U8K7TB/CFIv41avONQJxUUITEKF+6+7U25ixkbbPeMttMOSx4WrlJmSfR2bz3LyCdniK3EyD7wTGz6FWpPIjdV3ZApJDL+/0yFm6hrilsq3aMtnrdaGdQ+tQtSNlT/PhBtRYkQs+0WlkmHfUaS3EDHbGw9vI2NBmp7EoPnmKNbyHmHb6EyXa8X/oMFvhwVoaRE8Gw5jkJJthCDTsfuTUq7s90/URwtCPGBs+eP1FQROBnw55oH2lBzoZ98l3p/7+T3QHKlQRRjr3XP4FkyxF/hiOylBk6COWLfDQqijmmSWfgeGykyo4Vk8jvV820HpOa95GmrB+k1qPPgezJi9kC/8rIzKV0LhqlmNuGqtWTAFFPqnM4Lo7pCfw1tRxyITQ3xObr/xRLHcgKr6ZMg5SwgN/Qrc8FXD31c77kaVUQg4dJSUSo9OAwrKprqC0tvUprIknXoXTpfxaYUKr9yPSBdXUGgidZTjA6kHdo0VXt3kPJXlccN+YzLsRgmq+k2XXoDncLhYTAQN6KaCLCnGX/OCBKVhFUnALLp95djdH1gYQg="
19
- gem: lita-diabetter
20
- on:
21
- all_branches: true
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ notifications:
5
+ email:
6
+ recipients:
7
+ - cas.eliens@gmail.com
8
+ on_success: change
9
+ on_failure: change
10
+ script: bundle exec rake
11
+ before_install:
12
+ - gem update --system
13
+ services:
14
+ - redis-server
15
+ deploy:
16
+ provider: rubygems
17
+ api_key:
18
+ secure: "xEC9fzPXl1/la7ONuPipqXpbOEpA3GhIm+Dc74OPl20+RbOjHGmhRWOQWi4DCX/zNnWFKnIPxp0NMT2mW28hqRZBaUPKj9jN3AnrJ6EgWOaaWkAkwhXBou16+5Xgz2U8K7TB/CFIv41avONQJxUUITEKF+6+7U25ixkbbPeMttMOSx4WrlJmSfR2bz3LyCdniK3EyD7wTGz6FWpPIjdV3ZApJDL+/0yFm6hrilsq3aMtnrdaGdQ+tQtSNlT/PhBtRYkQs+0WlkmHfUaS3EDHbGw9vI2NBmp7EoPnmKNbyHmHb6EyXa8X/oMFvhwVoaRE8Gw5jkJJthCDTsfuTUq7s90/URwtCPGBs+eP1FQROBnw55oH2lBzoZ98l3p/7+T3QHKlQRRjr3XP4FkyxF/hiOylBk6COWLfDQqijmmSWfgeGykyo4Vk8jvV820HpOa95GmrB+k1qPPgezJi9kC/8rIzKV0LhqlmNuGqtWTAFFPqnM4Lo7pCfw1tRxyITQ3xObr/xRLHcgKr6ZMg5SwgN/Qrc8FXD31c77kaVUQg4dJSUSo9OAwrKprqC0tvUprIknXoXTpfxaYUKr9yPSBdXUGgidZTjA6kHdo0VXt3kPJXlccN+YzLsRgmq+k2XXoDncLhYTAQN6KaCLCnGX/OCBKVhFUnALLp95djdH1gYQg="
19
+ gem: lita-diabetter
20
+ on:
21
+ all_branches: true
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,8 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lita-diabetter (1.0.0)
5
- lita (~> 4.7)
4
+ lita-diabetter (1.2.1)
6
5
 
7
6
  GEM
8
7
  remote: https://rubygems.org/
@@ -70,10 +69,11 @@ PLATFORMS
70
69
 
71
70
  DEPENDENCIES
72
71
  bundler (~> 1.3)
72
+ lita (~> 4.7)
73
73
  lita-diabetter!
74
74
  pry-byebug
75
75
  rack-test
76
- rake (< 11.0)
76
+ rake (~> 10.4.2)
77
77
  rspec (~> 3.0.0)
78
78
 
79
79
  BUNDLED WITH
data/README.md CHANGED
@@ -1,36 +1,36 @@
1
- # lita-diabetter
2
-
3
- [![Build Status][travis-img]][travis-url]
4
- [![Gem Version][gem-img]][gem-url]
5
- [![Gem Downloads][gem-dl-img]][gem-url]
6
- [![Dependency status][gem-dep-img]][gem-dep-url]
7
- [![Codacy Badge][codacy-img]][codacy-url]
8
-
9
- TODO: Add a description of the plugin.
10
-
11
- ## Installation
12
-
13
- Add lita-diabetter to your Lita instance's Gemfile:
14
-
15
- ``` ruby
16
- gem "lita-diabetter"
17
- ```
18
-
19
- ## Configuration
20
-
21
- TODO: Describe any configuration attributes the plugin exposes.
22
-
23
- ## Usage
24
-
25
- TODO: Describe the plugin's features and how to use them.
26
-
27
-
28
- [travis-img]: https://img.shields.io/travis/cascer1/lita-diabetter.svg
29
- [travis-url]: https://travis-ci.org/cascer1/lita-diabetter
30
- [gem-img]: https://img.shields.io/gem/v/lita-diabetter.svg
31
- [gem-url]: https://badge.fury.io/rb/lita-diabetter
32
- [gem-dl-img]: https://img.shields.io/gem/dv/lita-diabetter/stable.svg
33
- [gem-dep-img]: https://img.shields.io/gemnasium/cascer1/lita-diabetter.svg
34
- [gem-dep-url]: https://gemnasium.com/github.com/cascer1/lita-diabetter
35
- [codacy-img]: https://img.shields.io/codacy/grade/218ed88601a243ccae18e98e590b622d.svg
36
- [codacy-url]: https://www.codacy.com/app/cascer1/lita-diabetter?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=cascer1/lita-diabetter&amp;utm_campaign=Badge_Grade
1
+ # lita-diabetter
2
+
3
+ [![Build Status][travis-img]][travis-url]
4
+ [![Gem Version][gem-img]][gem-url]
5
+ [![Gem Downloads][gem-dl-img]][gem-url]
6
+ [![Dependency status][gem-dep-img]][gem-dep-url]
7
+ [![Codacy Badge][codacy-img]][codacy-url]
8
+
9
+ TODO: Add a description of the plugin.
10
+
11
+ ## Installation
12
+
13
+ Add lita-diabetter to your Lita instance's Gemfile:
14
+
15
+ ``` ruby
16
+ gem "lita-diabetter"
17
+ ```
18
+
19
+ ## Configuration
20
+
21
+ TODO: Describe any configuration attributes the plugin exposes.
22
+
23
+ ## Usage
24
+
25
+ TODO: Describe the plugin's features and how to use them.
26
+
27
+
28
+ [travis-img]: https://img.shields.io/travis/cascer1/lita-diabetter.svg
29
+ [travis-url]: https://travis-ci.org/cascer1/lita-diabetter
30
+ [gem-img]: https://img.shields.io/gem/v/lita-diabetter.svg
31
+ [gem-url]: https://badge.fury.io/rb/lita-diabetter
32
+ [gem-dl-img]: https://img.shields.io/gem/dv/lita-diabetter/stable.svg
33
+ [gem-dep-img]: https://img.shields.io/gemnasium/cascer1/lita-diabetter.svg
34
+ [gem-dep-url]: https://gemnasium.com/github.com/cascer1/lita-diabetter
35
+ [codacy-img]: https://img.shields.io/codacy/grade/218ed88601a243ccae18e98e590b622d.svg
36
+ [codacy-url]: https://www.codacy.com/app/cascer1/lita-diabetter?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=cascer1/lita-diabetter&amp;utm_campaign=Badge_Grade
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task default: :spec
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -1,159 +1,159 @@
1
- module Lita
2
- module Handlers
3
- class Diabetter < Handler
4
- @@conversion_ratio = 18.0182
5
- @@lower = 25.0 # Lower limit for mmol/L - mg/dL cutoff
6
- @@upper = 50.0 # Upper limit for mmol/L - mg/dL cutoff
7
-
8
- route(/(?:^|_)(\d{1,3}|\d{1,2}\.\d+)(?:$|_)/, :convert, command: false, help: {
9
- '<number>' => 'Convert glucose between mass/molar concentration units.',
10
- '_<number>_' => 'Convert glucose between mass/molar concentration units inline. E.g "I started at _125_ today"'
11
- })
12
-
13
- route(/estimate a1c(?: from average)?\s+(\d{1,3}|\d{1,2}\.\d+)$/i, :estimate_a1c, command: true, help: {
14
- 'estimate a1c [from average] <glucose level>' => 'Estimates A1C based on average BG level'
15
- })
16
-
17
- route(/estimate average(?: from a1c)?\s+(\d{1,3}|\d{1,2}\.\d+)$/i, :estimate_average_from_a1c, command: true, help: {
18
- 'estimate average [from a1c] <A1C>' => 'Estimates average blood glucose'
19
- })
20
-
21
- def convert(response)
22
- if response.message.body.match(URI.regexp(%w(http https))).nil?
23
- input = response.matches[0][0]
24
- Lita.logger.debug('Converting BG for input "' + input + '"')
25
-
26
- if input.to_f < @@lower
27
- response.reply("#{input} mmol/L is #{mmol_to_mgdl(input).to_s} mg/dL")
28
- elsif input.to_f >= @@lower && input.to_f < @@upper
29
- mmol = mgdl_to_mmol(input).to_s
30
- mgdl = mmol_to_mgdl(input).to_s
31
-
32
- result = '*I\'m not sure if you gave me mmol/L or mg/dL, so I\'ll give you both.*\n'
33
- result += "#{input} mg/dL is **#{mmol} mmol/L**\n"
34
- result += "#{input} mmol/L is **#{mgdl} mg/dL**"
35
-
36
- response.reply(result)
37
- else
38
- response.reply("#{input} mg/dL is #{mgdl_to_mmol(input).to_s} mmol/L")
39
- end
40
- end
41
- end
42
-
43
- def estimate_a1c(response)
44
- input = response.matches[0][0]
45
- Lita.logger.debug('Estimating a1c for input "' + input + '"')
46
-
47
-
48
- if input.to_f < @@lower
49
- mmol = input.to_f.round(1)
50
- mgdl = mmol_to_mgdl(mmol)
51
-
52
- type = 'mmol'
53
- elsif input.to_f >= @@lower && input.to_f < @@upper
54
- mmol = input.to_f.round(1)
55
- mgdl_from_mmol = mmol_to_mgdl(input.to_f)
56
- mgdl = input.to_f
57
-
58
- dcct_alt = mgdl_to_dcct(mgdl_from_mmol)
59
- ifcc_alt = dcct_to_ifcc(dcct_alt).round(0).to_s
60
- dcct_alt = dcct.round(1).to_s
61
-
62
- type = 'unknown'
63
- else
64
- mgdl = input.to_i
65
- mmol = mgdl_to_mmol(mgdl)
66
-
67
- type = 'mgdl'
68
- end
69
-
70
- dcct = mgdl_to_dcct(mgdl)
71
- ifcc = dcct_to_ifcc(dcct).round(0).to_s
72
- dcct = dcct.round(1).to_s
73
-
74
-
75
- if type == 'unknown'
76
- reply = "*I'm not sure if you entered mmol/L or mg/dL, so I'll give you both*\n"
77
- reply += make_average_sentence('mmol', mmol, dcct_alt, ifcc_alt) + "\n"
78
- reply += make_average_sentence('mgdl', mgdl, dcct, ifcc)
79
- elsif type=='mmol'
80
- reply = make_average_sentence('mmol', mmol, dcct, ifcc)
81
- else
82
- reply = make_average_sentence('mgdl', mgdl, dcct, ifcc)
83
- end
84
-
85
- response.reply(reply)
86
- end
87
-
88
- def make_average_sentence(type, value, dcct, ifcc)
89
- if type == 'mmol'
90
- string = "An average of **#{value} mmol/L** is about "
91
- elsif type == 'mgdl'
92
- string = "An average of **#{value} mg/dL** is about "
93
- end
94
-
95
- string += "**#{dcct}%** (DCCT) or **#{ifcc} mmol/mol** (IFCC)"
96
- end
97
-
98
- def estimate_average_from_a1c(response)
99
- input = response.matches[0][0]
100
- Lita.logger.debug('Converting a1c to BG for input "' + input + '"')
101
- a1c = input.to_f
102
- dcct = 0
103
- ifcc = 0
104
-
105
- if input.index('.') == nil
106
- ifcc = a1c.round(0)
107
- dcct = ifcc_to_dcct(a1c).round(1)
108
- else
109
- dcct = a1c.round(1)
110
- ifcc = dcct_to_ifcc(a1c).round
111
- end
112
-
113
- mgdl = dcct_to_mgdl(dcct)
114
-
115
- reply = 'an A1C of ' + dcct.to_s + '% (DCCT) or '
116
- reply = reply + ifcc.to_s + ' mmol/mol (IFCC)'
117
- reply = reply + ' is about '
118
- reply = reply + mgdl.round.to_s + ' mg/dL or '
119
- reply = reply + mgdl_to_mmol(mgdl).round(1).to_s + ' mmol/L'
120
- response.reply(reply)
121
- end
122
-
123
- def mgdl_to_mmol(n)
124
- (n.to_i / @@conversion_ratio).round(1)
125
- end
126
-
127
- def mmol_to_mgdl(n)
128
- (n.to_f * @@conversion_ratio).round
129
- end
130
-
131
- def mgdl_to_dcct(n)
132
- ((n.to_i + 46.7) / 28.7)
133
- end
134
-
135
- def mgdl_to_ifcc(n)
136
- ((mgdl_to_dcct(n) - 2.15) * 10.929)
137
- end
138
-
139
- def dcct_to_ifcc(n)
140
- (n.to_f - 2.15) * 10.929
141
- end
142
-
143
- def ifcc_to_dcct(n)
144
- (n.to_f / 10.929) + 2.15
145
- end
146
-
147
- def dcct_to_mgdl(n)
148
- (n.to_f * 28.7) - 46.7
149
- end
150
-
151
- def ifcc_to_mgdl(n)
152
- dcct_to_mgdl((n / 10.929) + 2.5)
153
- end
154
-
155
-
156
- end
157
- Lita.register_handler(Diabetter)
158
- end
159
- end
1
+ module Lita
2
+ module Handlers
3
+ class Diabetter < Handler
4
+ @@conversion_ratio = 18.0182
5
+ @@lower = 25.0 # Lower limit for mmol/L - mg/dL cutoff
6
+ @@upper = 50.0 # Upper limit for mmol/L - mg/dL cutoff
7
+
8
+ route(/(?:^|_)(\d{1,3}|\d{1,2}\.\d+)(?:$|_)/, :convert, command: false, help: {
9
+ '<number>' => 'Convert glucose between mass/molar concentration units.',
10
+ '_<number>_' => 'Convert glucose between mass/molar concentration units inline. E.g "I started at _125_ today"'
11
+ })
12
+
13
+ route(/estimate a1c(?: from average)?\s+(\d{1,3}|\d{1,2}\.\d+)$/i, :estimate_a1c, command: true, help: {
14
+ 'estimate a1c [from average] <glucose level>' => 'Estimates A1C based on average BG level'
15
+ })
16
+
17
+ route(/estimate average(?: from a1c)?\s+(\d{1,3}|\d{1,2}\.\d+)$/i, :estimate_average_from_a1c, command: true, help: {
18
+ 'estimate average [from a1c] <A1C>' => 'Estimates average blood glucose'
19
+ })
20
+
21
+ def convert(response)
22
+ if response.message.body.match(URI.regexp(%w(http https))).nil?
23
+ input = response.matches[0][0]
24
+ Lita.logger.debug('Converting BG for input "' + input + '"')
25
+
26
+ if input.to_f < @@lower
27
+ response.reply("#{input} mmol/L is #{mmol_to_mgdl(input).to_s} mg/dL")
28
+ elsif input.to_f >= @@lower && input.to_f < @@upper
29
+ mmol = mgdl_to_mmol(input).to_s
30
+ mgdl = mmol_to_mgdl(input).to_s
31
+
32
+ result = '*I\'m not sure if you gave me mmol/L or mg/dL, so I\'ll give you both.*\n'
33
+ result += "#{input} mg/dL is **#{mmol} mmol/L**\n"
34
+ result += "#{input} mmol/L is **#{mgdl} mg/dL**"
35
+
36
+ response.reply(result)
37
+ else
38
+ response.reply("#{input} mg/dL is #{mgdl_to_mmol(input).to_s} mmol/L")
39
+ end
40
+ end
41
+ end
42
+
43
+ def estimate_a1c(response)
44
+ input = response.matches[0][0]
45
+ Lita.logger.debug('Estimating a1c for input "' + input + '"')
46
+
47
+
48
+ if input.to_f < @@lower
49
+ mmol = input.to_f.round(1)
50
+ mgdl = mmol_to_mgdl(mmol)
51
+
52
+ type = 'mmol'
53
+ elsif input.to_f >= @@lower && input.to_f < @@upper
54
+ mmol = input.to_f.round(1)
55
+ mgdl_from_mmol = mmol_to_mgdl(input.to_f)
56
+ mgdl = input.to_f
57
+
58
+ dcct_alt = mgdl_to_dcct(mgdl_from_mmol)
59
+ ifcc_alt = dcct_to_ifcc(dcct_alt).round(0).to_s
60
+ dcct_alt = dcct.round(1).to_s
61
+
62
+ type = 'unknown'
63
+ else
64
+ mgdl = input.to_i
65
+ mmol = mgdl_to_mmol(mgdl)
66
+
67
+ type = 'mgdl'
68
+ end
69
+
70
+ dcct = mgdl_to_dcct(mgdl)
71
+ ifcc = dcct_to_ifcc(dcct).round(0).to_s
72
+ dcct = dcct.round(1).to_s
73
+
74
+
75
+ if type == 'unknown'
76
+ reply = "*I'm not sure if you entered mmol/L or mg/dL, so I'll give you both*\n"
77
+ reply += make_average_sentence('mmol', mmol, dcct_alt, ifcc_alt) + "\n"
78
+ reply += make_average_sentence('mgdl', mgdl, dcct, ifcc)
79
+ elsif type=='mmol'
80
+ reply = make_average_sentence('mmol', mmol, dcct, ifcc)
81
+ else
82
+ reply = make_average_sentence('mgdl', mgdl, dcct, ifcc)
83
+ end
84
+
85
+ response.reply(reply)
86
+ end
87
+
88
+ def make_average_sentence(type, value, dcct, ifcc)
89
+ if type == 'mmol'
90
+ string = "An average of **#{value} mmol/L** is about "
91
+ elsif type == 'mgdl'
92
+ string = "An average of **#{value} mg/dL** is about "
93
+ end
94
+
95
+ string += "**#{dcct}%** (DCCT) or **#{ifcc} mmol/mol** (IFCC)"
96
+ end
97
+
98
+ def estimate_average_from_a1c(response)
99
+ input = response.matches[0][0]
100
+ Lita.logger.debug('Converting a1c to BG for input "' + input + '"')
101
+ a1c = input.to_f
102
+ dcct = 0
103
+ ifcc = 0
104
+
105
+ if input.index('.') == nil
106
+ ifcc = a1c.round(0)
107
+ dcct = ifcc_to_dcct(a1c).round(1)
108
+ else
109
+ dcct = a1c.round(1)
110
+ ifcc = dcct_to_ifcc(a1c).round
111
+ end
112
+
113
+ mgdl = dcct_to_mgdl(dcct)
114
+
115
+ reply = 'an A1C of ' + dcct.to_s + '% (DCCT) or '
116
+ reply = reply + ifcc.to_s + ' mmol/mol (IFCC)'
117
+ reply = reply + ' is about '
118
+ reply = reply + mgdl.round.to_s + ' mg/dL or '
119
+ reply = reply + mgdl_to_mmol(mgdl).round(1).to_s + ' mmol/L'
120
+ response.reply(reply)
121
+ end
122
+
123
+ def mgdl_to_mmol(n)
124
+ (n.to_i / @@conversion_ratio).round(1)
125
+ end
126
+
127
+ def mmol_to_mgdl(n)
128
+ (n.to_f * @@conversion_ratio).round
129
+ end
130
+
131
+ def mgdl_to_dcct(n)
132
+ ((n.to_i + 46.7) / 28.7)
133
+ end
134
+
135
+ def mgdl_to_ifcc(n)
136
+ ((mgdl_to_dcct(n) - 2.15) * 10.929)
137
+ end
138
+
139
+ def dcct_to_ifcc(n)
140
+ (n.to_f - 2.15) * 10.929
141
+ end
142
+
143
+ def ifcc_to_dcct(n)
144
+ (n.to_f / 10.929) + 2.15
145
+ end
146
+
147
+ def dcct_to_mgdl(n)
148
+ (n.to_f * 28.7) - 46.7
149
+ end
150
+
151
+ def ifcc_to_mgdl(n)
152
+ dcct_to_mgdl((n / 10.929) + 2.5)
153
+ end
154
+
155
+
156
+ end
157
+ Lita.register_handler(Diabetter)
158
+ end
159
+ end
@@ -1,20 +1,26 @@
1
- module Lita
2
- module Handlers
3
- class DiabetterMisc < Handler
4
-
5
- route(/^-diabot.*$/i, :deprecated, command: false)
6
-
7
- route(/^diabetes y$/i, :diabetesy, command: false, restrict_to: :diabot_meme)
8
-
9
- def deprecated(response)
10
- response.reply('The -diabot prefix is deprecated. See `diabot help` for more info')
11
- end
12
-
13
- def diabetesy(response)
14
- response.reply('Because diabetes r hard')
15
- end
16
-
17
- end
18
- Lita.register_handler(DiabetterMisc)
19
- end
20
- end
1
+ module Lita
2
+ module Handlers
3
+ class DiabetterMisc < Handler
4
+
5
+ route(/^-diabot.*$/i, :deprecated, command: false)
6
+
7
+ route(/^diabetes y$/i, :diabetesy, command: false, restrict_to: :diabot_meme)
8
+
9
+ route(/^diab((etes)|(ot)) plz$/i, :plz, command: false, restrict_to: :diabot_meme)
10
+
11
+ def deprecated(response)
12
+ response.reply('The -diabot prefix is deprecated. See `diabot help` for more info')
13
+ end
14
+
15
+ def diabetesy(response)
16
+ response.reply('Because diabetes r hard')
17
+ end
18
+
19
+ def plz(response)
20
+ response.reply('K')
21
+ end
22
+
23
+ end
24
+ Lita.register_handler(DiabetterMisc)
25
+ end
26
+ end
@@ -1,13 +1,13 @@
1
- require 'lita'
2
-
3
- Lita.load_locales Dir[File.expand_path(
4
- File.join('..', '..', 'locales', '*.yml'), __FILE__
5
- )]
6
-
7
- require 'lita/handlers/diabetter'
8
- require 'lita/handlers/diabetter-misc'
9
-
10
- Lita::Handlers::Diabetter.template_root File.expand_path(
11
- File.join('..', '..', 'templates'),
12
- __FILE__
13
- )
1
+ require 'lita'
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join('..', '..', 'locales', '*.yml'), __FILE__
5
+ )]
6
+
7
+ require 'lita/handlers/diabetter'
8
+ require 'lita/handlers/diabettermisc'
9
+
10
+ Lita::Handlers::Diabetter.template_root File.expand_path(
11
+ File.join('..', '..', 'templates'),
12
+ __FILE__
13
+ )
@@ -1,26 +1,48 @@
1
- Gem::Specification.new do |spec|
2
- spec.name = 'lita-diabetter'
3
- spec.version = '1.1.0'
4
- spec.version = "#{spec.version}.alpha.#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
5
- spec.authors = ['Cas Eliëns']
6
- spec.email = ['cas.eliens@gmail.com']
7
- spec.description = 'A better diabetes handler for Lita'
8
- spec.summary = 'Provides diabetes-related commands like glucose value conversions'
9
- spec.homepage = 'https://github.com/cascer1/lita-diabetter'
10
- spec.license = 'GPL-3.0+'
11
- spec.metadata = {'lita_plugin_type' => 'handler'}
12
-
13
- spec.files = `git ls-files`.split($/)
14
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
- spec.require_paths = ['lib']
17
-
18
- spec.add_runtime_dependency 'lita', '~> 4.7'
19
- spec.required_ruby_version = '>= 2.0.0'
20
-
21
- spec.add_development_dependency 'bundler', '~> 1.3'
22
- spec.add_development_dependency 'pry-byebug'
23
- spec.add_development_dependency 'rake', '< 11.0'
24
- spec.add_development_dependency 'rack-test'
25
- spec.add_development_dependency 'rspec', '~> 3.0.0'
26
- end
1
+ Gem::Specification.new do |spec|
2
+ base_version = '1.2.1'
3
+
4
+ spec.name = 'lita-diabetter'
5
+ spec.version = base_version
6
+
7
+ if ENV['TRAVIS']
8
+ branch_name = ENV['TRAVIS_BRANCH']
9
+
10
+ is_release = branch_name.include? 'release/'
11
+ else
12
+ branch_name = 'master'
13
+ is_release = false
14
+ end
15
+
16
+
17
+ spec.version = "#{base_version}.alpha.#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS'] && branch_name != 'master' && ENV['TRAVIS_PULL_REQUEST'] == 'false'
18
+ spec.version = "#{base_version}.rc.#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS'] && is_release && ENV['TRAVIS_PULL_REQUEST'] == 'false'
19
+ spec.version = "#{base_version}.pull.#{ENV['TARVIS_PULL_REQUEST']}" if ENV['TRAVIS'] && ENV['TRAVIS_PULL_REQUEST'] != 'false'
20
+ spec.authors = ['Cas Eliëns']
21
+ spec.email = ['cas.eliens@gmail.com']
22
+ spec.description = 'A better diabetes handler for Lita'
23
+ spec.summary = 'Provides diabetes-related commands like glucose value conversions'
24
+ spec.homepage = 'https://github.com/cascer1/lita-diabetter'
25
+ spec.license = 'GPL-3.0+'
26
+ spec.metadata = {'lita_plugin_type' => 'handler'}
27
+
28
+ if ENV['TRAVIS']
29
+ puts 'Branch: ' + ENV['TRAVIS_BRANCH']
30
+ puts 'Tag: ' + ENV['TRAVIS_TAG']
31
+ puts 'Release: '+ spec.version.to_s
32
+ end
33
+
34
+ spec.files = `git ls-files`.split($/)
35
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
36
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
37
+ spec.require_paths = ['lib']
38
+
39
+ # spec.add_runtime_dependency 'lita', '~> 4.7'
40
+ spec.required_ruby_version = '>= 2.0.0'
41
+
42
+ spec.add_development_dependency 'lita', '~> 4.7'
43
+ spec.add_development_dependency 'bundler', '~> 1.3'
44
+ spec.add_development_dependency 'pry-byebug'
45
+ spec.add_development_dependency 'rake', '~> 10.4.2'
46
+ spec.add_development_dependency 'rack-test'
47
+ spec.add_development_dependency 'rspec', '~> 3.0.0'
48
+ end
@@ -1,4 +1,7 @@
1
- require 'spec_helper'
2
-
3
- describe Lita::Handlers::Diabetter, lita_handler: true do
4
- end
1
+ require 'spec_helper'
2
+
3
+ describe Lita::Handlers::Diabetter, lita_handler: true do
4
+ end
5
+
6
+ describe Lita::Handlers::DiabetterMisc, lita_handler: true do
7
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,14 +1,14 @@
1
- # require 'simplecov'
2
- # require 'coveralls'
3
- # SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
4
- # SimpleCov::Formatter::HTMLFormatter,
5
- # Coveralls::SimpleCov::Formatter
6
- # ]
7
- # SimpleCov.start { add_filter "/spec/" }
8
-
9
- require 'lita-diabetter'
10
- require 'lita/rspec'
11
-
12
- # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
13
- # was generated with Lita 4, the compatibility mode should be left disabled.
14
- Lita.version_3_compatibility_mode = false
1
+ # require 'simplecov'
2
+ # require 'coveralls'
3
+ # SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
4
+ # SimpleCov::Formatter::HTMLFormatter,
5
+ # Coveralls::SimpleCov::Formatter
6
+ # ]
7
+ # SimpleCov.start { add_filter "/spec/" }
8
+
9
+ require 'lita-diabetter'
10
+ require 'lita/rspec'
11
+
12
+ # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
13
+ # was generated with Lita 4, the compatibility mode should be left disabled.
14
+ Lita.version_3_compatibility_mode = false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-diabetter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.1.alpha.58
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cas Eliëns
@@ -17,7 +17,7 @@ dependencies:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.7'
20
- type: :runtime
20
+ type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "<"
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '11.0'
61
+ version: 10.4.2
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "<"
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '11.0'
68
+ version: 10.4.2
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rack-test
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -108,8 +108,8 @@ files:
108
108
  - README.md
109
109
  - Rakefile
110
110
  - lib/lita-diabetter.rb
111
- - lib/lita/handlers/diabetter-misc.rb
112
111
  - lib/lita/handlers/diabetter.rb
112
+ - lib/lita/handlers/diabettermisc.rb
113
113
  - lita-diabetter.gemspec
114
114
  - locales/en.yml
115
115
  - spec/lita/handlers/diabetter_spec.rb
@@ -131,12 +131,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
131
  version: 2.0.0
132
132
  required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  requirements:
134
- - - ">="
134
+ - - ">"
135
135
  - !ruby/object:Gem::Version
136
- version: '0'
136
+ version: 1.3.1
137
137
  requirements: []
138
138
  rubyforge_project:
139
- rubygems_version: 2.5.1
139
+ rubygems_version: 2.4.5
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: Provides diabetes-related commands like glucose value conversions