jpcalendar 0.0.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.
- data/.gitignore +6 -0
- data/Gemfile +15 -0
- data/LICENSE.md +7 -0
- data/README.md +321 -0
- data/Rakefile +2 -0
- data/jpcalendar.gemspec +23 -0
- data/lib/jpcalendar.rb +19 -0
- data/lib/jpcalendar/format.rb +105 -0
- data/lib/jpcalendar/generator.rb +172 -0
- data/lib/jpcalendar/util.rb +37 -0
- data/lib/jpcalendar/version.rb +3 -0
- data/lib/jpcalendar/weekday_scale.rb +96 -0
- data/spec/format_spec.rb +232 -0
- data/spec/generator_spec.rb +17 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/util_spec.rb +68 -0
- data/spec/weekday_scale_spec.rb +158 -0
- metadata +83 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Jpcalendar::Generator do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
extend Jpcalendar::Generator
|
8
|
+
end
|
9
|
+
|
10
|
+
context "generator_feed" do
|
11
|
+
context "引数なし" do
|
12
|
+
it { lambda{ generator_feed }.should raise_error ArgumentError }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# あとはformatクラスでテストしてるから、いいんじゃないかと
|
17
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/spec/util_spec.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Util do
|
5
|
+
|
6
|
+
describe "tag wrap" do #{{{
|
7
|
+
|
8
|
+
describe "異常系" do #{{{
|
9
|
+
context "引数なし blockなし" do
|
10
|
+
it { lambda{ Util.tag_wrap }.should raise_error ArgumentError }
|
11
|
+
end
|
12
|
+
end #}}}
|
13
|
+
|
14
|
+
describe "正常系" do #{{{
|
15
|
+
context "引数文字列 blockなし" do
|
16
|
+
it { Util.tag_wrap("br").should eql "<br />" }
|
17
|
+
end
|
18
|
+
|
19
|
+
context "引数シンボル blockなし" do
|
20
|
+
it { Util.tag_wrap(:tr).should eql "<tr />" }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "引数文字列 blockあり" do
|
24
|
+
it { Util.tag_wrap("div"){"Lorem ipsum dolor sit amet"}.should eql "<div>Lorem ipsum dolor sit amet</div>" }
|
25
|
+
end
|
26
|
+
|
27
|
+
context "引数シンボル blockあり" do
|
28
|
+
it { Util.tag_wrap(:div){"Lorem ipsum dolor sit amet"}.should eql "<div>Lorem ipsum dolor sit amet</div>" }
|
29
|
+
end
|
30
|
+
|
31
|
+
context "引数シンボル blockあり class指定あり" do
|
32
|
+
it { Util.tag_wrap(:div,class: "mrgn"){"Lorem ipsum dolor sit amet"}.should eql "<div class='mrgn'>Lorem ipsum dolor sit amet</div>" }
|
33
|
+
end
|
34
|
+
|
35
|
+
context "引数シンボル blockあり id class指定あり" do
|
36
|
+
it { Util.tag_wrap(:div,class: "mrgn", id: "tag_wrap"){"Lorem ipsum dolor sit amet"}.should eql "<div id='tag_wrap' class='mrgn'>Lorem ipsum dolor sit amet</div>" }
|
37
|
+
end
|
38
|
+
|
39
|
+
context "blockが空" do
|
40
|
+
it { Util.tag_wrap(:div).should eql "<div />" }
|
41
|
+
end
|
42
|
+
context "blockがnil" do
|
43
|
+
it { Util.tag_wrap(:div){ nil }.should eql "<div></div>" }
|
44
|
+
end
|
45
|
+
end #}}}
|
46
|
+
end #}}}
|
47
|
+
|
48
|
+
context "is_numeric?" do #{{{
|
49
|
+
context "数値" do
|
50
|
+
it { Util.is_numeric?("123456789").should be_true }
|
51
|
+
end
|
52
|
+
|
53
|
+
context "文字列" do
|
54
|
+
it { Util.is_numeric?("abcあいう").should be_false }
|
55
|
+
end
|
56
|
+
|
57
|
+
context "数値文字列" do
|
58
|
+
it { Util.is_numeric?("12345678abcあいう").should be_false }
|
59
|
+
end
|
60
|
+
end #}}}
|
61
|
+
|
62
|
+
context "expression_not_nil" do
|
63
|
+
let(:str) { "abcde" }
|
64
|
+
it { Util.expr_not_nil(str).should be_nil }
|
65
|
+
it { Util.expr_not_nil(str){ "aaa/" + str + "/bbb"}.should eql "aaa/abcde/bbb" }
|
66
|
+
end #}}}
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Jpcalendar::WeekdayScale do
|
5
|
+
|
6
|
+
# WeekDayElem{{{
|
7
|
+
context "WeekDayElem" do
|
8
|
+
before do
|
9
|
+
@wde = Jpcalendar::WeekdayScale::WeekDayElem.new(0,'日曜日','sunday')
|
10
|
+
end
|
11
|
+
|
12
|
+
subject{@wde}
|
13
|
+
its(:number){ should eql 0}
|
14
|
+
its(:jpname){ should eql '日曜日'}
|
15
|
+
its(:enname){ should eql 'sunday'}
|
16
|
+
|
17
|
+
context "再設定" do
|
18
|
+
before do
|
19
|
+
@wde.number = 1
|
20
|
+
@wde.jpname = '月曜日'
|
21
|
+
@wde.enname = 'monday'
|
22
|
+
end
|
23
|
+
|
24
|
+
its(:number){ should eql 1}
|
25
|
+
its(:jpname){ should eql '月曜日'}
|
26
|
+
its(:enname){ should eql 'monday'}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
#}}}
|
30
|
+
|
31
|
+
context "Weekday" do #{{{
|
32
|
+
|
33
|
+
context "日曜始まり(デフォルト)" do #{{{
|
34
|
+
before do
|
35
|
+
@wd = Jpcalendar::WeekdayScale::WeekDay.new
|
36
|
+
end
|
37
|
+
|
38
|
+
context "find_by_*" do
|
39
|
+
context "number" do
|
40
|
+
subject{ @wd.find_by_number(2) }
|
41
|
+
its(:number) { should eql 2}
|
42
|
+
its(:jpname) { should eql "火"}
|
43
|
+
its(:enname) { should eql "tue"}
|
44
|
+
end
|
45
|
+
|
46
|
+
context "jpname" do
|
47
|
+
subject{ @wd.find_by_jpname("木") }
|
48
|
+
its(:number) { should eql 4}
|
49
|
+
its(:jpname) { should eql "木"}
|
50
|
+
its(:enname) { should eql "thu"}
|
51
|
+
end
|
52
|
+
|
53
|
+
context "enname" do
|
54
|
+
subject{ @wd.find_by_enname('sat') }
|
55
|
+
its(:number) { should eql 6}
|
56
|
+
its(:jpname) { should eql "土"}
|
57
|
+
its(:enname) { should eql "sat"}
|
58
|
+
end
|
59
|
+
|
60
|
+
context "存在しない要素の呼び出し" do
|
61
|
+
it { lambda{ @wd.find_by_hoge('hoge') }.should raise_error NoMethodError }
|
62
|
+
end
|
63
|
+
|
64
|
+
context "もしも検索にひっかからなかったら" do
|
65
|
+
it { @wd.find_by_number(-1).should be_nil }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'map' do
|
70
|
+
subject{@wd}
|
71
|
+
|
72
|
+
its(:map){ should be_an_instance_of Enumerator }
|
73
|
+
it{ @wd.map.with_index{|wd,idx| wd }.should have(7).items }
|
74
|
+
it{ @wd.map{|wd,idx| wd }.should have(7).items }
|
75
|
+
end
|
76
|
+
|
77
|
+
context "each" do
|
78
|
+
subject{@wd}
|
79
|
+
|
80
|
+
its(:each){ should be_an_instance_of Enumerator }
|
81
|
+
it{ @wd.each.with_index{|wd,idx| wd }.should have(7).items }
|
82
|
+
it{ @wd.each{|wd,idx| wd }.should have(7).items }
|
83
|
+
end
|
84
|
+
|
85
|
+
context "last" do
|
86
|
+
subject{@wd}
|
87
|
+
its("last.number"){ should eql 6 }
|
88
|
+
its("last.jpname"){ should eql "土" }
|
89
|
+
its("last.enname"){ should eql "sat" }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
#}}}
|
93
|
+
|
94
|
+
context "月曜始まり" do #{{{
|
95
|
+
before do
|
96
|
+
@wd = Jpcalendar::WeekdayScale::WeekDay.new(true)
|
97
|
+
end
|
98
|
+
|
99
|
+
context "find_by_*" do
|
100
|
+
context "number" do
|
101
|
+
subject{ @wd.find_by_number(2) }
|
102
|
+
its(:number) { should eql 2}
|
103
|
+
its(:jpname) { should eql "火"}
|
104
|
+
its(:enname) { should eql "tue"}
|
105
|
+
end
|
106
|
+
|
107
|
+
context "jpname" do
|
108
|
+
subject{ @wd.find_by_jpname("木") }
|
109
|
+
its(:number) { should eql 4}
|
110
|
+
its(:jpname) { should eql "木"}
|
111
|
+
its(:enname) { should eql "thu"}
|
112
|
+
end
|
113
|
+
|
114
|
+
context "enname" do
|
115
|
+
subject{ @wd.find_by_enname('sat') }
|
116
|
+
its(:number) { should eql 6}
|
117
|
+
its(:jpname) { should eql "土"}
|
118
|
+
its(:enname) { should eql "sat"}
|
119
|
+
end
|
120
|
+
|
121
|
+
context "存在しない要素の呼び出し" do
|
122
|
+
it { lambda{ @wd.find_by_hoge('hoge') }.should raise_error NoMethodError }
|
123
|
+
end
|
124
|
+
|
125
|
+
context "もしも検索にひっかからなかったら" do
|
126
|
+
it { @wd.find_by_number(-1).should be_nil }
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'map' do
|
131
|
+
subject{@wd}
|
132
|
+
|
133
|
+
its(:map){ should be_an_instance_of Enumerator }
|
134
|
+
it{ @wd.map.with_index{|wd,idx| wd }.should have(7).items }
|
135
|
+
it{ @wd.map{|wd,idx| wd }.should have(7).items }
|
136
|
+
end
|
137
|
+
|
138
|
+
context "each" do
|
139
|
+
subject{@wd}
|
140
|
+
|
141
|
+
its(:each){ should be_an_instance_of Enumerator }
|
142
|
+
it{ @wd.each.with_index{|wd,idx| wd }.should have(7).items }
|
143
|
+
it{ @wd.each{|wd,idx| wd }.should have(7).items }
|
144
|
+
end
|
145
|
+
|
146
|
+
context "last" do
|
147
|
+
subject{@wd}
|
148
|
+
its("last.number"){ should eql 0 }
|
149
|
+
its("last.jpname"){ should eql "日" }
|
150
|
+
its("last.enname"){ should eql "sun" }
|
151
|
+
end
|
152
|
+
end
|
153
|
+
# }}}
|
154
|
+
|
155
|
+
end
|
156
|
+
#}}}
|
157
|
+
|
158
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jpcalendar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- yoshitsugu fujii
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: holiday_jp
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.3.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.3.1
|
30
|
+
description: 日本の祝祭日に対応したカレンダー
|
31
|
+
email:
|
32
|
+
- ishikurasakura@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE.md
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- jpcalendar.gemspec
|
43
|
+
- lib/jpcalendar.rb
|
44
|
+
- lib/jpcalendar/format.rb
|
45
|
+
- lib/jpcalendar/generator.rb
|
46
|
+
- lib/jpcalendar/util.rb
|
47
|
+
- lib/jpcalendar/version.rb
|
48
|
+
- lib/jpcalendar/weekday_scale.rb
|
49
|
+
- spec/format_spec.rb
|
50
|
+
- spec/generator_spec.rb
|
51
|
+
- spec/spec_helper.rb
|
52
|
+
- spec/util_spec.rb
|
53
|
+
- spec/weekday_scale_spec.rb
|
54
|
+
homepage: https://github.com/YoshitsuguFujii/jpcalendar
|
55
|
+
licenses: []
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project: jpcalendar
|
74
|
+
rubygems_version: 1.8.24
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: japanese calendar
|
78
|
+
test_files:
|
79
|
+
- spec/format_spec.rb
|
80
|
+
- spec/generator_spec.rb
|
81
|
+
- spec/spec_helper.rb
|
82
|
+
- spec/util_spec.rb
|
83
|
+
- spec/weekday_scale_spec.rb
|