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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f67fc7c50a8236d6096d02eae9a37030f7fedd3
4
- data.tar.gz: 27f63a0490f82dfbadafcd0d6b81ae159e733a18
3
+ metadata.gz: 3ee9d672d0e7be5563cae485a8a5e907933184b5
4
+ data.tar.gz: 66160d875ba22993fbd1221a8fc9bcb810ce3f4e
5
5
  SHA512:
6
- metadata.gz: c5fd15d4cf141055360511e20345bac46ab8dafd5ba3634f3ee6e7e0982962d6d2f4b5c9599d808b901b2fa5359f816b9cd7c18028ae56d96064ee65a346b9bc
7
- data.tar.gz: 69067448a2f89eedefb7d0faf3fcbebe14c68aad17ed17bef51b8b7c63093d0fb9165b10def25183cbafb7b3d1c68011e5730f6d950ad24a6fe9562775c7bca1
6
+ metadata.gz: b8bf412c95c275f4d8fcd7565680d3a77109fdd3359ba1008e0eb4f884c64877a3188391e09d8cbd5a01cff30e855c8d31715ef3367dd1a175dfa32573fbf419
7
+ data.tar.gz: 9c17be6e120d2edf4b31e4a029039801245c87336c53dad9095d96c1feb5513569369ea2732f85231b9d5dd8501d562521c009f11065231267359e876809382d
data/.travis.yml CHANGED
@@ -1,5 +1,8 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
+ - 2.2.0
4
5
  - 2.3.0
6
+ - 2.4.0
7
+ - 2.5.0
5
8
  before_install: gem install bundler -v 1.13.1
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
- attr_accessor :dob
6
- include MyAge::Calculator
5
+ attr_accessor :dob
6
+ include MyAge::Calculator
7
7
 
8
- desc "is AGE", "-d date_of_birth -a as_of_date, Dates are in yyyy-mm-dd format"
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
- begin
21
- if date =~ /^\d{4}-\d{2}-\d{2}$/
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.gsub(")", "").split("(")
23
+ dates = date.delete(")").split("(")
25
24
  if dates.length == 2
26
- Date.today.send(dates[0].to_sym, dates[1].to_i)
25
+ Date.today.send(dates[0].to_sym, dates[1].to_i)
27
26
  else
28
- Date.today.send(dates[0].to_sym)
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
@@ -1,3 +1,3 @@
1
1
  module MyAge
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
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.3.0"
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
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-30 00:00:00.000000000 Z
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.3.0
163
+ version: 2.2.0
164
164
  required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  requirements:
166
166
  - - ">="