bahai_date 1.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.
- checksums.yaml +7 -0
- data/LICENSE.md +25 -0
- data/README.md +124 -0
- data/lib/bahai_date/bahai_date.rb +118 -0
- data/lib/bahai_date/day.rb +54 -0
- data/lib/bahai_date/month.rb +57 -0
- data/lib/bahai_date/occasion.rb +24 -0
- data/lib/bahai_date/occasion_factory.rb +321 -0
- data/lib/bahai_date/weekday.rb +51 -0
- data/lib/bahai_date/year.rb +66 -0
- data/lib/bahai_date/year_calendar.rb +32 -0
- data/lib/bahai_date/year_data.rb +23 -0
- data/spec/bahai_date/bahai_date_spec.rb +251 -0
- data/spec/bahai_date/day_spec.rb +68 -0
- data/spec/bahai_date/month_spec.rb +75 -0
- data/spec/bahai_date/occasion_factory_spec.rb +92 -0
- data/spec/bahai_date/occasion_spec.rb +28 -0
- data/spec/bahai_date/weekday_spec.rb +46 -0
- data/spec/bahai_date/year_calendar_spec.rb +45 -0
- data/spec/bahai_date/year_data_spec.rb +19 -0
- data/spec/bahai_date/year_spec.rb +113 -0
- metadata +87 -0
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'bahai_date/year'
|
2
|
+
|
3
|
+
module BahaiDate
|
4
|
+
|
5
|
+
describe Year do
|
6
|
+
it "can be created given a number greater than or equal to 1" do
|
7
|
+
expect(Year.new(1)).to_not be_nil
|
8
|
+
expect(Year.new(160)).to_not be_nil
|
9
|
+
end
|
10
|
+
|
11
|
+
it "can't be created with a number less than 1" do
|
12
|
+
expect { Year.new(0) }.to raise_error(
|
13
|
+
ArgumentError, "'0' is not a valid year. Please use a number greater than or equal to 1.")
|
14
|
+
|
15
|
+
expect { Year.new('hello') }.to raise_error(
|
16
|
+
ArgumentError, "'0' is not a valid year. Please use a number greater than or equal to 1.")
|
17
|
+
end
|
18
|
+
|
19
|
+
subject(:year) { Year.new(1) }
|
20
|
+
|
21
|
+
it "can be converted to string showing the B.E. number" do
|
22
|
+
expect(year.to_s).to eq "1"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "provides access to the title" do
|
26
|
+
expect(year.title).to eq "Alif"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "provides access to the year number" do
|
30
|
+
expect(year.number).to be 1
|
31
|
+
end
|
32
|
+
|
33
|
+
it "provides access to the translated title" do
|
34
|
+
expect(year.translation).to eq "A"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "provides access to the title in HTML" do
|
38
|
+
expect(year.html).to eq "Alif"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "provides access to the vahid" do
|
42
|
+
expect(year.vahid).to be 1
|
43
|
+
end
|
44
|
+
|
45
|
+
it "provides access to the kull-i-shay" do
|
46
|
+
expect(year.kull_i_shay).to be 1
|
47
|
+
end
|
48
|
+
|
49
|
+
it "calculates the number properly" do
|
50
|
+
year = Year.new(1)
|
51
|
+
expect(year.number).to eq(1)
|
52
|
+
|
53
|
+
year = Year.new(19)
|
54
|
+
expect(year.number).to eq(19)
|
55
|
+
|
56
|
+
year = Year.new(20)
|
57
|
+
expect(year.number).to eq(1)
|
58
|
+
|
59
|
+
year = Year.new(361)
|
60
|
+
expect(year.number).to eq(19)
|
61
|
+
|
62
|
+
year = Year.new(362)
|
63
|
+
expect(year.number).to eq(1)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "calculates the vahid properly" do
|
67
|
+
year = Year.new(1)
|
68
|
+
expect(year.vahid).to eq(1)
|
69
|
+
|
70
|
+
year = Year.new(20)
|
71
|
+
expect(year.vahid).to eq(2)
|
72
|
+
|
73
|
+
year = Year.new(361)
|
74
|
+
expect(year.vahid).to eq(19)
|
75
|
+
|
76
|
+
year = Year.new(362)
|
77
|
+
expect(year.vahid).to eq(1)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "calculates the kull-i-shay properly" do
|
81
|
+
year = Year.new(1)
|
82
|
+
expect(year.kull_i_shay).to eq(1)
|
83
|
+
|
84
|
+
year = Year.new(361)
|
85
|
+
expect(year.kull_i_shay).to eq(1)
|
86
|
+
|
87
|
+
year = Year.new(362)
|
88
|
+
expect(year.kull_i_shay).to eq(2)
|
89
|
+
end
|
90
|
+
|
91
|
+
context "working with a hash of months" do
|
92
|
+
it "is readable" do
|
93
|
+
year = Year.new(1)
|
94
|
+
expect(year.months).to eq({})
|
95
|
+
end
|
96
|
+
|
97
|
+
it "can be added to" do
|
98
|
+
year = Year.new(1)
|
99
|
+
year.set_month(-1)
|
100
|
+
expect(year.months[-1].number).to be -1
|
101
|
+
end
|
102
|
+
|
103
|
+
it "doesn't create a new Month object if one exists" do
|
104
|
+
year = Year.new(1)
|
105
|
+
month = year.set_month(1)
|
106
|
+
year.set_month(1)
|
107
|
+
expect(year.months[1]).to be month
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bahai_date
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lessan Vaezi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3'
|
27
|
+
description:
|
28
|
+
email: lessan@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- LICENSE.md
|
34
|
+
- README.md
|
35
|
+
- lib/bahai_date/bahai_date.rb
|
36
|
+
- lib/bahai_date/day.rb
|
37
|
+
- lib/bahai_date/month.rb
|
38
|
+
- lib/bahai_date/occasion.rb
|
39
|
+
- lib/bahai_date/occasion_factory.rb
|
40
|
+
- lib/bahai_date/weekday.rb
|
41
|
+
- lib/bahai_date/year.rb
|
42
|
+
- lib/bahai_date/year_calendar.rb
|
43
|
+
- lib/bahai_date/year_data.rb
|
44
|
+
- spec/bahai_date/bahai_date_spec.rb
|
45
|
+
- spec/bahai_date/day_spec.rb
|
46
|
+
- spec/bahai_date/month_spec.rb
|
47
|
+
- spec/bahai_date/occasion_factory_spec.rb
|
48
|
+
- spec/bahai_date/occasion_spec.rb
|
49
|
+
- spec/bahai_date/weekday_spec.rb
|
50
|
+
- spec/bahai_date/year_calendar_spec.rb
|
51
|
+
- spec/bahai_date/year_data_spec.rb
|
52
|
+
- spec/bahai_date/year_spec.rb
|
53
|
+
homepage: https://github.com/lessan/bahai-date
|
54
|
+
licenses:
|
55
|
+
- Unlicense
|
56
|
+
metadata: {}
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '2.0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 2.2.2
|
74
|
+
signing_key:
|
75
|
+
specification_version: 4
|
76
|
+
summary: Gem to provide date conversion between the Gregorian calendar and the Baha'i
|
77
|
+
(or Badi) calendar
|
78
|
+
test_files:
|
79
|
+
- spec/bahai_date/day_spec.rb
|
80
|
+
- spec/bahai_date/year_calendar_spec.rb
|
81
|
+
- spec/bahai_date/weekday_spec.rb
|
82
|
+
- spec/bahai_date/month_spec.rb
|
83
|
+
- spec/bahai_date/occasion_spec.rb
|
84
|
+
- spec/bahai_date/occasion_factory_spec.rb
|
85
|
+
- spec/bahai_date/year_spec.rb
|
86
|
+
- spec/bahai_date/year_data_spec.rb
|
87
|
+
- spec/bahai_date/bahai_date_spec.rb
|