Class: Holidays::Definition::Generator::Module
- Inherits:
-
Object
- Object
- Holidays::Definition::Generator::Module
- Defined in:
- lib/holidays/definition/generator/module.rb
Instance Method Summary collapse
-
#call(module_name, files, regions, month_strings, custom_methods = nil) ⇒ Object
NOTE:
custom_methodsis accepted for backwards-compatible call sites but is no longer baked into the generated module.
Instance Method Details
#call(module_name, files, regions, month_strings, custom_methods = nil) ⇒ Object
NOTE: custom_methods is accepted for backwards-compatible call sites but is
no longer baked into the generated module. Per-region custom methods are now
hosted natively under lib/holidays/definition/custom_methods/ and seeded into
the repository at boot. YAML files that still carry methods:/ruby: blocks are
tolerated: their bodies are simply ignored here.
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 51 52 53 |
# File 'lib/holidays/definition/generator/module.rb', line 12 def call(module_name, files, regions, month_strings, custom_methods = nil) 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 {} end end end EOM module_src end |