my_age 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/lib/my_age/cli.rb +10 -12
- data/lib/my_age/version.rb +1 -1
- data/my_age.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ee9d672d0e7be5563cae485a8a5e907933184b5
|
4
|
+
data.tar.gz: 66160d875ba22993fbd1221a8fc9bcb810ce3f4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8bf412c95c275f4d8fcd7565680d3a77109fdd3359ba1008e0eb4f884c64877a3188391e09d8cbd5a01cff30e855c8d31715ef3367dd1a175dfa32573fbf419
|
7
|
+
data.tar.gz: 9c17be6e120d2edf4b31e4a029039801245c87336c53dad9095d96c1feb5513569369ea2732f85231b9d5dd8501d562521c009f11065231267359e876809382d
|
data/.travis.yml
CHANGED
data/lib/my_age/cli.rb
CHANGED
@@ -2,14 +2,14 @@ require 'thor'
|
|
2
2
|
require 'my_age'
|
3
3
|
module MyAge
|
4
4
|
class CLI < Thor
|
5
|
-
|
6
|
-
|
5
|
+
attr_accessor :dob
|
6
|
+
include MyAge::Calculator
|
7
7
|
|
8
|
-
|
8
|
+
desc "is AGE", "-d date_of_birth -a as_of_date, Dates are in yyyy-mm-dd format"
|
9
9
|
method_option :dob, aliases: "d", desc: "date of birth in yyyy-mm-dd", required: true
|
10
|
-
method_option :as_of, aliases: "a", desc: "as of date in yyyy-mm-dd", required: false
|
10
|
+
method_option :as_of, aliases: "a", desc: "as of date in yyyy-mm-dd", required: false
|
11
11
|
def is
|
12
|
-
self.dob = get_date(options[:dob])
|
12
|
+
self.dob = get_date(options[:dob])
|
13
13
|
date = options[:as_of].present? ? get_date(options[:as_of]) : Date.today
|
14
14
|
puts self.age(date)
|
15
15
|
end
|
@@ -17,21 +17,19 @@ module MyAge
|
|
17
17
|
|
18
18
|
private
|
19
19
|
def get_date(date)
|
20
|
-
|
21
|
-
|
22
|
-
DateTime.strptime(date, "%Y-%m-%d")
|
20
|
+
if date =~ /^\d{4}-\d{2}-\d{2}$/
|
21
|
+
DateTime.strptime(date, "%Y-%m-%d")
|
23
22
|
else
|
24
|
-
dates = date.
|
23
|
+
dates = date.delete(")").split("(")
|
25
24
|
if dates.length == 2
|
26
|
-
|
25
|
+
Date.today.send(dates[0].to_sym, dates[1].to_i)
|
27
26
|
else
|
28
|
-
|
27
|
+
Date.today.send(dates[0].to_sym)
|
29
28
|
end
|
30
29
|
end
|
31
30
|
rescue NoMethodError
|
32
31
|
Date.send(date)
|
33
32
|
end
|
34
|
-
end
|
35
33
|
|
36
34
|
end
|
37
35
|
end
|
data/lib/my_age/version.rb
CHANGED
data/my_age.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.required_ruby_version = ">=2.
|
24
|
+
spec.required_ruby_version = ">=2.2.0"
|
25
25
|
|
26
26
|
spec.add_dependency "activesupport", ">= 4.2"
|
27
27
|
spec.add_dependency "thor", "~>0.20.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_age
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -160,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
160
|
requirements:
|
161
161
|
- - ">="
|
162
162
|
- !ruby/object:Gem::Version
|
163
|
-
version: 2.
|
163
|
+
version: 2.2.0
|
164
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
165
|
requirements:
|
166
166
|
- - ">="
|