socrates 0.1.11 → 0.1.12

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5888e238834056167ec5db70cabf1a25c59aa1f7
4
- data.tar.gz: 360b99fbb350f111fadd4c9ad8596e3c3f7351fc
3
+ metadata.gz: b189f7e8275110163865fd7fdc586ad30d7481c6
4
+ data.tar.gz: fe7bdee2a73be689015c61a83981eb3fb424b6a9
5
5
  SHA512:
6
- metadata.gz: 3404c0d12161fa105efaa44085f47af4780490102f4ca836ac1c2d5db0995c21a565c6e9185ee9cec9f65fcc027bfc92ff449924f385529550b3bcc1b64d787c
7
- data.tar.gz: 51192c1becf7d53506895b13e9a4f0fc933996f786bfa34c74075c1ee62a0c08a1a1bf07223ade0a9182b1a015f75e764c35f86b25ce23ef89eb0f8b7d86b143
6
+ metadata.gz: 238271e59d1a7f141a104092ad4a689882f75e20c85c58a081624a7666174904ecd1d173707449763f811937eb3d85603ca090259fea6be6aca54618228fae1b
7
+ data.tar.gz: 327d7cc6207e3d4f1b70e3f29c65351bf7ba7a25e477de0a3eef298920b621b256604d1e1aebe94f586cc617468bf233fdb89af3968f6c6069dfc093788e963b
@@ -52,6 +52,11 @@ module Socrates
52
52
  end
53
53
  end
54
54
 
55
+ # Note: this triggers a call to the Slack API which makes it ill-suited for use within a loop.
56
+ def lookup_user(email:)
57
+ users_list.members.find { |user| email == user.profile&.email }
58
+ end
59
+
55
60
  def lookup_email(context:)
56
61
  raise ArgumentError, "Expected :context to respond to :user" unless context.respond_to?(:user)
57
62
 
@@ -136,7 +136,13 @@ module Socrates
136
136
  end
137
137
 
138
138
  def calculate_age
139
- ((Date.today.to_time - birth_date.to_time) / 1.year).floor
139
+ today = Time.current.to_date
140
+
141
+ if today.month < birth_date.month || (today.month == birth_date.month && birth_date.day > today.day)
142
+ today.year - birth_date.year - 1
143
+ else
144
+ today.year - birth_date.year
145
+ end
140
146
  end
141
147
  end
142
148
 
@@ -1,3 +1,3 @@
1
1
  module Socrates
2
- VERSION = "0.1.11"
2
+ VERSION = "0.1.12"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socrates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Nelson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-15 00:00:00.000000000 Z
11
+ date: 2017-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler