From 21810adf771dd26a9d14ced33403ad525565b88d Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Fri, 26 Sep 2014 23:47:22 -0300 Subject: [PATCH] rails4: require missing dependencies --- vendor/ezcrypto/lib/active_crypto.rb | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------- vendor/plugins/access_control/init.rb | 5 +++++ vendor/plugins/action_tracker/lib/action_tracker.rb | 17 +++++++++-------- vendor/plugins/action_tracker/lib/action_tracker_model.rb | 2 +- vendor/plugins/acts_as_tree/init.rb | 2 ++ vendor/plugins/user_stamp/init.rb | 5 ----- vendor/plugins/user_stamp/lib/user_stamp.rb | 25 +++++++++++++++++-------- 7 files changed, 84 insertions(+), 74 deletions(-) delete mode 100644 vendor/plugins/user_stamp/init.rb diff --git a/vendor/ezcrypto/lib/active_crypto.rb b/vendor/ezcrypto/lib/active_crypto.rb index 9c1cb20..260feb9 100644 --- a/vendor/ezcrypto/lib/active_crypto.rb +++ b/vendor/ezcrypto/lib/active_crypto.rb @@ -1,11 +1,11 @@ require "ezcrypto.rb" module ActiveCrypto # :nodoc: - + def self.append_features(base) #:nodoc: super base.extend(ClassMethods) end - + =begin rdoc Usage is very simple. You will generally only need the two class methods listed here in your ActiveRecord class model. @@ -47,19 +47,19 @@ Options are: belongs_to :user encrypt :title,:body,:key=>:user, :base64 => true end - + =end - def encrypt(*attributes) + def encrypt(*attributes) include ActiveCrypto::Encrypted before_save :encrypt_attributes after_save :decrypt_attributes options=attributes.last.is_a?(Hash) ? attributes.pop : {} keyholder if options and options[:key] - module_eval <<-"end;" + module_eval <<-"end;" def session_key (send :#{options[:key]} ).send :session_key - end + end @@external_key=true end; end @@ -70,10 +70,10 @@ Options are: #{base64_encode.to_s} end end; - + self.encrypted_attributes=attributes - end - + end + =begin rdoc Creates support in this class for holding a key. Adds the following methods: @@ -88,10 +88,10 @@ Use it as follows: keyholder end -=end +=end def keyholder() - include ActiveCrypto::AssociationKeyHolder - after_create :save_session_key + include ActiveCrypto::AssociationKeyHolder + after_create :save_session_key end =begin rdoc @@ -100,8 +100,8 @@ do something out of the ordinary. =end def clear_session_keys() #:nodoc: @@session_keys.clear - end - + end + =begin rdoc Sets the session_keys array. Only use these if you need to do something out of the ordinary, as it is handled @@ -109,17 +109,17 @@ do something out of the ordinary, as it is handled def session_keys=(keys) #:nodoc: @@session_keys=keys end - + def session_keys() #:nodoc: @@session_keys end - + end =begin rdoc This module handles all standard key management features. =end - module KeyHolder + module KeyHolder =begin rdoc Creates a key for object based on given password and an optional salt. @@ -137,10 +137,10 @@ Decodes the Base64 encoded key and uses it as it's session key =begin rdoc Sets a session key for the object. This should be a EzCrypto::Key instance. =end - def set_session_key(key) + def set_session_key(key) @session_key=key self.decrypt_attributes if self.class.include? Encrypted - end + end =begin rdoc Returns the session_key @@ -148,28 +148,28 @@ Returns the session_key def session_key @session_key end - + end - module AssociationKeyHolder + module AssociationKeyHolder include ActiveCrypto::KeyHolder - - + + def save_session_key ActiveRecord::Base.session_keys[session_key_id]=@session_key if @session_key end =begin rdoc Sets a session key for the object. This should be a EzCrypto::Key instance. =end - def set_session_key(key) + def set_session_key(key) if self.new_record? @session_key=key else ActiveRecord::Base.session_keys[session_key_id]=key end decrypt_attributes if self.class.include? Encrypted #if respond_to?(:decrypt_attributes) - - end + + end =begin rdoc Returns the session_key @@ -181,13 +181,13 @@ Returns the session_key ActiveRecord::Base.session_keys[session_key_id] end end - - + + def session_key_id "#{self.class.to_s}:#{id}" - end - + end + end module Encrypted #:nodoc: @@ -195,7 +195,7 @@ Returns the session_key super base.extend ClassAccessors end - + module ClassAccessors def encrypted_attributes @encrypted_attributes||=[] @@ -204,9 +204,9 @@ Returns the session_key def encrypted_attributes=(attrs) @encrypted_attributes=attrs end - + end - + protected def encrypt_attributes @@ -219,7 +219,7 @@ Returns the session_key end true end - + def decrypt_attributes if is_encrypted? self.class.encrypted_attributes.each do |key| @@ -230,17 +230,17 @@ Returns the session_key end true end - + def after_find @is_encrypted=true decrypt_attributes unless session_key.nil? end - + private def is_encrypted? @is_encrypted end - + def _decrypt(data) if session_key.nil? raise MissingKeyError @@ -252,11 +252,11 @@ Returns the session_key end end end - + def _encrypt(data) if session_key.nil? raise MissingKeyError - else + else if data self.class.ezcrypto_base64? ? session_key.encrypt64(data) : session_key.encrypt(data) else @@ -264,28 +264,28 @@ Returns the session_key end end end - + end - + module ActionController # :nodoc: =begin rdoc This includes some basic support in the ActionController for handling session keys. It creates two filters one before the action and one after. These do the following: - -If the users session already has a 'session_keys' value it loads it into the ActiveRecord::Base.session_keys class field. If not it + +If the users session already has a 'session_keys' value it loads it into the ActiveRecord::Base.session_keys class field. If not it clears any existing session_keys. Leaving the action it stores any session_keys in the corresponding session variable. These filters are automatically enabled. You do not have to do anything. - + To manually clear the session keys call clear_session_keys. This should be done for example as part of a session log off action. -=end +=end def self.append_features(base) #:nodoc: super base.send :prepend_before_filter, :load_session_keys - base.send :prepend_after_filter, :save_session_keys + base.send :prepend_after_filter, :save_session_keys end =begin rdoc @@ -294,8 +294,8 @@ Clears the session keys. Call this when a user logs of. def clear_session_keys ActiveRecord::Base.clear_session_keys end - - + + private def load_session_keys if session['session_keys'] @@ -312,14 +312,12 @@ Clears the session keys. Call this when a user logs of. session['session_keys']=nil end end - + end class MissingKeyError < RuntimeError -end +end end ActiveRecord::Base.send :include, ActiveCrypto -require 'actionpack' -require 'action_controller' ActionController::Base.send :include, ActiveCrypto::ActionController diff --git a/vendor/plugins/access_control/init.rb b/vendor/plugins/access_control/init.rb index 3ce5421..751ab99 100644 --- a/vendor/plugins/access_control/init.rb +++ b/vendor/plugins/access_control/init.rb @@ -1,6 +1,11 @@ +require 'access_control' require 'acts_as_accessor' require 'acts_as_accessible' require 'permission_name_helper' +require 'role' +require 'role_assignment' +require 'permission_check' + module ApplicationHelper include PermissionNameHelper end diff --git a/vendor/plugins/action_tracker/lib/action_tracker.rb b/vendor/plugins/action_tracker/lib/action_tracker.rb index 24ce96a..41294a5 100644 --- a/vendor/plugins/action_tracker/lib/action_tracker.rb +++ b/vendor/plugins/action_tracker/lib/action_tracker.rb @@ -1,4 +1,5 @@ require File.join(File.dirname(__FILE__), 'action_tracker_model.rb') +require 'user_stamp' module ActionTracker @@ -8,21 +9,21 @@ module ActionTracker base.send :user_stamp, ActionTracker::Record base.send :extend, ClassMethods end - + module ClassMethods def track_actions_after(verb, options = {}, &block) track_actions_by_time(verb, :after, options, &block) end - + def track_actions_before(verb, options = {}, &block) track_actions_by_time(verb, :before, options, &block) end - + def track_actions(verb, options = {}, &block) track_actions_by_time(verb, ActionTrackerConfig.default_filter_time, options, &block) end - + def track_actions_by_time(verb, time, options = {}, &block) keep_params = options.delete(:keep_params) || options.delete('keep_params') || :all send("#{time}_filter", options) do |x| @@ -32,7 +33,7 @@ module ActionTracker send :include, InstanceMethods end end - + module InstanceMethods def save_action_for_verb(verb, keep_params = :all) if keep_params.is_a? Array @@ -62,7 +63,7 @@ module ActionTracker def self.included(base) base.send :extend, ClassMethods end - + module ClassMethods def track_actions(verb, callback, options = {}, &block) keep_params = options.delete(:keep_params) || options.delete('keep_params') || :all @@ -78,11 +79,11 @@ module ActionTracker send :include, InstanceMethods end end - + module InstanceMethods def time_spent_doing(verb, conditions = {}) time = 0 - tracked_actions.all(:conditions => conditions.merge({ :verb => verb.to_s })).each do |t| + tracked_actions.all(:conditions => conditions.merge({ :verb => verb.to_s })).each do |t| time += t.updated_at - t.created_at end time.to_f diff --git a/vendor/plugins/action_tracker/lib/action_tracker_model.rb b/vendor/plugins/action_tracker/lib/action_tracker_model.rb index 66f50b7..586f81b 100644 --- a/vendor/plugins/action_tracker/lib/action_tracker_model.rb +++ b/vendor/plugins/action_tracker/lib/action_tracker_model.rb @@ -2,7 +2,7 @@ module ActionTracker class Record < ActiveRecord::Base attr_accessible :verb, :params, :user, :target - set_table_name 'action_tracker' + self.table_name = 'action_tracker' belongs_to :user, :polymorphic => true belongs_to :target, :polymorphic => true diff --git a/vendor/plugins/acts_as_tree/init.rb b/vendor/plugins/acts_as_tree/init.rb index 0901ddb..927308d 100644 --- a/vendor/plugins/acts_as_tree/init.rb +++ b/vendor/plugins/acts_as_tree/init.rb @@ -1 +1,3 @@ +require 'active_record/acts/tree' + ActiveRecord::Base.send :include, ActiveRecord::Acts::Tree diff --git a/vendor/plugins/user_stamp/init.rb b/vendor/plugins/user_stamp/init.rb deleted file mode 100644 index 18d0ac4..0000000 --- a/vendor/plugins/user_stamp/init.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'user_stamp' - -class ActionController::Base - extend UserStamp::ClassMethods -end diff --git a/vendor/plugins/user_stamp/lib/user_stamp.rb b/vendor/plugins/user_stamp/lib/user_stamp.rb index 001ad07..1fbbb69 100644 --- a/vendor/plugins/user_stamp/lib/user_stamp.rb +++ b/vendor/plugins/user_stamp/lib/user_stamp.rb @@ -2,19 +2,19 @@ module UserStamp mattr_accessor :creator_attribute mattr_accessor :updater_attribute mattr_accessor :current_user_method - + def self.creator_assignment_method "#{UserStamp.creator_attribute}=" end - + def self.updater_assignment_method "#{UserStamp.updater_attribute}=" end - + module ClassMethods def user_stamp(*models) models.each { |klass| UserStampSweeper.observe(klass) } - + class_eval do cache_sweeper :user_stamp_sweeper end @@ -26,25 +26,34 @@ UserStamp.creator_attribute = :creator_id UserStamp.updater_attribute = :updater_id UserStamp.current_user_method = :current_user +# see https://github.com/rails/rails-observers/issues/4 +require 'rails/observers/active_model/active_model' +require "rails/observers/activerecord/active_record" +require 'rails/observers/action_controller/caching' + class UserStampSweeper < ActionController::Caching::Sweeper def before_validation(record) return unless current_user - + attribute, method = UserStamp.creator_attribute, UserStamp.creator_assignment_method if record.respond_to?(method) && record.new_record? record.send(method, current_user) unless record.send("#{attribute}_id_changed?") || record.send("#{attribute}_type_changed?") end - + attribute, method = UserStamp.updater_attribute, UserStamp.updater_assignment_method if record.respond_to?(method) record.send(method, current_user) if record.send(attribute).blank? end end - - private + + private def current_user if controller.respond_to?(UserStamp.current_user_method) controller.send UserStamp.current_user_method end end end + +class ActionController::Base + extend UserStamp::ClassMethods +end -- libgit2 0.21.2