feast_fast 0.1.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 +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +74 -0
- data/Rakefile +2 -0
- data/bin/feast_fast +31 -0
- data/feast_fast.gemspec +19 -0
- data/lib/feast_fast/calculator.rb +196 -0
- data/lib/feast_fast/date.rb +73 -0
- data/lib/feast_fast/db.rb +31 -0
- data/lib/feast_fast/fast.rb +41 -0
- data/lib/feast_fast/feast.rb +30 -0
- data/lib/feast_fast/version.rb +3 -0
- data/lib/feast_fast.rb +11 -0
- metadata +79 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 il.zoff
|
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,74 @@
|
|
1
|
+
# FeastFast
|
2
|
+
|
3
|
+
Feasts and Fasts of Eastern Orthodox Church hardcoded and calculated.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'feast_fast'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install feast_fast
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
``` ruby
|
22
|
+
day = Date.today
|
23
|
+
puts "Feast: #{day.feasts.first}"
|
24
|
+
puts "Fast: #{day.fast}"
|
25
|
+
```
|
26
|
+
or
|
27
|
+
|
28
|
+
``` ruby
|
29
|
+
today = Date.today
|
30
|
+
|
31
|
+
puts "Congrats! It's Easter today!" if today.easter?
|
32
|
+
|
33
|
+
days_till_easter = today.next_easter - today
|
34
|
+
|
35
|
+
puts "#{days_till_easter} days till next easter."
|
36
|
+
|
37
|
+
if days_till_easter > 50
|
38
|
+
if today.feasts.any?
|
39
|
+
puts "Don't be sad, today you can celebrate #{today.feasts.first}"
|
40
|
+
else
|
41
|
+
remaining_feasts = Date.with_feasts(today.year, FeastFast::Feast::STATUS::TWELVE).select{ |feast_day| feast_day > today }
|
42
|
+
if remaining_feasts.size > 1
|
43
|
+
puts "Don't be sad, there are still #{remaining_feasts.size} Great Feasts in this year:"
|
44
|
+
remaining_feasts.sort.each { |date| puts "At #{date.strftime('%d %b')}: #{date.feasts.first}" }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
puts "And don't forget to fast today!" if today.fast?
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
## TODO
|
52
|
+
|
53
|
+
- I18n
|
54
|
+
- rdoc
|
55
|
+
- exceptions handling
|
56
|
+
- tests
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
1. Fork it
|
61
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
62
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
63
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
64
|
+
5. Create new Pull Request
|
65
|
+
|
66
|
+
## Credits
|
67
|
+
|
68
|
+
Way to calculate feasts and fasts was taken from http://calendar.lenacom.spb.ru/
|
69
|
+
|
70
|
+
## License
|
71
|
+
|
72
|
+
Released under the MIT license.
|
73
|
+
|
74
|
+
Copyright (c) 2012 il.zoff
|
data/Rakefile
ADDED
data/bin/feast_fast
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib feast_fast]))
|
5
|
+
|
6
|
+
if ARGV.any? && ARGV.size == 3
|
7
|
+
begin
|
8
|
+
d1 = Date.new(ARGV[0].to_i, ARGV[1].to_i, ARGV[2].to_i)
|
9
|
+
rescue Exception => e
|
10
|
+
puts "Не удалось сформировать дату"
|
11
|
+
puts e
|
12
|
+
exit 1
|
13
|
+
end
|
14
|
+
else
|
15
|
+
d1 = Date.today
|
16
|
+
end
|
17
|
+
|
18
|
+
puts "====================="
|
19
|
+
puts "Дата: #{d1}"
|
20
|
+
puts "Пост: #{d1.fast}"
|
21
|
+
if d1.feasts.any?
|
22
|
+
d1.feasts.each_with_index do |feast, index|
|
23
|
+
if index == 0
|
24
|
+
puts "Праздники: #{feast}"
|
25
|
+
else
|
26
|
+
puts " #{feast}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
else
|
30
|
+
puts "Праздники: Нет праздников"
|
31
|
+
end
|
data/feast_fast.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/feast_fast/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["ilzoff"]
|
6
|
+
gem.email = ["il.zoff@gmail.com"]
|
7
|
+
gem.description = %q{Feasts and Fasts of Eastern Orthodox Church hardcoded and calculated based on easter.}
|
8
|
+
gem.summary = %q{Feasts and Fasts of Eastern Orthodox Church hardcoded and calculated}
|
9
|
+
gem.homepage = "https://github.com/ilzoff/feast_fast"
|
10
|
+
|
11
|
+
gem.license = 'MIT'
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split($\)
|
14
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
|
+
gem.name = "feast_fast"
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
gem.version = FeastFast::VERSION
|
19
|
+
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
module FeastFast
|
3
|
+
module Calculator
|
4
|
+
|
5
|
+
def self.build_data(year)
|
6
|
+
|
7
|
+
year = year.to_i
|
8
|
+
easter = Date.easter
|
9
|
+
|
10
|
+
hash = Hash.new do |h, day|
|
11
|
+
h[day] = {
|
12
|
+
:feasts => [],
|
13
|
+
:fast => [3,5].include?(day.wday) ? Fast.new(:status => Fast::STATUS::COMMON) : Fast.new(:status => Fast::STATUS::NO)
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
# Пасха
|
18
|
+
|
19
|
+
hash[easter][:feasts] << Feast.new(:status => Feast::STATUS::EASTER, :text => "Воскресение Христово. Пасха")
|
20
|
+
|
21
|
+
# Непереходящие праздники
|
22
|
+
|
23
|
+
hash[Date.new(year, 1, 7)][:feasts] << Feast.new(:status => Feast::STATUS::TWELVE, :text => "Рождество Христово")
|
24
|
+
hash[Date.new(year, 1, 14)][:feasts] << Feast.new(:status => Feast::STATUS::GREAT, :text => "Обрезание Господне")
|
25
|
+
hash[Date.new(year, 1, 19)][:feasts] << Feast.new(:status => Feast::STATUS::TWELVE, :text => "Крещение Господне")
|
26
|
+
hash[Date.new(year, 2, 15)][:feasts] << Feast.new(:status => Feast::STATUS::TWELVE, :text => "Сретение Господне")
|
27
|
+
hash[Date.new(year, 4, 7)][:feasts] << Feast.new(:status => Feast::STATUS::TWELVE, :text => "Благовещение Пресвятой Богородицы")
|
28
|
+
hash[Date.new(year, 5, 21)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Апостола и евангелиста Иоанна Богослова")
|
29
|
+
hash[Date.new(year, 5, 22)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Святителя Николая, архиепископа Мир Ликийских, чудотворца")
|
30
|
+
hash[Date.new(year, 7, 7)][:feasts] << Feast.new(:status => Feast::STATUS::GREAT, :text => "Рождество Иоанна Предтечи")
|
31
|
+
hash[Date.new(year, 7, 12)][:feasts] << Feast.new(:status => Feast::STATUS::GREAT, :text => "Святых перв. апостолов Петра и Павла")
|
32
|
+
hash[Date.new(year, 8, 19)][:feasts] << Feast.new(:status => Feast::STATUS::TWELVE, :text => "Преображение Господне")
|
33
|
+
hash[Date.new(year, 8, 28)][:feasts] << Feast.new(:status => Feast::STATUS::TWELVE, :text => "Успение Пресвятой Богородицы")
|
34
|
+
hash[Date.new(year, 9, 11)][:feasts] << Feast.new(:status => Feast::STATUS::GREAT, :text => "Усекновение главы Иоанна Предтечи")
|
35
|
+
hash[Date.new(year, 9, 21)][:feasts] << Feast.new(:status => Feast::STATUS::TWELVE, :text => "Рождество Пресвятой Богородицы")
|
36
|
+
hash[Date.new(year, 9, 27)][:feasts] << Feast.new(:status => Feast::STATUS::TWELVE, :text => "Воздвижение Креста Господня")
|
37
|
+
hash[Date.new(year, 10, 9)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Апостола и евангелиста Иоанна Богослова")
|
38
|
+
hash[Date.new(year, 10, 14)][:feasts] << Feast.new(:status => Feast::STATUS::GREAT, :text => "Покров Пресвятой Богородицы")
|
39
|
+
hash[Date.new(year, 12, 4)][:feasts] << Feast.new(:status => Feast::STATUS::TWELVE, :text => "Введение во храм Пресвятой Богородицы")
|
40
|
+
hash[Date.new(year, 12, 19)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Святителя Николая, архиепископа Мир Ликийских, чудотворца")
|
41
|
+
|
42
|
+
# Переходящие праздники
|
43
|
+
|
44
|
+
hash[Date.new(year, 2, 7).next_sunday][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Собор новомучеников и исповедников Российских")
|
45
|
+
|
46
|
+
hash[easter.weeks_ago(11)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Неделя о Закхее-мытаре")
|
47
|
+
hash[easter.weeks_ago(10)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Неделя о мытаре и фарисее")
|
48
|
+
hash[easter.weeks_ago(9)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Неделя о блудном сыне")
|
49
|
+
hash[easter.weeks_ago(8)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Неделя о Страшном Суде")
|
50
|
+
hash[easter.weeks_ago(7)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Воспоминание Адамова изгнания. Прощеное воскресенье")
|
51
|
+
hash[easter.weeks_ago(6)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Торжество Православия")
|
52
|
+
hash[easter.weeks_ago(5)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Неделя 2-я Великого поста, свт. Григория Паламы, архиеп. Солунского")
|
53
|
+
hash[easter.weeks_ago(4)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Неделя 3-я Великого поста, Крестопоклонная")
|
54
|
+
hash[easter.weeks_ago(3)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Неделя 4-я Великого поста, прп. Иоанна Лествичника")
|
55
|
+
hash[easter.weeks_ago(2)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Неделя 5-я Великого поста, прп. Марии Египетской")
|
56
|
+
hash[easter.week_ago.prev_date][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Лазарева суббота")
|
57
|
+
hash[easter.week_ago][:feasts] << Feast.new(:status => Feast::STATUS::TWELVE, :text => "Вход Господень в Иерусалим")
|
58
|
+
|
59
|
+
hash[easter.prev_date(6)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Великий Понедельник")
|
60
|
+
hash[easter.prev_date(5)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Великий Вторник")
|
61
|
+
hash[easter.prev_date(4)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Великая Среда")
|
62
|
+
hash[easter.prev_date(3)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Великий Четверг. Тайная Вечеря")
|
63
|
+
hash[easter.prev_date(2)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Великая Пятница. Распятие Христа")
|
64
|
+
hash[easter.prev_date][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Великая Суббота. Сошествие Христа во ад")
|
65
|
+
|
66
|
+
hash[easter.week_since][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Неделя 2-я по Пасхе (Антипасха). Воспоминание уверения ап. Фомы")
|
67
|
+
hash[easter.weeks_since(2)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Неделя 3-я по Пасхе, святых жен-мироносиц")
|
68
|
+
hash[easter.weeks_since(3)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Неделя 4-я по Пасхе, о расслабленном")
|
69
|
+
hash[easter.weeks_since(4)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Неделя 5-я по Пасхе, о самарянке")
|
70
|
+
hash[easter.weeks_since(5)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Неделя 6-я по Пасхе, о слепом")
|
71
|
+
hash[easter.next_date(39)][:feasts] << Feast.new(:status => Feast::STATUS::TWELVE, :text => "Вознесение Господне (40-й день по Пасхе)")
|
72
|
+
hash[easter.weeks_since(6)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Неделя 7-я по Пасхе, свв. отцев I Вселенского Собора")
|
73
|
+
hash[easter.next_date(49)][:feasts] << Feast.new(:status => Feast::STATUS::TWELVE, :text => "Пятидесятница. День Святой Троицы (50-й день по Пасхе)")
|
74
|
+
hash[easter.next_date(50)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "День Святого Духа (первый понедельник по Пятидесятнице)")
|
75
|
+
hash[easter.weeks_since(8)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Неделя 1-я по Пятидесятнице, всех святых")
|
76
|
+
hash[easter.weeks_since(9)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Неделя 2-я по Пятидесятнице, всех святых, в земле Российской просиявших")
|
77
|
+
|
78
|
+
# Дни особого поминовения усопших
|
79
|
+
|
80
|
+
hash[easter.weeks_ago(8).prev_date][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Вселенская родительская суббота (суббота перед неделей о Страшном Суде)")
|
81
|
+
hash[easter.weeks_ago(5).prev_date][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Вселенская родительская суббота 2-й недели Великого поста")
|
82
|
+
hash[easter.weeks_ago(4).prev_date][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Вселенская родительская суббота 3-й недели Великого поста")
|
83
|
+
hash[easter.weeks_ago(3).prev_date][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Вселенская родительская суббота 4-й недели Великого поста")
|
84
|
+
hash[easter.week_since.next_date(2)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Радоница (вторник 2-й седмицы по Пасхе)")
|
85
|
+
hash[easter.next_date(48)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Троицкая родительская суббота (суббота перед Троицей)")
|
86
|
+
hash[Date.new(year, 5, 9)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Поминовение усопших воинов")
|
87
|
+
hash[Date.new(year, 11, 7).prev_sunday.prev_date][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "Дмитриевская родительская суббота (суббота перед 8 ноября)")
|
88
|
+
|
89
|
+
# Контрабанда
|
90
|
+
|
91
|
+
hash[Date.new(year, 11, 12)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "День памяти Преподобной Елены Сербской")
|
92
|
+
hash[Date.new(year, 1, 21)][:feasts] << Feast.new(:status => Feast::STATUS::COMMON, :text => "День памяти Преподобного Илии Египетского")
|
93
|
+
|
94
|
+
# ПОСТЫ
|
95
|
+
|
96
|
+
# Рождественский пост
|
97
|
+
|
98
|
+
(Date.new(year, 11, 28)..Date.new(year, 12, 31)).each do |date|
|
99
|
+
if date.wday == 3 or date.wday == 5
|
100
|
+
hash[date][:fast] = Fast.new(:status => Fast::STATUS::STRICT)
|
101
|
+
else
|
102
|
+
hash[date][:fast] = Fast.new(:status => Fast::STATUS::COMMON)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
(Date.new(year, 1, 1)..Date.new(year, 1, 6)).each do |date|
|
107
|
+
if date.day == 6
|
108
|
+
hash[date][:fast] = Fast.new(:status => Fast::STATUS::STRICT, :text => "Рождественский сочельник")
|
109
|
+
elsif date.wday == 3 or date.wday == 5
|
110
|
+
hash[date][:fast] = Fast.new(:status => Fast::STATUS::STRICT)
|
111
|
+
else
|
112
|
+
hash[date][:fast] = Fast.new(:status => Fast::STATUS::COMMON)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
hash[Date.new(year, 12, 4)][:fast] = Fast.new(:status => Fast::STATUS::COMMON) # Введение во храм Пресвятой Богородицы
|
118
|
+
hash[Date.new(year, 12, 19)][:fast] = Fast.new(:status => Fast::STATUS::COMMON) # Святителя Николая
|
119
|
+
|
120
|
+
# Святки
|
121
|
+
(Date.new(year, 1, 7)..Date.new(year, 1, 17)).each do |date|
|
122
|
+
hash[date][:fast] = Fast.new(:status => Fast::STATUS::NO)
|
123
|
+
end
|
124
|
+
hash[Date.new(year, 1, 18)][:fast] = Fast.new(:status => Fast::STATUS::STRICT, :text => "Крещенский сочельник")
|
125
|
+
hash[Date.new(year, 1, 19)][:fast] = Fast.new(:status => Fast::STATUS::NO) # Крещение Господне или Богоявление
|
126
|
+
|
127
|
+
# Успенский пост
|
128
|
+
hash[Date.new(year, 8, 14)][:fast] = Fast.new(:status => Fast::STATUS::STRICT, :text => "Начало Успенского поста")
|
129
|
+
(Date.new(year, 8, 15)..Date.new(year, 8, 27)).each do |date|
|
130
|
+
hash[date][:fast] = Fast.new(:status => Fast::STATUS::STRICT)
|
131
|
+
end
|
132
|
+
hash[Date.new(year, 8, 19)][:fast] = Fast.new(:status => Fast::STATUS::COMMON) # Преображение Господне
|
133
|
+
|
134
|
+
hash[Date.new(year, 9, 11)][:fast] = Fast.new(:status => Fast::STATUS::STRICT) # Усекновение главы Иоанна Предтечи
|
135
|
+
hash[Date.new(year, 9, 27)][:fast] = Fast.new(:status => Fast::STATUS::STRICT) # Воздвижение Креста Господня
|
136
|
+
|
137
|
+
|
138
|
+
# Седмица после Недели о мытаре и фарисее - сплошная, пост в среду и пятницу отменяется.
|
139
|
+
(easter.weeks_ago(10).next_date..easter.weeks_ago(9)).each do |date|
|
140
|
+
hash[date][:fast] = Fast.new(:status => Fast::STATUS::NO)
|
141
|
+
end
|
142
|
+
|
143
|
+
# Седмица сырная (масленица)
|
144
|
+
hash[easter.prev_date(55)][:fast] = Fast.new(:status => Fast::STATUS::LOOSE, :text => "Седмица сырная (масленица)")
|
145
|
+
(easter.prev_date(54)..easter.prev_date(49)).each do |date|
|
146
|
+
hash[date][:fast] = Fast.new(:status => Fast::STATUS::LOOSE)
|
147
|
+
end
|
148
|
+
|
149
|
+
# Великий пост
|
150
|
+
hash[easter.prev_date(48)][:fast] = Fast.new(:status => Fast::STATUS::STRICT, :text => "Начало Великого поста")
|
151
|
+
(easter.prev_date(47)..easter.prev_date).each do |date|
|
152
|
+
hash[date][:fast] = Fast.new(:status => Fast::STATUS::STRICT)
|
153
|
+
end
|
154
|
+
|
155
|
+
hash[easter.week_ago][:fast] = Fast.new(:status => Fast::STATUS::COMMON) # Вход Господень в Иерусалим
|
156
|
+
|
157
|
+
# Светлая седмица
|
158
|
+
(easter.next_date..easter.week_since).each do |date|
|
159
|
+
hash[date][:fast] = Fast.new(:status => Fast::STATUS::NO)
|
160
|
+
end
|
161
|
+
|
162
|
+
# Сплошная неделя после пятидесяинцы
|
163
|
+
(easter.next_date(50)..easter.next_date(56)).each do |date|
|
164
|
+
hash[date][:fast] = Fast.new(:status => Fast::STATUS::NO)
|
165
|
+
end
|
166
|
+
|
167
|
+
# Петров пост
|
168
|
+
hash[easter.next_date(57)][:fast] = Fast.new(:status => Fast::STATUS::STRICT, :text => "Начало Петрова поста")
|
169
|
+
(easter.next_date(58)..Date.new(year, 7, 11)).each do |date|
|
170
|
+
if date.wday == 3 || date.wday == 5
|
171
|
+
hash[date][:fast] = Fast.new(:status => Fast::STATUS::STRICT)
|
172
|
+
else
|
173
|
+
hash[date][:fast] = Fast.new(:status => Fast::STATUS::COMMON)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
# Рождество Иоанна Предтечи
|
178
|
+
unless hash[Date.new(year, 7, 7)][:fast].status == Fast::STATUS::NO
|
179
|
+
hash[Date.new(year, 7, 7)][:fast] = Fast.new(:status => Fast::STATUS::COMMON)
|
180
|
+
end
|
181
|
+
|
182
|
+
# Благовещение Пресвятой Богородицы
|
183
|
+
date = Date.new(year, 4, 7)
|
184
|
+
unless hash[date][:fast].status == Fast::STATUS::NO
|
185
|
+
unless (easter.prev_date(6)..easter.prev_date).include?( date )
|
186
|
+
hash[date][:fast] = Fast.new(:status => Fast::STATUS::COMMON)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
return easter, hash
|
191
|
+
end
|
192
|
+
|
193
|
+
class << self; alias_method :easter_and_days, :build_data; end
|
194
|
+
|
195
|
+
end
|
196
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
class Date
|
2
|
+
|
3
|
+
def self.easter(year=self.today.year)
|
4
|
+
# FeastFast::DB.data(year.to_i)[:easter]
|
5
|
+
raise TypeError, 'expected fixnum' unless year.instance_of? Fixnum
|
6
|
+
a = (19 * (year % 19) + 15) % 30
|
7
|
+
b = (2 * (year % 4) + 4 * (year % 7) + 6 * a + 6) % 7
|
8
|
+
c = a + b
|
9
|
+
if c > 10
|
10
|
+
d = c - 9 # day
|
11
|
+
m = 4 # month
|
12
|
+
else
|
13
|
+
d = 22 + c # day
|
14
|
+
m = 3 # month
|
15
|
+
end
|
16
|
+
self.new(year, m, d) + 13
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.with_feasts(year, status)
|
20
|
+
FeastFast::DB.feasts(year, status).map{|a| a[0]}
|
21
|
+
end
|
22
|
+
|
23
|
+
def feasts
|
24
|
+
@feasts ||= FeastFast::DB.date(self)[:feasts]
|
25
|
+
end
|
26
|
+
def fast
|
27
|
+
@fast ||= FeastFast::DB.date(self)[:fast]
|
28
|
+
end
|
29
|
+
|
30
|
+
def easter?
|
31
|
+
self == FeastFast::DB.data(self.year)[:easter]
|
32
|
+
end
|
33
|
+
|
34
|
+
def fast?
|
35
|
+
self.fast.status != FeastFast::Fast::STATUS::NO
|
36
|
+
end
|
37
|
+
|
38
|
+
def feasts?() self.feasts.any? end
|
39
|
+
|
40
|
+
def next_date(n=1) self + n end
|
41
|
+
def prev_date(n=1) self - n end
|
42
|
+
|
43
|
+
def next_sunday(step=1)
|
44
|
+
days_to_sunday = self.wday!=0 ? 7-self.wday : 0
|
45
|
+
days_to_sunday = days_to_sunday + 7*(step-1)
|
46
|
+
result = self + days_to_sunday
|
47
|
+
end
|
48
|
+
|
49
|
+
def prev_sunday(step=1)
|
50
|
+
days_to_sunday = self.wday!=0 ? self.wday : 0
|
51
|
+
days_to_sunday = days_to_sunday + 7*(step-1)
|
52
|
+
result = self - days_to_sunday
|
53
|
+
end
|
54
|
+
|
55
|
+
def weeks_ago(step=1)
|
56
|
+
self - 7*step
|
57
|
+
end
|
58
|
+
def weeks_since(step=1)
|
59
|
+
self + 7*step
|
60
|
+
end
|
61
|
+
def week_ago() weeks_ago end
|
62
|
+
def week_since() weeks_since end
|
63
|
+
|
64
|
+
def next_easter
|
65
|
+
easter = self.class.easter(self.year)
|
66
|
+
if easter > self
|
67
|
+
easter
|
68
|
+
else
|
69
|
+
self.class.easter(self.year + 1)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module FeastFast
|
2
|
+
module DB
|
3
|
+
def self.data(year)
|
4
|
+
year = year.to_i
|
5
|
+
return @data[year] if @data && @data.has_key?( year )
|
6
|
+
|
7
|
+
@data ||= {}
|
8
|
+
e, d = Calculator.easter_and_days(year)
|
9
|
+
@data[year] = {
|
10
|
+
:easter => e,
|
11
|
+
:days => d
|
12
|
+
}
|
13
|
+
@data[year]
|
14
|
+
end
|
15
|
+
|
16
|
+
class << self; alias_method :year, :data; end
|
17
|
+
|
18
|
+
def self.date(date)
|
19
|
+
raise( TypeError, 'expected date' ) unless date.instance_of? Date
|
20
|
+
self.data(date.year)[:days][date]
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.feasts(year, status)
|
24
|
+
year = year.to_i
|
25
|
+
self.data(year)[:days].select do |date, hash|
|
26
|
+
hash[:feasts].map{|feast| feast.status == status}.any?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
module FeastFast
|
3
|
+
class Fast
|
4
|
+
|
5
|
+
module STATUS
|
6
|
+
NO = 0
|
7
|
+
LOOSE = 1
|
8
|
+
COMMON = 2
|
9
|
+
STRICT = 3
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :status, :text
|
13
|
+
|
14
|
+
def initialize(hsh={:status => STATUS::NO, :text => nil})
|
15
|
+
@status = hsh[:status]
|
16
|
+
@text = get_text(hsh[:text])
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
@text
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def get_text(hsh_text)
|
26
|
+
text = case @status
|
27
|
+
when STATUS::LOOSE
|
28
|
+
"Пища без мяса"
|
29
|
+
when STATUS::COMMON
|
30
|
+
"Постный день"
|
31
|
+
when STATUS::STRICT
|
32
|
+
"Строгий пост"
|
33
|
+
when STATUS::NO
|
34
|
+
"Нет поста"
|
35
|
+
end
|
36
|
+
text = "#{hsh_text.chomp('.')}. #{text}" if hsh_text
|
37
|
+
text
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
module FeastFast
|
3
|
+
class Feast
|
4
|
+
|
5
|
+
module STATUS
|
6
|
+
EASTER = 1
|
7
|
+
TWELVE = 2
|
8
|
+
GREAT = 3
|
9
|
+
COMMON = 4
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :status, :text
|
13
|
+
|
14
|
+
def initialize(hsh={:status => 0, :text => "No feast today"})
|
15
|
+
@status = hsh[:status]
|
16
|
+
@text = hsh[:text]
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
@text + case @status
|
21
|
+
when STATUS::GREAT
|
22
|
+
". (великий)"
|
23
|
+
when STATUS::TWELVE
|
24
|
+
". (двунадесятый)"
|
25
|
+
else
|
26
|
+
""
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/feast_fast.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
module FeastFast
|
2
|
+
def self.require_all_libs_relative_to( fname, dir = nil )
|
3
|
+
dir ||= ::File.basename(fname, '.*')
|
4
|
+
search_me = ::File.expand_path(
|
5
|
+
::File.join(::File.dirname(fname), dir, '**', '*.rb'))
|
6
|
+
|
7
|
+
Dir.glob(search_me).sort.each {|rb| require rb}
|
8
|
+
end
|
9
|
+
end
|
10
|
+
require "date"
|
11
|
+
FeastFast.require_all_libs_relative_to(__FILE__)
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: feast_fast
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- ilzoff
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-06-08 00:00:00 Z
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Feasts and Fasts of Eastern Orthodox Church hardcoded and calculated based on easter.
|
22
|
+
email:
|
23
|
+
- il.zoff@gmail.com
|
24
|
+
executables:
|
25
|
+
- feast_fast
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- LICENSE
|
34
|
+
- README.md
|
35
|
+
- Rakefile
|
36
|
+
- bin/feast_fast
|
37
|
+
- feast_fast.gemspec
|
38
|
+
- lib/feast_fast.rb
|
39
|
+
- lib/feast_fast/calculator.rb
|
40
|
+
- lib/feast_fast/date.rb
|
41
|
+
- lib/feast_fast/db.rb
|
42
|
+
- lib/feast_fast/fast.rb
|
43
|
+
- lib/feast_fast/feast.rb
|
44
|
+
- lib/feast_fast/version.rb
|
45
|
+
homepage: https://github.com/ilzoff/feast_fast
|
46
|
+
licenses:
|
47
|
+
- MIT
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
hash: 3
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 1.8.24
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: Feasts and Fasts of Eastern Orthodox Church hardcoded and calculated
|
78
|
+
test_files: []
|
79
|
+
|