Class: CalendariumRomanum::CLI::Dumper Private

Inherits:
Object
  • Object
show all
Defined in:
lib/calendarium-romanum/cli/dumper.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Produces a condensed text representation of a Calendar, used in regression tests. Not loaded by default by require ‘calendarium-romanum’

Instance Method Summary collapse

Constructor Details

#initialize(io = STDOUT) ⇒ Dumper

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Dumper.



8
9
10
# File 'lib/calendarium-romanum/cli/dumper.rb', line 8

def initialize(io=STDOUT)
  @io = io
end

Instance Method Details

#call(calendar, *other_calendars) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Dumps calendar. If other_calendars are specified, dumps an alternative entry for any date for which any of other_calendars differs from calendar.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/calendarium-romanum/cli/dumper.rb', line 14

def call(calendar, *other_calendars)
  @io.puts "Calendar for liturgical year #{calendar.year}"
  calendar.each do |day|
    dump_day(day)

    other_calendars.each do |cal|
      day2 = cal[day.date]
      if day2 != day
        @io.print 'or '
        dump_day(day2)
      end
    end
  end
end

#regression_tests_dump(year) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Produces the dump used for regression tests for the specified year.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/calendarium-romanum/cli/dumper.rb', line 30

def regression_tests_dump(year)
  sanctorale = Data::GENERAL_ROMAN_LATIN.load
  calendar = Calendar.new(
    year,
    sanctorale,
    vespers: true
  )
  calendar_with_transfers = Calendar.new(
    Temporale.new(year, transfer_to_sunday: Temporale::SUNDAY_TRANSFERABLE_SOLEMNITIES),
    sanctorale,
    vespers: true
  )
  calendar_with_extensions = Calendar.new(
    Temporale.new(year, extensions: Temporale::Extensions.all),
    sanctorale,
    vespers: true
  )

  I18n.with_locale(:la) do
    call(
      calendar,
      calendar_with_transfers,
      calendar_with_extensions,
    )
  end
end