From af40b298a6270a8e08c57de8482bc0cff4526f45 Mon Sep 17 00:00:00 2001 From: Kevin Pratt Date: Fri, 15 Dec 2023 14:04:54 -0700 Subject: [PATCH 1/5] Add convenience methods for occasion date ranges --- Gemfile | 2 +- lib/bahai_date/logic.rb | 4 ++-- lib/bahai_date/occasion_factory.rb | 13 ++++++++++ spec/bahai_date/occasion_factory_spec.rb | 30 ++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 6b482d7..83c19f6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'astro-algo', :github => 'lessan/astro-algo' +gem 'astro-algo', github: 'lessan/astro-algo' # Specify your gem's dependencies in bahai_date.gemspec gemspec diff --git a/lib/bahai_date/logic.rb b/lib/bahai_date/logic.rb index 5f88ed0..6259656 100644 --- a/lib/bahai_date/logic.rb +++ b/lib/bahai_date/logic.rb @@ -16,8 +16,8 @@ class Logic # Latitude: 35° 41' 45.9996", Longitude: 51° 25' 23.0016" # Converted to decimal using: # http://transition.fcc.gov/mb/audio/bickel/DDDMMSS-decimal.html - TEHRAN_LAT = BigDecimal.new('35.696111') - TEHRAN_LONG = BigDecimal.new('51.423056') + TEHRAN_LAT = BigDecimal("35.696111") + TEHRAN_LONG = BigDecimal("51.423056") # *** Azimuth (for determining sunset times) *** # Source: http://www.timeanddate.com/astronomy/about-sun-calculator.html diff --git a/lib/bahai_date/occasion_factory.rb b/lib/bahai_date/occasion_factory.rb index 798d45c..0a8556c 100644 --- a/lib/bahai_date/occasion_factory.rb +++ b/lib/bahai_date/occasion_factory.rb @@ -147,6 +147,19 @@ def occasions create_occasions_classes_from occasions_hashes end + def self.ayyam_i_ha_range(year) + first = BahaiDate.new(year:, month: -1, day: 1) + last = BahaiDate.new(year:, month: 19, day: 1) + + first.gregorian_date..(last.gregorian_date.prev_day) + end + + def self.fasting_range(year) + first = BahaiDate.new(year:, month: 19, day: 1) + last = BahaiDate.new(year:, month: 19, day: 19) + + first.gregorian_date..(last.gregorian_date) + end def self.find(occasion, year) if year < 172 all_dates = DATES.merge(DATES_BEFORE_172) diff --git a/spec/bahai_date/occasion_factory_spec.rb b/spec/bahai_date/occasion_factory_spec.rb index 6aa21cc..73c41c8 100644 --- a/spec/bahai_date/occasion_factory_spec.rb +++ b/spec/bahai_date/occasion_factory_spec.rb @@ -67,6 +67,36 @@ module BahaiDate end end + context "Ayyam-i-ha date ranges" do + it "Finds the date range for Ayyam-i-ha" do + range = OccasionFactory.ayyam_i_ha_range(180) + expect(range.first).to eq(Date.parse("2024-02-26")) + expect(range.last).to eq(Date.parse("2024-02-29")) + expect(range.to_a.length).to eq(4) + end + + it "Finds the date range for Ayyam-i-ha for the current year" do + range = OccasionFactory.ayyam_i_ha_range(187) + expect(range.first).to eq(Date.parse("2031-02-25")) + expect(range.last).to eq(Date.parse("2031-03-01")) + expect(range.to_a.length).to eq(5) + end + end + + context "Fasting date ranges" do + it "Finds the date range for Fasting month" do + range = OccasionFactory.fasting_range(180) + expect(range.first).to eq(Date.parse("2024-03-01")) + expect(range.last).to eq(Date.parse("2024-03-19")) + end + + it "Finds the date range for Fasting month leap year" do + range = OccasionFactory.fasting_range(187) + expect(range.first).to eq(Date.parse("2031-03-02")) + expect(range.last).to eq(Date.parse("2031-03-20")) + end + end + context 'for dates after 172 B.E.' do it 'provides the Declaration of the Bab on the correct day' do occasions = OccasionFactory.new(172, 4, 7).occasions From 38f7e794a3bde69458a98fb627c366618291f84f Mon Sep 17 00:00:00 2001 From: Kevin Pratt Date: Fri, 15 Dec 2023 14:06:58 -0700 Subject: [PATCH 2/5] Standardrbizing the codebase - becasuse standards --- Gemfile | 4 +- Rakefile | 4 +- bahai_date.gemspec | 33 ++- lib/bahai_date.rb | 22 +- lib/bahai_date/bahai_date.rb | 14 +- lib/bahai_date/day.rb | 8 +- lib/bahai_date/logic.rb | 12 +- lib/bahai_date/month.rb | 8 +- lib/bahai_date/occasion.rb | 10 +- lib/bahai_date/occasion_factory.rb | 279 ++++++++++++----------- lib/bahai_date/version.rb | 2 +- lib/bahai_date/weekday.rb | 10 +- lib/bahai_date/year.rb | 6 +- spec/bahai_date/bahai_date_spec.rb | 100 ++++---- spec/bahai_date/day_spec.rb | 39 ++-- spec/bahai_date/logic_spec.rb | 4 +- spec/bahai_date/month_spec.rb | 42 ++-- spec/bahai_date/occasion_factory_spec.rb | 50 ++-- spec/bahai_date/occasion_spec.rb | 14 +- spec/bahai_date/weekday_spec.rb | 31 +-- spec/bahai_date/year_calendar_spec.rb | 12 +- spec/bahai_date/year_spec.rb | 44 ++-- spec/spec_helper.rb | 4 +- 23 files changed, 382 insertions(+), 370 deletions(-) diff --git a/Gemfile b/Gemfile index 83c19f6..ce48db6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ -source 'https://rubygems.org' +source "https://rubygems.org" -gem 'astro-algo', github: 'lessan/astro-algo' +gem "astro-algo", github: "lessan/astro-algo" # Specify your gem's dependencies in bahai_date.gemspec gemspec diff --git a/Rakefile b/Rakefile index 7d6de42..0e4aab9 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,4 @@ -desc 'Open an irb session preloaded with this library' +desc "Open an irb session preloaded with this library" task :console do - sh 'irb -rubygems -I lib -r bahai_date.rb' + sh "irb -rubygems -I lib -r bahai_date.rb" end diff --git a/bahai_date.gemspec b/bahai_date.gemspec index 013aaa1..317e4ed 100644 --- a/bahai_date.gemspec +++ b/bahai_date.gemspec @@ -1,24 +1,23 @@ lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'bahai_date/version' +require "bahai_date/version" Gem::Specification.new do |s| - s.name = 'bahai_date' - s.version = BahaiDate::VERSION - s.author = 'Lessan Vaezi' - s.email = 'lessan@gmail.com' - s.homepage = 'https://github.com/lessan/bahai-date' - s.summary = "Conversion between Gregorian and Baha'i (or Badi) calendars" - s.description = "Provides functionality to convert between the Gregorian and Baha'i calendar, as well as significant dates and occasions in the Baha'i calendar such as the new year and holy days" - s.licenses = ['Unlicense'] + s.name = "bahai_date" + s.version = BahaiDate::VERSION + s.author = "Lessan Vaezi" + s.email = "lessan@gmail.com" + s.homepage = "https://github.com/lessan/bahai-date" + s.summary = "Conversion between Gregorian and Baha'i (or Badi) calendars" + s.description = "Provides functionality to convert between the Gregorian and Baha'i calendar, as well as significant dates and occasions in the Baha'i calendar such as the new year and holy days" + s.licenses = ["Unlicense"] - s.files = Dir['{bin,lib,spec}/**/*'] + %w(LICENSE.md README.md) - s.test_files = Dir['spec/**/*'] + s.files = Dir["{bin,lib,spec}/**/*"] + %w[LICENSE.md README.md] - s.required_ruby_version = '>=2.0' - s.add_runtime_dependency 'tzinfo', '~> 1.2' - s.add_runtime_dependency 'RubySunrise', '~> 0.3' - s.add_runtime_dependency 'astro-algo', '~> 0' - s.add_development_dependency 'rspec', '~> 3' - s.add_development_dependency 'simplecov', '~> 0' + s.required_ruby_version = ">=2.0" + s.add_runtime_dependency "tzinfo", "~> 1.2" + s.add_runtime_dependency "RubySunrise", "~> 0.3" + s.add_runtime_dependency "astro-algo", "~> 0" + s.add_development_dependency "rspec", "~> 3" + s.add_development_dependency "simplecov", "~> 0" end diff --git a/lib/bahai_date.rb b/lib/bahai_date.rb index 1831562..7ce8472 100644 --- a/lib/bahai_date.rb +++ b/lib/bahai_date.rb @@ -1,11 +1,11 @@ -require 'date' -require 'bahai_date/version' -require 'bahai_date/logic' -require 'bahai_date/bahai_date' -require 'bahai_date/year' -require 'bahai_date/month' -require 'bahai_date/day' -require 'bahai_date/weekday' -require 'bahai_date/occasion' -require 'bahai_date/occasion_factory' -require 'bahai_date/year_calendar' +require "date" +require "bahai_date/version" +require "bahai_date/logic" +require "bahai_date/bahai_date" +require "bahai_date/year" +require "bahai_date/month" +require "bahai_date/day" +require "bahai_date/weekday" +require "bahai_date/occasion" +require "bahai_date/occasion_factory" +require "bahai_date/year_calendar" diff --git a/lib/bahai_date/bahai_date.rb b/lib/bahai_date/bahai_date.rb index c070b85..184634e 100644 --- a/lib/bahai_date/bahai_date.rb +++ b/lib/bahai_date/bahai_date.rb @@ -18,7 +18,7 @@ def initialize(params) validate_ayyam_i_ha @gregorian_date = to_gregorian else - fail ArgumentError, 'Invalid arguments. Use a hash with :date or with :year, :month, and :day.' + fail ArgumentError, "Invalid arguments. Use a hash with :date or with :year, :month, and :day." end @weekday = Weekday.new(weekday_from_gregorian) end @@ -39,12 +39,12 @@ def short_format "#{@day.number} #{@month} #{@year.bahai_era}" end - def +(val) - self.class.new(date: @gregorian_date + val) + def +(other) + self.class.new(date: @gregorian_date + other) end - def -(val) - self.class.new(date: @gregorian_date - val) + def -(other) + self.class.new(date: @gregorian_date - other) end private @@ -84,7 +84,7 @@ def from_gregorian day = days - (342 + ayyam_i_ha_days(year)) end else - month, day = (days).divmod(19) + month, day = days.divmod(19) month += 1 end day += 1 @@ -93,7 +93,7 @@ def from_gregorian def weekday_from_gregorian # saturday (6 in ruby) is the first day of the week - @gregorian_date.wday == 6 ? 1 : @gregorian_date.wday + 2 + (@gregorian_date.wday == 6) ? 1 : @gregorian_date.wday + 2 end def days_from_nawruz diff --git a/lib/bahai_date/day.rb b/lib/bahai_date/day.rb index 043b997..646ae87 100644 --- a/lib/bahai_date/day.rb +++ b/lib/bahai_date/day.rb @@ -1,8 +1,8 @@ module BahaiDate class Day - TITLES = %w(Baha Jalal Jamal Azamat Nur Rahmat Kalimat Kamal Asma Izzat Mashiyyat Ilm Qudrat Qawl Masail Sharaf Sultan Mulk Ala) - TITLES_HTML = %w(Bahá Jalál Jamál ‘Aẓamat Núr Raḥmat Kalimát Kamál Asmá’ ‘Izzat Mashíyyat ‘Ilm Qudrat Qawl Masá’il Sharaf Sulṭán Mulk ‘Alá’) - TITLES_EN = %w(Splendour Glory Beauty Grandeur Light Mercy Words Perfection Names Might Will Knowledge Power Speech Questions Honour Sovereignty Dominion Loftiness) + TITLES = %w[Baha Jalal Jamal Azamat Nur Rahmat Kalimat Kamal Asma Izzat Mashiyyat Ilm Qudrat Qawl Masail Sharaf Sultan Mulk Ala] + TITLES_HTML = %w[Bahá Jalál Jamál ‘Aẓamat Núr Raḥmat Kalimát Kamál Asmá’ ‘Izzat Mashíyyat ‘Ilm Qudrat Qawl Masá’il Sharaf Sulṭán Mulk ‘Alá’] + TITLES_EN = %w[Splendour Glory Beauty Grandeur Light Mercy Words Perfection Names Might Will Knowledge Power Speech Questions Honour Sovereignty Dominion Loftiness] attr_reader :number attr_accessor :occasions, :weekday @@ -36,7 +36,7 @@ def title_index def validate(number_arg) number = number_arg.to_i - return if (1..19).include? number + return if (1..19).cover? number fail ArgumentError, "'#{number}' is not a valid day. Please use 1 to 19." end end diff --git a/lib/bahai_date/logic.rb b/lib/bahai_date/logic.rb index 6259656..ff24c67 100644 --- a/lib/bahai_date/logic.rb +++ b/lib/bahai_date/logic.rb @@ -1,7 +1,7 @@ -require 'bundler/setup' -require 'tzinfo' -require 'solareventcalculator' -require 'astro-algo' +require "bundler/setup" +require "tzinfo" +require "solareventcalculator" +require "astro-algo" module BahaiDate class Logic @@ -27,7 +27,7 @@ class Logic AZIMUTH = 90.833333 def initialize - @tz = TZInfo::Timezone.get('Asia/Tehran') + @tz = TZInfo::Timezone.get("Asia/Tehran") end def self.nawruz_for(year) @@ -100,7 +100,7 @@ def bahai_era_to_gregorian_year(year) private def localize(time) - (@tz.utc_to_local(time)).to_time + @tz.utc_to_local(time).to_time end def increment_if_after_sunset(time) diff --git a/lib/bahai_date/month.rb b/lib/bahai_date/month.rb index 07e1295..ebebd59 100644 --- a/lib/bahai_date/month.rb +++ b/lib/bahai_date/month.rb @@ -1,8 +1,8 @@ module BahaiDate class Month - TITLES = %w(Baha Jalal Jamal Azamat Nur Rahmat Kalimat Kamal Asma Izzat Mashiyyat Ilm Qudrat Qawl Masail Sharaf Sultan Mulk Ala Ayyam-i-Ha) - TITLES_HTML = %w(Bahá Jalál Jamál ‘Aẓamat Núr Raḥmat Kalimát Kamál Asmá’ ‘Izzat Mashíyyat ‘Ilm Qudrat Qawl Masá’il Sharaf Sulṭán Mulk ‘Alá’ Ayyám-i-Há) - TITLES_EN = %w(Splendour Glory Beauty Grandeur Light Mercy Words Perfection Names Might Will Knowledge Power Speech Questions Honour Sovereignty Dominion Loftiness Ayyam-i-Ha) + TITLES = %w[Baha Jalal Jamal Azamat Nur Rahmat Kalimat Kamal Asma Izzat Mashiyyat Ilm Qudrat Qawl Masail Sharaf Sultan Mulk Ala Ayyam-i-Ha] + TITLES_HTML = %w[Bahá Jalál Jamál ‘Aẓamat Núr Raḥmat Kalimát Kamál Asmá’ ‘Izzat Mashíyyat ‘Ilm Qudrat Qawl Masá’il Sharaf Sulṭán Mulk ‘Alá’ Ayyám-i-Há] + TITLES_EN = %w[Splendour Glory Beauty Grandeur Light Mercy Words Perfection Names Might Will Knowledge Power Speech Questions Honour Sovereignty Dominion Loftiness Ayyam-i-Ha] attr_reader :number, :days @@ -45,7 +45,7 @@ def title_index def validate(number_arg) number = number_arg.to_i - return if (1..19).include?(number) || number == -1 + return if (1..19).cover?(number) || number == -1 fail ArgumentError, "'#{number}' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha." end end diff --git a/lib/bahai_date/occasion.rb b/lib/bahai_date/occasion.rb index 26b7b7a..4df0937 100644 --- a/lib/bahai_date/occasion.rb +++ b/lib/bahai_date/occasion.rb @@ -1,11 +1,11 @@ module BahaiDate class Occasion attr_reader :type, - :work_suspended, - :title, - :short_title, - :title_html, - :short_title_html + :work_suspended, + :title, + :short_title, + :title_html, + :short_title_html alias_method :work_suspended?, :work_suspended def initialize(opts = {}) diff --git a/lib/bahai_date/occasion_factory.rb b/lib/bahai_date/occasion_factory.rb index 0a8556c..5cf51ce 100644 --- a/lib/bahai_date/occasion_factory.rb +++ b/lib/bahai_date/occasion_factory.rb @@ -1,140 +1,140 @@ module BahaiDate class OccasionFactory OCCASIONS = { - ayyam_i_ha_1: { type: :ayyam_i_ha, work_suspended: false, title: 'First day of Ayyam-i-Ha (Intercalery Days)', short_title: '1st day of Ayyam-i-Ha', title_html: 'First day of Ayyám-i-Há (Intercalery Days)', short_title_html: '1st day of Ayyám-i-Há' }, - ayyam_i_ha_2: { type: :ayyam_i_ha, work_suspended: false, title: 'Second day of Ayyam-i-Ha (Intercalery Days)', short_title: '2nd day of Ayyam-i-Ha', title_html: 'Second day of Ayyám-i-Há (Intercalery Days)', short_title_html: '2nd day of Ayyám-i-Há' }, - ayyam_i_ha_3: { type: :ayyam_i_ha, work_suspended: false, title: 'Third day of Ayyam-i-Ha (Intercalery Days)', short_title: '3rd day of Ayyam-i-Ha', title_html: 'Third day of Ayyám-i-Há (Intercalery Days)', short_title_html: '3rd day of Ayyám-i-Há' }, - ayyam_i_ha_4: { type: :ayyam_i_ha, work_suspended: false, title: 'Fourth day of Ayyam-i-Ha (Intercalery Days)', short_title: '4th day of Ayyam-i-Ha', title_html: 'Fourth day of Ayyám-i-Há (Intercalery Days)', short_title_html: '4th day of Ayyám-i-Há' }, - ayyam_i_ha_5: { type: :ayyam_i_ha, work_suspended: false, title: 'Fifth day of Ayyam-i-Ha (Intercalery Days)', short_title: '5th day of Ayyam-i-Ha', title_html: 'Fifth day of Ayyám-i-Há (Intercalery Days)', short_title_html: '5th day of Ayyám-i-Há' }, - fasting_1: { type: :fasting, work_suspended: false, title: 'First day of the period of Fasting', short_title: '1st day of Fasting', title_html: 'First day of the period of Fasting', short_title_html: '1st day of Fasting' }, - fasting_2: { type: :fasting, work_suspended: false, title: 'Second day of the period of Fasting', short_title: '2nd day of Fasting', title_html: 'Second day of the period of Fasting', short_title_html: '2nd day of Fasting' }, - fasting_3: { type: :fasting, work_suspended: false, title: 'Third day of the period of Fasting', short_title: '3rd day of Fasting', title_html: 'Third day of the period of Fasting', short_title_html: '3rd day of Fasting' }, - fasting_4: { type: :fasting, work_suspended: false, title: 'Fourth day of the period of Fasting', short_title: '4th day of Fasting', title_html: 'Fourth day of the period of Fasting', short_title_html: '4th day of Fasting' }, - fasting_5: { type: :fasting, work_suspended: false, title: 'Fifth day of the period of Fasting', short_title: '5th day of Fasting', title_html: 'Fifth day of the period of Fasting', short_title_html: '5th day of Fasting' }, - fasting_6: { type: :fasting, work_suspended: false, title: 'Sixth day of the period of Fasting', short_title: '6th day of Fasting', title_html: 'Sixth day of the period of Fasting', short_title_html: '6th day of Fasting' }, - fasting_7: { type: :fasting, work_suspended: false, title: 'Seventh day of the period of Fasting', short_title: '7th day of Fasting', title_html: 'Seventh day of the period of Fasting', short_title_html: '7th day of Fasting' }, - fasting_8: { type: :fasting, work_suspended: false, title: 'Eighth day of the period of Fasting', short_title: '8th day of Fasting', title_html: 'Eighth day of the period of Fasting', short_title_html: '8th day of Fasting' }, - fasting_9: { type: :fasting, work_suspended: false, title: 'Ninth day of the period of Fasting', short_title: '9th day of Fasting', title_html: 'Ninth day of the period of Fasting', short_title_html: '9th day of Fasting' }, - fasting_10: { type: :fasting, work_suspended: false, title: 'Tenth day of the period of Fasting', short_title: '10th day of Fasting', title_html: 'Tenth day of the period of Fasting', short_title_html: '10th day of Fasting' }, - fasting_11: { type: :fasting, work_suspended: false, title: 'Eleventh day of the period of Fasting', short_title: '11th day of Fasting', title_html: 'Eleventh day of the period of Fasting', short_title_html: '11th day of Fasting' }, - fasting_12: { type: :fasting, work_suspended: false, title: 'Twelfth day of the period of Fasting', short_title: '12th day of Fasting', title_html: 'Twelfth day of the period of Fasting', short_title_html: '12th day of Fasting' }, - fasting_13: { type: :fasting, work_suspended: false, title: 'Thirteenth day of the period of Fasting', short_title: '13th day of Fasting', title_html: 'Thirteenth day of the period of Fasting', short_title_html: '13th day of Fasting' }, - fasting_14: { type: :fasting, work_suspended: false, title: 'Fourteenth day of the period of Fasting', short_title: '14th day of Fasting', title_html: 'Fourteenth day of the period of Fasting', short_title_html: '14th day of Fasting' }, - fasting_15: { type: :fasting, work_suspended: false, title: 'Fifteenth day of the period of Fasting', short_title: '15th day of Fasting', title_html: 'Fifteenth day of the period of Fasting', short_title_html: '15th day of Fasting' }, - fasting_16: { type: :fasting, work_suspended: false, title: 'Sixteenth day of the period of Fasting', short_title: '16th day of Fasting', title_html: 'Sixteenth day of the period of Fasting', short_title_html: '16th day of Fasting' }, - fasting_17: { type: :fasting, work_suspended: false, title: 'Seventeenth day of the period of Fasting', short_title: '17th day of Fasting', title_html: 'Seventeenth day of the period of Fasting', short_title_html: '17th day of Fasting' }, - fasting_18: { type: :fasting, work_suspended: false, title: 'Eighteenth day of the period of Fasting', short_title: '18th day of Fasting', title_html: 'Eighteenth day of the period of Fasting', short_title_html: '18th day of Fasting' }, - fasting_19: { type: :fasting, work_suspended: false, title: 'Nineteenth day of the period of Fasting', short_title: '19th day of Fasting', title_html: 'Nineteenth day of the period of Fasting', short_title_html: '19th day of Fasting' }, - feast_1: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Baha (Splendour)', short_title: 'Feast of Baha', title_html: 'Nineteen Day Feast of the month of Bahá (Splendour)', short_title_html: 'Feast of Bahá' }, - feast_2: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Jalal (Glory)', short_title: 'Feast of Jalal', title_html: 'Nineteen Day Feast of the month of Jalál (Glory)', short_title_html: 'Feast of Jalál' }, - feast_3: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Jamal (Beauty)', short_title: 'Feast of Jamal', title_html: 'Nineteen Day Feast of the month of Jamál (Beauty)', short_title_html: 'Feast of Jamál' }, - feast_4: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Azamat (Grandeur)', short_title: 'Feast of Azamat', title_html: 'Nineteen Day Feast of the month of ‘Aẓamat (Grandeur)', short_title_html: 'Feast of ‘Aẓamat' }, - feast_5: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Nur (Light)', short_title: 'Feast of Nur', title_html: 'Nineteen Day Feast of the month of Núr (Light)', short_title_html: 'Feast of Núr' }, - feast_6: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Rahmat (Mercy)', short_title: 'Feast of Rahmat', title_html: 'Nineteen Day Feast of the month of Raḥmat (Mercy)', short_title_html: 'Feast of Raḥmat' }, - feast_7: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Kalimat (Words)', short_title: 'Feast of Kalimat', title_html: 'Nineteen Day Feast of the month of Kalimát (Words)', short_title_html: 'Feast of Kalimát' }, - feast_8: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Kamal (Perfection)', short_title: 'Feast of Kamal', title_html: 'Nineteen Day Feast of the month of Kamál (Perfection)', short_title_html: 'Feast of Kamál' }, - feast_9: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Asma (Names)', short_title: 'Feast of Asma', title_html: 'Nineteen Day Feast of the month of Asmá’ (Names)', short_title_html: 'Feast of Asmá’' }, - feast_10: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Izzat (Might)', short_title: 'Feast of Izzat', title_html: 'Nineteen Day Feast of the month of ‘Izzat (Might)', short_title_html: 'Feast of ‘Izzat' }, - feast_11: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Mashiyyat (Will)', short_title: 'Feast of Mashiyyat', title_html: 'Nineteen Day Feast of the month of Mashíyyat (Will)', short_title_html: 'Feast of Mashíyyat' }, - feast_12: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Ilm (Knowledge)', short_title: 'Feast of Ilm', title_html: 'Nineteen Day Feast of the month of ‘Ilm (Knowledge)', short_title_html: 'Feast of ‘Ilm' }, - feast_13: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Qudrat (Power)', short_title: 'Feast of Qudrat', title_html: 'Nineteen Day Feast of the month of Qudrat (Power)', short_title_html: 'Feast of Qudrat' }, - feast_14: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Qawl (Speech)', short_title: 'Feast of Qawl', title_html: 'Nineteen Day Feast of the month of Qawl (Speech)', short_title_html: 'Feast of Qawl' }, - feast_15: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Masail (Questions)', short_title: 'Feast of Masail', title_html: 'Nineteen Day Feast of the month of Masá’il (Questions)', short_title_html: 'Feast of Masá’il' }, - feast_16: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Sharaf (Honour)', short_title: 'Feast of Sharaf', title_html: 'Nineteen Day Feast of the month of Sharaf (Honour)', short_title_html: 'Feast of Sharaf' }, - feast_17: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Sultan (Sovereignty)', short_title: 'Feast of Sultan', title_html: 'Nineteen Day Feast of the month of Sulṭán (Sovereignty)', short_title_html: 'Feast of Sulṭán' }, - feast_18: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Mulk (Dominion)', short_title: 'Feast of Mulk', title_html: 'Nineteen Day Feast of the month of Mulk (Dominion)', short_title_html: 'Feast of Mulk' }, - feast_19: { type: :feast, work_suspended: false, title: 'Nineteen Day Feast of the month of Ala (Loftiness)', short_title: 'Feast of Ala', title_html: 'Nineteen Day Feast of the month of ‘Alá’ (Loftiness)', short_title_html: 'Feast of ‘Alá’' }, - ridvan_1: { type: :holy, work_suspended: true, title: 'First day of the Festival of Ridvan', short_title: '1st day of Ridvan', title_html: 'First day of the Festival of Riḍván', short_title_html: '1st day of Riḍván' }, - ridvan_2: { type: :ridvan, work_suspended: false, title: 'Second day of the Festival of Ridvan', short_title: '2nd day of Ridvan', title_html: 'Second day of the Festival of Riḍván', short_title_html: '2nd day of Riḍván' }, - ridvan_3: { type: :ridvan, work_suspended: false, title: 'Third day of the Festival of Ridvan', short_title: '3rd day of Ridvan', title_html: 'Third day of the Festival of Riḍván', short_title_html: '3rd day of Riḍván' }, - ridvan_4: { type: :ridvan, work_suspended: false, title: 'Fourth day of the Festival of Ridvan', short_title: '4th day of Ridvan', title_html: 'Fourth day of the Festival of Riḍván', short_title_html: '4th day of Riḍván' }, - ridvan_5: { type: :ridvan, work_suspended: false, title: 'Fifth day of the Festival of Ridvan', short_title: '5th day of Ridvan', title_html: 'Fifth day of the Festival of Riḍván', short_title_html: '5th day of Riḍván' }, - ridvan_6: { type: :ridvan, work_suspended: false, title: 'Sixth day of the Festival of Ridvan', short_title: '6th day of Ridvan', title_html: 'Sixth day of the Festival of Riḍván', short_title_html: '6th day of Riḍván' }, - ridvan_7: { type: :ridvan, work_suspended: false, title: 'Seventh day of the Festival of Ridvan', short_title: '7th day of Ridvan', title_html: 'Seventh day of the Festival of Riḍván', short_title_html: '7th day of Riḍván' }, - ridvan_8: { type: :ridvan, work_suspended: false, title: 'Eighth day of the Festival of Ridvan', short_title: '8th day of Ridvan', title_html: 'Eighth day of the Festival of Riḍván', short_title_html: '8th day of Riḍván' }, - ridvan_9: { type: :holy, work_suspended: true, title: 'Ninth day of the Festival of Ridvan', short_title: '9th day of Ridvan', title_html: 'Ninth day of the Festival of Riḍván', short_title_html: '9th day of Riḍván' }, - ridvan_10: { type: :ridvan, work_suspended: false, title: 'Tenth day of the Festival of Ridvan', short_title: '10th day of Ridvan', title_html: 'Tenth day of the Festival of Riḍván', short_title_html: '10th day of Riḍván' }, - ridvan_11: { type: :ridvan, work_suspended: false, title: 'Eleventh day of the Festival of Ridvan', short_title: '11th day of Ridvan', title_html: 'Eleventh day of the Festival of Riḍván', short_title_html: '11th day of Riḍván' }, - ridvan_12: { type: :holy, work_suspended: true, title: 'Twelfth day of the Festival of Ridvan', short_title: '12th day of Ridvan', title_html: 'Twelfth day of the Festival of Riḍván', short_title_html: '12th day of Riḍván' }, - nawruz: { type: :holy, work_suspended: true, title: 'Naw-Ruz (New Year)', short_title: 'Naw-Ruz', title_html: 'Naw-Rúz (New Year)', short_title_html: 'Naw-Rúz' }, - declaration_bab: { type: :holy, work_suspended: true, title: 'Declaration of the Bab', short_title: 'Declaration of the Bab', title_html: 'Declaration of the Báb', short_title_html: 'Declaration of the Báb' }, - ascension_bahaullah: { type: :holy, work_suspended: true, title: "Ascension of Baha'u'llah", short_title: "Ascension of Baha'u'llah", title_html: 'Ascension of Bahá’u’lláh', short_title_html: 'Ascension of Bahá’u’lláh' }, - martyrdom_bab: { type: :holy, work_suspended: true, title: 'Martyrdom of the Bab', short_title: 'Martyrdom of the Bab', title_html: 'Martyrdom of the Báb', short_title_html: 'Martyrdom of the Báb' }, - birth_bab: { type: :holy, work_suspended: true, title: 'Anniversary of the Birth of the Bab', short_title: 'Birth of the Bab', title_html: 'Anniversary of the Birth of the Báb', short_title_html: 'Birth of the Báb' }, - birth_bahaullah: { type: :holy, work_suspended: true, title: "Anniversary of the Birth of Baha'u'llah", short_title: "Birth of Baha'u'llah", title_html: 'Anniversary of the Birth of Bahá’u’lláh', short_title_html: 'Birth of Bahá’u’lláh' }, - covenant: { type: :holy, work_suspended: false, title: 'Day of the Covenant', short_title: 'Day of the Covenant', title_html: 'Day of the Covenant', short_title_html: 'Day of the Covenant' }, - ascension_abdulbaha: { type: :holy, work_suspended: false, title: "Ascension of Abdu'l-Baha", short_title: "Ascension of Abdu'l-Baha", title_html: 'Ascension of ‘Abdu’l-Bahá', short_title_html: 'Ascension of ‘Abdu’l-Bahá' } + ayyam_i_ha_1: {type: :ayyam_i_ha, work_suspended: false, title: "First day of Ayyam-i-Ha (Intercalery Days)", short_title: "1st day of Ayyam-i-Ha", title_html: "First day of Ayyám-i-Há (Intercalery Days)", short_title_html: "1st day of Ayyám-i-Há"}, + ayyam_i_ha_2: {type: :ayyam_i_ha, work_suspended: false, title: "Second day of Ayyam-i-Ha (Intercalery Days)", short_title: "2nd day of Ayyam-i-Ha", title_html: "Second day of Ayyám-i-Há (Intercalery Days)", short_title_html: "2nd day of Ayyám-i-Há"}, + ayyam_i_ha_3: {type: :ayyam_i_ha, work_suspended: false, title: "Third day of Ayyam-i-Ha (Intercalery Days)", short_title: "3rd day of Ayyam-i-Ha", title_html: "Third day of Ayyám-i-Há (Intercalery Days)", short_title_html: "3rd day of Ayyám-i-Há"}, + ayyam_i_ha_4: {type: :ayyam_i_ha, work_suspended: false, title: "Fourth day of Ayyam-i-Ha (Intercalery Days)", short_title: "4th day of Ayyam-i-Ha", title_html: "Fourth day of Ayyám-i-Há (Intercalery Days)", short_title_html: "4th day of Ayyám-i-Há"}, + ayyam_i_ha_5: {type: :ayyam_i_ha, work_suspended: false, title: "Fifth day of Ayyam-i-Ha (Intercalery Days)", short_title: "5th day of Ayyam-i-Ha", title_html: "Fifth day of Ayyám-i-Há (Intercalery Days)", short_title_html: "5th day of Ayyám-i-Há"}, + fasting_1: {type: :fasting, work_suspended: false, title: "First day of the period of Fasting", short_title: "1st day of Fasting", title_html: "First day of the period of Fasting", short_title_html: "1st day of Fasting"}, + fasting_2: {type: :fasting, work_suspended: false, title: "Second day of the period of Fasting", short_title: "2nd day of Fasting", title_html: "Second day of the period of Fasting", short_title_html: "2nd day of Fasting"}, + fasting_3: {type: :fasting, work_suspended: false, title: "Third day of the period of Fasting", short_title: "3rd day of Fasting", title_html: "Third day of the period of Fasting", short_title_html: "3rd day of Fasting"}, + fasting_4: {type: :fasting, work_suspended: false, title: "Fourth day of the period of Fasting", short_title: "4th day of Fasting", title_html: "Fourth day of the period of Fasting", short_title_html: "4th day of Fasting"}, + fasting_5: {type: :fasting, work_suspended: false, title: "Fifth day of the period of Fasting", short_title: "5th day of Fasting", title_html: "Fifth day of the period of Fasting", short_title_html: "5th day of Fasting"}, + fasting_6: {type: :fasting, work_suspended: false, title: "Sixth day of the period of Fasting", short_title: "6th day of Fasting", title_html: "Sixth day of the period of Fasting", short_title_html: "6th day of Fasting"}, + fasting_7: {type: :fasting, work_suspended: false, title: "Seventh day of the period of Fasting", short_title: "7th day of Fasting", title_html: "Seventh day of the period of Fasting", short_title_html: "7th day of Fasting"}, + fasting_8: {type: :fasting, work_suspended: false, title: "Eighth day of the period of Fasting", short_title: "8th day of Fasting", title_html: "Eighth day of the period of Fasting", short_title_html: "8th day of Fasting"}, + fasting_9: {type: :fasting, work_suspended: false, title: "Ninth day of the period of Fasting", short_title: "9th day of Fasting", title_html: "Ninth day of the period of Fasting", short_title_html: "9th day of Fasting"}, + fasting_10: {type: :fasting, work_suspended: false, title: "Tenth day of the period of Fasting", short_title: "10th day of Fasting", title_html: "Tenth day of the period of Fasting", short_title_html: "10th day of Fasting"}, + fasting_11: {type: :fasting, work_suspended: false, title: "Eleventh day of the period of Fasting", short_title: "11th day of Fasting", title_html: "Eleventh day of the period of Fasting", short_title_html: "11th day of Fasting"}, + fasting_12: {type: :fasting, work_suspended: false, title: "Twelfth day of the period of Fasting", short_title: "12th day of Fasting", title_html: "Twelfth day of the period of Fasting", short_title_html: "12th day of Fasting"}, + fasting_13: {type: :fasting, work_suspended: false, title: "Thirteenth day of the period of Fasting", short_title: "13th day of Fasting", title_html: "Thirteenth day of the period of Fasting", short_title_html: "13th day of Fasting"}, + fasting_14: {type: :fasting, work_suspended: false, title: "Fourteenth day of the period of Fasting", short_title: "14th day of Fasting", title_html: "Fourteenth day of the period of Fasting", short_title_html: "14th day of Fasting"}, + fasting_15: {type: :fasting, work_suspended: false, title: "Fifteenth day of the period of Fasting", short_title: "15th day of Fasting", title_html: "Fifteenth day of the period of Fasting", short_title_html: "15th day of Fasting"}, + fasting_16: {type: :fasting, work_suspended: false, title: "Sixteenth day of the period of Fasting", short_title: "16th day of Fasting", title_html: "Sixteenth day of the period of Fasting", short_title_html: "16th day of Fasting"}, + fasting_17: {type: :fasting, work_suspended: false, title: "Seventeenth day of the period of Fasting", short_title: "17th day of Fasting", title_html: "Seventeenth day of the period of Fasting", short_title_html: "17th day of Fasting"}, + fasting_18: {type: :fasting, work_suspended: false, title: "Eighteenth day of the period of Fasting", short_title: "18th day of Fasting", title_html: "Eighteenth day of the period of Fasting", short_title_html: "18th day of Fasting"}, + fasting_19: {type: :fasting, work_suspended: false, title: "Nineteenth day of the period of Fasting", short_title: "19th day of Fasting", title_html: "Nineteenth day of the period of Fasting", short_title_html: "19th day of Fasting"}, + feast_1: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Baha (Splendour)", short_title: "Feast of Baha", title_html: "Nineteen Day Feast of the month of Bahá (Splendour)", short_title_html: "Feast of Bahá"}, + feast_2: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Jalal (Glory)", short_title: "Feast of Jalal", title_html: "Nineteen Day Feast of the month of Jalál (Glory)", short_title_html: "Feast of Jalál"}, + feast_3: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Jamal (Beauty)", short_title: "Feast of Jamal", title_html: "Nineteen Day Feast of the month of Jamál (Beauty)", short_title_html: "Feast of Jamál"}, + feast_4: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Azamat (Grandeur)", short_title: "Feast of Azamat", title_html: "Nineteen Day Feast of the month of ‘Aẓamat (Grandeur)", short_title_html: "Feast of ‘Aẓamat"}, + feast_5: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Nur (Light)", short_title: "Feast of Nur", title_html: "Nineteen Day Feast of the month of Núr (Light)", short_title_html: "Feast of Núr"}, + feast_6: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Rahmat (Mercy)", short_title: "Feast of Rahmat", title_html: "Nineteen Day Feast of the month of Raḥmat (Mercy)", short_title_html: "Feast of Raḥmat"}, + feast_7: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Kalimat (Words)", short_title: "Feast of Kalimat", title_html: "Nineteen Day Feast of the month of Kalimát (Words)", short_title_html: "Feast of Kalimát"}, + feast_8: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Kamal (Perfection)", short_title: "Feast of Kamal", title_html: "Nineteen Day Feast of the month of Kamál (Perfection)", short_title_html: "Feast of Kamál"}, + feast_9: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Asma (Names)", short_title: "Feast of Asma", title_html: "Nineteen Day Feast of the month of Asmá’ (Names)", short_title_html: "Feast of Asmá’"}, + feast_10: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Izzat (Might)", short_title: "Feast of Izzat", title_html: "Nineteen Day Feast of the month of ‘Izzat (Might)", short_title_html: "Feast of ‘Izzat"}, + feast_11: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Mashiyyat (Will)", short_title: "Feast of Mashiyyat", title_html: "Nineteen Day Feast of the month of Mashíyyat (Will)", short_title_html: "Feast of Mashíyyat"}, + feast_12: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Ilm (Knowledge)", short_title: "Feast of Ilm", title_html: "Nineteen Day Feast of the month of ‘Ilm (Knowledge)", short_title_html: "Feast of ‘Ilm"}, + feast_13: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Qudrat (Power)", short_title: "Feast of Qudrat", title_html: "Nineteen Day Feast of the month of Qudrat (Power)", short_title_html: "Feast of Qudrat"}, + feast_14: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Qawl (Speech)", short_title: "Feast of Qawl", title_html: "Nineteen Day Feast of the month of Qawl (Speech)", short_title_html: "Feast of Qawl"}, + feast_15: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Masail (Questions)", short_title: "Feast of Masail", title_html: "Nineteen Day Feast of the month of Masá’il (Questions)", short_title_html: "Feast of Masá’il"}, + feast_16: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Sharaf (Honour)", short_title: "Feast of Sharaf", title_html: "Nineteen Day Feast of the month of Sharaf (Honour)", short_title_html: "Feast of Sharaf"}, + feast_17: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Sultan (Sovereignty)", short_title: "Feast of Sultan", title_html: "Nineteen Day Feast of the month of Sulṭán (Sovereignty)", short_title_html: "Feast of Sulṭán"}, + feast_18: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Mulk (Dominion)", short_title: "Feast of Mulk", title_html: "Nineteen Day Feast of the month of Mulk (Dominion)", short_title_html: "Feast of Mulk"}, + feast_19: {type: :feast, work_suspended: false, title: "Nineteen Day Feast of the month of Ala (Loftiness)", short_title: "Feast of Ala", title_html: "Nineteen Day Feast of the month of ‘Alá’ (Loftiness)", short_title_html: "Feast of ‘Alá’"}, + ridvan_1: {type: :holy, work_suspended: true, title: "First day of the Festival of Ridvan", short_title: "1st day of Ridvan", title_html: "First day of the Festival of Riḍván", short_title_html: "1st day of Riḍván"}, + ridvan_2: {type: :ridvan, work_suspended: false, title: "Second day of the Festival of Ridvan", short_title: "2nd day of Ridvan", title_html: "Second day of the Festival of Riḍván", short_title_html: "2nd day of Riḍván"}, + ridvan_3: {type: :ridvan, work_suspended: false, title: "Third day of the Festival of Ridvan", short_title: "3rd day of Ridvan", title_html: "Third day of the Festival of Riḍván", short_title_html: "3rd day of Riḍván"}, + ridvan_4: {type: :ridvan, work_suspended: false, title: "Fourth day of the Festival of Ridvan", short_title: "4th day of Ridvan", title_html: "Fourth day of the Festival of Riḍván", short_title_html: "4th day of Riḍván"}, + ridvan_5: {type: :ridvan, work_suspended: false, title: "Fifth day of the Festival of Ridvan", short_title: "5th day of Ridvan", title_html: "Fifth day of the Festival of Riḍván", short_title_html: "5th day of Riḍván"}, + ridvan_6: {type: :ridvan, work_suspended: false, title: "Sixth day of the Festival of Ridvan", short_title: "6th day of Ridvan", title_html: "Sixth day of the Festival of Riḍván", short_title_html: "6th day of Riḍván"}, + ridvan_7: {type: :ridvan, work_suspended: false, title: "Seventh day of the Festival of Ridvan", short_title: "7th day of Ridvan", title_html: "Seventh day of the Festival of Riḍván", short_title_html: "7th day of Riḍván"}, + ridvan_8: {type: :ridvan, work_suspended: false, title: "Eighth day of the Festival of Ridvan", short_title: "8th day of Ridvan", title_html: "Eighth day of the Festival of Riḍván", short_title_html: "8th day of Riḍván"}, + ridvan_9: {type: :holy, work_suspended: true, title: "Ninth day of the Festival of Ridvan", short_title: "9th day of Ridvan", title_html: "Ninth day of the Festival of Riḍván", short_title_html: "9th day of Riḍván"}, + ridvan_10: {type: :ridvan, work_suspended: false, title: "Tenth day of the Festival of Ridvan", short_title: "10th day of Ridvan", title_html: "Tenth day of the Festival of Riḍván", short_title_html: "10th day of Riḍván"}, + ridvan_11: {type: :ridvan, work_suspended: false, title: "Eleventh day of the Festival of Ridvan", short_title: "11th day of Ridvan", title_html: "Eleventh day of the Festival of Riḍván", short_title_html: "11th day of Riḍván"}, + ridvan_12: {type: :holy, work_suspended: true, title: "Twelfth day of the Festival of Ridvan", short_title: "12th day of Ridvan", title_html: "Twelfth day of the Festival of Riḍván", short_title_html: "12th day of Riḍván"}, + nawruz: {type: :holy, work_suspended: true, title: "Naw-Ruz (New Year)", short_title: "Naw-Ruz", title_html: "Naw-Rúz (New Year)", short_title_html: "Naw-Rúz"}, + declaration_bab: {type: :holy, work_suspended: true, title: "Declaration of the Bab", short_title: "Declaration of the Bab", title_html: "Declaration of the Báb", short_title_html: "Declaration of the Báb"}, + ascension_bahaullah: {type: :holy, work_suspended: true, title: "Ascension of Baha'u'llah", short_title: "Ascension of Baha'u'llah", title_html: "Ascension of Bahá’u’lláh", short_title_html: "Ascension of Bahá’u’lláh"}, + martyrdom_bab: {type: :holy, work_suspended: true, title: "Martyrdom of the Bab", short_title: "Martyrdom of the Bab", title_html: "Martyrdom of the Báb", short_title_html: "Martyrdom of the Báb"}, + birth_bab: {type: :holy, work_suspended: true, title: "Anniversary of the Birth of the Bab", short_title: "Birth of the Bab", title_html: "Anniversary of the Birth of the Báb", short_title_html: "Birth of the Báb"}, + birth_bahaullah: {type: :holy, work_suspended: true, title: "Anniversary of the Birth of Baha'u'llah", short_title: "Birth of Baha'u'llah", title_html: "Anniversary of the Birth of Bahá’u’lláh", short_title_html: "Birth of Bahá’u’lláh"}, + covenant: {type: :holy, work_suspended: false, title: "Day of the Covenant", short_title: "Day of the Covenant", title_html: "Day of the Covenant", short_title_html: "Day of the Covenant"}, + ascension_abdulbaha: {type: :holy, work_suspended: false, title: "Ascension of Abdu'l-Baha", short_title: "Ascension of Abdu'l-Baha", title_html: "Ascension of ‘Abdu’l-Bahá", short_title_html: "Ascension of ‘Abdu’l-Bahá"} } DATES = { - '1.1' => [:nawruz, :feast_1], - '2.1' => [:feast_2], - '2.13' => [:ridvan_1], - '2.14' => [:ridvan_2], - '2.15' => [:ridvan_3], - '2.16' => [:ridvan_4], - '2.17' => [:ridvan_5], - '2.18' => [:ridvan_6], - '2.19' => [:ridvan_7], - '3.1' => [:feast_3, :ridvan_8], - '3.2' => [:ridvan_9], - '3.3' => [:ridvan_10], - '3.4' => [:ridvan_11], - '3.5' => [:ridvan_12], - '4.1' => [:feast_4], - '4.13' => [:ascension_bahaullah], - '5.1' => [:feast_5], - '6.1' => [:feast_6], - '7.1' => [:feast_7], - '8.1' => [:feast_8], - '9.1' => [:feast_9], - '10.1' => [:feast_10], - '11.1' => [:feast_11], - '12.1' => [:feast_12], - '13.1' => [:feast_13], - '14.1' => [:feast_14], - '14.4' => [:covenant], - '14.6' => [:ascension_abdulbaha], - '15.1' => [:feast_15], - '16.1' => [:feast_16], - '17.1' => [:feast_17], - '18.1' => [:feast_18], - '-1.1' => [:ayyam_i_ha_1], - '-1.2' => [:ayyam_i_ha_2], - '-1.3' => [:ayyam_i_ha_3], - '-1.4' => [:ayyam_i_ha_4], - '-1.5' => [:ayyam_i_ha_5], - '19.1' => [:feast_19, :fasting_1], - '19.2' => [:fasting_2], - '19.3' => [:fasting_3], - '19.4' => [:fasting_4], - '19.5' => [:fasting_5], - '19.6' => [:fasting_6], - '19.7' => [:fasting_7], - '19.8' => [:fasting_8], - '19.9' => [:fasting_9], - '19.10' => [:fasting_10], - '19.11' => [:fasting_11], - '19.12' => [:fasting_12], - '19.13' => [:fasting_13], - '19.14' => [:fasting_14], - '19.15' => [:fasting_15], - '19.16' => [:fasting_16], - '19.17' => [:fasting_17], - '19.18' => [:fasting_18], - '19.19' => [:fasting_19] + "1.1" => [:nawruz, :feast_1], + "2.1" => [:feast_2], + "2.13" => [:ridvan_1], + "2.14" => [:ridvan_2], + "2.15" => [:ridvan_3], + "2.16" => [:ridvan_4], + "2.17" => [:ridvan_5], + "2.18" => [:ridvan_6], + "2.19" => [:ridvan_7], + "3.1" => [:feast_3, :ridvan_8], + "3.2" => [:ridvan_9], + "3.3" => [:ridvan_10], + "3.4" => [:ridvan_11], + "3.5" => [:ridvan_12], + "4.1" => [:feast_4], + "4.13" => [:ascension_bahaullah], + "5.1" => [:feast_5], + "6.1" => [:feast_6], + "7.1" => [:feast_7], + "8.1" => [:feast_8], + "9.1" => [:feast_9], + "10.1" => [:feast_10], + "11.1" => [:feast_11], + "12.1" => [:feast_12], + "13.1" => [:feast_13], + "14.1" => [:feast_14], + "14.4" => [:covenant], + "14.6" => [:ascension_abdulbaha], + "15.1" => [:feast_15], + "16.1" => [:feast_16], + "17.1" => [:feast_17], + "18.1" => [:feast_18], + "-1.1" => [:ayyam_i_ha_1], + "-1.2" => [:ayyam_i_ha_2], + "-1.3" => [:ayyam_i_ha_3], + "-1.4" => [:ayyam_i_ha_4], + "-1.5" => [:ayyam_i_ha_5], + "19.1" => [:feast_19, :fasting_1], + "19.2" => [:fasting_2], + "19.3" => [:fasting_3], + "19.4" => [:fasting_4], + "19.5" => [:fasting_5], + "19.6" => [:fasting_6], + "19.7" => [:fasting_7], + "19.8" => [:fasting_8], + "19.9" => [:fasting_9], + "19.10" => [:fasting_10], + "19.11" => [:fasting_11], + "19.12" => [:fasting_12], + "19.13" => [:fasting_13], + "19.14" => [:fasting_14], + "19.15" => [:fasting_15], + "19.16" => [:fasting_16], + "19.17" => [:fasting_17], + "19.18" => [:fasting_18], + "19.19" => [:fasting_19] } DATES_BEFORE_172 = { - '4.7' => [:declaration_bab], - '6.16' => [:martyrdom_bab], - '12.5' => [:birth_bab], - '13.9' => [:birth_bahaullah] + "4.7" => [:declaration_bab], + "6.16" => [:martyrdom_bab], + "12.5" => [:birth_bab], + "13.9" => [:birth_bahaullah] } DATES_AFTER_172 = { - '4.8' => [:declaration_bab], - '6.17' => [:martyrdom_bab] + "4.8" => [:declaration_bab], + "6.17" => [:martyrdom_bab] } def initialize(year, month, day) @@ -160,15 +160,25 @@ def self.fasting_range(year) first.gregorian_date..(last.gregorian_date) end + def self.find(occasion, year) - if year < 172 - all_dates = DATES.merge(DATES_BEFORE_172) + all_dates = if year < 172 + DATES.merge(DATES_BEFORE_172) else - all_dates = DATES.merge(DATES_AFTER_172).merge(dates_lunar(year)) + DATES.merge(DATES_AFTER_172).merge(dates_lunar(year)) end all_dates.find { |_key, array| array.include? occasion }.first end + def self.dates_lunar(year) + twin = Logic.twin_holy_days_date year + birth_bab = BahaiDate.new(date: twin) + birth_bab_string = "#{birth_bab.month.number}.#{birth_bab.day.number}" + birth_bahaullah = BahaiDate.new(date: twin + 1) + birth_bahaullah_string = "#{birth_bahaullah.month.number}.#{birth_bahaullah.day.number}" + {birth_bab_string => [:birth_bab], birth_bahaullah_string => [:birth_bahaullah]} + end + private def create_occasions_classes_from(hashes_array) @@ -177,7 +187,7 @@ def create_occasions_classes_from(hashes_array) def occasions_hashes hashes_array = [] - each_ids do | ids | + each_ids do |ids| next unless ids hashes_array += OCCASIONS.values_at(*ids) end @@ -191,17 +201,8 @@ def each_ids yield DATES_BEFORE_172[key] else yield DATES_AFTER_172[key] - yield (self.class.dates_lunar(@year))[key] + yield self.class.dates_lunar(@year)[key] end end - - def self.dates_lunar(year) - twin = Logic.twin_holy_days_date year - birth_bab = BahaiDate.new(date: twin) - birth_bab_string = "#{birth_bab.month.number}.#{birth_bab.day.number}" - birth_bahaullah = BahaiDate.new(date: twin + 1) - birth_bahaullah_string = "#{birth_bahaullah.month.number}.#{birth_bahaullah.day.number}" - { birth_bab_string => [:birth_bab], birth_bahaullah_string => [:birth_bahaullah] } - end end end diff --git a/lib/bahai_date/version.rb b/lib/bahai_date/version.rb index 362cb21..572439d 100644 --- a/lib/bahai_date/version.rb +++ b/lib/bahai_date/version.rb @@ -1,3 +1,3 @@ module BahaiDate - VERSION = '1.4.0' + VERSION = "1.4.0" end diff --git a/lib/bahai_date/weekday.rb b/lib/bahai_date/weekday.rb index 59a8d28..f4f5018 100644 --- a/lib/bahai_date/weekday.rb +++ b/lib/bahai_date/weekday.rb @@ -1,9 +1,9 @@ module BahaiDate class Weekday - TITLES = %w(Jalal Jamal Kamal Fidal Idal Istijlal Istiqlal) - TITLES_HTML = %w(Jalál Jamál Kamál Fiḍál ‘Idál Istijlál Istiqlál) - TITLES_EN = %w(Glory Beauty Perfection Grace Justice Majesty Independence) - ENGLISH_EQUIVALENTS = %w(Saturday Sunday Monday Tuesday Wednesday Thursday Friday) + TITLES = %w[Jalal Jamal Kamal Fidal Idal Istijlal Istiqlal] + TITLES_HTML = %w[Jalál Jamál Kamál Fiḍál ‘Idál Istijlál Istiqlál] + TITLES_EN = %w[Glory Beauty Perfection Grace Justice Majesty Independence] + ENGLISH_EQUIVALENTS = %w[Saturday Sunday Monday Tuesday Wednesday Thursday Friday] attr_reader :number @@ -40,7 +40,7 @@ def title_index def validate(number_arg) number = number_arg.to_i - return if (1..7).include? number + return if (1..7).cover? number fail ArgumentError, "'#{number}' is not a valid weekday. Please use 1 to 7." end diff --git a/lib/bahai_date/year.rb b/lib/bahai_date/year.rb index 7d4e266..75a9f13 100644 --- a/lib/bahai_date/year.rb +++ b/lib/bahai_date/year.rb @@ -1,8 +1,8 @@ module BahaiDate class Year - TITLES = %w(Alif Ba Ab Dal Bab Vav Abad Jad Baha Hubb Bahhaj Javab Ahad Vahhab Vidad Badi Bahi Abha Vahid) - TITLES_HTML = %w(Alif Bá’ Ab Dál Báb Váv Abad Jád Bahá Ḥubb Bahháj Javáb Aḥad Vahháb Vidád Badí‘ Bahí Abhá Váḥid) - TITLES_EN = %w(A B Father D Gate V Eternity Generosity Splendour Love Delightful Answer Single Bountiful Affection Beginning Luminous Most Luminous Unity) + TITLES = %w[Alif Ba Ab Dal Bab Vav Abad Jad Baha Hubb Bahhaj Javab Ahad Vahhab Vidad Badi Bahi Abha Vahid] + TITLES_HTML = %w[Alif Bá’ Ab Dál Báb Váv Abad Jád Bahá Ḥubb Bahháj Javáb Aḥad Vahháb Vidád Badí‘ Bahí Abhá Váḥid] + TITLES_EN = %w[A B Father D Gate V Eternity Generosity Splendour Love Delightful Answer Single Bountiful Affection Beginning Luminous Most Luminous Unity] attr_reader :bahai_era, :number, :vahid, :kull_i_shay, :months diff --git a/spec/bahai_date/bahai_date_spec.rb b/spec/bahai_date/bahai_date_spec.rb index 8459f2f..19f67e9 100644 --- a/spec/bahai_date/bahai_date_spec.rb +++ b/spec/bahai_date/bahai_date_spec.rb @@ -1,63 +1,63 @@ module BahaiDate describe BahaiDate do - it 'can be created from a year, month and day' do + it "can be created from a year, month and day" do bahai_date = BahaiDate.new(year: 1, month: 1, day: 1) expect(bahai_date).to_not be_nil end - it 'can be created from a gregorian Date object' do + it "can be created from a gregorian Date object" do bahai_date = BahaiDate.new(date: Date.new(2010, 1, 1)) expect(bahai_date).to_not be_nil end - it 'raises an error if invalid arguments are passed to the initializer' do + it "raises an error if invalid arguments are passed to the initializer" do expect { BahaiDate.new }.to raise_error(ArgumentError) expect { BahaiDate.new({}) }.to raise_error(ArgumentError) expect { BahaiDate.new(day: 1) }.to raise_error(ArgumentError) end context "when validating the Baha'i Era date" do - context 'year' do - it 'raises an error if less than 1' do + context "year" do + it "raises an error if less than 1" do expect do BahaiDate.new(year: 0, month: 1, day: 1) end.to raise_error(ArgumentError) end end - context 'month' do - it 'raises an error if 0' do + context "month" do + it "raises an error if 0" do expect do BahaiDate.new(year: 1, month: 0, day: 1) end.to raise_error(ArgumentError) end - it 'raises an error if less than -1' do + it "raises an error if less than -1" do expect do BahaiDate.new(year: 1, month: -2, day: 1) end.to raise_error(ArgumentError) end - it 'raises an error if greater than 19' do + it "raises an error if greater than 19" do expect do BahaiDate.new(year: 1, month: 20, day: 1) end.to raise_error(ArgumentError) end end - context 'day' do - it 'raises an error if less than 1' do + context "day" do + it "raises an error if less than 1" do expect do BahaiDate.new(year: 1, month: 1, day: 0) end.to raise_error(ArgumentError) end - it 'raises an error if greater than 19' do + it "raises an error if greater than 19" do expect do BahaiDate.new(year: 1, month: 1, day: 20) end.to raise_error(ArgumentError) end - context 'in Ayyam-i-Ha' do - it 'raises an error if greater than 4 on a non-leap year' do + context "in Ayyam-i-Ha" do + it "raises an error if greater than 4 on a non-leap year" do expect do BahaiDate.new(year: 1, month: -1, day: 5) end.to raise_error(ArgumentError) @@ -67,7 +67,7 @@ module BahaiDate BahaiDate.new(year: 4, month: -1, day: 5) end.not_to raise_error end - it 'raises an error if greater than 5 on a leap year' do + it "raises an error if greater than 5 on a leap year" do expect do BahaiDate.new(year: 4, month: -1, day: 6) end.to raise_error(ArgumentError) @@ -76,7 +76,7 @@ module BahaiDate end end - it 'exposes weekday, day, month, year and gregorian_date' do + it "exposes weekday, day, month, year and gregorian_date" do bahai_date = BahaiDate.new(year: 1, month: 1, day: 1) expect(bahai_date.weekday).to be_an_instance_of(Weekday) @@ -86,97 +86,97 @@ module BahaiDate expect(bahai_date.gregorian_date).to be_an_instance_of(Date) end - context 'when converting to a gregorian date' do - it 'handles the first day of the calendar' do + context "when converting to a gregorian date" do + it "handles the first day of the calendar" do bahai_date = BahaiDate.new(year: 1, month: 1, day: 1) expect(bahai_date.gregorian_date).to eq(Date.new(1844, 3, 21)) end - it 'handles the last day of the year' do + it "handles the last day of the year" do bahai_date = BahaiDate.new(year: 1, month: 19, day: 19) expect(bahai_date.gregorian_date).to eq(Date.new(1845, 3, 20)) end - it 'handles the year component' do + it "handles the year component" do bahai_date = BahaiDate.new(year: 2, month: 1, day: 1) expect(bahai_date.gregorian_date).to eq(Date.new(1845, 3, 21)) end - context 'in a leap year' do - it 'handles the day before Ayyam-i-Ha' do + context "in a leap year" do + it "handles the day before Ayyam-i-Ha" do bahai_date = BahaiDate.new(year: 168, month: 18, day: 19) expect(bahai_date.gregorian_date).to eq(Date.new(2012, 2, 25)) end - it 'handles the first day of Ayyam-i-Ha' do + it "handles the first day of Ayyam-i-Ha" do bahai_date = BahaiDate.new(year: 168, month: -1, day: 1) expect(bahai_date.gregorian_date).to eq(Date.new(2012, 2, 26)) end - it 'handles the last day of Ayyam-i-Ha' do + it "handles the last day of Ayyam-i-Ha" do bahai_date = BahaiDate.new(year: 168, month: -1, day: 5) expect(bahai_date.gregorian_date).to eq(Date.new(2012, 3, 1)) end - it 'handles the first day of the month after Ayyam-i-Ha' do + it "handles the first day of the month after Ayyam-i-Ha" do bahai_date = BahaiDate.new(year: 168, month: 19, day: 1) expect(bahai_date.gregorian_date).to eq(Date.new(2012, 3, 2)) end end - context 'in a non-leap year' do - it 'handles the last day of Ayyam-i-Ha' do + context "in a non-leap year" do + it "handles the last day of Ayyam-i-Ha" do bahai_date = BahaiDate.new(year: 169, month: -1, day: 4) expect(bahai_date.gregorian_date).to eq(Date.new(2013, 3, 1)) end end end - context 'when converting from gregorian date' do - it 'handles the first day of the calendar' do + context "when converting from gregorian date" do + it "handles the first day of the calendar" do bahai_date = BahaiDate.new(date: Date.new(1844, 3, 21)) expect(bahai_date.year.bahai_era).to be 1 expect(bahai_date.month.number).to be 1 expect(bahai_date.day.number).to be 1 end - it 'handles the last day of the year' do + it "handles the last day of the year" do bahai_date = BahaiDate.new(date: Date.new(1845, 3, 20)) expect(bahai_date.year.bahai_era).to be 1 expect(bahai_date.month.number).to be 19 expect(bahai_date.day.number).to be 19 end - it 'handles the year component' do + it "handles the year component" do bahai_date = BahaiDate.new(date: Date.new(1845, 3, 21)) expect(bahai_date.year.bahai_era).to be 2 expect(bahai_date.month.number).to be 1 expect(bahai_date.day.number).to be 1 end - context 'in a leap year' do - it 'handles the day before Ayyam-i-Ha' do + context "in a leap year" do + it "handles the day before Ayyam-i-Ha" do bahai_date = BahaiDate.new(date: Date.new(2012, 2, 25)) expect(bahai_date.year.bahai_era).to be 168 expect(bahai_date.month.number).to be 18 expect(bahai_date.day.number).to be 19 end - it 'handles the first day of Ayyam-i-Ha' do + it "handles the first day of Ayyam-i-Ha" do bahai_date = BahaiDate.new(date: Date.new(2012, 2, 26)) expect(bahai_date.year.bahai_era).to be 168 expect(bahai_date.month.number).to be(-1) expect(bahai_date.day.number).to be 1 end - it 'handles the last day of Ayyam-i-Ha' do + it "handles the last day of Ayyam-i-Ha" do bahai_date = BahaiDate.new(date: Date.new(2012, 3, 1)) expect(bahai_date.year.bahai_era).to be 168 expect(bahai_date.month.number).to be(-1) expect(bahai_date.day.number).to be 5 end - it 'handles the first day of the month after Ayyam-i-Ha' do + it "handles the first day of the month after Ayyam-i-Ha" do bahai_date = BahaiDate.new(date: Date.new(2012, 3, 2)) expect(bahai_date.year.bahai_era).to be 168 expect(bahai_date.month.number).to be 19 @@ -184,8 +184,8 @@ module BahaiDate end end - context 'in a non-leap year' do - it 'handles the last day of Ayyam-i-Ha' do + context "in a non-leap year" do + it "handles the last day of Ayyam-i-Ha" do bahai_date = BahaiDate.new(date: Date.new(2013, 3, 1)) expect(bahai_date.year.bahai_era).to be 169 expect(bahai_date.month.number).to be(-1) @@ -194,7 +194,7 @@ module BahaiDate end end - it 'can get weekday from a gregorian date accurately' do + it "can get weekday from a gregorian date accurately" do bahai_date = BahaiDate.new(date: Date.new(1844, 3, 21)) expect(bahai_date.weekday.number).to be 6 @@ -220,36 +220,36 @@ module BahaiDate expect(bahai_date.weekday.number).to be 6 end - it 'can be converted to string' do + it "can be converted to string" do bahai_date = BahaiDate.new(date: Date.new(1844, 3, 21)) - expect(bahai_date.to_s).to eq '1.1.1' + expect(bahai_date.to_s).to eq "1.1.1" end - it 'can provide the date in long format' do + it "can provide the date in long format" do bahai_date = BahaiDate.new(date: Date.new(1844, 3, 21)) - expect(bahai_date.long_format).to eq 'Istijlal 1 Baha 1 B.E.' + expect(bahai_date.long_format).to eq "Istijlal 1 Baha 1 B.E." end - it 'can provide the date in short format' do + it "can provide the date in short format" do bahai_date = BahaiDate.new(date: Date.new(1844, 3, 21)) - expect(bahai_date.short_format).to eq '1 Baha 1' + expect(bahai_date.short_format).to eq "1 Baha 1" end - it 'can provide an array of occasions for a given day' do + it "can provide an array of occasions for a given day" do bahai_date = BahaiDate.new(date: Date.new(1844, 3, 21)) occasions_array = bahai_date.occasions expect(occasions_array.size).to be 2 - expect(occasions_array.first.short_title).to eq 'Naw-Ruz' - expect(occasions_array.last.short_title).to eq 'Feast of Baha' + expect(occasions_array.first.short_title).to eq "Naw-Ruz" + expect(occasions_array.last.short_title).to eq "Feast of Baha" end - it 'can add to date, returning itself' do + it "can add to date, returning itself" do bahai_date = BahaiDate.new(date: Date.new(1844, 3, 21)) bahai_date += 1 expect(bahai_date.gregorian_date).to eq Date.new(1844, 3, 22) end - it 'can subtract from the date, returning itself' do + it "can subtract from the date, returning itself" do bahai_date = BahaiDate.new(date: Date.new(1844, 3, 22)) bahai_date -= 1 expect(bahai_date.gregorian_date).to eq Date.new(1844, 3, 21) diff --git a/spec/bahai_date/day_spec.rb b/spec/bahai_date/day_spec.rb index 3c06955..5ff6cb4 100644 --- a/spec/bahai_date/day_spec.rb +++ b/spec/bahai_date/day_spec.rb @@ -1,56 +1,59 @@ module BahaiDate describe Day do - it 'can be created given a number from 1 to 19' do + it "can be created given a number from 1 to 19" do expect(Day.new(1)).to_not be_nil expect(Day.new(19)).to_not be_nil end it "can't be created with a number other than 1 to 19" do expect { Day.new(0) }.to raise_error( - ArgumentError, "'0' is not a valid day. Please use 1 to 19.") + ArgumentError, "'0' is not a valid day. Please use 1 to 19." + ) expect { Day.new(20) }.to raise_error( - ArgumentError, "'20' is not a valid day. Please use 1 to 19.") + ArgumentError, "'20' is not a valid day. Please use 1 to 19." + ) - expect { Day.new('hello') }.to raise_error( - ArgumentError, "'0' is not a valid day. Please use 1 to 19.") + expect { Day.new("hello") }.to raise_error( + ArgumentError, "'0' is not a valid day. Please use 1 to 19." + ) end subject(:day) { Day.new(1) } - it 'can be converted to string' do - expect(day.to_s).to eq 'Baha' + it "can be converted to string" do + expect(day.to_s).to eq "Baha" end - it 'provides access to the day number' do + it "provides access to the day number" do expect(day.number).to be 1 end - it 'provides access to the translated title' do - expect(day.translation).to eq 'Splendour' + it "provides access to the translated title" do + expect(day.translation).to eq "Splendour" end - it 'provides access to the title in HTML' do - expect(day.html).to eq 'Bahá' + it "provides access to the title in HTML" do + expect(day.html).to eq "Bahá" end - context 'working with the weekday' do - it 'is initially nil' do + context "working with the weekday" do + it "is initially nil" do expect(day.weekday).to be_nil end - it 'can be set' do + it "can be set" do weekday = day.weekday = Weekday.new(1) expect(day.weekday).to be weekday end end - context 'working with the occasions' do - it 'is initially nil' do + context "working with the occasions" do + it "is initially nil" do expect(day.occasions).to be_nil end - it 'can be set' do + it "can be set" do occasions = day.occasions = OccasionFactory.new(1, 1, 1).occasions expect(day.occasions).to be occasions end diff --git a/spec/bahai_date/logic_spec.rb b/spec/bahai_date/logic_spec.rb index 123f1ff..58e0b26 100644 --- a/spec/bahai_date/logic_spec.rb +++ b/spec/bahai_date/logic_spec.rb @@ -1,10 +1,10 @@ module BahaiDate describe Logic do - it 'supplies a Date object for Naw Ruz of a given year' do + it "supplies a Date object for Naw Ruz of a given year" do expect(Logic.nawruz_for(1844)).to eq(Date.new(1844, 3, 21)) end - it 'determines whether a year is leap or not' do + it "determines whether a year is leap or not" do expect(Logic.leap?(1)).to eq(false) expect(Logic.leap?(4)).to eq(true) expect(Logic.leap?(168)).to eq(true) diff --git a/spec/bahai_date/month_spec.rb b/spec/bahai_date/month_spec.rb index 785c591..021cfcd 100644 --- a/spec/bahai_date/month_spec.rb +++ b/spec/bahai_date/month_spec.rb @@ -1,6 +1,6 @@ module BahaiDate describe Month do - it 'can be created given a number from 1 to 19 or -1' do + it "can be created given a number from 1 to 19 or -1" do expect(Month.new(1)).to_not be_nil expect(Month.new(19)).to_not be_nil expect(Month.new(-1)).to_not be_nil @@ -8,51 +8,55 @@ module BahaiDate it "can't be created with a number other than 1 to 19 or -1" do expect { Month.new(0) }.to raise_error( - ArgumentError, "'0' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha.") + ArgumentError, "'0' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha." + ) expect { Month.new(-2) }.to raise_error( - ArgumentError, "'-2' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha.") + ArgumentError, "'-2' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha." + ) expect { Month.new(20) }.to raise_error( - ArgumentError, "'20' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha.") + ArgumentError, "'20' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha." + ) - expect { Month.new('hello') }.to raise_error( - ArgumentError, "'0' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha.") + expect { Month.new("hello") }.to raise_error( + ArgumentError, "'0' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha." + ) end - context 'when created using -1' do - it 'has a title of Ayyam-i-Ha' do + context "when created using -1" do + it "has a title of Ayyam-i-Ha" do month = Month.new(-1) - expect(month.to_s).to eq 'Ayyam-i-Ha' + expect(month.to_s).to eq "Ayyam-i-Ha" end end subject(:month) { Month.new(1) } - it 'can be converted to string' do - expect(month.to_s).to eq 'Baha' + it "can be converted to string" do + expect(month.to_s).to eq "Baha" end - it 'provides access to the month number' do + it "provides access to the month number" do expect(month.number).to be 1 end - it 'provides access to the translated title' do - expect(month.translation).to eq 'Splendour' + it "provides access to the translated title" do + expect(month.translation).to eq "Splendour" end - it 'provides access to the title in HTML' do - expect(month.html).to eq 'Bahá' + it "provides access to the title in HTML" do + expect(month.html).to eq "Bahá" end - context 'working with a hash of days' do - it 'is readable' do + context "working with a hash of days" do + it "is readable" do month = Month.new(1) expect(month.days).to eq({}) end - it 'can be added to' do + it "can be added to" do month = Month.new(1) month.add_day(1) expect(month.days[1].number).to be 1 diff --git a/spec/bahai_date/occasion_factory_spec.rb b/spec/bahai_date/occasion_factory_spec.rb index 73c41c8..7e995a0 100644 --- a/spec/bahai_date/occasion_factory_spec.rb +++ b/spec/bahai_date/occasion_factory_spec.rb @@ -1,59 +1,59 @@ module BahaiDate describe OccasionFactory do - it 'can be created given a year, month, and day' do + it "can be created given a year, month, and day" do occasion_factory = OccasionFactory.new(1, 1, 1) expect(occasion_factory).not_to be_nil end - it 'provides a valid occasion for feast days' do + it "provides a valid occasion for feast days" do occasions = OccasionFactory.new(1, 2, 1).occasions expect(occasions.first.type).to eq :feast end - it 'provides a valid occasion for days of fasting' do + it "provides a valid occasion for days of fasting" do occasions = OccasionFactory.new(1, 19, 2).occasions expect(occasions.first.type).to eq :fasting end - it 'provides a valid occasion for days during ayyam-i-ha' do + it "provides a valid occasion for days during ayyam-i-ha" do occasions = OccasionFactory.new(1, -1, 1).occasions expect(occasions.first.type).to eq :ayyam_i_ha end - it 'provides a valid occasion for days during the festival of ridvan' do + it "provides a valid occasion for days during the festival of ridvan" do occasions = OccasionFactory.new(1, 2, 14).occasions expect(occasions.first.type).to eq :ridvan end - it 'provides a valid occasion for holy days' do + it "provides a valid occasion for holy days" do occasions = OccasionFactory.new(1, 1, 1).occasions expect(occasions.first.type).to eq :holy end - it 'provides valid occasions when more than one occurs on the same day' do + it "provides valid occasions when more than one occurs on the same day" do occasions = OccasionFactory.new(1, 1, 1).occasions expect(occasions.size).to be 2 expect(occasions.first.type).to eq :holy expect(occasions.last.type).to eq :feast end - context 'for dates before 172 B.E.' do - it 'provides the Declaration of the Bab on the correct day' do + context "for dates before 172 B.E." do + it "provides the Declaration of the Bab on the correct day" do occasions = OccasionFactory.new(1, 4, 7).occasions - expect(occasions.first.short_title).to eq 'Declaration of the Bab' + expect(occasions.first.short_title).to eq "Declaration of the Bab" occasions = OccasionFactory.new(1, 4, 8).occasions expect(occasions.size).to be 0 end - it 'provides the Martyrdom of the Bab on the correct day' do + it "provides the Martyrdom of the Bab on the correct day" do occasions = OccasionFactory.new(1, 6, 16).occasions - expect(occasions.first.short_title).to eq 'Martyrdom of the Bab' + expect(occasions.first.short_title).to eq "Martyrdom of the Bab" end - it 'provides the Birth of the Bab on the correct day' do + it "provides the Birth of the Bab on the correct day" do occasions = OccasionFactory.new(1, 12, 5).occasions - expect(occasions.first.short_title).to eq 'Birth of the Bab' + expect(occasions.first.short_title).to eq "Birth of the Bab" end it "provides the Birth of Baha'u'llah on the correct day" do @@ -61,9 +61,9 @@ module BahaiDate expect(occasions.first.short_title).to eq "Birth of Baha'u'llah" end - it 'can find the month and day for a given occasion on a given year' do + it "can find the month and day for a given occasion on a given year" do month_and_day = OccasionFactory.find(:birth_bab, 163) - expect(month_and_day).to eq '12.5' + expect(month_and_day).to eq "12.5" end end @@ -97,28 +97,28 @@ module BahaiDate end end - context 'for dates after 172 B.E.' do - it 'provides the Declaration of the Bab on the correct day' do + context "for dates after 172 B.E." do + it "provides the Declaration of the Bab on the correct day" do occasions = OccasionFactory.new(172, 4, 7).occasions expect(occasions.size).to be 0 occasions = OccasionFactory.new(172, 4, 8).occasions - expect(occasions.first.short_title).to eq 'Declaration of the Bab' + expect(occasions.first.short_title).to eq "Declaration of the Bab" end - it 'provides the Martyrdom of the Bab on the correct day' do + it "provides the Martyrdom of the Bab on the correct day" do occasions = OccasionFactory.new(172, 6, 17).occasions - expect(occasions.first.short_title).to eq 'Martyrdom of the Bab' + expect(occasions.first.short_title).to eq "Martyrdom of the Bab" end - it 'provides the Birth of the Bab on the correct day' do + it "provides the Birth of the Bab on the correct day" do occasions = OccasionFactory.new(172, 13, 10).occasions - expect(occasions.first.short_title).to eq 'Birth of the Bab' + expect(occasions.first.short_title).to eq "Birth of the Bab" end - it 'can find the month and day for a given occasion on a given year' do + it "can find the month and day for a given occasion on a given year" do month_and_day = OccasionFactory.find(:birth_bab, 173) - expect(month_and_day).to eq '12.18' + expect(month_and_day).to eq "12.18" end end end diff --git a/spec/bahai_date/occasion_spec.rb b/spec/bahai_date/occasion_spec.rb index fcdea85..fc6d83a 100644 --- a/spec/bahai_date/occasion_spec.rb +++ b/spec/bahai_date/occasion_spec.rb @@ -2,18 +2,18 @@ module BahaiDate describe Occasion do subject(:occasion) do Occasion.new(type: :ayyam_i_ha, - work_suspended: false, - title: 'Test title', - short_title: 'Test short title', - title_html: 'Test title html', - short_title_html: 'Test short title html ') + work_suspended: false, + title: "Test title", + short_title: "Test short title", + title_html: "Test title html", + short_title_html: "Test short title html ") end - it 'can be created given an options hash' do + it "can be created given an options hash" do expect(occasion).not_to be_nil end - it 'exposes a work_suspended? method' do + it "exposes a work_suspended? method" do expect(occasion.work_suspended?).to be false end end diff --git a/spec/bahai_date/weekday_spec.rb b/spec/bahai_date/weekday_spec.rb index b8ef691..86b4359 100644 --- a/spec/bahai_date/weekday_spec.rb +++ b/spec/bahai_date/weekday_spec.rb @@ -1,41 +1,44 @@ module BahaiDate describe Weekday do - it 'can be created given a number from 1 to 7' do + it "can be created given a number from 1 to 7" do expect(Weekday.new(1)).to_not be_nil expect(Weekday.new(7)).to_not be_nil end it "can't be created with a number other than 1 to 7" do expect { Weekday.new(0) }.to raise_error( - ArgumentError, "'0' is not a valid weekday. Please use 1 to 7.") + ArgumentError, "'0' is not a valid weekday. Please use 1 to 7." + ) expect { Weekday.new(8) }.to raise_error( - ArgumentError, "'8' is not a valid weekday. Please use 1 to 7.") + ArgumentError, "'8' is not a valid weekday. Please use 1 to 7." + ) - expect { Weekday.new('hello') }.to raise_error( - ArgumentError, "'0' is not a valid weekday. Please use 1 to 7.") + expect { Weekday.new("hello") }.to raise_error( + ArgumentError, "'0' is not a valid weekday. Please use 1 to 7." + ) end subject(:weekday) { Weekday.new(1) } - it 'can be converted to string' do - expect(weekday.to_s).to eq 'Jalal' + it "can be converted to string" do + expect(weekday.to_s).to eq "Jalal" end - it 'provides access to the day number' do + it "provides access to the day number" do expect(weekday.number).to be 1 end - it 'provides access to the translated title' do - expect(weekday.translation).to eq 'Glory' + it "provides access to the translated title" do + expect(weekday.translation).to eq "Glory" end - it 'provides access to the title in HTML' do - expect(weekday.html).to eq 'Jalál' + it "provides access to the title in HTML" do + expect(weekday.html).to eq "Jalál" end - it 'provides access to the English equivalent' do - expect(weekday.english_equivalent).to eq('Saturday') + it "provides access to the English equivalent" do + expect(weekday.english_equivalent).to eq("Saturday") end end end diff --git a/spec/bahai_date/year_calendar_spec.rb b/spec/bahai_date/year_calendar_spec.rb index 03abf9f..4f34911 100644 --- a/spec/bahai_date/year_calendar_spec.rb +++ b/spec/bahai_date/year_calendar_spec.rb @@ -2,15 +2,15 @@ module BahaiDate describe YearCalendar do subject(:year_calendar) { YearCalendar.new(1) } - it 'can be created' do + it "can be created" do expect(year_calendar).not_to be_nil end - it 'is an instance of year' do + it "is an instance of year" do expect(year_calendar).to be_a Year end - it 'has months set' do + it "has months set" do months = year_calendar.months expect(months.size).to be 20 expect(months[-1]).not_to be_nil @@ -18,20 +18,20 @@ module BahaiDate expect(months[19]).not_to be_nil end - it 'has days set' do + it "has days set" do days = year_calendar.months[1].days expect(days.size).to be 19 expect(days[1]).not_to be_nil expect(days[19]).not_to be_nil end - it 'has weekdays set' do + it "has weekdays set" do day = year_calendar.months[1].days[1] expect(day.weekday).not_to be_nil expect(day.weekday.number).to be 6 end - it 'has occasions set' do + it "has occasions set" do day = year_calendar.months[1].days[1] expect(day.occasions.size).to be 2 end diff --git a/spec/bahai_date/year_spec.rb b/spec/bahai_date/year_spec.rb index 6f7af8a..fea4d96 100644 --- a/spec/bahai_date/year_spec.rb +++ b/spec/bahai_date/year_spec.rb @@ -1,49 +1,51 @@ module BahaiDate describe Year do - it 'can be created given a number greater than or equal to 1' do + it "can be created given a number greater than or equal to 1" do expect(Year.new(1)).to_not be_nil expect(Year.new(160)).to_not be_nil end it "can't be created with a number less than 1" do expect { Year.new(0) }.to raise_error( - ArgumentError, "'0' is not a valid year. Please use a number greater than or equal to 1.") + ArgumentError, "'0' is not a valid year. Please use a number greater than or equal to 1." + ) - expect { Year.new('hello') }.to raise_error( - ArgumentError, "'0' is not a valid year. Please use a number greater than or equal to 1.") + expect { Year.new("hello") }.to raise_error( + ArgumentError, "'0' is not a valid year. Please use a number greater than or equal to 1." + ) end subject(:year) { Year.new(1) } - it 'can be converted to string showing the B.E. number' do - expect(year.to_s).to eq '1' + it "can be converted to string showing the B.E. number" do + expect(year.to_s).to eq "1" end - it 'provides access to the title' do - expect(year.title).to eq 'Alif' + it "provides access to the title" do + expect(year.title).to eq "Alif" end - it 'provides access to the year number' do + it "provides access to the year number" do expect(year.number).to be 1 end - it 'provides access to the translated title' do - expect(year.translation).to eq 'A' + it "provides access to the translated title" do + expect(year.translation).to eq "A" end - it 'provides access to the title in HTML' do - expect(year.html).to eq 'Alif' + it "provides access to the title in HTML" do + expect(year.html).to eq "Alif" end - it 'provides access to the vahid' do + it "provides access to the vahid" do expect(year.vahid).to be 1 end - it 'provides access to the kull-i-shay' do + it "provides access to the kull-i-shay" do expect(year.kull_i_shay).to be 1 end - it 'calculates the number properly' do + it "calculates the number properly" do year = Year.new(1) expect(year.number).to eq(1) @@ -60,7 +62,7 @@ module BahaiDate expect(year.number).to eq(1) end - it 'calculates the vahid properly' do + it "calculates the vahid properly" do year = Year.new(1) expect(year.vahid).to eq(1) @@ -74,7 +76,7 @@ module BahaiDate expect(year.vahid).to eq(1) end - it 'calculates the kull-i-shay properly' do + it "calculates the kull-i-shay properly" do year = Year.new(1) expect(year.kull_i_shay).to eq(1) @@ -85,13 +87,13 @@ module BahaiDate expect(year.kull_i_shay).to eq(2) end - context 'working with a hash of months' do - it 'is readable' do + context "working with a hash of months" do + it "is readable" do year = Year.new(1) expect(year.months).to eq({}) end - it 'can be added to' do + it "can be added to" do year = Year.new(1) year.add_month(-1) expect(year.months[-1].number).to be(-1) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9a70a41..1e27ac7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,3 @@ -require 'simplecov' +require "simplecov" SimpleCov.start -require 'bahai_date' +require "bahai_date" From 244cad056ccb9c1805b69fdbe8381595cbc2e8c8 Mon Sep 17 00:00:00 2001 From: Kevin Pratt Date: Fri, 15 Dec 2023 14:08:15 -0700 Subject: [PATCH 3/5] Bump minor version --- lib/bahai_date/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bahai_date/version.rb b/lib/bahai_date/version.rb index 572439d..aab4da3 100644 --- a/lib/bahai_date/version.rb +++ b/lib/bahai_date/version.rb @@ -1,3 +1,3 @@ module BahaiDate - VERSION = "1.4.0" + VERSION = "1.4.1" end From c346795ebbad4403865900fb4f4c4271f88dad5e Mon Sep 17 00:00:00 2001 From: Kevin Pratt Date: Fri, 1 Nov 2024 09:59:23 -0600 Subject: [PATCH 4/5] Why is this lockfile ignored!! --- .gitignore | 1 - Gemfile.lock | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 Gemfile.lock diff --git a/.gitignore b/.gitignore index c50a6f3..5ac785a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ *.swp .DS_Store .ruby-version -Gemfile.lock coverage/ diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..a5adf9b --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,55 @@ +GIT + remote: https://github.com/lessan/astro-algo.git + revision: 3613e6fe68597458f3f8079dfcc534c90112a287 + specs: + astro-algo (0.0.1) + +PATH + remote: . + specs: + bahai_date (1.4.1) + RubySunrise (~> 0.3) + astro-algo (~> 0) + tzinfo (~> 1.2) + +GEM + remote: https://rubygems.org/ + specs: + RubySunrise (0.3.3) + tzinfo + diff-lcs (1.5.0) + docile (1.4.0) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.6) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-support (3.12.1) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) + thread_safe (0.3.6) + tzinfo (1.2.11) + thread_safe (~> 0.1) + +PLATFORMS + arm64-darwin-22 + +DEPENDENCIES + astro-algo! + bahai_date! + rspec (~> 3) + simplecov (~> 0) + +BUNDLED WITH + 2.4.22 From 9ebce2b20ac5a4488b39deced71c63b922af4a72 Mon Sep 17 00:00:00 2001 From: Kevin Pratt Date: Mon, 4 Nov 2024 11:36:16 -0700 Subject: [PATCH 5/5] Create .ruby-version --- .ruby-version | 1 + 1 file changed, 1 insertion(+) create mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..9e79f6c --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +ruby-3.2.2