ehou 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +14 -0
- data/.rspec +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +57 -0
- data/Rakefile +7 -0
- data/ehou.gemspec +23 -0
- data/lib/ehou.rb +6 -0
- data/lib/ehou/ehou_extend.rb +18 -0
- data/lib/ehou/ehou_string.rb +44 -0
- data/lib/ehou/version.rb +3 -0
- data/spec/ehou/ehou_extend_spec.rb +51 -0
- data/spec/ehou/ehou_string_spec.rb +23 -0
- data/spec/ehou_spec.rb +7 -0
- data/spec/spec_helper.rb +5 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 57aba793e68b5b06e63ab48946d2ec2251991f93
|
4
|
+
data.tar.gz: 66dc11280c60cd1ad65d0e2cbca005ff8aabac15
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 219b7d30fef7937b755998dcb3bc14800118c67b464411f96b3c14e7902537b26746dda0b1e3f90ea83e3f94a0d3750c8b6a53a0202df2092e9348118e322ab7
|
7
|
+
data.tar.gz: 467a39c7a64315bcc258bd67d8f00544b03ee7475874496dea39e4a2a6261f317f168f237d5159b3f326c9f197806fef3023d0fa2dd720a2181f3d34b01cd1b6
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Koozyt, Inc.
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Ehou
|
2
|
+
|
3
|
+
[](https://travis-ci.org/koozyt/ehou)
|
4
|
+
[](https://coveralls.io/r/koozyt/ehou?branch=master)
|
5
|
+
[](https://codeclimate.com/github/koozyt/ehou)
|
6
|
+
|
7
|
+
Patches `Date` and `Time` to add methods and convert to Japanese **Ehou** direction.
|
8
|
+
|
9
|
+
Ehou is the lucky direction of the year which is determined every year by the [Celestial stems][1].
|
10
|
+
It is customary in Japan at Setsubun (celebrated on Feb 3) to eat a special sushi roll in silence facing the "Ehou" direction for good fortune.
|
11
|
+
|
12
|
+
Have a great Setsubun!
|
13
|
+
|
14
|
+
For more info on "Ehou", see: [Ehou][2]
|
15
|
+
|
16
|
+
[1]:http://en.wikipedia.org/wiki/Celestial_stem
|
17
|
+
[2]:http://ja.wikipedia.org/wiki/%E6%AD%B3%E5%BE%B3%E7%A5%9E#.E6.81.B5.E6.96.B9
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'ehou'
|
23
|
+
|
24
|
+
Date.new(2015).ehou # "西南西"
|
25
|
+
Date.new(2015).ehou.angle # 255 (0 means north, 90 is east, 180 is south)
|
26
|
+
Date.new(2015).ehou.to_en # "West-southwest"
|
27
|
+
Date.new(2015).ehou.shorten # "WSW"
|
28
|
+
Time.local(2016).ehou # "南南東"
|
29
|
+
Time.local(2016).ehou.angle # 165
|
30
|
+
Time.local(2016).ehou.to_en # "South-southeast"
|
31
|
+
Time.local(2016).ehou.shorten # "SSE"
|
32
|
+
```
|
33
|
+
|
34
|
+
## Installation
|
35
|
+
|
36
|
+
Add this line to your application's Gemfile:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
gem 'ehou'
|
40
|
+
```
|
41
|
+
|
42
|
+
And then execute:
|
43
|
+
|
44
|
+
$ bundle
|
45
|
+
|
46
|
+
Or install it yourself as:
|
47
|
+
|
48
|
+
$ gem install ehou
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
1. Fork it ( https://github.com/koozyt/ehou/fork )
|
53
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
54
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
55
|
+
4. Make sure all your changes are covered by tests
|
56
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
57
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/ehou.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ehou/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ehou"
|
8
|
+
spec.version = Ehou::VERSION
|
9
|
+
spec.authors = ["ikesato"]
|
10
|
+
spec.email = ["github@koozyt.com"]
|
11
|
+
spec.summary = %q{Japanese Ehou converter}
|
12
|
+
spec.description = %q{Patches Date and Time to add methods and convert to Japanese Ehou direction.}
|
13
|
+
spec.homepage = "https://github.com/koozyt/ehou"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
data/lib/ehou.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
module Ehou
|
5
|
+
module EhouExtend
|
6
|
+
def ehou
|
7
|
+
return @ehou if @ehou
|
8
|
+
@ehou = EhouString.new(self.year)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
::Date.class_eval do
|
14
|
+
include ::Ehou::EhouExtend
|
15
|
+
end
|
16
|
+
::Time.class_eval do
|
17
|
+
include ::Ehou::EhouExtend
|
18
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Ehou
|
4
|
+
class EhouString < String
|
5
|
+
EHOU_ENE = {angle: 75, shorten:"ENE", ja:"東北東", en:"East-northeast"}
|
6
|
+
EHOU_SSE = {angle: 165, shorten:"SSE", ja:"南南東", en:"South-southeast"}
|
7
|
+
EHOU_WSW = {angle: 255, shorten:"WSW", ja:"西南西", en:"West-southwest"}
|
8
|
+
EHOU_NNW = {angle: 345, shorten:"NNW", ja:"北北西", en:"North-northwest"}
|
9
|
+
EHOUS = {
|
10
|
+
0 => EHOU_WSW,
|
11
|
+
1 => EHOU_SSE,
|
12
|
+
2 => EHOU_NNW,
|
13
|
+
3 => EHOU_SSE,
|
14
|
+
4 => EHOU_ENE,
|
15
|
+
5 => EHOU_WSW,
|
16
|
+
6 => EHOU_SSE,
|
17
|
+
7 => EHOU_NNW,
|
18
|
+
8 => EHOU_SSE,
|
19
|
+
9 => EHOU_ENE
|
20
|
+
}
|
21
|
+
|
22
|
+
def initialize(year)
|
23
|
+
y = year % 10
|
24
|
+
@ehou = EHOUS[y]
|
25
|
+
super(@ehou[:ja])
|
26
|
+
end
|
27
|
+
|
28
|
+
def angle
|
29
|
+
@ehou[:angle]
|
30
|
+
end
|
31
|
+
|
32
|
+
def shorten
|
33
|
+
@ehou[:shorten]
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_en
|
37
|
+
@ehou[:en]
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_ja
|
41
|
+
self
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/ehou/version.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'active_support/time'
|
4
|
+
|
5
|
+
describe Ehou::EhouExtend do
|
6
|
+
describe Date do
|
7
|
+
it 'should return ehou string' do
|
8
|
+
expect(Date.new(2014).ehou).to eq "東北東"
|
9
|
+
expect(Date.new(2015).ehou).to eq "西南西"
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should return ehou angle' do
|
13
|
+
expect(Date.new(2014).ehou.angle).to eq 75
|
14
|
+
expect(Date.new(2015).ehou.angle).to eq 255
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should return same object when calling twice' do
|
18
|
+
d = Date.new(2014)
|
19
|
+
last = d.ehou
|
20
|
+
expect(d.ehou.object_id).to eq last.object_id
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe Time do
|
25
|
+
it 'should return ehou string' do
|
26
|
+
expect(Time.local(2014).ehou).to eq "東北東"
|
27
|
+
expect(Time.local(2015).ehou).to eq "西南西"
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should return ehou angle' do
|
31
|
+
expect(Time.local(2014).ehou.angle).to eq 75
|
32
|
+
expect(Time.local(2015).ehou.angle).to eq 255
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should return same object when calling twice' do
|
36
|
+
d = Time.local(2014)
|
37
|
+
last = d.ehou
|
38
|
+
expect(d.ehou.object_id).to eq last.object_id
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe ActiveSupport::TimeWithZone do
|
43
|
+
it 'should work using ActiveSupport::TimeWithZone' do
|
44
|
+
Time.zone = 'Asia/Tokyo'
|
45
|
+
expect(Time.zone.local(2014).ehou).to eq "東北東"
|
46
|
+
expect(Time.zone.local(2014).ehou.angle).to eq 75
|
47
|
+
expect(Time.zone.local(2015).ehou).to eq "西南西"
|
48
|
+
expect(Time.zone.local(2015).ehou.angle).to eq 255
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'active_support/time'
|
4
|
+
|
5
|
+
describe Ehou::EhouString do
|
6
|
+
def get_ehou(year)
|
7
|
+
e = Date.new(year)
|
8
|
+
[e.ehou.angle, e.ehou, e.ehou.to_ja, e.ehou.shorten, e.ehou.to_en]
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should select correct ehous' do
|
12
|
+
expect(get_ehou(2010)).to eq [255, "西南西", "西南西", "WSW", "West-southwest"]
|
13
|
+
expect(get_ehou(2011)).to eq [165, "南南東", "南南東", "SSE", "South-southeast"]
|
14
|
+
expect(get_ehou(2012)).to eq [345, "北北西", "北北西", "NNW", "North-northwest"]
|
15
|
+
expect(get_ehou(2013)).to eq [165, "南南東", "南南東", "SSE", "South-southeast"]
|
16
|
+
expect(get_ehou(2014)).to eq [ 75, "東北東", "東北東", "ENE", "East-northeast"]
|
17
|
+
expect(get_ehou(2015)).to eq [255, "西南西", "西南西", "WSW", "West-southwest"]
|
18
|
+
expect(get_ehou(2016)).to eq [165, "南南東", "南南東", "SSE", "South-southeast"]
|
19
|
+
expect(get_ehou(2017)).to eq [345, "北北西", "北北西", "NNW", "North-northwest"]
|
20
|
+
expect(get_ehou(2018)).to eq [165, "南南東", "南南東", "SSE", "South-southeast"]
|
21
|
+
expect(get_ehou(2019)).to eq [ 75, "東北東", "東北東", "ENE", "East-northeast"]
|
22
|
+
end
|
23
|
+
end
|
data/spec/ehou_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ehou
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ikesato
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Patches Date and Time to add methods and convert to Japanese Ehou direction.
|
42
|
+
email:
|
43
|
+
- github@koozyt.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".coveralls.yml"
|
49
|
+
- ".gitignore"
|
50
|
+
- ".rspec"
|
51
|
+
- ".travis.yml"
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- ehou.gemspec
|
57
|
+
- lib/ehou.rb
|
58
|
+
- lib/ehou/ehou_extend.rb
|
59
|
+
- lib/ehou/ehou_string.rb
|
60
|
+
- lib/ehou/version.rb
|
61
|
+
- spec/ehou/ehou_extend_spec.rb
|
62
|
+
- spec/ehou/ehou_string_spec.rb
|
63
|
+
- spec/ehou_spec.rb
|
64
|
+
- spec/spec_helper.rb
|
65
|
+
homepage: https://github.com/koozyt/ehou
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 2.4.2
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Japanese Ehou converter
|
89
|
+
test_files:
|
90
|
+
- spec/ehou/ehou_extend_spec.rb
|
91
|
+
- spec/ehou/ehou_string_spec.rb
|
92
|
+
- spec/ehou_spec.rb
|
93
|
+
- spec/spec_helper.rb
|