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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84a788ac4632d04952f42217b048db94d2a73f89
4
- data.tar.gz: 6bb17aa13c75ea681fd983e51d280b664c431efb
3
+ metadata.gz: 72ebd515e75947c86d1e32a88206d4e6de306efd
4
+ data.tar.gz: 6f27f54d6ce987e25c736adba1e50c4c9ba63d62
5
5
  SHA512:
6
- metadata.gz: dc4f615d218039bfa561b3b2b751c224e03c77a7fd43520e757848c06835d0255d90938c08452af2eceded98f8f46b6405df0e966e56c246e46786af4d1c8bd8
7
- data.tar.gz: c4179d3884d1730e6c67805b59b8260ac6e8f907d475899fa4b3e90e493e393c771f9418c6909708fa48766abbe0063a35d6d7884f808efdfe6d9c5b8aa823cc
6
+ metadata.gz: 7970c7b36c3cc1fc52828e32ebe27fc7ee5ef3fdb42cf1b022dc584deeefaf442016df639342f5babc5d4b27de5b28f67f212e84f93cc8de20af7fc9e96be018
7
+ data.tar.gz: 87ab7ca0ac3826df3096d826d7b35f0b983b065646545bb4f9156e3d91ca1bda80ea85e581235310f2f6cbcef5d96431e5e67e25f02b19ca03cc7c01e382be5d
@@ -0,0 +1,2 @@
1
+ Style/AsciiComments:
2
+ Enabled: false
@@ -0,0 +1,11 @@
1
+ ## v.1.0.1
2
+ 2014/11/29
3
+
4
+ ### Update Feature
5
+ * Add japanese_zodiac option to Eto.name
6
+ * Add --not-japanese_zodiac option to eto name command
7
+
8
+ ## v.1.0.0
9
+ 2014/11/27
10
+
11
+ * first release
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 に対応する干支の emoji を取得|
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 1977
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 1977
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
- # Eto Names
8
- NAMES = %w( 酉 戌 亥).freeze
9
- # Eto Hash ( EtoName => EtoEmoji )
10
- HASH = {
11
- '子' => ':mouse:',
12
- '丑' => ':cow:',
13
- '' => ':tiger:',
14
- '' => ':rabbit:',
15
- '' => ':dragon:',
16
- '' => ':snake:',
17
- '' => ':horse:',
18
- '' => ':sheep:',
19
- '' => ':monkey:',
20
- '' => ':chicken:',
21
- '' => ':dog:',
22
- '' => ':boar:'
23
- }.freeze
24
-
25
- # get eto names
26
- def names
27
- NAMES
28
- end
29
-
30
- # get eto eto_hash
31
- def eto_hash
32
- HASH
33
- end
34
-
35
- # get eto name from year
36
- def name(year)
37
- int_year = validate_year(year)
38
- NAMES[(int_year + 8) % 12]
39
- end
40
-
41
- # get eto emoji from year
42
- def emoji(year)
43
- int_year = validate_year(year)
44
- HASH[name(int_year)]
45
- end
46
-
47
- private
48
-
49
- def self.validate_year(year)
50
- Integer(year)
51
- end
52
- end
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
@@ -1,4 +1,4 @@
1
1
  # Eto
2
2
  module Eto
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
@@ -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::NAMES
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.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-27 00:00:00.000000000 Z
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