public_activity 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +6 -14
- data/Gemfile +2 -2
- data/lib/public_activity.rb +18 -9
- data/lib/public_activity/activity.rb +4 -0
- data/lib/public_activity/common.rb +10 -11
- data/lib/public_activity/config.rb +0 -10
- data/lib/public_activity/models/activist.rb +7 -0
- data/lib/public_activity/models/activity.rb +4 -0
- data/lib/public_activity/models/adapter.rb +4 -0
- data/lib/public_activity/models/trackable.rb +7 -0
- data/lib/public_activity/orm/active_record/activist.rb +3 -0
- data/lib/public_activity/orm/active_record/adapter.rb +4 -6
- data/lib/public_activity/orm/active_record/trackable.rb +1 -1
- data/lib/public_activity/orm/mongoid/activist.rb +3 -0
- data/lib/public_activity/orm/mongoid/adapter.rb +4 -6
- data/lib/public_activity/orm/mongoid/trackable.rb +1 -1
- data/lib/public_activity/roles/tracked.rb +2 -2
- data/lib/public_activity/version.rb +1 -1
- metadata +13 -8
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
ZWFhOWI3NWNlMTlhZGRlYjU3NThiZjMyZGMxMDdmMTk3MTdjZDU2MTBlYTkw
|
10
|
-
ZDM4YTllMjNlZjVmNTk1OWE1MWI3NDc4OGFiY2E1ZmIyZjdiZGJhNzlmMmFk
|
11
|
-
OWUzZGVlNWE1NTAwMTkzNGJkNDUwMWJkZDI0YmRkNWQ4OGY3ZmE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZTg0N2JlNDBlOWViOTE5NWIzYjZmMmI0YTU4MmE5ODM0ZWVkN2ZiM2UzYzQy
|
14
|
-
ZGM4NWYzNGEzMjQ5NWYzMjAzMWM1OWIyYzdmMGRjMjVkMmQxODM5ZTExODY2
|
15
|
-
MjE3NDhjYjM5NDYzN2EyMWRhYTIwOTNkYWUyZDRhZGExMWY0NDU=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8fd39acfbf854c069a2b94620e3053830683b8fb
|
4
|
+
data.tar.gz: d8c98bb1597029b47b4926aa98afd16a5afaf7ce
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b21e5ce84fd4c69efb5c0a8ea47ad594c46d2405340ee51930ce7d05f9249adc173a25f2120bb404d475339a7c95716ee23053b1c8dcd1dab5b544a9e6bda888
|
7
|
+
data.tar.gz: e41642ab559c0616592d20e59ccbbec11e0bd3183855b493fe819bddb60bc04d9a5cd820086afc97c77eb055faa06daa44a726b569b7ec21ececb3748c54fcc5
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
ENV['PA_ORM'] ||= 'active_record'
|
2
2
|
|
3
|
-
source
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
5
|
|
6
6
|
case ENV['PA_ORM']
|
@@ -14,7 +14,7 @@ group :development, :test do
|
|
14
14
|
gem 'sqlite3', '~> 1.3.7' if ENV['PA_ORM'] == 'active_record'
|
15
15
|
gem 'mocha', '~> 0.13.0', require: false
|
16
16
|
gem 'simplecov', '~> 0.7.0'
|
17
|
-
gem 'minitest', '
|
17
|
+
gem 'minitest', '< 5.0.0'
|
18
18
|
gem 'redcarpet'
|
19
19
|
gem 'yard', '~> 0.8'
|
20
20
|
end
|
data/lib/public_activity.rb
CHANGED
@@ -8,15 +8,20 @@ require 'action_view'
|
|
8
8
|
module PublicActivity
|
9
9
|
extend ActiveSupport::Concern
|
10
10
|
extend ActiveSupport::Autoload
|
11
|
+
|
12
|
+
autoload :Activity, 'public_activity/models/activity'
|
13
|
+
autoload :Activist, 'public_activity/models/activist'
|
14
|
+
autoload :Adapter, 'public_activity/models/adapter'
|
15
|
+
autoload :Trackable, 'public_activity/models/trackable'
|
16
|
+
autoload :Common
|
11
17
|
autoload :Config
|
12
|
-
autoload :Tracked, 'public_activity/roles/tracked.rb'
|
13
|
-
autoload :Deactivatable,'public_activity/roles/deactivatable.rb'
|
14
18
|
autoload :Creation, 'public_activity/actions/creation.rb'
|
15
|
-
autoload :
|
19
|
+
autoload :Deactivatable,'public_activity/roles/deactivatable.rb'
|
16
20
|
autoload :Destruction, 'public_activity/actions/destruction.rb'
|
17
|
-
autoload :VERSION
|
18
|
-
autoload :Common
|
19
21
|
autoload :Renderable
|
22
|
+
autoload :Tracked, 'public_activity/roles/tracked.rb'
|
23
|
+
autoload :Update, 'public_activity/actions/update.rb'
|
24
|
+
autoload :VERSION
|
20
25
|
|
21
26
|
# Switches PublicActivity on or off.
|
22
27
|
# @param value [Boolean]
|
@@ -39,6 +44,14 @@ module PublicActivity
|
|
39
44
|
@@config ||= PublicActivity::Config.instance
|
40
45
|
end
|
41
46
|
|
47
|
+
# Method used to choose which ORM to load
|
48
|
+
# when PublicActivity::Activity class is being autoloaded
|
49
|
+
def self.inherit_orm(model="Activity")
|
50
|
+
orm = PublicActivity.config.orm
|
51
|
+
require "public_activity/orm/#{orm.to_s}"
|
52
|
+
"PublicActivity::ORM::#{orm.to_s.classify}::#{model}".constantize
|
53
|
+
end
|
54
|
+
|
42
55
|
# Module to be included in ActiveRecord models. Adds required functionality.
|
43
56
|
module Model
|
44
57
|
extend ActiveSupport::Concern
|
@@ -51,9 +64,5 @@ module PublicActivity
|
|
51
64
|
end
|
52
65
|
end
|
53
66
|
|
54
|
-
# Force Active Record ORM to load
|
55
|
-
# makes initializer optional for default config
|
56
|
-
PublicActivity.config if defined? ActiveRecord
|
57
|
-
|
58
67
|
require 'public_activity/utility/store_controller'
|
59
68
|
require 'public_activity/utility/view_helpers'
|
@@ -22,8 +22,6 @@ module PublicActivity
|
|
22
22
|
extend ActiveSupport::Concern
|
23
23
|
|
24
24
|
included do
|
25
|
-
::PublicActivity.config # it's the first module to be loaded into models
|
26
|
-
# we need to have pieces provided by orm loaded
|
27
25
|
include Trackable
|
28
26
|
class_attribute :activity_owner_global, :activity_recipient_global,
|
29
27
|
:activity_params_global, :activity_hooks, :activity_custom_fields_global
|
@@ -273,9 +271,7 @@ module PublicActivity
|
|
273
271
|
all_options = args.extract_options!
|
274
272
|
options = {
|
275
273
|
key: all_options.delete(:key),
|
276
|
-
owner: all_options.delete(:owner),
|
277
274
|
action: all_options.delete(:action),
|
278
|
-
recipient: all_options.delete(:recipient),
|
279
275
|
parameters: all_options.delete(:parameters) || all_options.delete(:params)
|
280
276
|
}
|
281
277
|
action = (args.first || options[:action]).try(:to_s)
|
@@ -288,22 +284,25 @@ module PublicActivity
|
|
288
284
|
|
289
285
|
# user responsible for the activity
|
290
286
|
options[:owner] = PublicActivity.resolve_value(self,
|
291
|
-
|
292
|
-
|
293
|
-
|
287
|
+
(all_options.has_key?(:owner) ? all_options[:owner] : (
|
288
|
+
self.activity_owner || self.class.activity_owner_global
|
289
|
+
)
|
290
|
+
)
|
294
291
|
)
|
295
292
|
|
296
293
|
# recipient of the activity
|
297
294
|
options[:recipient] = PublicActivity.resolve_value(self,
|
298
|
-
|
299
|
-
|
300
|
-
|
295
|
+
(all_options.has_key?(:recipient) ? all_options[:recipient] : (
|
296
|
+
self.activity_recipient || self.class.activity_recipient_global
|
297
|
+
)
|
298
|
+
)
|
301
299
|
)
|
302
300
|
|
303
301
|
#customizable parameters
|
304
|
-
params =
|
302
|
+
params = {}
|
305
303
|
params.merge!(self.class.activity_params_global)
|
306
304
|
params.merge!(self.activity_params) if self.activity_params
|
305
|
+
params.merge!(options[:params] || options[:parameters] || {})
|
307
306
|
params.each { |k, v| params[k] = PublicActivity.resolve_value(self, v) }
|
308
307
|
options[:parameters] = params
|
309
308
|
options.delete(:params)
|
@@ -11,7 +11,6 @@ module PublicActivity
|
|
11
11
|
def initialize
|
12
12
|
# Indicates whether PublicActivity is enabled globally
|
13
13
|
@enabled = true
|
14
|
-
load_orm
|
15
14
|
end
|
16
15
|
|
17
16
|
def self.set &block
|
@@ -36,15 +35,6 @@ module PublicActivity
|
|
36
35
|
self.class.orm(orm)
|
37
36
|
end
|
38
37
|
|
39
|
-
def load_orm
|
40
|
-
require "public_activity/orm/#{@@orm.to_s}"
|
41
|
-
m = "PublicActivity::ORM::#{@@orm.to_s.classify}".constantize
|
42
|
-
::PublicActivity.const_set(:Activity, m.const_get(:Activity))
|
43
|
-
::PublicActivity.const_set(:Adapter, m.const_get(:Adapter))
|
44
|
-
::PublicActivity.const_set(:Activist, m.const_get(:Activist))
|
45
|
-
::PublicActivity.const_set(:Trackable, m.const_get(:Trackable))
|
46
|
-
end
|
47
|
-
|
48
38
|
class Block
|
49
39
|
def orm(orm = nil)
|
50
40
|
@orm = (orm ? orm.to_sym : false) || @orm
|
@@ -5,6 +5,9 @@ module PublicActivity
|
|
5
5
|
module Activist
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
|
+
def self.extended(base)
|
9
|
+
base.extend(ClassMethods)
|
10
|
+
end
|
8
11
|
# Association of activities as their owner.
|
9
12
|
# @!method activities
|
10
13
|
# @return [Array<Activity>] Activities which self is the owner of.
|
@@ -1,12 +1,10 @@
|
|
1
1
|
module PublicActivity
|
2
2
|
module ORM
|
3
3
|
module ActiveRecord
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
trackable.activities.create options
|
9
|
-
end
|
4
|
+
class Adapter
|
5
|
+
# Creates the activity on `trackable` with `options`
|
6
|
+
def self.create_activity(trackable, options)
|
7
|
+
trackable.activities.create options
|
10
8
|
end
|
11
9
|
end
|
12
10
|
end
|
@@ -5,6 +5,9 @@ module PublicActivity
|
|
5
5
|
module Activist
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
|
+
def self.extended(base)
|
9
|
+
base.extend(ClassMethods)
|
10
|
+
end
|
8
11
|
# Association of activities as their owner.
|
9
12
|
# @!method activities
|
10
13
|
# @return [Array<Activity>] Activities which self is the owner of.
|
@@ -1,12 +1,10 @@
|
|
1
1
|
module PublicActivity
|
2
2
|
module ORM
|
3
3
|
module Mongoid
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
trackable.activities.create options
|
9
|
-
end
|
4
|
+
class Adapter
|
5
|
+
# Creates the activity on `trackable` with `options`
|
6
|
+
def self.create_activity(trackable, options)
|
7
|
+
trackable.activities.create options
|
10
8
|
end
|
11
9
|
end
|
12
10
|
end
|
@@ -50,7 +50,7 @@ module PublicActivity
|
|
50
50
|
# == Examples:
|
51
51
|
#
|
52
52
|
# tracked :owner => :author
|
53
|
-
# tracked :owner => {|o| o.author}
|
53
|
+
# tracked :owner => proc {|o| o.author}
|
54
54
|
#
|
55
55
|
# Keep in mind that owner relation is polymorphic, so you can't just
|
56
56
|
# provide id number of the owner object.
|
@@ -60,7 +60,7 @@ module PublicActivity
|
|
60
60
|
# == Examples:
|
61
61
|
#
|
62
62
|
# tracked :recipient => :author
|
63
|
-
# tracked :recipient => {|o| o.author}
|
63
|
+
# tracked :recipient => proc {|o| o.author}
|
64
64
|
#
|
65
65
|
# Keep in mind that recipient relation is polymorphic, so you can't just
|
66
66
|
# provide id number of the owner object.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: public_activity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotrek Okoński
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -43,14 +43,14 @@ dependencies:
|
|
43
43
|
name: i18n
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - '>='
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: 0.5.0
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - '>='
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: 0.5.0
|
56
56
|
- !ruby/object:Gem::Dependency
|
@@ -86,8 +86,13 @@ files:
|
|
86
86
|
- lib/public_activity/actions/creation.rb
|
87
87
|
- lib/public_activity/actions/destruction.rb
|
88
88
|
- lib/public_activity/actions/update.rb
|
89
|
+
- lib/public_activity/activity.rb
|
89
90
|
- lib/public_activity/common.rb
|
90
91
|
- lib/public_activity/config.rb
|
92
|
+
- lib/public_activity/models/activist.rb
|
93
|
+
- lib/public_activity/models/activity.rb
|
94
|
+
- lib/public_activity/models/adapter.rb
|
95
|
+
- lib/public_activity/models/trackable.rb
|
91
96
|
- lib/public_activity/orm/active_record.rb
|
92
97
|
- lib/public_activity/orm/active_record/activist.rb
|
93
98
|
- lib/public_activity/orm/active_record/activity.rb
|
@@ -112,7 +117,7 @@ files:
|
|
112
117
|
homepage: https://github.com/pokonski/public_activity
|
113
118
|
licenses: []
|
114
119
|
metadata: {}
|
115
|
-
post_install_message:
|
120
|
+
post_install_message: "##################################################\n# NOTE
|
116
121
|
FOR UPGRADING FROM PRE-0.4.0 VERSION #\n##################################################\n\npublic_activity
|
117
122
|
0.4.0 brings major changes compared to 0.3.X versions,\nplease read https://github.com/pokonski/public_activity#upgrading
|
118
123
|
\nto learn about all the changes you need to apply to properly\nupgrade your applications.\n"
|
@@ -121,17 +126,17 @@ require_paths:
|
|
121
126
|
- lib
|
122
127
|
required_ruby_version: !ruby/object:Gem::Requirement
|
123
128
|
requirements:
|
124
|
-
- -
|
129
|
+
- - '>='
|
125
130
|
- !ruby/object:Gem::Version
|
126
131
|
version: 1.9.2
|
127
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
133
|
requirements:
|
129
|
-
- -
|
134
|
+
- - '>='
|
130
135
|
- !ruby/object:Gem::Version
|
131
136
|
version: '0'
|
132
137
|
requirements: []
|
133
138
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.0.
|
139
|
+
rubygems_version: 2.0.3
|
135
140
|
signing_key:
|
136
141
|
specification_version: 4
|
137
142
|
summary: Easy activity tracking for ActiveRecord models
|