Class: RemindMe::Reminder::Generator
- Inherits:
-
Object
- Object
- RemindMe::Reminder::Generator
- Defined in:
- lib/remind_me/reminder/generator.rb
Class Method Summary collapse
- .generate(source_location, reminder_comment, parser) ⇒ Object
- .load_predefined_reminders ⇒ Object
- .register(reminder_klass) ⇒ Object
- .registered_reminders ⇒ Object
Class Method Details
.generate(source_location, reminder_comment, parser) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/remind_me/reminder/generator.rb', line 27 def self.generate(source_location, reminder_comment, parser) parser.reset begin reminder_comment_ast = parser.class.parse(reminder_comment) rescue Parser::SyntaxError => e return [unparsable_reminder(source_location, e)] end relevant_reminders_classes = relevant_reminders_classes(reminder_comment_ast) return [unknown_reminder(source_location, reminder_comment)] if relevant_reminders_classes.empty? create_reminders_from(reminder_comment_ast, source_location, relevant_reminders_classes) end |
.load_predefined_reminders ⇒ Object
18 19 20 21 22 23 |
# File 'lib/remind_me/reminder/generator.rb', line 18 def self.load_predefined_reminders predefined_remiders = Dir.entries(File.dirname(__FILE__)).select do |path| !path.end_with?('base_reminder.rb') && path.end_with?('_reminder.rb') end predefined_remiders.each { |f| require_relative f } end |
.register(reminder_klass) ⇒ Object
9 10 11 12 |
# File 'lib/remind_me/reminder/generator.rb', line 9 def self.register(reminder_klass) @registered_reminders ||= Set.new @registered_reminders << reminder_klass end |
.registered_reminders ⇒ Object
14 15 16 |
# File 'lib/remind_me/reminder/generator.rb', line 14 def self.registered_reminders @registered_reminders.dup end |