jpdate 0.2.2 → 0.2.3
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 +4 -4
- data/README.md +10 -10
- data/bin/jcal +12 -8
- data/lib/jpdate/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba5362c3d78f6735bcf282c71bbfd3e7b0b5f8bc874ef55d9d2f867ba51fa787
|
4
|
+
data.tar.gz: '013497e6bb445da846b2549c592c8da6f1d8dfd2d77a87acbeb59ffb7c4affec'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 302567e4a37f9fff4ab929a58776304885f570dd5c5fa512bb4b62f9b555658fc9d647cec8950bc301f52a3f805ec1fee88e31cd7ce1e3a10eb699eed4728c79
|
7
|
+
data.tar.gz: 5f9449016be613f1b4a6f35c8f9f4997b600619ca5aabd8dad5320e4657dbaeeb1ae07acbc01d0ab26b2a6c31ebd21ccb655a4cdbfc1f6c72b8c1d383ac2ee22
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#jcalコマンド & JPDateクラス
|
1
|
+
# jcalコマンド & JPDateクラス
|
2
2
|
|
3
3
|
* jcal : 日本の祝日もちゃんと表示するカレンダー出力コマンド。
|
4
4
|
* JPDate: 祝日名称と年号を返すクラス&モジュール。
|
@@ -12,16 +12,16 @@
|
|
12
12
|
* 日本の暦は、明治6年・1873年1月1日より太陽暦で動いている。(それ以前は太陰暦)
|
13
13
|
* jcal・JPDateは、太陽暦以降の祝日に関する法律に可能な限り準拠しようとしている。
|
14
14
|
|
15
|
-
##Installation インストール
|
15
|
+
## Installation インストール
|
16
16
|
|
17
17
|
$ sudo gem install jpdate
|
18
18
|
|
19
|
-
##Usage 使い方(jcal)
|
19
|
+
## Usage 使い方(jcal)
|
20
20
|
|
21
21
|
Usage: jcal [options] [yyyy|mm] [yyyy|mm] [yyyy|mm]
|
22
22
|
|
23
|
-
-y[NUM]
|
24
|
-
-m[NUM] Show NUM months.
|
23
|
+
-y[NUM] Show NUM years.(0-10)
|
24
|
+
-m[NUM] Show NUM months.
|
25
25
|
-e List with the name of Japanese era.
|
26
26
|
|
27
27
|
Example:
|
@@ -36,7 +36,7 @@
|
|
36
36
|
jcal -m6 2010 1 # Show monthly calendar from Jan.2010 to Jun.2010.
|
37
37
|
jcal 2010 2 8 # Show monthly calendar from Feb.2010 to Aug.2010.
|
38
38
|
|
39
|
-
##Usage 使い方(JPDate, JPDate::Holiday, JPDate::Era)
|
39
|
+
## Usage 使い方(JPDate, JPDate::Holiday, JPDate::Era)
|
40
40
|
|
41
41
|
require 'jpdate'
|
42
42
|
|
@@ -74,21 +74,21 @@
|
|
74
74
|
JPDate::Era.short_name_year(1989)
|
75
75
|
=> ["S64", "H01"]
|
76
76
|
|
77
|
-
##More Document さらなるドキュメント
|
77
|
+
## More Document さらなるドキュメント
|
78
78
|
|
79
|
-
###gemサーバーを起動する方法
|
79
|
+
### gemサーバーを起動する方法
|
80
80
|
$ gem server -l
|
81
81
|
|
82
82
|
* gemサーバー起動後、以下のURLを開く。
|
83
83
|
* http://0.0.0.0:8808/doc_root/jpdate-0.1/
|
84
84
|
|
85
|
-
###Rdocを生成する方法
|
85
|
+
### Rdocを生成する方法
|
86
86
|
|
87
87
|
$ cd ~/Desktop
|
88
88
|
$ rdoc $(dirname `gem which jpdate`)
|
89
89
|
$ open doc/index.html
|
90
90
|
|
91
|
-
##Contributing 貢献
|
91
|
+
## Contributing 貢献
|
92
92
|
|
93
93
|
1. フォークする。 ( https://github.com/[my-github-username]/sample/fork )
|
94
94
|
2. フィーチャーブランチを作る。 (`git checkout -b my-new-feature`)
|
data/bin/jcal
CHANGED
@@ -30,10 +30,10 @@ module Jcal
|
|
30
30
|
|
31
31
|
module_function
|
32
32
|
|
33
|
-
def render_matrix(y, m)
|
33
|
+
def render_matrix(y, m, cell=16)
|
34
34
|
m = 12 if m == 0
|
35
|
-
title = (sprintf("#{JPDate::Era.name_year(y, m).join('/')} %4d年 %2d月", y, m)).center_ja(
|
36
|
-
week_names = WEEK_JA.map {|s| s.rjust_ja(
|
35
|
+
title = (sprintf("#{JPDate::Era.name_year(y, m).join('/')} %4d年 %2d月", y, m)).center_ja(cell * 7)
|
36
|
+
week_names = WEEK_JA.map {|s| s.rjust_ja(cell)}
|
37
37
|
week_names[0] = "\e[31m#{week_names[0]}\e[0m"
|
38
38
|
week_names[6] = "\e[36m#{week_names[6]}\e[0m"
|
39
39
|
puts title, week_names.join
|
@@ -44,7 +44,7 @@ module Jcal
|
|
44
44
|
week.each do |date|
|
45
45
|
today_marker = date.month == m && date == Date.today ? "\e[7m" : ''
|
46
46
|
month_marker = date.month != m ? "\e[2m" : ''
|
47
|
-
holiday_name = date.holiday.to_s.rjust_ja(
|
47
|
+
holiday_name = date.holiday.to_s[0, cell/2 - 2].rjust_ja(cell - 2)
|
48
48
|
fgcolor = case
|
49
49
|
when date.month != m then 0
|
50
50
|
when date.wday == 0, date.holiday then 31
|
@@ -81,10 +81,11 @@ module Jcal
|
|
81
81
|
list366.each {|list| puts list}
|
82
82
|
end
|
83
83
|
|
84
|
-
def matrix(base_year, start_month, end_month=start_month)
|
84
|
+
def matrix(size, base_year, start_month, end_month=start_month)
|
85
|
+
cell_size = 16 - size*6
|
85
86
|
end_month += 12 if start_month > end_month
|
86
87
|
(start_month..end_month).each do |i|
|
87
|
-
render_matrix(base_year + (i / 12.0).ceil - 1, i % 12)
|
88
|
+
render_matrix(base_year + (i / 12.0).ceil - 1, i % 12, cell_size)
|
88
89
|
end
|
89
90
|
end
|
90
91
|
|
@@ -99,11 +100,13 @@ require 'optparse'
|
|
99
100
|
# オプション解析
|
100
101
|
options = {}
|
101
102
|
OptionParser.new do |opt|
|
103
|
+
opt.version = JPDate::VERSION
|
102
104
|
opt.banner = 'Usage: jcal [options] [yyyy|mm] [yyyy|mm] [yyyy|mm]'
|
103
105
|
opt.separator('')
|
104
106
|
opt.on('-y[NUM]', 'Show NUM years.(0-10)') {|v| options[:years] = v.to_i}
|
105
107
|
opt.on('-m[NUM]', 'Show NUM months.') {|v| options[:months] = v.to_i}
|
106
108
|
opt.on('-e' , 'List with the name of Japanese era.') {|v| options[:era] = v}
|
109
|
+
opt.on('-s', '--size=compact|minimum', ['compact', 'minimum'], 'Set width of monthly calendar.') {|v| options[:size] = v}
|
107
110
|
opt.separator('')
|
108
111
|
opt.on('Example:',
|
109
112
|
' jcal # Show monthly calendar of this month.',
|
@@ -116,7 +119,6 @@ OptionParser.new do |opt|
|
|
116
119
|
' jcal -m # Show monthly calendar from last month to next month.',
|
117
120
|
' jcal -m6 2010 1 # Show monthly calendar from Jan.2010 to Jun.2010.',
|
118
121
|
' jcal 2010 2 8 # Show monthly calendar from Feb.2010 to Aug.2010.',
|
119
|
-
' jcal --version=JPDate # Show version of JPDate.',
|
120
122
|
)
|
121
123
|
begin
|
122
124
|
opt.parse!(ARGV)
|
@@ -127,6 +129,7 @@ OptionParser.new do |opt|
|
|
127
129
|
end
|
128
130
|
|
129
131
|
# 引数解析
|
132
|
+
monthly_size = {'compact' => 1, 'minimum' => 2}
|
130
133
|
y = ARGV.map(&:to_i).select {|i| i > 12 }
|
131
134
|
m = ARGV.map(&:to_i).select {|i| i <= 12 }
|
132
135
|
m.map! {|i| i == 0 ? Date.today.month : i}
|
@@ -139,8 +142,9 @@ m = [m[0] , m[0] + options[:months] - 1] if options.key?(:months) && option
|
|
139
142
|
(y[0] = options[:years]; options[:years] = 0) if options.key?(:years) && options[:years] >= 1900 # -y西暦なら、西暦と解釈
|
140
143
|
m = [1, 12] if options.key?(:years) && options[:years] <= 1 # -y指定期間が1年以下は、12カ月分表示
|
141
144
|
options[:years] ||= (y[1] - y[0]).abs + 1 if y.size == 2 && (options.empty? || options[:era]) # 西暦2個・月0個・オプションなしは、-yに期間を追加
|
145
|
+
|
142
146
|
if options.key?(:years) && options[:years] >= 2
|
143
147
|
Jcal::list(y.min, options[:years], options[:era])
|
144
148
|
else
|
145
|
-
Jcal::matrix(y[0], *m)
|
149
|
+
Jcal::matrix(monthly_size[options[:size]].to_i, y[0], *m)
|
146
150
|
end
|
data/lib/jpdate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jpdate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zariganitosh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|