trading_day_jp 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c436eff89e1857fd7e2162baeaece5e867d082b3
4
+ data.tar.gz: 36c25e98de015322863e44e7910cfb0357d605bf
5
+ SHA512:
6
+ metadata.gz: b3e6d05318f72d16b59c6a361437c34ebb990d67a1110168b7af01a725719a7f7c7114255315b20c94ba4584ea4dede6adb6be7e9ab147e73304fee6d62050d7
7
+ data.tar.gz: b58b4f6ee293832eac92ae5cd6d06b40861671a9cbdef9f9aa21b88509b6ac615a20956254b0bddd49db2fa48ae6eb5ff70ca61b8436e27e8667bd41b1ff3abb
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ vendor
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in trading_day_jp.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Takehiko Shinkura
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,42 @@
1
+ # TradingDayJp
2
+
3
+ Trading days for Japanese stock market.
4
+
5
+ ## Usage
6
+
7
+ 日本の証券取引所で取引が行われる日であるか判定します。<br>
8
+ 大発会〜大納会のうち、休日及び祝日でない日が該当します。
9
+
10
+ ``` ruby
11
+ date = Date.new(2014, 12, 30)
12
+
13
+ date.trading_day_jp? # => true
14
+ TradingDayJp.open?(date) # => true
15
+
16
+ date = Date.new(2014, 12, 31)
17
+
18
+ date.trading_day_jp? # => false
19
+ TradingDayJp.open?(date) # => false
20
+ ```
21
+
22
+ ## Installation
23
+
24
+ Add this line to your application's Gemfile:
25
+
26
+ gem 'trading_day_jp'
27
+
28
+ And then execute:
29
+
30
+ $ bundle
31
+
32
+ Or install it yourself as:
33
+
34
+ $ gem install trading_day_jp
35
+
36
+ ## Contributing
37
+
38
+ 1. Fork it ( https://github.com/[my-github-username]/trading_day_jp/fork )
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,9 @@
1
+ require "trading_day_jp/date"
2
+
3
+ module TradingDayJp
4
+
5
+ def self.open?(date)
6
+ date.trading_day_jp?
7
+ end
8
+
9
+ end
@@ -0,0 +1,20 @@
1
+ require "holiday_jp"
2
+
3
+ class Date
4
+
5
+ def trading_day_jp?
6
+ date_open = Date.new(self.year, 1, 4)
7
+ date_close = Date.new(self.year, 12, 30)
8
+
9
+ if saturday? || sunday?
10
+ false
11
+ elsif HolidayJp.holiday? self
12
+ false
13
+ elsif self < date_open || self > date_close
14
+ false
15
+ else
16
+ true
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,3 @@
1
+ module TradingDayJp
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1 @@
1
+ require 'trading_day_jp'
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+
3
+ describe Date do
4
+
5
+ describe '#trading_day_jp?' do
6
+ context '月曜日' do
7
+ let(:date) { Date.new 2014, 8, 18 }
8
+
9
+ it { expect(date.trading_day_jp?).to eq true }
10
+ end
11
+
12
+ context '金曜日' do
13
+ let(:date) { Date.new 2014, 8, 22 }
14
+
15
+ it { expect(date.trading_day_jp?).to eq true }
16
+ end
17
+
18
+ context '土曜日' do
19
+ let(:date) { Date.new 2014, 8, 23 }
20
+
21
+ it { expect(date.trading_day_jp?).to eq false }
22
+ end
23
+
24
+ context '日曜日' do
25
+ let(:date) { Date.new 2014, 8, 24 }
26
+
27
+ it { expect(date.trading_day_jp?).to eq false }
28
+ end
29
+
30
+ context '海の日(祝日)' do
31
+ let(:date) { Date.new 2014, 7, 21 }
32
+
33
+ it { expect(date.trading_day_jp?).to eq false }
34
+ end
35
+
36
+ context '大発会前日' do
37
+ let(:date) { Date.new 2017, 1, 3 }
38
+
39
+ it { expect(date.trading_day_jp?).to eq false }
40
+ end
41
+
42
+ context '大発会' do
43
+ let(:date) { Date.new 2017, 1, 4 }
44
+
45
+ it { expect(date.trading_day_jp?).to eq true }
46
+ end
47
+
48
+ context '大発会翌日' do
49
+ let(:date) { Date.new 2017, 1, 5 }
50
+
51
+ it { expect(date.trading_day_jp?).to eq true }
52
+ end
53
+
54
+ context '大発会(休日)' do
55
+ let(:date) { Date.new 2014, 1, 4 }
56
+
57
+ it { expect(date.trading_day_jp?).to eq false }
58
+ end
59
+
60
+ context '大納会前日' do
61
+ let(:date) { Date.new 2014, 12, 29 }
62
+
63
+ it { expect(date.trading_day_jp?).to eq true }
64
+ end
65
+
66
+ context '大納会' do
67
+ let(:date) { Date.new 2014, 12, 30 }
68
+
69
+ it { expect(date.trading_day_jp?).to eq true }
70
+ end
71
+
72
+ context '大納会翌日' do
73
+ let(:date) { Date.new 2014, 12, 31 }
74
+
75
+ it { expect(date.trading_day_jp?).to eq false }
76
+ end
77
+
78
+ context '大納会(休日)' do
79
+ let(:date) { Date.new 2017, 12, 30 }
80
+
81
+ it { expect(date.trading_day_jp?).to eq false }
82
+ end
83
+ end
84
+
85
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe TradingDayJp do
4
+
5
+ describe '.open?' do
6
+ it { expect(TradingDayJp.open? Date.new(2014, 8, 28)).to eq true }
7
+ end
8
+
9
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'trading_day_jp/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "trading_day_jp"
8
+ spec.version = TradingDayJp::VERSION
9
+ spec.authors = ["Takehiko Shinkura"]
10
+ spec.email = ["tynmarket@gmail.com"]
11
+ spec.summary = %q{Trading days for Japanese stock market}
12
+ # spec.description = %q{TODO: Write a longer description. Optional.}
13
+ spec.homepage = "https://github.com/tyn-iMarket/trading_day_jp.git"
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_runtime_dependency "holiday_jp"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec", "~> 3.0.0"
26
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trading_day_jp
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Takehiko Shinkura
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: holiday_jp
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
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'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0
69
+ description:
70
+ email:
71
+ - tynmarket@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - lib/trading_day_jp.rb
83
+ - lib/trading_day_jp/date.rb
84
+ - lib/trading_day_jp/version.rb
85
+ - spec/spec_helper.rb
86
+ - spec/trading_day_jp/date_spec.rb
87
+ - spec/trading_day_jp_spec.rb
88
+ - trading_day_jp.gemspec
89
+ homepage: https://github.com/tyn-iMarket/trading_day_jp.git
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.2.2
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Trading days for Japanese stock market
113
+ test_files:
114
+ - spec/spec_helper.rb
115
+ - spec/trading_day_jp/date_spec.rb
116
+ - spec/trading_day_jp_spec.rb