1 module RedminePublications
2 # Patches Redmine's Issues dynamically. Adds a +after_save+ filter.
5 def self.included(base) # :nodoc:
6 base.extend(ClassMethods)
8 base.send(:include, InstanceMethods)
10 # Same as typing in the class
12 unloadable # Send unloadable so it will not be unloaded in development
13 after_save :update_publication
21 module InstanceMethods
23 def update_publication
25 regexp = Regexp.new(Setting.plugin_redmine_publications[:pattern])
26 match = self.path.match(regexp)
27 Rails.logger.info('[INFO] Adding publication: "' << match[1])
28 Publication.find_or_create_by_name(:name => match[1],
29 :source_file => self.path, :repository_id => self.changeset.repository.id )