7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/holidays/definition/generator/module.rb', line 7
def call(module_name, files, regions, month_strings, custom_methods)
raise ArgumentError.new("module name cannot be nil") if module_name.nil?
raise ArgumentError.new("module name cannot be blank") if module_name.empty?
raise ArgumentError.new("files cannot be nil") if files.nil?
raise ArgumentError.new("files cannot be empty") if files.empty?
raise ArgumentError.new("files must all be strings") unless files.all? { |f| f.is_a?(String) }
raise ArgumentError.new("regions cannot be nil") if regions.nil?
raise ArgumentError.new("regions cannot be empty") if regions.empty?
raise ArgumentError.new("month strings cannot be nil") if month_strings.nil?
raise ArgumentError.new("month strings cannot be empty") if month_strings.empty?
module_src =<<-EOM
# encoding: utf-8
module Holidays
# This file is generated by the Ruby Holidays gem.
#
# Definitions loaded: #{files.join(', ')}
#
# All the definitions are available at https://github.com/holidays/holidays
module #{module_name.to_s.upcase} # :nodoc:
def self.defined_regions
[:#{regions.join(', :')}]
end
def self.holidays_by_month
{
#{month_strings.join(",\n")}
}
end
def self.custom_methods
{
#{custom_methods}
}
end
end
end
EOM
module_src
end
|