eto 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +11 -0
- data/README.md +16 -5
- data/bin/eto +2 -1
- data/lib/eto.rb +57 -52
- data/lib/eto/version.rb +1 -1
- data/spec/eto_spec.rb +22 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72ebd515e75947c86d1e32a88206d4e6de306efd
|
4
|
+
data.tar.gz: 6f27f54d6ce987e25c736adba1e50c4c9ba63d62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7970c7b36c3cc1fc52828e32ebe27fc7ee5ef3fdb42cf1b022dc584deeefaf442016df639342f5babc5d4b27de5b28f67f212e84f93cc8de20af7fc9e96be018
|
7
|
+
data.tar.gz: 87ab7ca0ac3826df3096d826d7b35f0b983b065646545bb4f9156e3d91ca1bda80ea85e581235310f2f6cbcef5d96431e5e67e25f02b19ca03cc7c01e382be5d
|
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
Get Eto (Japanese Zodiac) name or emoji.
|
4
4
|
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/eto.svg)](http://badge.fury.io/rb/eto)
|
5
6
|
[![Build Status](https://travis-ci.org/tbpgr/eto.png?branch=master)](https://travis-ci.org/tbpgr/eto)
|
6
7
|
[![Coverage Status](https://coveralls.io/repos/tbpgr/eto/badge.png)](https://coveralls.io/r/tbpgr/eto)
|
7
8
|
|
@@ -28,9 +29,9 @@ $ gem install ruboty-articlegen
|
|
28
29
|
### Commands (Command Line)
|
29
30
|
|name|args|memo|
|
30
31
|
|:--|:--|:--|
|
31
|
-
|names
|
32
|
-
|name|year|year
|
33
|
-
|emoji|year|year
|
32
|
+
|names|--|全ての十二支を配列で返却|
|
33
|
+
|name|year, japanese_zodiac|year の 十干十二支 or 十二支名を取得|
|
34
|
+
|emoji|year|year に対応する十二支の emoji を取得|
|
34
35
|
|
35
36
|
## Usage ( Command Line Interface)
|
36
37
|
### names
|
@@ -43,15 +44,19 @@ $ eto names
|
|
43
44
|
~~~bash
|
44
45
|
$ eto name 1977
|
45
46
|
巳
|
46
|
-
$ eto name
|
47
|
+
$ eto name 1978
|
47
48
|
午
|
49
|
+
$ eto name 1965 --not-japanese_zodiac
|
50
|
+
丁巳
|
51
|
+
$ eto name 1977 --not-japanese_zodiac
|
52
|
+
乙巳
|
48
53
|
~~~
|
49
54
|
|
50
55
|
### emoji year
|
51
56
|
~~~bash
|
52
57
|
$ eto emoji 1977
|
53
58
|
:snake:
|
54
|
-
$ eto emoji
|
59
|
+
$ eto emoji 1978
|
55
60
|
:horse:
|
56
61
|
~~~
|
57
62
|
|
@@ -90,6 +95,12 @@ output
|
|
90
95
|
require 'eto'
|
91
96
|
Eto.name(1977) #=> '巳'
|
92
97
|
Eto.name(1978) #=> '午'
|
98
|
+
Eto.name(1965, true) #=> '巳'
|
99
|
+
Eto.name(1977, true) #=> '巳'
|
100
|
+
Eto.name(1978, true) #=> '午'
|
101
|
+
Eto.name(1965, false) #=> '乙巳'
|
102
|
+
Eto.name(1977, false) #=> '丁巳'
|
103
|
+
Eto.name(1978, false) #=> '戊午'
|
93
104
|
~~~
|
94
105
|
|
95
106
|
### Eto.emoji(year)
|
data/bin/eto
CHANGED
@@ -23,9 +23,10 @@ module Eto
|
|
23
23
|
end
|
24
24
|
|
25
25
|
desc 'name', 'get eto name from year'
|
26
|
+
option 'njz', type: :boolean, aliases: '--not-japanese_zodiac'
|
26
27
|
def name(year = 1970)
|
27
28
|
setting_debug_mode
|
28
|
-
puts Eto.name(year)
|
29
|
+
puts Eto.name(year, !options['njz'])
|
29
30
|
rescue => e
|
30
31
|
output_error_if_debug_mode(e)
|
31
32
|
exit(false)
|
data/lib/eto.rb
CHANGED
@@ -1,52 +1,57 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# Eto
|
4
|
-
module Eto
|
5
|
-
module_function
|
6
|
-
|
7
|
-
#
|
8
|
-
|
9
|
-
#
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
'
|
14
|
-
'
|
15
|
-
'
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'
|
20
|
-
'
|
21
|
-
'
|
22
|
-
'
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Eto
|
4
|
+
module Eto
|
5
|
+
module_function
|
6
|
+
|
7
|
+
# 十干
|
8
|
+
TEN_CALENDAR_SIGNS = %w(庚 辛 壬 癸 甲 乙 丙 丁 戊 己).freeze
|
9
|
+
# 十二支
|
10
|
+
JAPANESE_ZODIAC_NAMES = %w(子 丑 寅 卯 辰 巳 午 未 申 酉 戌 亥).freeze
|
11
|
+
# Eto Hash ( EtoName => EtoEmoji )
|
12
|
+
HASH = {
|
13
|
+
'子' => ':mouse:',
|
14
|
+
'丑' => ':cow:',
|
15
|
+
'寅' => ':tiger:',
|
16
|
+
'卯' => ':rabbit:',
|
17
|
+
'辰' => ':dragon:',
|
18
|
+
'巳' => ':snake:',
|
19
|
+
'午' => ':horse:',
|
20
|
+
'未' => ':sheep:',
|
21
|
+
'申' => ':monkey:',
|
22
|
+
'酉' => ':chicken:',
|
23
|
+
'戌' => ':dog:',
|
24
|
+
'亥' => ':boar:'
|
25
|
+
}.freeze
|
26
|
+
|
27
|
+
# get eto names
|
28
|
+
def names
|
29
|
+
JAPANESE_ZODIAC_NAMES
|
30
|
+
end
|
31
|
+
|
32
|
+
# get eto eto_hash
|
33
|
+
def eto_hash
|
34
|
+
HASH
|
35
|
+
end
|
36
|
+
|
37
|
+
# get eto name from year
|
38
|
+
def name(year, japanese_zodiac = true)
|
39
|
+
int_year = validate_year(year)
|
40
|
+
japanese_zodiac_text = JAPANESE_ZODIAC_NAMES[(int_year + 8) % 12]
|
41
|
+
return japanese_zodiac_text if japanese_zodiac
|
42
|
+
ten_calendar_signs_text = TEN_CALENDAR_SIGNS[(int_year) % 10]
|
43
|
+
"#{ten_calendar_signs_text}#{japanese_zodiac_text}"
|
44
|
+
end
|
45
|
+
|
46
|
+
# get eto emoji from year
|
47
|
+
def emoji(year)
|
48
|
+
int_year = validate_year(year)
|
49
|
+
HASH[name(int_year)]
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def self.validate_year(year)
|
55
|
+
Integer(year)
|
56
|
+
end
|
57
|
+
end
|
data/lib/eto/version.rb
CHANGED
data/spec/eto_spec.rb
CHANGED
@@ -2,13 +2,14 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'eto'
|
4
4
|
|
5
|
+
# rubocop: disable LineLength
|
5
6
|
describe Eto do
|
6
7
|
context :names do
|
7
8
|
cases = [
|
8
9
|
{
|
9
10
|
case_no: 1,
|
10
11
|
case_title: 'eto names',
|
11
|
-
expected: Eto::
|
12
|
+
expected: Eto::JAPANESE_ZODIAC_NAMES
|
12
13
|
}
|
13
14
|
]
|
14
15
|
|
@@ -83,19 +84,36 @@ describe Eto do
|
|
83
84
|
case_no: 1,
|
84
85
|
case_title: 'eto name from year',
|
85
86
|
year: 1977,
|
87
|
+
japanese_zodiac: true,
|
86
88
|
expected: '巳'
|
87
89
|
},
|
88
90
|
{
|
89
91
|
case_no: 2,
|
90
92
|
case_title: 'eto name from year',
|
91
93
|
year: 1978,
|
94
|
+
japanese_zodiac: true,
|
92
95
|
expected: '午'
|
93
96
|
},
|
94
97
|
{
|
95
98
|
case_no: 3,
|
96
99
|
case_title: 'not integer year',
|
97
100
|
year: 'abc',
|
101
|
+
japanese_zodiac: true,
|
98
102
|
expect_error: true
|
103
|
+
},
|
104
|
+
{
|
105
|
+
case_no: 4,
|
106
|
+
case_title: 'eto name from year (japanese_zodiac = false)',
|
107
|
+
year: 1965,
|
108
|
+
japanese_zodiac: false,
|
109
|
+
expected: '乙巳'
|
110
|
+
},
|
111
|
+
{
|
112
|
+
case_no: 5,
|
113
|
+
case_title: 'eto name from year (japanese_zodiac = false)',
|
114
|
+
year: 1977,
|
115
|
+
japanese_zodiac: false,
|
116
|
+
expected: '丁巳'
|
99
117
|
}
|
100
118
|
]
|
101
119
|
|
@@ -109,10 +127,10 @@ describe Eto do
|
|
109
127
|
|
110
128
|
# -- when --
|
111
129
|
if c[:expect_error]
|
112
|
-
expect { Eto.name(c[:year]) }.to raise_error(ArgumentError)
|
130
|
+
expect { Eto.name(c[:year], c[:japanese_zodiac]) }.to raise_error(ArgumentError)
|
113
131
|
next
|
114
132
|
end
|
115
|
-
actual = Eto.name(c[:year])
|
133
|
+
actual = Eto.name(c[:year], c[:japanese_zodiac])
|
116
134
|
|
117
135
|
# -- then --
|
118
136
|
expect(actual).to eq(c[:expected])
|
@@ -185,3 +203,4 @@ describe Eto do
|
|
185
203
|
end
|
186
204
|
end
|
187
205
|
end
|
206
|
+
# rubocop: enable LineLength
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tbpgr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -63,7 +63,9 @@ files:
|
|
63
63
|
- .coveralls.yml
|
64
64
|
- .gitignore
|
65
65
|
- .rspec
|
66
|
+
- .rubocop.yml
|
66
67
|
- .travis.yml
|
68
|
+
- CHANGELOG.md
|
67
69
|
- Gemfile
|
68
70
|
- LICENSE.txt
|
69
71
|
- README.md
|