my_age 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/my_age/calculator.rb +1 -1
- data/lib/my_age/cli.rb +9 -7
- data/lib/my_age/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94b8a543fa3af2693be174f088a77026200cdd2b
|
4
|
+
data.tar.gz: df31200e745181d457332916b91d86e519f2bab4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a6e30945d86c319f00c7c8ff9a4a7bcdb5c795fe2ff6c0619fb3dbc1b79e8897e58437b3362721da211412e84a78661b1737c2e65e4f866a99abfb83b1ac286
|
7
|
+
data.tar.gz: 51639941c07681e648f793eee0e16b21a5dfdc209ee4187ec7c1840b7618bff62c4c3c2ab0923b3b84f7617d8abc1692cb869175a16d32f253270ba759402de2
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# MyAge
|
2
|
-
|
2
|
+
[![Build Status](https://travis-ci.org/ej2015/my_age.svg?branch=master)](https://travis-ci.org/ej2015/my_age)
|
3
|
+
[![CodeFactor](https://www.codefactor.io/repository/github/ej2015/my_age/badge)](https://www.codefactor.io/repository/github/ej2015/my_age)
|
4
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/eba3926f39c9682e47ed/maintainability)](https://codeclimate.com/github/ej2015/my_age/maintainability)
|
3
5
|
## Installation
|
4
6
|
|
5
7
|
Add this line to your application's Gemfile:
|
data/lib/my_age/calculator.rb
CHANGED
data/lib/my_age/cli.rb
CHANGED
@@ -14,22 +14,24 @@ module MyAge
|
|
14
14
|
puts self.age(date)
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
17
|
private
|
19
18
|
def get_date(date)
|
20
19
|
if date =~ /^\d{4}-\d{2}-\d{2}$/
|
21
20
|
DateTime.strptime(date, "%Y-%m-%d")
|
22
21
|
else
|
23
|
-
|
24
|
-
if dates.length == 2
|
25
|
-
Date.today.send(dates[0].to_sym, dates[1].to_i)
|
26
|
-
else
|
27
|
-
Date.today.send(dates[0].to_sym)
|
28
|
-
end
|
22
|
+
date_from_active_support_core_ext_helper(date)
|
29
23
|
end
|
30
24
|
rescue NoMethodError
|
31
25
|
Date.send(date)
|
32
26
|
end
|
33
27
|
|
28
|
+
def date_from_active_support_core_ext_helper(date)
|
29
|
+
dates = date.delete(")").split("(")
|
30
|
+
method = dates[0].to_sym
|
31
|
+
arg = dates[1]
|
32
|
+
arg.nil? ? Date.today.send(method) :
|
33
|
+
Date.today.send(method, arg.to_i)
|
34
|
+
end
|
35
|
+
|
34
36
|
end
|
35
37
|
end
|
data/lib/my_age/version.rb
CHANGED