public_activity 1.6.3 → 1.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/README.md +4 -4
- data/Rakefile +2 -0
- data/lib/generators/public_activity.rb +2 -0
- data/lib/generators/public_activity/activity/activity_generator.rb +2 -0
- data/lib/generators/public_activity/activity/templates/activity.rb +2 -0
- data/lib/generators/public_activity/migration/migration_generator.rb +2 -0
- data/lib/generators/public_activity/migration/templates/migration.rb +2 -0
- data/lib/generators/public_activity/migration_upgrade/migration_upgrade_generator.rb +2 -0
- data/lib/generators/public_activity/migration_upgrade/templates/upgrade.rb +2 -0
- data/lib/public_activity.rb +2 -0
- data/lib/public_activity/actions/creation.rb +3 -1
- data/lib/public_activity/actions/destruction.rb +2 -0
- data/lib/public_activity/actions/update.rb +2 -0
- data/lib/public_activity/activity.rb +3 -1
- data/lib/public_activity/common.rb +16 -0
- data/lib/public_activity/config.rb +2 -0
- data/lib/public_activity/models/activist.rb +3 -1
- data/lib/public_activity/models/activity.rb +3 -1
- data/lib/public_activity/models/adapter.rb +3 -1
- data/lib/public_activity/models/trackable.rb +3 -1
- data/lib/public_activity/orm/active_record.rb +3 -1
- data/lib/public_activity/orm/active_record/activist.rb +2 -0
- data/lib/public_activity/orm/active_record/activity.rb +17 -1
- data/lib/public_activity/orm/active_record/adapter.rb +7 -0
- data/lib/public_activity/orm/active_record/trackable.rb +2 -0
- data/lib/public_activity/orm/mongo_mapper.rb +3 -1
- data/lib/public_activity/orm/mongo_mapper/activist.rb +2 -0
- data/lib/public_activity/orm/mongo_mapper/activity.rb +2 -0
- data/lib/public_activity/orm/mongo_mapper/adapter.rb +7 -0
- data/lib/public_activity/orm/mongo_mapper/trackable.rb +2 -0
- data/lib/public_activity/orm/mongoid.rb +3 -1
- data/lib/public_activity/orm/mongoid/activist.rb +2 -0
- data/lib/public_activity/orm/mongoid/activity.rb +2 -0
- data/lib/public_activity/orm/mongoid/adapter.rb +7 -0
- data/lib/public_activity/orm/mongoid/trackable.rb +2 -0
- data/lib/public_activity/renderable.rb +2 -0
- data/lib/public_activity/roles/deactivatable.rb +2 -0
- data/lib/public_activity/roles/tracked.rb +2 -0
- data/lib/public_activity/testing.rb +2 -0
- data/lib/public_activity/utility/store_controller.rb +2 -0
- data/lib/public_activity/utility/view_helpers.rb +2 -0
- data/lib/public_activity/version.rb +3 -1
- data/test/migrations/002_create_articles.rb +2 -0
- data/test/migrations/003_create_users.rb +2 -0
- data/test/migrations/004_add_nonstandard_to_activities.rb +2 -0
- data/test/migrations_base.rb +2 -0
- data/test/test_activist.rb +2 -0
- data/test/test_activity.rb +2 -0
- data/test/test_common.rb +9 -0
- data/test/test_controller_integration.rb +2 -0
- data/test/test_generators.rb +2 -0
- data/test/test_helper.rb +2 -0
- data/test/test_testing.rb +2 -0
- data/test/test_tracking.rb +2 -0
- data/test/test_view_helpers.rb +3 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed14383fee5beb59cc2e6963aec4b151edac0d910dba6ae076f158dce0791ba8
|
4
|
+
data.tar.gz: 2cb71a7c50553cddeb0500c882bf7709a780b3ca8cb60318da8d7e4b6be00e77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57aed9400b411ae43657dea3944be5aa062139356e4c5a686c97f84439369619ea6471e1685946d71c63a8765014250467646f2da37699e4f8b7723ec09e8b64
|
7
|
+
data.tar.gz: '098d249436ad7f6d16e1f7d3dfff28a8da55ee567e480a1030db9bdf0d3a68fe4d8ffcc011ad96fc332d5b98d001186b483ba41f3681cacb74a072a6a8e22ccb'
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -4,11 +4,11 @@
|
|
4
4
|
in Rails 3.0 - 5.0. Simply put: it records what has been changed or created and gives you the ability to present those
|
5
5
|
recorded activities to users - in a similar way to how GitHub does it.
|
6
6
|
|
7
|
-
## Sponsors
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
12
|
|
13
13
|
## Rails 5
|
14
14
|
|
data/Rakefile
CHANGED
data/lib/public_activity.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module PublicActivity
|
2
4
|
# Happens when creating custom activities without either action or a key.
|
3
5
|
class NoKeyProvided < Exception; end
|
@@ -257,6 +259,20 @@ module PublicActivity
|
|
257
259
|
nil
|
258
260
|
end
|
259
261
|
|
262
|
+
# Directly saves activity to database. Works the same as create_activity
|
263
|
+
# but throws validation error for each supported ORM.
|
264
|
+
#
|
265
|
+
# @see #create_activity
|
266
|
+
def create_activity!(*args)
|
267
|
+
return unless self.public_activity_enabled?
|
268
|
+
options = prepare_settings(*args)
|
269
|
+
|
270
|
+
if call_hook_safe(options[:key].split('.').last)
|
271
|
+
reset_activity_instance_options
|
272
|
+
return PublicActivity::Adapter.create_activity!(self, options)
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
260
276
|
# Prepares settings used during creation of Activity record.
|
261
277
|
# params passed directly to tracked model have priority over
|
262
278
|
# settings specified in tracked() method
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module PublicActivity
|
2
4
|
# Provides association for activities bound to this object by *trackable*.
|
3
5
|
module Trackable
|
@@ -6,4 +8,4 @@ module PublicActivity
|
|
6
8
|
base.extend PublicActivity::inherit_orm("Trackable")
|
7
9
|
end
|
8
10
|
end
|
9
|
-
end
|
11
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_record'
|
2
4
|
require_relative 'active_record/activity.rb'
|
3
5
|
require_relative 'active_record/adapter.rb'
|
4
6
|
require_relative 'active_record/activist.rb'
|
5
|
-
require_relative 'active_record/trackable.rb'
|
7
|
+
require_relative 'active_record/trackable.rb'
|
@@ -1,4 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module PublicActivity
|
4
|
+
|
5
|
+
if not defined? ::PG::ConnectionBad
|
6
|
+
module ::PG
|
7
|
+
class ConnectionBad < Exception; end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
if not defined? Mysql2::Error::ConnectionError
|
11
|
+
module Mysql2
|
12
|
+
module Error
|
13
|
+
class ConnectionError < Exception; end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
2
18
|
module ORM
|
3
19
|
module ActiveRecord
|
4
20
|
# The ActiveRecord model containing
|
@@ -17,7 +33,7 @@ module PublicActivity
|
|
17
33
|
belongs_to :owner, :polymorphic => true
|
18
34
|
# Define ownership to a resource targeted by this activity
|
19
35
|
belongs_to :recipient, :polymorphic => true
|
20
|
-
when 5
|
36
|
+
when 5..6
|
21
37
|
with_options(:required => false) do
|
22
38
|
# Define ownership to a resource responsible for this activity
|
23
39
|
belongs_to :owner, :polymorphic => true
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module PublicActivity
|
2
4
|
module ORM
|
3
5
|
# Support for ActiveRecord for PublicActivity. Used by default and supported
|
@@ -10,6 +12,11 @@ module PublicActivity
|
|
10
12
|
def self.create_activity(trackable, options)
|
11
13
|
trackable.activities.create options
|
12
14
|
end
|
15
|
+
|
16
|
+
# Creates activity on `trackable` with `options`; throws error on validation failure
|
17
|
+
def self.create_activity!(trackable, options)
|
18
|
+
trackable.activities.create! options
|
19
|
+
end
|
13
20
|
end
|
14
21
|
end
|
15
22
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module PublicActivity
|
2
4
|
module ORM
|
3
5
|
module MongoMapper
|
@@ -6,6 +8,11 @@ module PublicActivity
|
|
6
8
|
def self.create_activity(trackable, options)
|
7
9
|
trackable.activities.create options
|
8
10
|
end
|
11
|
+
|
12
|
+
# Creates activity on `trackable` with `options`; throws error on validation failure
|
13
|
+
def self.create_activity!(trackable, options)
|
14
|
+
trackable.activities.create! options
|
15
|
+
end
|
9
16
|
end
|
10
17
|
end
|
11
18
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module PublicActivity
|
2
4
|
module ORM
|
3
5
|
module Mongoid
|
@@ -6,6 +8,11 @@ module PublicActivity
|
|
6
8
|
def self.create_activity(trackable, options)
|
7
9
|
trackable.activities.create options
|
8
10
|
end
|
11
|
+
|
12
|
+
# Creates activity on `trackable` with `options`; throws error on validation failure
|
13
|
+
def self.create_activity!(trackable, options)
|
14
|
+
trackable.activities.create! options
|
15
|
+
end
|
9
16
|
end
|
10
17
|
end
|
11
18
|
end
|
data/test/migrations_base.rb
CHANGED
data/test/test_activist.rb
CHANGED
data/test/test_activity.rb
CHANGED
data/test/test_common.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_helper'
|
2
4
|
|
3
5
|
describe PublicActivity::Common do
|
@@ -48,6 +50,13 @@ describe PublicActivity::Common do
|
|
48
50
|
subject.create_activity("some.key").wont_be_nil
|
49
51
|
end
|
50
52
|
|
53
|
+
it '#create_activity! returns a new activity object' do
|
54
|
+
subject.save
|
55
|
+
activity = subject.create_activity!("some.key")
|
56
|
+
assert activity.persisted?
|
57
|
+
assert_equal 'article.some.key', activity.key
|
58
|
+
end
|
59
|
+
|
51
60
|
it 'update action should not create activity on save unless model changed' do
|
52
61
|
subject.save
|
53
62
|
before_count = subject.activities.count
|
data/test/test_generators.rb
CHANGED
data/test/test_helper.rb
CHANGED
data/test/test_testing.rb
CHANGED
data/test/test_tracking.rb
CHANGED
data/test/test_view_helpers.rb
CHANGED
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.6.
|
4
|
+
version: 1.6.4
|
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:
|
12
|
+
date: 2019-09-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -271,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
271
|
version: '0'
|
272
272
|
requirements: []
|
273
273
|
rubyforge_project:
|
274
|
-
rubygems_version: 2.7.6
|
274
|
+
rubygems_version: 2.7.6.2
|
275
275
|
signing_key:
|
276
276
|
specification_version: 4
|
277
277
|
summary: Easy activity tracking for ActiveRecord models
|