age 0.0.2 → 0.0.3

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: 414296d83ea818481dff152254369db537137e08
4
- data.tar.gz: 31327f2fdba23082a33a65e2abf35e342f6d7d75
3
+ metadata.gz: 2ccc9f1398b1000fd73bed91eed7e8deb8433fa3
4
+ data.tar.gz: 72cc3700d31f4d1bf341b5465507e4b02b73c0f5
5
5
  SHA512:
6
- metadata.gz: 462f2be3f9fb217ee4e65da56ec5a385b356fe7959602e81b8ca3541a8e48386aced46d98776999c1f2285a94fe6bfef55c894c416762f48311f17b3c5e268a2
7
- data.tar.gz: 1ad7fd4deb521073187a522026a68cd9b7f8488d1af1c1080547d8a28dd09dee8ae03ebe00adccaf27c884e7572c9ab1f7c808ae85a6c921e057a6b3d6ce7f39
6
+ metadata.gz: 1fd9af9ec3f1882967e15b2fbe8dd4ca0bf03a05551318cd58669d156e95c002a0adca1441406b618952f6911b11d9b034828bbab236d89965b35bfd40b70379
7
+ data.tar.gz: 9def0c60cb890c59f908994f0753ee8807da676c4f07489e1aede6fb041e91d97b794a2967049df4ef1fcad5288cb008d5e0dd6b7ba5bcc79759d0fc387c5c6b
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ branches:
6
+ only:
7
+ - master
data/Gemfile CHANGED
@@ -2,3 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in age.gemspec
4
4
  gemspec
5
+ gem 'pry'
data/Rakefile CHANGED
@@ -1 +1,10 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ desc 'Default Task'
5
+ task default: :test
6
+
7
+ Rake::TestTask.new do |t|
8
+ t.libs << 'test'
9
+ t.pattern = 'test/test_*.rb'
10
+ end
@@ -20,4 +20,5 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "minitest"
23
24
  end
data/lib/age.rb CHANGED
@@ -1,5 +1,30 @@
1
- require "age/version"
1
+ require 'age/version'
2
+ require 'date'
2
3
 
3
- module Age
4
- # Your code goes here...
4
+ class Age
5
+ attr_accessor :birth, :end
6
+
7
+ def initialize(options)
8
+ @birth = options[:birth] || DateTime.now.offset(0)
9
+ @end = options[:end] || DateTime.now.offset(0)
10
+ end
11
+
12
+ def years
13
+ leep_year = 2004
14
+ end_with_leep_year = DateTime.new(leep_year, @end.month, @end.day, @end.hour, @end.min, @end.sec)
15
+ birth_with_leep_year = DateTime.new(leep_year, @birth.month, @birth.day, @birth.hour, @birth.min, @birth.sec)
16
+ if end_with_leep_year < birth_with_leep_year
17
+ @end.year - @birth.year - 1
18
+ else
19
+ @end.year - @birth.year
20
+ end
21
+ end
22
+
23
+ def to_i
24
+ years
25
+ end
26
+
27
+ def inspect
28
+ years.inspect
29
+ end
5
30
  end
@@ -1,3 +1,3 @@
1
- module Age
2
- VERSION = "0.0.2"
1
+ class Age
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,17 @@
1
+ #coding: utf-8
2
+ require 'minitest/autorun'
3
+ require 'age'
4
+
5
+ class TestAge < MiniTest::Unit::TestCase
6
+ def test_sanemat
7
+ assert_equal Age.new(birth: DateTime.new(1982, 7, 16), end: DateTime.new(2013, 5, 24)).to_i, 30
8
+ end
9
+
10
+ def test_ruby
11
+ assert_equal Age.new(birth: DateTime.new(1993, 2, 24), end: DateTime.new(2013, 5, 31)).to_i, 20
12
+ end
13
+
14
+ def test_inspect
15
+ assert_equal Age.new(birth: DateTime.new(1993, 2, 24), end: DateTime.new(2013, 5, 31)).inspect, '20'
16
+ end
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: age
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - sanemat
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-22 00:00:00.000000000 Z
11
+ date: 2013-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: Show your age.
42
56
  email:
43
57
  - o.gata.ken@gmail.com
@@ -46,6 +60,7 @@ extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
48
62
  - .gitignore
63
+ - .travis.yml
49
64
  - Gemfile
50
65
  - LICENSE.txt
51
66
  - README.md
@@ -53,6 +68,7 @@ files:
53
68
  - age.gemspec
54
69
  - lib/age.rb
55
70
  - lib/age/version.rb
71
+ - test/test_age.rb
56
72
  homepage: ''
57
73
  licenses:
58
74
  - MIT
@@ -77,4 +93,5 @@ rubygems_version: 2.0.2
77
93
  signing_key:
78
94
  specification_version: 4
79
95
  summary: Show your age.
80
- test_files: []
96
+ test_files:
97
+ - test/test_age.rb