annotate .svn/pristine/91/91fff5d063700a66adfd914048571c90c7fa442e.svn-base @ 1433:cfa80f738847 bibliography_testing

Fixed assertion error message.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Tue, 08 Oct 2013 17:29:47 +0100
parents 038ba2d95de8
children
rev   line source
Chris@1296 1 # Redmine - project management software
Chris@1296 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
Chris@1296 3 #
Chris@1296 4 # This program is free software; you can redistribute it and/or
Chris@1296 5 # modify it under the terms of the GNU General Public License
Chris@1296 6 # as published by the Free Software Foundation; either version 2
Chris@1296 7 # of the License, or (at your option) any later version.
Chris@1296 8 #
Chris@1296 9 # This program is distributed in the hope that it will be useful,
Chris@1296 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1296 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1296 12 # GNU General Public License for more details.
Chris@1296 13 #
Chris@1296 14 # You should have received a copy of the GNU General Public License
Chris@1296 15 # along with this program; if not, write to the Free Software
Chris@1296 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1296 17
Chris@1296 18 module Redmine #:nodoc:
Chris@1296 19
Chris@1296 20 class PluginNotFound < StandardError; end
Chris@1296 21 class PluginRequirementError < StandardError; end
Chris@1296 22
Chris@1296 23 # Base class for Redmine plugins.
Chris@1296 24 # Plugins are registered using the <tt>register</tt> class method that acts as the public constructor.
Chris@1296 25 #
Chris@1296 26 # Redmine::Plugin.register :example do
Chris@1296 27 # name 'Example plugin'
Chris@1296 28 # author 'John Smith'
Chris@1296 29 # description 'This is an example plugin for Redmine'
Chris@1296 30 # version '0.0.1'
Chris@1296 31 # settings :default => {'foo'=>'bar'}, :partial => 'settings/settings'
Chris@1296 32 # end
Chris@1296 33 #
Chris@1296 34 # === Plugin attributes
Chris@1296 35 #
Chris@1296 36 # +settings+ is an optional attribute that let the plugin be configurable.
Chris@1296 37 # It must be a hash with the following keys:
Chris@1296 38 # * <tt>:default</tt>: default value for the plugin settings
Chris@1296 39 # * <tt>:partial</tt>: path of the configuration partial view, relative to the plugin <tt>app/views</tt> directory
Chris@1296 40 # Example:
Chris@1296 41 # settings :default => {'foo'=>'bar'}, :partial => 'settings/settings'
Chris@1296 42 # In this example, the settings partial will be found here in the plugin directory: <tt>app/views/settings/_settings.rhtml</tt>.
Chris@1296 43 #
Chris@1296 44 # When rendered, the plugin settings value is available as the local variable +settings+
Chris@1296 45 class Plugin
Chris@1296 46 cattr_accessor :directory
Chris@1296 47 self.directory = File.join(Rails.root, 'plugins')
Chris@1296 48
Chris@1296 49 cattr_accessor :public_directory
Chris@1296 50 self.public_directory = File.join(Rails.root, 'public', 'plugin_assets')
Chris@1296 51
Chris@1296 52 @registered_plugins = {}
Chris@1296 53 class << self
Chris@1296 54 attr_reader :registered_plugins
Chris@1296 55 private :new
Chris@1296 56
Chris@1296 57 def def_field(*names)
Chris@1296 58 class_eval do
Chris@1296 59 names.each do |name|
Chris@1296 60 define_method(name) do |*args|
Chris@1296 61 args.empty? ? instance_variable_get("@#{name}") : instance_variable_set("@#{name}", *args)
Chris@1296 62 end
Chris@1296 63 end
Chris@1296 64 end
Chris@1296 65 end
Chris@1296 66 end
Chris@1296 67 def_field :name, :description, :url, :author, :author_url, :version, :settings
Chris@1296 68 attr_reader :id
Chris@1296 69
Chris@1296 70 # Plugin constructor
Chris@1296 71 def self.register(id, &block)
Chris@1296 72 p = new(id)
Chris@1296 73 p.instance_eval(&block)
Chris@1296 74 # Set a default name if it was not provided during registration
Chris@1296 75 p.name(id.to_s.humanize) if p.name.nil?
Chris@1296 76
Chris@1296 77 # Adds plugin locales if any
Chris@1296 78 # YAML translation files should be found under <plugin>/config/locales/
Chris@1296 79 ::I18n.load_path += Dir.glob(File.join(p.directory, 'config', 'locales', '*.yml'))
Chris@1296 80
Chris@1296 81 # Prepends the app/views directory of the plugin to the view path
Chris@1296 82 view_path = File.join(p.directory, 'app', 'views')
Chris@1296 83 if File.directory?(view_path)
Chris@1296 84 ActionController::Base.prepend_view_path(view_path)
Chris@1296 85 ActionMailer::Base.prepend_view_path(view_path)
Chris@1296 86 end
Chris@1296 87
Chris@1296 88 # Adds the app/{controllers,helpers,models} directories of the plugin to the autoload path
Chris@1296 89 Dir.glob File.expand_path(File.join(p.directory, 'app', '{controllers,helpers,models}')) do |dir|
Chris@1296 90 ActiveSupport::Dependencies.autoload_paths += [dir]
Chris@1296 91 end
Chris@1296 92
Chris@1296 93 registered_plugins[id] = p
Chris@1296 94 end
Chris@1296 95
Chris@1296 96 # Returns an array of all registered plugins
Chris@1296 97 def self.all
Chris@1296 98 registered_plugins.values.sort
Chris@1296 99 end
Chris@1296 100
Chris@1296 101 # Finds a plugin by its id
Chris@1296 102 # Returns a PluginNotFound exception if the plugin doesn't exist
Chris@1296 103 def self.find(id)
Chris@1296 104 registered_plugins[id.to_sym] || raise(PluginNotFound)
Chris@1296 105 end
Chris@1296 106
Chris@1296 107 # Clears the registered plugins hash
Chris@1296 108 # It doesn't unload installed plugins
Chris@1296 109 def self.clear
Chris@1296 110 @registered_plugins = {}
Chris@1296 111 end
Chris@1296 112
Chris@1296 113 # Checks if a plugin is installed
Chris@1296 114 #
Chris@1296 115 # @param [String] id name of the plugin
Chris@1296 116 def self.installed?(id)
Chris@1296 117 registered_plugins[id.to_sym].present?
Chris@1296 118 end
Chris@1296 119
Chris@1296 120 def self.load
Chris@1296 121 Dir.glob(File.join(self.directory, '*')).sort.each do |directory|
Chris@1296 122 if File.directory?(directory)
Chris@1296 123 lib = File.join(directory, "lib")
Chris@1296 124 if File.directory?(lib)
Chris@1296 125 $:.unshift lib
Chris@1296 126 ActiveSupport::Dependencies.autoload_paths += [lib]
Chris@1296 127 end
Chris@1296 128 initializer = File.join(directory, "init.rb")
Chris@1296 129 if File.file?(initializer)
Chris@1296 130 require initializer
Chris@1296 131 end
Chris@1296 132 end
Chris@1296 133 end
Chris@1296 134 end
Chris@1296 135
Chris@1296 136 def initialize(id)
Chris@1296 137 @id = id.to_sym
Chris@1296 138 end
Chris@1296 139
Chris@1296 140 def directory
Chris@1296 141 File.join(self.class.directory, id.to_s)
Chris@1296 142 end
Chris@1296 143
Chris@1296 144 def public_directory
Chris@1296 145 File.join(self.class.public_directory, id.to_s)
Chris@1296 146 end
Chris@1296 147
Chris@1296 148 def assets_directory
Chris@1296 149 File.join(directory, 'assets')
Chris@1296 150 end
Chris@1296 151
Chris@1296 152 def <=>(plugin)
Chris@1296 153 self.id.to_s <=> plugin.id.to_s
Chris@1296 154 end
Chris@1296 155
Chris@1296 156 # Sets a requirement on Redmine version
Chris@1296 157 # Raises a PluginRequirementError exception if the requirement is not met
Chris@1296 158 #
Chris@1296 159 # Examples
Chris@1296 160 # # Requires Redmine 0.7.3 or higher
Chris@1296 161 # requires_redmine :version_or_higher => '0.7.3'
Chris@1296 162 # requires_redmine '0.7.3'
Chris@1296 163 #
Chris@1296 164 # # Requires Redmine 0.7.x or higher
Chris@1296 165 # requires_redmine '0.7'
Chris@1296 166 #
Chris@1296 167 # # Requires a specific Redmine version
Chris@1296 168 # requires_redmine :version => '0.7.3' # 0.7.3 only
Chris@1296 169 # requires_redmine :version => '0.7' # 0.7.x
Chris@1296 170 # requires_redmine :version => ['0.7.3', '0.8.0'] # 0.7.3 or 0.8.0
Chris@1296 171 #
Chris@1296 172 # # Requires a Redmine version within a range
Chris@1296 173 # requires_redmine :version => '0.7.3'..'0.9.1' # >= 0.7.3 and <= 0.9.1
Chris@1296 174 # requires_redmine :version => '0.7'..'0.9' # >= 0.7.x and <= 0.9.x
Chris@1296 175 def requires_redmine(arg)
Chris@1296 176 arg = { :version_or_higher => arg } unless arg.is_a?(Hash)
Chris@1296 177 arg.assert_valid_keys(:version, :version_or_higher)
Chris@1296 178
Chris@1296 179 current = Redmine::VERSION.to_a
Chris@1296 180 arg.each do |k, req|
Chris@1296 181 case k
Chris@1296 182 when :version_or_higher
Chris@1296 183 raise ArgumentError.new(":version_or_higher accepts a version string only") unless req.is_a?(String)
Chris@1296 184 unless compare_versions(req, current) <= 0
Chris@1296 185 raise PluginRequirementError.new("#{id} plugin requires Redmine #{req} or higher but current is #{current.join('.')}")
Chris@1296 186 end
Chris@1296 187 when :version
Chris@1296 188 req = [req] if req.is_a?(String)
Chris@1296 189 if req.is_a?(Array)
Chris@1296 190 unless req.detect {|ver| compare_versions(ver, current) == 0}
Chris@1296 191 raise PluginRequirementError.new("#{id} plugin requires one the following Redmine versions: #{req.join(', ')} but current is #{current.join('.')}")
Chris@1296 192 end
Chris@1296 193 elsif req.is_a?(Range)
Chris@1296 194 unless compare_versions(req.first, current) <= 0 && compare_versions(req.last, current) >= 0
Chris@1296 195 raise PluginRequirementError.new("#{id} plugin requires a Redmine version between #{req.first} and #{req.last} but current is #{current.join('.')}")
Chris@1296 196 end
Chris@1296 197 else
Chris@1296 198 raise ArgumentError.new(":version option accepts a version string, an array or a range of versions")
Chris@1296 199 end
Chris@1296 200 end
Chris@1296 201 end
Chris@1296 202 true
Chris@1296 203 end
Chris@1296 204
Chris@1296 205 def compare_versions(requirement, current)
Chris@1296 206 requirement = requirement.split('.').collect(&:to_i)
Chris@1296 207 requirement <=> current.slice(0, requirement.size)
Chris@1296 208 end
Chris@1296 209 private :compare_versions
Chris@1296 210
Chris@1296 211 # Sets a requirement on a Redmine plugin version
Chris@1296 212 # Raises a PluginRequirementError exception if the requirement is not met
Chris@1296 213 #
Chris@1296 214 # Examples
Chris@1296 215 # # Requires a plugin named :foo version 0.7.3 or higher
Chris@1296 216 # requires_redmine_plugin :foo, :version_or_higher => '0.7.3'
Chris@1296 217 # requires_redmine_plugin :foo, '0.7.3'
Chris@1296 218 #
Chris@1296 219 # # Requires a specific version of a Redmine plugin
Chris@1296 220 # requires_redmine_plugin :foo, :version => '0.7.3' # 0.7.3 only
Chris@1296 221 # requires_redmine_plugin :foo, :version => ['0.7.3', '0.8.0'] # 0.7.3 or 0.8.0
Chris@1296 222 def requires_redmine_plugin(plugin_name, arg)
Chris@1296 223 arg = { :version_or_higher => arg } unless arg.is_a?(Hash)
Chris@1296 224 arg.assert_valid_keys(:version, :version_or_higher)
Chris@1296 225
Chris@1296 226 plugin = Plugin.find(plugin_name)
Chris@1296 227 current = plugin.version.split('.').collect(&:to_i)
Chris@1296 228
Chris@1296 229 arg.each do |k, v|
Chris@1296 230 v = [] << v unless v.is_a?(Array)
Chris@1296 231 versions = v.collect {|s| s.split('.').collect(&:to_i)}
Chris@1296 232 case k
Chris@1296 233 when :version_or_higher
Chris@1296 234 raise ArgumentError.new("wrong number of versions (#{versions.size} for 1)") unless versions.size == 1
Chris@1296 235 unless (current <=> versions.first) >= 0
Chris@1296 236 raise PluginRequirementError.new("#{id} plugin requires the #{plugin_name} plugin #{v} or higher but current is #{current.join('.')}")
Chris@1296 237 end
Chris@1296 238 when :version
Chris@1296 239 unless versions.include?(current.slice(0,3))
Chris@1296 240 raise PluginRequirementError.new("#{id} plugin requires one the following versions of #{plugin_name}: #{v.join(', ')} but current is #{current.join('.')}")
Chris@1296 241 end
Chris@1296 242 end
Chris@1296 243 end
Chris@1296 244 true
Chris@1296 245 end
Chris@1296 246
Chris@1296 247 # Adds an item to the given +menu+.
Chris@1296 248 # The +id+ parameter (equals to the project id) is automatically added to the url.
Chris@1296 249 # menu :project_menu, :plugin_example, { :controller => 'example', :action => 'say_hello' }, :caption => 'Sample'
Chris@1296 250 #
Chris@1296 251 # +name+ parameter can be: :top_menu, :account_menu, :application_menu or :project_menu
Chris@1296 252 #
Chris@1296 253 def menu(menu, item, url, options={})
Chris@1296 254 Redmine::MenuManager.map(menu).push(item, url, options)
Chris@1296 255 end
Chris@1296 256 alias :add_menu_item :menu
Chris@1296 257
Chris@1296 258 # Removes +item+ from the given +menu+.
Chris@1296 259 def delete_menu_item(menu, item)
Chris@1296 260 Redmine::MenuManager.map(menu).delete(item)
Chris@1296 261 end
Chris@1296 262
Chris@1296 263 # Defines a permission called +name+ for the given +actions+.
Chris@1296 264 #
Chris@1296 265 # The +actions+ argument is a hash with controllers as keys and actions as values (a single value or an array):
Chris@1296 266 # permission :destroy_contacts, { :contacts => :destroy }
Chris@1296 267 # permission :view_contacts, { :contacts => [:index, :show] }
Chris@1296 268 #
Chris@1296 269 # The +options+ argument is a hash that accept the following keys:
Chris@1296 270 # * :public => the permission is public if set to true (implicitly given to any user)
Chris@1296 271 # * :require => can be set to one of the following values to restrict users the permission can be given to: :loggedin, :member
Chris@1296 272 # * :read => set it to true so that the permission is still granted on closed projects
Chris@1296 273 #
Chris@1296 274 # Examples
Chris@1296 275 # # A permission that is implicitly given to any user
Chris@1296 276 # # This permission won't appear on the Roles & Permissions setup screen
Chris@1296 277 # permission :say_hello, { :example => :say_hello }, :public => true, :read => true
Chris@1296 278 #
Chris@1296 279 # # A permission that can be given to any user
Chris@1296 280 # permission :say_hello, { :example => :say_hello }
Chris@1296 281 #
Chris@1296 282 # # A permission that can be given to registered users only
Chris@1296 283 # permission :say_hello, { :example => :say_hello }, :require => :loggedin
Chris@1296 284 #
Chris@1296 285 # # A permission that can be given to project members only
Chris@1296 286 # permission :say_hello, { :example => :say_hello }, :require => :member
Chris@1296 287 def permission(name, actions, options = {})
Chris@1296 288 if @project_module
Chris@1296 289 Redmine::AccessControl.map {|map| map.project_module(@project_module) {|map|map.permission(name, actions, options)}}
Chris@1296 290 else
Chris@1296 291 Redmine::AccessControl.map {|map| map.permission(name, actions, options)}
Chris@1296 292 end
Chris@1296 293 end
Chris@1296 294
Chris@1296 295 # Defines a project module, that can be enabled/disabled for each project.
Chris@1296 296 # Permissions defined inside +block+ will be bind to the module.
Chris@1296 297 #
Chris@1296 298 # project_module :things do
Chris@1296 299 # permission :view_contacts, { :contacts => [:list, :show] }, :public => true
Chris@1296 300 # permission :destroy_contacts, { :contacts => :destroy }
Chris@1296 301 # end
Chris@1296 302 def project_module(name, &block)
Chris@1296 303 @project_module = name
Chris@1296 304 self.instance_eval(&block)
Chris@1296 305 @project_module = nil
Chris@1296 306 end
Chris@1296 307
Chris@1296 308 # Registers an activity provider.
Chris@1296 309 #
Chris@1296 310 # Options:
Chris@1296 311 # * <tt>:class_name</tt> - one or more model(s) that provide these events (inferred from event_type by default)
Chris@1296 312 # * <tt>:default</tt> - setting this option to false will make the events not displayed by default
Chris@1296 313 #
Chris@1296 314 # A model can provide several activity event types.
Chris@1296 315 #
Chris@1296 316 # Examples:
Chris@1296 317 # register :news
Chris@1296 318 # register :scrums, :class_name => 'Meeting'
Chris@1296 319 # register :issues, :class_name => ['Issue', 'Journal']
Chris@1296 320 #
Chris@1296 321 # Retrieving events:
Chris@1296 322 # Associated model(s) must implement the find_events class method.
Chris@1296 323 # ActiveRecord models can use acts_as_activity_provider as a way to implement this class method.
Chris@1296 324 #
Chris@1296 325 # The following call should return all the scrum events visible by current user that occured in the 5 last days:
Chris@1296 326 # Meeting.find_events('scrums', User.current, 5.days.ago, Date.today)
Chris@1296 327 # Meeting.find_events('scrums', User.current, 5.days.ago, Date.today, :project => foo) # events for project foo only
Chris@1296 328 #
Chris@1296 329 # Note that :view_scrums permission is required to view these events in the activity view.
Chris@1296 330 def activity_provider(*args)
Chris@1296 331 Redmine::Activity.register(*args)
Chris@1296 332 end
Chris@1296 333
Chris@1296 334 # Registers a wiki formatter.
Chris@1296 335 #
Chris@1296 336 # Parameters:
Chris@1296 337 # * +name+ - human-readable name
Chris@1296 338 # * +formatter+ - formatter class, which should have an instance method +to_html+
Chris@1296 339 # * +helper+ - helper module, which will be included by wiki pages
Chris@1296 340 def wiki_format_provider(name, formatter, helper)
Chris@1296 341 Redmine::WikiFormatting.register(name, formatter, helper)
Chris@1296 342 end
Chris@1296 343
Chris@1296 344 # Returns +true+ if the plugin can be configured.
Chris@1296 345 def configurable?
Chris@1296 346 settings && settings.is_a?(Hash) && !settings[:partial].blank?
Chris@1296 347 end
Chris@1296 348
Chris@1296 349 def mirror_assets
Chris@1296 350 source = assets_directory
Chris@1296 351 destination = public_directory
Chris@1296 352 return unless File.directory?(source)
Chris@1296 353
Chris@1296 354 source_files = Dir[source + "/**/*"]
Chris@1296 355 source_dirs = source_files.select { |d| File.directory?(d) }
Chris@1296 356 source_files -= source_dirs
Chris@1296 357
Chris@1296 358 unless source_files.empty?
Chris@1296 359 base_target_dir = File.join(destination, File.dirname(source_files.first).gsub(source, ''))
Chris@1296 360 begin
Chris@1296 361 FileUtils.mkdir_p(base_target_dir)
Chris@1296 362 rescue Exception => e
Chris@1296 363 raise "Could not create directory #{base_target_dir}: " + e.message
Chris@1296 364 end
Chris@1296 365 end
Chris@1296 366
Chris@1296 367 source_dirs.each do |dir|
Chris@1296 368 # strip down these paths so we have simple, relative paths we can
Chris@1296 369 # add to the destination
Chris@1296 370 target_dir = File.join(destination, dir.gsub(source, ''))
Chris@1296 371 begin
Chris@1296 372 FileUtils.mkdir_p(target_dir)
Chris@1296 373 rescue Exception => e
Chris@1296 374 raise "Could not create directory #{target_dir}: " + e.message
Chris@1296 375 end
Chris@1296 376 end
Chris@1296 377
Chris@1296 378 source_files.each do |file|
Chris@1296 379 begin
Chris@1296 380 target = File.join(destination, file.gsub(source, ''))
Chris@1296 381 unless File.exist?(target) && FileUtils.identical?(file, target)
Chris@1296 382 FileUtils.cp(file, target)
Chris@1296 383 end
Chris@1296 384 rescue Exception => e
Chris@1296 385 raise "Could not copy #{file} to #{target}: " + e.message
Chris@1296 386 end
Chris@1296 387 end
Chris@1296 388 end
Chris@1296 389
Chris@1296 390 # Mirrors assets from one or all plugins to public/plugin_assets
Chris@1296 391 def self.mirror_assets(name=nil)
Chris@1296 392 if name.present?
Chris@1296 393 find(name).mirror_assets
Chris@1296 394 else
Chris@1296 395 all.each do |plugin|
Chris@1296 396 plugin.mirror_assets
Chris@1296 397 end
Chris@1296 398 end
Chris@1296 399 end
Chris@1296 400
Chris@1296 401 # The directory containing this plugin's migrations (<tt>plugin/db/migrate</tt>)
Chris@1296 402 def migration_directory
Chris@1296 403 File.join(Rails.root, 'plugins', id.to_s, 'db', 'migrate')
Chris@1296 404 end
Chris@1296 405
Chris@1296 406 # Returns the version number of the latest migration for this plugin. Returns
Chris@1296 407 # nil if this plugin has no migrations.
Chris@1296 408 def latest_migration
Chris@1296 409 migrations.last
Chris@1296 410 end
Chris@1296 411
Chris@1296 412 # Returns the version numbers of all migrations for this plugin.
Chris@1296 413 def migrations
Chris@1296 414 migrations = Dir[migration_directory+"/*.rb"]
Chris@1296 415 migrations.map { |p| File.basename(p).match(/0*(\d+)\_/)[1].to_i }.sort
Chris@1296 416 end
Chris@1296 417
Chris@1296 418 # Migrate this plugin to the given version
Chris@1296 419 def migrate(version = nil)
Chris@1296 420 puts "Migrating #{id} (#{name})..."
Chris@1296 421 Redmine::Plugin::Migrator.migrate_plugin(self, version)
Chris@1296 422 end
Chris@1296 423
Chris@1296 424 # Migrates all plugins or a single plugin to a given version
Chris@1296 425 # Exemples:
Chris@1296 426 # Plugin.migrate
Chris@1296 427 # Plugin.migrate('sample_plugin')
Chris@1296 428 # Plugin.migrate('sample_plugin', 1)
Chris@1296 429 #
Chris@1296 430 def self.migrate(name=nil, version=nil)
Chris@1296 431 if name.present?
Chris@1296 432 find(name).migrate(version)
Chris@1296 433 else
Chris@1296 434 all.each do |plugin|
Chris@1296 435 plugin.migrate
Chris@1296 436 end
Chris@1296 437 end
Chris@1296 438 end
Chris@1296 439
Chris@1296 440 class Migrator < ActiveRecord::Migrator
Chris@1296 441 # We need to be able to set the 'current' plugin being migrated.
Chris@1296 442 cattr_accessor :current_plugin
Chris@1296 443
Chris@1296 444 class << self
Chris@1296 445 # Runs the migrations from a plugin, up (or down) to the version given
Chris@1296 446 def migrate_plugin(plugin, version)
Chris@1296 447 self.current_plugin = plugin
Chris@1296 448 return if current_version(plugin) == version
Chris@1296 449 migrate(plugin.migration_directory, version)
Chris@1296 450 end
Chris@1296 451
Chris@1296 452 def current_version(plugin=current_plugin)
Chris@1296 453 # Delete migrations that don't match .. to_i will work because the number comes first
Chris@1296 454 ::ActiveRecord::Base.connection.select_values(
Chris@1296 455 "SELECT version FROM #{schema_migrations_table_name}"
Chris@1296 456 ).delete_if{ |v| v.match(/-#{plugin.id}/) == nil }.map(&:to_i).max || 0
Chris@1296 457 end
Chris@1296 458 end
Chris@1296 459
Chris@1296 460 def migrated
Chris@1296 461 sm_table = self.class.schema_migrations_table_name
Chris@1296 462 ::ActiveRecord::Base.connection.select_values(
Chris@1296 463 "SELECT version FROM #{sm_table}"
Chris@1296 464 ).delete_if{ |v| v.match(/-#{current_plugin.id}/) == nil }.map(&:to_i).sort
Chris@1296 465 end
Chris@1296 466
Chris@1296 467 def record_version_state_after_migrating(version)
Chris@1296 468 super(version.to_s + "-" + current_plugin.id.to_s)
Chris@1296 469 end
Chris@1296 470 end
Chris@1296 471 end
Chris@1296 472 end