white_hare 0.2.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/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/white_hare.rb +8 -0
- data/lib/white_hare/monthly.rb +84 -0
- data/lib/white_hare/version.rb +5 -0
- data/white_hare.gemspec +30 -0
- metadata +141 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: abf6229f69e930da5fffea3bc0d47befdbcb746b
|
|
4
|
+
data.tar.gz: a3d51f1bf67b0d49bf45c02b8000ab5a5b7cfea6
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: acae9e02af118070c1fedcc1e42bec8e7e93cfb338bb0f85b664ae8071aedd990c20762b6ef15db35eda528eb05ebf8af0d087ace18303ad0abae631f2e14984
|
|
7
|
+
data.tar.gz: 0604eb9cd243391b848b034da66bbb9e1b423685782f33a7e5f3472ff20f43e746beb35ad02e05e640ab1f767d3bd27b6cc4ea50c02d8e789f57aea1e3022379
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
sudo: false
|
|
2
|
+
language: ruby
|
|
3
|
+
rvm:
|
|
4
|
+
- 2.3.1
|
|
5
|
+
before_install: gem install bundler -v 1.13.5
|
|
6
|
+
notifications:
|
|
7
|
+
slack:
|
|
8
|
+
secure: f8/WMyY7+rxgoFMA44w1yRh6kZTJAXjkof6C8Bqdzk/Y9yNN9LZPP7NCvWEPuWS2ARUHCTW7YaxPFEziqNu80w3s8w6OD+/1cFH8q+m1onsTgz0OKtRJtOXmIewRq8Stnsy/fv6iQUBolLiVZUlN2FK/n2K8C090Ysdwrlcs04OW9bl9QWf4X6cnX3Orsyc5tj5boaKPBUvCXn+vsUhhGy0V2FNYfcjPozM6U1kLVZLKkDp6sAuKenJY7CrEPC3YrX/AGjClSYlzG/Ic3GwGWIOjYLkp7oMiVLvCymW/cY6DTDqQbgAuPvI83cA46qVLxPNDtnSk48TXgVBjUD8dstJgEGd6loBma72H6OcI/ZWuBmYNqSJK7eZRzviOAjYiyyEVVxm901ZslTUYRWhkvN9UZy57Jqw5eVrSk34cQ/F4hdxKaoPLD7JScZ4Lv7tT/geoMaFh50f8W79hA+/FR4WxEHc2J9GaRotnIKCEuCRC783Sv4miqsU3E8HT2PzGj002DBb9Y77a1DaEtWWkLjecVtIG+M1im/3p3vUR0uDHdxI1oAjogEptaZQHQ/murgOa1EcjWmgWjIkkdPiw7gIjzgiKdC8z/8RM8YIVZvIVW3oq7Oc+C1QNNsVhzKW5vh9xdVTSByxbW91k6Fcf82imD2ArELyesF2r/EUtz7s=
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 SAKAI, Kazuaki
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# WhiteHare [](https://travis-ci.org/send/white_hare)
|
|
2
|
+
|
|
3
|
+
"Oh dear! Oh dear! I shall be too late!" WhiteHare is a library for business date usages like closing date.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'white_hare'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install white_hare
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
TODO: Write usage instructions here
|
|
24
|
+
|
|
25
|
+
## Development
|
|
26
|
+
|
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
28
|
+
|
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
30
|
+
|
|
31
|
+
## Contributing
|
|
32
|
+
|
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/send/white_hare.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
39
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "white_hare"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/white_hare.rb
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module WhiteHare
|
|
4
|
+
module Monthly
|
|
5
|
+
def self.next_month(year, month, day)
|
|
6
|
+
Date.new(year, month, day) >> 1
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.prev_month(year, month, day)
|
|
10
|
+
Date.new(year, month, day) << 1
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.beginning_of(year, month, closing_date: nil)
|
|
14
|
+
return Date.new(year, month, 1) if closing_date.nil?
|
|
15
|
+
prev_month(year, month, closing_date) + 1
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.end_of(year, month, closing_date: nil)
|
|
19
|
+
return Date.new(year, month, closing_date) unless closing_date.nil?
|
|
20
|
+
next_month(year, month, 1) - 1
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.term(year, month, closing_date: nil)
|
|
24
|
+
first = beginning_of(year, month, closing_date: closing_date)
|
|
25
|
+
last = end_of(year, month, closing_date: closing_date)
|
|
26
|
+
first..last
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
%w(
|
|
30
|
+
sunday monday tuesday wednesday thursday friday saturday
|
|
31
|
+
).each_with_index do |weekday, wday|
|
|
32
|
+
%w(first second third fourth fifth).each_with_index do |nth, week|
|
|
33
|
+
module_eval <<-METHODS
|
|
34
|
+
def self.#{nth}_#{weekday}_of(year, month)
|
|
35
|
+
first = Date.new(year, month, 1)
|
|
36
|
+
wday_offset = (7 - first.wday + #{wday}) % 7
|
|
37
|
+
week_offset = 7 * #{week}
|
|
38
|
+
first + (wday_offset + week_offset)
|
|
39
|
+
end
|
|
40
|
+
METHODS
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
refine Date do
|
|
45
|
+
# Active Support has same methods below.
|
|
46
|
+
unless (
|
|
47
|
+
defined?(DateAndTime::Calculations) &&
|
|
48
|
+
self.included?(DateAndTime::Calculations)
|
|
49
|
+
)
|
|
50
|
+
def next_month
|
|
51
|
+
WhiteHare::Monthly.next_month(year, month, day)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def prev_month
|
|
55
|
+
WhiteHare::Monthly.prev_month(year, month, day)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def beginning_of_monthly(closing_date = nil)
|
|
60
|
+
WhiteHare::Monthly.beginning_of(year, month, closing_date: closing_date)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def end_of_monthly(closing_date = nil)
|
|
64
|
+
WhiteHare::Monthly.end_of(year, month, closing_date: closing_date)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def monthly_term(closing_date = nil)
|
|
68
|
+
WhiteHare::Monthly.term(year, month, closing_date: closing_date)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
%w(
|
|
72
|
+
sunday monday tuesday wednesday thursday friday saturday
|
|
73
|
+
).each_with_index do |weekday, wday|
|
|
74
|
+
%w(first second third fourth fifth).each_with_index do |nth, week|
|
|
75
|
+
module_eval <<-METHODS
|
|
76
|
+
def #{nth}_#{weekday}
|
|
77
|
+
WhiteHare::Monthly.#{nth}_#{weekday}_of(year, month)
|
|
78
|
+
end
|
|
79
|
+
METHODS
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
data/white_hare.gemspec
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'white_hare/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "white_hare"
|
|
8
|
+
spec.version = WhiteHare::VERSION
|
|
9
|
+
spec.authors = ["SAKAI, Kazuaki"]
|
|
10
|
+
spec.email = ["kaz.july.7@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{A library for business date usages}
|
|
13
|
+
spec.description = %q{WhiteHare is a library for business date usage like the closing date.}
|
|
14
|
+
spec.homepage = "https://github.com/send/white_hare"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
|
19
|
+
end
|
|
20
|
+
spec.bindir = "exe"
|
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
22
|
+
spec.require_paths = ["lib"]
|
|
23
|
+
|
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
|
25
|
+
spec.add_development_dependency "pry", "~> 0.10.4"
|
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
28
|
+
spec.add_development_dependency "simplecov", "~> 0.12.0"
|
|
29
|
+
spec.add_development_dependency "travis", "~> 1.8.2"
|
|
30
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: white_hare
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- SAKAI, Kazuaki
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-04-06 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.13'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.13'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: pry
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 0.10.4
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 0.10.4
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '10.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '10.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'
|
|
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'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: simplecov
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 0.12.0
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 0.12.0
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: travis
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: 1.8.2
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 1.8.2
|
|
97
|
+
description: WhiteHare is a library for business date usage like the closing date.
|
|
98
|
+
email:
|
|
99
|
+
- kaz.july.7@gmail.com
|
|
100
|
+
executables: []
|
|
101
|
+
extensions: []
|
|
102
|
+
extra_rdoc_files: []
|
|
103
|
+
files:
|
|
104
|
+
- ".gitignore"
|
|
105
|
+
- ".rspec"
|
|
106
|
+
- ".travis.yml"
|
|
107
|
+
- Gemfile
|
|
108
|
+
- LICENSE.txt
|
|
109
|
+
- README.md
|
|
110
|
+
- Rakefile
|
|
111
|
+
- bin/console
|
|
112
|
+
- bin/setup
|
|
113
|
+
- lib/white_hare.rb
|
|
114
|
+
- lib/white_hare/monthly.rb
|
|
115
|
+
- lib/white_hare/version.rb
|
|
116
|
+
- white_hare.gemspec
|
|
117
|
+
homepage: https://github.com/send/white_hare
|
|
118
|
+
licenses:
|
|
119
|
+
- MIT
|
|
120
|
+
metadata: {}
|
|
121
|
+
post_install_message:
|
|
122
|
+
rdoc_options: []
|
|
123
|
+
require_paths:
|
|
124
|
+
- lib
|
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
|
+
requirements:
|
|
127
|
+
- - ">="
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
version: '0'
|
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
|
+
requirements:
|
|
132
|
+
- - ">="
|
|
133
|
+
- !ruby/object:Gem::Version
|
|
134
|
+
version: '0'
|
|
135
|
+
requirements: []
|
|
136
|
+
rubyforge_project:
|
|
137
|
+
rubygems_version: 2.6.11
|
|
138
|
+
signing_key:
|
|
139
|
+
specification_version: 4
|
|
140
|
+
summary: A library for business date usages
|
|
141
|
+
test_files: []
|