Commit 21810adf771dd26a9d14ced33403ad525565b88d
1 parent
422b350a
Exists in
master
and in
11 other branches
rails4: require missing dependencies
Showing
7 changed files
with
84 additions
and
74 deletions
Show diff stats
vendor/ezcrypto/lib/active_crypto.rb
| 1 | 1 | require "ezcrypto.rb" |
| 2 | 2 | module ActiveCrypto # :nodoc: |
| 3 | - | |
| 3 | + | |
| 4 | 4 | def self.append_features(base) #:nodoc: |
| 5 | 5 | super |
| 6 | 6 | base.extend(ClassMethods) |
| 7 | 7 | end |
| 8 | - | |
| 8 | + | |
| 9 | 9 | =begin rdoc |
| 10 | 10 | |
| 11 | 11 | 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: |
| 47 | 47 | belongs_to :user |
| 48 | 48 | encrypt :title,:body,:key=>:user, :base64 => true |
| 49 | 49 | end |
| 50 | - | |
| 50 | + | |
| 51 | 51 | =end |
| 52 | - def encrypt(*attributes) | |
| 52 | + def encrypt(*attributes) | |
| 53 | 53 | include ActiveCrypto::Encrypted |
| 54 | 54 | before_save :encrypt_attributes |
| 55 | 55 | after_save :decrypt_attributes |
| 56 | 56 | options=attributes.last.is_a?(Hash) ? attributes.pop : {} |
| 57 | 57 | keyholder |
| 58 | 58 | if options and options[:key] |
| 59 | - module_eval <<-"end;" | |
| 59 | + module_eval <<-"end;" | |
| 60 | 60 | def session_key |
| 61 | 61 | (send :#{options[:key]} ).send :session_key |
| 62 | - end | |
| 62 | + end | |
| 63 | 63 | @@external_key=true |
| 64 | 64 | end; |
| 65 | 65 | end |
| ... | ... | @@ -70,10 +70,10 @@ Options are: |
| 70 | 70 | #{base64_encode.to_s} |
| 71 | 71 | end |
| 72 | 72 | end; |
| 73 | - | |
| 73 | + | |
| 74 | 74 | self.encrypted_attributes=attributes |
| 75 | - end | |
| 76 | - | |
| 75 | + end | |
| 76 | + | |
| 77 | 77 | =begin rdoc |
| 78 | 78 | Creates support in this class for holding a key. Adds the following methods: |
| 79 | 79 | |
| ... | ... | @@ -88,10 +88,10 @@ Use it as follows: |
| 88 | 88 | keyholder |
| 89 | 89 | end |
| 90 | 90 | |
| 91 | -=end | |
| 91 | +=end | |
| 92 | 92 | def keyholder() |
| 93 | - include ActiveCrypto::AssociationKeyHolder | |
| 94 | - after_create :save_session_key | |
| 93 | + include ActiveCrypto::AssociationKeyHolder | |
| 94 | + after_create :save_session_key | |
| 95 | 95 | end |
| 96 | 96 | |
| 97 | 97 | =begin rdoc |
| ... | ... | @@ -100,8 +100,8 @@ do something out of the ordinary. |
| 100 | 100 | =end |
| 101 | 101 | def clear_session_keys() #:nodoc: |
| 102 | 102 | @@session_keys.clear |
| 103 | - end | |
| 104 | - | |
| 103 | + end | |
| 104 | + | |
| 105 | 105 | =begin rdoc |
| 106 | 106 | Sets the session_keys array. Only use these if you need to |
| 107 | 107 | do something out of the ordinary, as it is handled |
| ... | ... | @@ -109,17 +109,17 @@ do something out of the ordinary, as it is handled |
| 109 | 109 | def session_keys=(keys) #:nodoc: |
| 110 | 110 | @@session_keys=keys |
| 111 | 111 | end |
| 112 | - | |
| 112 | + | |
| 113 | 113 | def session_keys() #:nodoc: |
| 114 | 114 | @@session_keys |
| 115 | 115 | end |
| 116 | - | |
| 116 | + | |
| 117 | 117 | end |
| 118 | 118 | |
| 119 | 119 | =begin rdoc |
| 120 | 120 | This module handles all standard key management features. |
| 121 | 121 | =end |
| 122 | - module KeyHolder | |
| 122 | + module KeyHolder | |
| 123 | 123 | |
| 124 | 124 | =begin rdoc |
| 125 | 125 | 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 |
| 137 | 137 | =begin rdoc |
| 138 | 138 | Sets a session key for the object. This should be a EzCrypto::Key instance. |
| 139 | 139 | =end |
| 140 | - def set_session_key(key) | |
| 140 | + def set_session_key(key) | |
| 141 | 141 | @session_key=key |
| 142 | 142 | self.decrypt_attributes if self.class.include? Encrypted |
| 143 | - end | |
| 143 | + end | |
| 144 | 144 | |
| 145 | 145 | =begin rdoc |
| 146 | 146 | Returns the session_key |
| ... | ... | @@ -148,28 +148,28 @@ Returns the session_key |
| 148 | 148 | def session_key |
| 149 | 149 | @session_key |
| 150 | 150 | end |
| 151 | - | |
| 151 | + | |
| 152 | 152 | end |
| 153 | 153 | |
| 154 | - module AssociationKeyHolder | |
| 154 | + module AssociationKeyHolder | |
| 155 | 155 | include ActiveCrypto::KeyHolder |
| 156 | - | |
| 157 | - | |
| 156 | + | |
| 157 | + | |
| 158 | 158 | def save_session_key |
| 159 | 159 | ActiveRecord::Base.session_keys[session_key_id]=@session_key if @session_key |
| 160 | 160 | end |
| 161 | 161 | =begin rdoc |
| 162 | 162 | Sets a session key for the object. This should be a EzCrypto::Key instance. |
| 163 | 163 | =end |
| 164 | - def set_session_key(key) | |
| 164 | + def set_session_key(key) | |
| 165 | 165 | if self.new_record? |
| 166 | 166 | @session_key=key |
| 167 | 167 | else |
| 168 | 168 | ActiveRecord::Base.session_keys[session_key_id]=key |
| 169 | 169 | end |
| 170 | 170 | decrypt_attributes if self.class.include? Encrypted #if respond_to?(:decrypt_attributes) |
| 171 | - | |
| 172 | - end | |
| 171 | + | |
| 172 | + end | |
| 173 | 173 | |
| 174 | 174 | =begin rdoc |
| 175 | 175 | Returns the session_key |
| ... | ... | @@ -181,13 +181,13 @@ Returns the session_key |
| 181 | 181 | ActiveRecord::Base.session_keys[session_key_id] |
| 182 | 182 | end |
| 183 | 183 | end |
| 184 | - | |
| 185 | - | |
| 184 | + | |
| 185 | + | |
| 186 | 186 | |
| 187 | 187 | def session_key_id |
| 188 | 188 | "#{self.class.to_s}:#{id}" |
| 189 | - end | |
| 190 | - | |
| 189 | + end | |
| 190 | + | |
| 191 | 191 | end |
| 192 | 192 | |
| 193 | 193 | module Encrypted #:nodoc: |
| ... | ... | @@ -195,7 +195,7 @@ Returns the session_key |
| 195 | 195 | super |
| 196 | 196 | base.extend ClassAccessors |
| 197 | 197 | end |
| 198 | - | |
| 198 | + | |
| 199 | 199 | module ClassAccessors |
| 200 | 200 | def encrypted_attributes |
| 201 | 201 | @encrypted_attributes||=[] |
| ... | ... | @@ -204,9 +204,9 @@ Returns the session_key |
| 204 | 204 | def encrypted_attributes=(attrs) |
| 205 | 205 | @encrypted_attributes=attrs |
| 206 | 206 | end |
| 207 | - | |
| 207 | + | |
| 208 | 208 | end |
| 209 | - | |
| 209 | + | |
| 210 | 210 | protected |
| 211 | 211 | |
| 212 | 212 | def encrypt_attributes |
| ... | ... | @@ -219,7 +219,7 @@ Returns the session_key |
| 219 | 219 | end |
| 220 | 220 | true |
| 221 | 221 | end |
| 222 | - | |
| 222 | + | |
| 223 | 223 | def decrypt_attributes |
| 224 | 224 | if is_encrypted? |
| 225 | 225 | self.class.encrypted_attributes.each do |key| |
| ... | ... | @@ -230,17 +230,17 @@ Returns the session_key |
| 230 | 230 | end |
| 231 | 231 | true |
| 232 | 232 | end |
| 233 | - | |
| 233 | + | |
| 234 | 234 | def after_find |
| 235 | 235 | @is_encrypted=true |
| 236 | 236 | decrypt_attributes unless session_key.nil? |
| 237 | 237 | end |
| 238 | - | |
| 238 | + | |
| 239 | 239 | private |
| 240 | 240 | def is_encrypted? |
| 241 | 241 | @is_encrypted |
| 242 | 242 | end |
| 243 | - | |
| 243 | + | |
| 244 | 244 | def _decrypt(data) |
| 245 | 245 | if session_key.nil? |
| 246 | 246 | raise MissingKeyError |
| ... | ... | @@ -252,11 +252,11 @@ Returns the session_key |
| 252 | 252 | end |
| 253 | 253 | end |
| 254 | 254 | end |
| 255 | - | |
| 255 | + | |
| 256 | 256 | def _encrypt(data) |
| 257 | 257 | if session_key.nil? |
| 258 | 258 | raise MissingKeyError |
| 259 | - else | |
| 259 | + else | |
| 260 | 260 | if data |
| 261 | 261 | self.class.ezcrypto_base64? ? session_key.encrypt64(data) : session_key.encrypt(data) |
| 262 | 262 | else |
| ... | ... | @@ -264,28 +264,28 @@ Returns the session_key |
| 264 | 264 | end |
| 265 | 265 | end |
| 266 | 266 | end |
| 267 | - | |
| 267 | + | |
| 268 | 268 | end |
| 269 | - | |
| 269 | + | |
| 270 | 270 | |
| 271 | 271 | module ActionController # :nodoc: |
| 272 | 272 | =begin rdoc |
| 273 | 273 | This includes some basic support in the ActionController for handling session keys. It creates two filters one before the action and one after. |
| 274 | 274 | These do the following: |
| 275 | - | |
| 276 | -If the users session already has a 'session_keys' value it loads it into the ActiveRecord::Base.session_keys class field. If not it | |
| 275 | + | |
| 276 | +If the users session already has a 'session_keys' value it loads it into the ActiveRecord::Base.session_keys class field. If not it | |
| 277 | 277 | clears any existing session_keys. |
| 278 | 278 | |
| 279 | 279 | Leaving the action it stores any session_keys in the corresponding session variable. |
| 280 | 280 | |
| 281 | 281 | These filters are automatically enabled. You do not have to do anything. |
| 282 | - | |
| 282 | + | |
| 283 | 283 | To manually clear the session keys call clear_session_keys. This should be done for example as part of a session log off action. |
| 284 | -=end | |
| 284 | +=end | |
| 285 | 285 | def self.append_features(base) #:nodoc: |
| 286 | 286 | super |
| 287 | 287 | base.send :prepend_before_filter, :load_session_keys |
| 288 | - base.send :prepend_after_filter, :save_session_keys | |
| 288 | + base.send :prepend_after_filter, :save_session_keys | |
| 289 | 289 | end |
| 290 | 290 | |
| 291 | 291 | =begin rdoc |
| ... | ... | @@ -294,8 +294,8 @@ Clears the session keys. Call this when a user logs of. |
| 294 | 294 | def clear_session_keys |
| 295 | 295 | ActiveRecord::Base.clear_session_keys |
| 296 | 296 | end |
| 297 | - | |
| 298 | - | |
| 297 | + | |
| 298 | + | |
| 299 | 299 | private |
| 300 | 300 | def load_session_keys |
| 301 | 301 | if session['session_keys'] |
| ... | ... | @@ -312,14 +312,12 @@ Clears the session keys. Call this when a user logs of. |
| 312 | 312 | session['session_keys']=nil |
| 313 | 313 | end |
| 314 | 314 | end |
| 315 | - | |
| 315 | + | |
| 316 | 316 | |
| 317 | 317 | end |
| 318 | 318 | |
| 319 | 319 | class MissingKeyError < RuntimeError |
| 320 | -end | |
| 320 | +end | |
| 321 | 321 | end |
| 322 | 322 | ActiveRecord::Base.send :include, ActiveCrypto |
| 323 | -require 'actionpack' | |
| 324 | -require 'action_controller' | |
| 325 | 323 | ActionController::Base.send :include, ActiveCrypto::ActionController | ... | ... |
vendor/plugins/access_control/init.rb
vendor/plugins/action_tracker/lib/action_tracker.rb
| 1 | 1 | require File.join(File.dirname(__FILE__), 'action_tracker_model.rb') |
| 2 | +require 'user_stamp' | |
| 2 | 3 | |
| 3 | 4 | module ActionTracker |
| 4 | 5 | |
| ... | ... | @@ -8,21 +9,21 @@ module ActionTracker |
| 8 | 9 | base.send :user_stamp, ActionTracker::Record |
| 9 | 10 | base.send :extend, ClassMethods |
| 10 | 11 | end |
| 11 | - | |
| 12 | + | |
| 12 | 13 | module ClassMethods |
| 13 | 14 | |
| 14 | 15 | def track_actions_after(verb, options = {}, &block) |
| 15 | 16 | track_actions_by_time(verb, :after, options, &block) |
| 16 | 17 | end |
| 17 | - | |
| 18 | + | |
| 18 | 19 | def track_actions_before(verb, options = {}, &block) |
| 19 | 20 | track_actions_by_time(verb, :before, options, &block) |
| 20 | 21 | end |
| 21 | - | |
| 22 | + | |
| 22 | 23 | def track_actions(verb, options = {}, &block) |
| 23 | 24 | track_actions_by_time(verb, ActionTrackerConfig.default_filter_time, options, &block) |
| 24 | 25 | end |
| 25 | - | |
| 26 | + | |
| 26 | 27 | def track_actions_by_time(verb, time, options = {}, &block) |
| 27 | 28 | keep_params = options.delete(:keep_params) || options.delete('keep_params') || :all |
| 28 | 29 | send("#{time}_filter", options) do |x| |
| ... | ... | @@ -32,7 +33,7 @@ module ActionTracker |
| 32 | 33 | send :include, InstanceMethods |
| 33 | 34 | end |
| 34 | 35 | end |
| 35 | - | |
| 36 | + | |
| 36 | 37 | module InstanceMethods |
| 37 | 38 | def save_action_for_verb(verb, keep_params = :all) |
| 38 | 39 | if keep_params.is_a? Array |
| ... | ... | @@ -62,7 +63,7 @@ module ActionTracker |
| 62 | 63 | def self.included(base) |
| 63 | 64 | base.send :extend, ClassMethods |
| 64 | 65 | end |
| 65 | - | |
| 66 | + | |
| 66 | 67 | module ClassMethods |
| 67 | 68 | def track_actions(verb, callback, options = {}, &block) |
| 68 | 69 | keep_params = options.delete(:keep_params) || options.delete('keep_params') || :all |
| ... | ... | @@ -78,11 +79,11 @@ module ActionTracker |
| 78 | 79 | send :include, InstanceMethods |
| 79 | 80 | end |
| 80 | 81 | end |
| 81 | - | |
| 82 | + | |
| 82 | 83 | module InstanceMethods |
| 83 | 84 | def time_spent_doing(verb, conditions = {}) |
| 84 | 85 | time = 0 |
| 85 | - tracked_actions.all(:conditions => conditions.merge({ :verb => verb.to_s })).each do |t| | |
| 86 | + tracked_actions.all(:conditions => conditions.merge({ :verb => verb.to_s })).each do |t| | |
| 86 | 87 | time += t.updated_at - t.created_at |
| 87 | 88 | end |
| 88 | 89 | time.to_f | ... | ... |
vendor/plugins/action_tracker/lib/action_tracker_model.rb
| ... | ... | @@ -2,7 +2,7 @@ module ActionTracker |
| 2 | 2 | class Record < ActiveRecord::Base |
| 3 | 3 | attr_accessible :verb, :params, :user, :target |
| 4 | 4 | |
| 5 | - set_table_name 'action_tracker' | |
| 5 | + self.table_name = 'action_tracker' | |
| 6 | 6 | |
| 7 | 7 | belongs_to :user, :polymorphic => true |
| 8 | 8 | belongs_to :target, :polymorphic => true | ... | ... |
vendor/plugins/acts_as_tree/init.rb
vendor/plugins/user_stamp/init.rb
vendor/plugins/user_stamp/lib/user_stamp.rb
| ... | ... | @@ -2,19 +2,19 @@ module UserStamp |
| 2 | 2 | mattr_accessor :creator_attribute |
| 3 | 3 | mattr_accessor :updater_attribute |
| 4 | 4 | mattr_accessor :current_user_method |
| 5 | - | |
| 5 | + | |
| 6 | 6 | def self.creator_assignment_method |
| 7 | 7 | "#{UserStamp.creator_attribute}=" |
| 8 | 8 | end |
| 9 | - | |
| 9 | + | |
| 10 | 10 | def self.updater_assignment_method |
| 11 | 11 | "#{UserStamp.updater_attribute}=" |
| 12 | 12 | end |
| 13 | - | |
| 13 | + | |
| 14 | 14 | module ClassMethods |
| 15 | 15 | def user_stamp(*models) |
| 16 | 16 | models.each { |klass| UserStampSweeper.observe(klass) } |
| 17 | - | |
| 17 | + | |
| 18 | 18 | class_eval do |
| 19 | 19 | cache_sweeper :user_stamp_sweeper |
| 20 | 20 | end |
| ... | ... | @@ -26,25 +26,34 @@ UserStamp.creator_attribute = :creator_id |
| 26 | 26 | UserStamp.updater_attribute = :updater_id |
| 27 | 27 | UserStamp.current_user_method = :current_user |
| 28 | 28 | |
| 29 | +# see https://github.com/rails/rails-observers/issues/4 | |
| 30 | +require 'rails/observers/active_model/active_model' | |
| 31 | +require "rails/observers/activerecord/active_record" | |
| 32 | +require 'rails/observers/action_controller/caching' | |
| 33 | + | |
| 29 | 34 | class UserStampSweeper < ActionController::Caching::Sweeper |
| 30 | 35 | def before_validation(record) |
| 31 | 36 | return unless current_user |
| 32 | - | |
| 37 | + | |
| 33 | 38 | attribute, method = UserStamp.creator_attribute, UserStamp.creator_assignment_method |
| 34 | 39 | if record.respond_to?(method) && record.new_record? |
| 35 | 40 | record.send(method, current_user) unless record.send("#{attribute}_id_changed?") || record.send("#{attribute}_type_changed?") |
| 36 | 41 | end |
| 37 | - | |
| 42 | + | |
| 38 | 43 | attribute, method = UserStamp.updater_attribute, UserStamp.updater_assignment_method |
| 39 | 44 | if record.respond_to?(method) |
| 40 | 45 | record.send(method, current_user) if record.send(attribute).blank? |
| 41 | 46 | end |
| 42 | 47 | end |
| 43 | - | |
| 44 | - private | |
| 48 | + | |
| 49 | + private | |
| 45 | 50 | def current_user |
| 46 | 51 | if controller.respond_to?(UserStamp.current_user_method) |
| 47 | 52 | controller.send UserStamp.current_user_method |
| 48 | 53 | end |
| 49 | 54 | end |
| 50 | 55 | end |
| 56 | + | |
| 57 | +class ActionController::Base | |
| 58 | + extend UserStamp::ClassMethods | |
| 59 | +end | ... | ... |