public_activity 1.6.4 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed14383fee5beb59cc2e6963aec4b151edac0d910dba6ae076f158dce0791ba8
4
- data.tar.gz: 2cb71a7c50553cddeb0500c882bf7709a780b3ca8cb60318da8d7e4b6be00e77
3
+ metadata.gz: 83290b8f83bb4db6127ed0b907380946d30a3d8a91b2ea3d1a835d7dfb36327d
4
+ data.tar.gz: 2a7e5abad8fae61ff03440747938653eb1624e14f62279fddb28b2d10362b75e
5
5
  SHA512:
6
- metadata.gz: 57aed9400b411ae43657dea3944be5aa062139356e4c5a686c97f84439369619ea6471e1685946d71c63a8765014250467646f2da37699e4f8b7723ec09e8b64
7
- data.tar.gz: '098d249436ad7f6d16e1f7d3dfff28a8da55ee567e480a1030db9bdf0d3a68fe4d8ffcc011ad96fc332d5b98d001186b483ba41f3681cacb74a072a6a8e22ccb'
6
+ metadata.gz: 502c70c85f62ec2838d592a2eaed2de714e97bbc27dcf0e7677dc27ac21e76e2fa1960c7c8d9fae218ff77ac1b103d0b7228ab4ed9afe2b50e7eb09bd2f6b7fe
7
+ data.tar.gz: ef18dda98ec4e763311971ec8a3a9382b4ba05a5b00a76c7ee6e3a58a9d4ec80f1c9a11487d9bb2e30c5ca9f0a336136033e2811f9ac52974a9cb8f9c95efa39
data/README.md CHANGED
@@ -1,37 +1,35 @@
1
1
  # PublicActivity [![Build Status](https://secure.travis-ci.org/chaps-io/public_activity.svg)](http://travis-ci.org/chaps-io/public_activity) [![Code Climate](https://codeclimate.com/github/chaps-io/public_activity.svg)](https://codeclimate.com/github/chaps-io/public_activity) [![Gem Version](https://badge.fury.io/rb/public_activity.svg)](http://badge.fury.io/rb/public_activity)
2
2
 
3
3
  `public_activity` provides easy activity tracking for your **ActiveRecord**, **Mongoid 3** and **MongoMapper** models
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
- recorded activities to users - in a similar way to how GitHub does it.
4
+ in Rails 5.0+. Simply put: it records what has been changed or created and gives you the ability to present those
5
+ recorded activities to users - similarly to how GitHub does it.
6
6
 
7
+ ## Rails 7
7
8
 
8
-
9
-
10
-
11
-
12
-
13
- ## Rails 5
14
-
15
- **As of 1.6.0 version, public_activity also supports Rails up to 5.2.**
9
+ **As of version 2.0.0, public_activity also supports Rails up to 7.0.**
16
10
 
17
11
  ## Table of contents
18
12
 
19
- 1. [Example](#example)
20
- * [Demo](#online-demo)
21
- * [Screencast](#screencast)
22
- * **[Common examples](#common-examples)**
23
- 2. [Setup](#setup)
24
- 1. [Gem installation](#gem-installation)
25
- 2. [Database setup](#database-setup)
26
- 3. [Model configuration](#model-configuration)
27
- 4. [Custom activities](#custom-activities)
28
- 5. [Displaying activities](#displaying-activities)
29
- 1. [Activity views](#activity-views)
30
- 2. [i18n](#i18n)
31
- 3. [Testing](#testing)
32
- 4. [Documentation](#documentation)
33
- 5. **[Help](#help)**
34
- 6. [Upgrading](https://github.com/pokonski/public_activity/wiki/Upgrading-from-pre-0.4.0-versions)
13
+ - [Rails 7](#rails-7)
14
+ - [Table of contents](#table-of-contents)
15
+ - [Example](#example)
16
+ - [Online demo](#online-demo)
17
+ - [Screencast](#screencast)
18
+ - [Setup](#setup)
19
+ - [Gem installation](#gem-installation)
20
+ - [Database setup](#database-setup)
21
+ - [Model configuration](#model-configuration)
22
+ - [Custom activities](#custom-activities)
23
+ - [Displaying activities](#displaying-activities)
24
+ - [Layouts](#layouts)
25
+ - [Locals](#locals)
26
+ - [Activity views](#activity-views)
27
+ - [I18n](#I18n)
28
+ - [Testing](#testing)
29
+ - [Documentation](#documentation)
30
+ - [Common examples](#common-examples)
31
+ - [Help](#help)
32
+ - [License](#license)
35
33
 
36
34
  ## Example
37
35
 
@@ -197,7 +195,7 @@ For example, if you have an activity with `:key` set to `"activity.user.changed_
197
195
 
198
196
  If a view file does not exist, then p_a falls back to the old behaviour and tries to translate the activity `:key` using `I18n#translate` method (see the section below).
199
197
 
200
- #### i18n
198
+ #### I18n
201
199
 
202
200
  Translations are used by the `#text` method, to which you can pass additional options in form of a hash. `#render` method uses translations when view templates have not been provided. You can render pure i18n strings by passing `{display: :i18n}` to `#render_activity` or `#render`.
203
201
 
@@ -224,7 +222,7 @@ require 'public_activity/testing'
224
222
  PublicActivity.enabled = false
225
223
  ```
226
224
 
227
- In your specs you can then blockwise decide wether to turn `public_activity` on
225
+ In your specs you can then blockwise decide whether to turn `public_activity` on
228
226
  or off.
229
227
 
230
228
  ```ruby
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'migrations_base'
4
+
3
5
  # Migration responsible for creating a table with activities
4
- class CreateActivities < (ActiveRecord.version.release() < Gem::Version.new('5.2.0') ? ActiveRecord::Migration : ActiveRecord::Migration[5.2])
5
- # Create table
6
+ class CreateActivities < MigrationsBase
6
7
  def self.up
7
8
  create_table :activities do |t|
8
9
  t.belongs_to :trackable, :polymorphic => true
@@ -33,7 +33,7 @@ module PublicActivity
33
33
  belongs_to :owner, :polymorphic => true
34
34
  # Define ownership to a resource targeted by this activity
35
35
  belongs_to :recipient, :polymorphic => true
36
- when 5..6
36
+ when 5..7
37
37
  with_options(:required => false) do
38
38
  # Define ownership to a resource responsible for this activity
39
39
  belongs_to :owner, :polymorphic => true
@@ -49,9 +49,9 @@ module PublicActivity
49
49
  else
50
50
  warn("[WARN] table #{name} doesn't exist. Skipping PublicActivity::Activity#parameters's serialization")
51
51
  end
52
- rescue ::ActiveRecord::NoDatabaseError => e
52
+ rescue ::ActiveRecord::NoDatabaseError
53
53
  warn("[WARN] database doesn't exist. Skipping PublicActivity::Activity#parameters's serialization")
54
- rescue ::PG::ConnectionBad => e
54
+ rescue ::PG::ConnectionBad
55
55
  warn("[WARN] couldn't connect to database. Skipping PublicActivity::Activity#parameters's serialization")
56
56
  rescue Mysql2::Error::ConnectionError
57
57
  warn("[WARN] couldn't connect to database. Skipping PublicActivity::Activity#parameters's serialization")
@@ -12,7 +12,8 @@ module PublicActivity
12
12
  k.unshift('activity') if k.first != 'activity'
13
13
  k = k.join('.')
14
14
 
15
- I18n.t(k, parameters.merge(params) || {})
15
+ translate_params = parameters.merge(params) || {}
16
+ I18n.t(k, **translate_params)
16
17
  end
17
18
 
18
19
  # Renders activity from views.
@@ -142,7 +143,7 @@ module PublicActivity
142
143
  def prepare_layout(root, layout)
143
144
  if layout
144
145
  path = layout.to_s
145
- unless path.starts_with?(root) || path.starts_with?("/")
146
+ unless path.start_with?(root) || path.start_with?("/")
146
147
  return File.join(root, path)
147
148
  end
148
149
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module PublicActivity
4
4
  # A constant with gem's version
5
- VERSION = '1.6.4'
5
+ VERSION = '2.0.0'
6
6
  end
@@ -1 +1 @@
1
- test/migrations/../../lib/generators/public_activity/migration/templates/migration.rb
1
+ ../../lib/generators/public_activity/migration/templates/migration.rb
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'migrations_base.rb'
3
+ require 'migrations_base'
4
4
 
5
5
  class CreateArticles < MigrationsBase
6
6
  def self.up
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'migrations_base.rb'
3
+ require 'migrations_base'
4
4
 
5
5
  class CreateUsers < MigrationsBase
6
6
  def self.up
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- MigrationsBase = if ActiveRecord.version.release() < Gem::Version.new('5.2.0')
3
+ MigrationsBase = if ActiveRecord.version.release() < Gem::Version.new('5.1.0')
4
4
  ActiveRecord::Migration
5
5
  else
6
- ActiveRecord::Migration[5.2]
6
+ ActiveRecord::Migration[5.1]
7
7
  end
@@ -4,21 +4,9 @@ if ENV["PA_ORM"] == "active_record"
4
4
 
5
5
  require 'test_helper'
6
6
  require 'rails/generators/test_case'
7
- require 'generators/public_activity/activity/activity_generator'
8
7
  require 'generators/public_activity/migration/migration_generator'
9
8
  require 'generators/public_activity/migration_upgrade/migration_upgrade_generator'
10
9
 
11
- class TestActivityGenerator < Rails::Generators::TestCase
12
- tests PublicActivity::Generators::ActivityGenerator
13
- destination File.expand_path("../tmp", File.dirname(__FILE__))
14
- setup :prepare_destination
15
-
16
- def test_generating_activity_model
17
- run_generator
18
- assert_file "app/models/activity.rb"
19
- end
20
- end
21
-
22
10
  class TestMigrationGenerator < Rails::Generators::TestCase
23
11
  tests PublicActivity::Generators::MigrationGenerator
24
12
  destination File.expand_path("../tmp", File.dirname(__FILE__))
data/test/test_helper.rb CHANGED
@@ -29,11 +29,15 @@ when :active_record
29
29
  ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
30
30
 
31
31
  migrations_path = File.expand_path('../migrations', __FILE__)
32
+ active_record_version = ActiveRecord.version.release()
32
33
 
33
- if ActiveRecord.version.release() < Gem::Version.new('5.2.0')
34
- ActiveRecord::Migrator.migrate(migrations_path)
35
- else
34
+ if active_record_version >= Gem::Version.new('6.0.0')
35
+ schema_path = File.expand_path("../tmp/schema.rb", File.dirname(__FILE__))
36
+ ActiveRecord::MigrationContext.new(migrations_path, ActiveRecord::SchemaMigration).migrate
37
+ elsif active_record_version >= Gem::Version.new('5.2.0')
36
38
  ActiveRecord::MigrationContext.new(migrations_path).migrate
39
+ else # active_record_version < Gem::Version.new('5.2.0')
40
+ ActiveRecord::Migrator.migrate(migrations_path)
37
41
  end
38
42
 
39
43
  $stdout = STDOUT
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: public_activity
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.4
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotrek Okoński
8
8
  - Kuba Okoński
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-09-30 00:00:00.000000000 Z
12
+ date: 2022-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -17,28 +17,28 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 3.0.0
20
+ version: 5.0.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 3.0.0
27
+ version: 5.0.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: railties
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 3.0.0
34
+ version: 5.0.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: 3.0.0
41
+ version: 5.0.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: i18n
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -59,84 +59,98 @@ dependencies:
59
59
  requirements:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: '3.0'
62
+ version: '5.0'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: '3.0'
69
+ version: '5.0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: appraisal
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
70
84
  - !ruby/object:Gem::Dependency
71
85
  name: sqlite3
72
86
  requirement: !ruby/object:Gem::Requirement
73
87
  requirements:
74
88
  - - "~>"
75
89
  - !ruby/object:Gem::Version
76
- version: 1.3.7
90
+ version: 1.4.1
77
91
  type: :development
78
92
  prerelease: false
79
93
  version_requirements: !ruby/object:Gem::Requirement
80
94
  requirements:
81
95
  - - "~>"
82
96
  - !ruby/object:Gem::Version
83
- version: 1.3.7
97
+ version: 1.4.1
84
98
  - !ruby/object:Gem::Dependency
85
99
  name: mocha
86
100
  requirement: !ruby/object:Gem::Requirement
87
101
  requirements:
88
- - - "~>"
102
+ - - ">="
89
103
  - !ruby/object:Gem::Version
90
- version: 1.5.0
104
+ version: '0'
91
105
  type: :development
92
106
  prerelease: false
93
107
  version_requirements: !ruby/object:Gem::Requirement
94
108
  requirements:
95
- - - "~>"
109
+ - - ">="
96
110
  - !ruby/object:Gem::Version
97
- version: 1.5.0
111
+ version: '0'
98
112
  - !ruby/object:Gem::Dependency
99
113
  name: simplecov
100
114
  requirement: !ruby/object:Gem::Requirement
101
115
  requirements:
102
- - - "~>"
116
+ - - ">="
103
117
  - !ruby/object:Gem::Version
104
- version: 0.7.0
118
+ version: '0'
105
119
  type: :development
106
120
  prerelease: false
107
121
  version_requirements: !ruby/object:Gem::Requirement
108
122
  requirements:
109
- - - "~>"
123
+ - - ">="
110
124
  - !ruby/object:Gem::Version
111
- version: 0.7.0
125
+ version: '0'
112
126
  - !ruby/object:Gem::Dependency
113
127
  name: test-unit
114
128
  requirement: !ruby/object:Gem::Requirement
115
129
  requirements:
116
- - - "~>"
130
+ - - ">="
117
131
  - !ruby/object:Gem::Version
118
- version: 3.2.8
132
+ version: '0'
119
133
  type: :development
120
134
  prerelease: false
121
135
  version_requirements: !ruby/object:Gem::Requirement
122
136
  requirements:
123
- - - "~>"
137
+ - - ">="
124
138
  - !ruby/object:Gem::Version
125
- version: 3.2.8
139
+ version: '0'
126
140
  - !ruby/object:Gem::Dependency
127
141
  name: minitest
128
142
  requirement: !ruby/object:Gem::Requirement
129
143
  requirements:
130
- - - "~>"
144
+ - - ">="
131
145
  - !ruby/object:Gem::Version
132
- version: 4.7.5
146
+ version: '0'
133
147
  type: :development
134
148
  prerelease: false
135
149
  version_requirements: !ruby/object:Gem::Requirement
136
150
  requirements:
137
- - - "~>"
151
+ - - ">="
138
152
  - !ruby/object:Gem::Version
139
- version: 4.7.5
153
+ version: '0'
140
154
  - !ruby/object:Gem::Dependency
141
155
  name: redcarpet
142
156
  requirement: !ruby/object:Gem::Requirement
@@ -155,16 +169,16 @@ dependencies:
155
169
  name: yard
156
170
  requirement: !ruby/object:Gem::Requirement
157
171
  requirements:
158
- - - "~>"
172
+ - - ">="
159
173
  - !ruby/object:Gem::Version
160
- version: 0.9.11
174
+ version: '0'
161
175
  type: :development
162
176
  prerelease: false
163
177
  version_requirements: !ruby/object:Gem::Requirement
164
178
  requirements:
165
- - - "~>"
179
+ - - ">="
166
180
  - !ruby/object:Gem::Version
167
- version: 0.9.11
181
+ version: '0'
168
182
  - !ruby/object:Gem::Dependency
169
183
  name: pry
170
184
  requirement: !ruby/object:Gem::Requirement
@@ -192,8 +206,6 @@ files:
192
206
  - README.md
193
207
  - Rakefile
194
208
  - lib/generators/public_activity.rb
195
- - lib/generators/public_activity/activity/activity_generator.rb
196
- - lib/generators/public_activity/activity/templates/activity.rb
197
209
  - lib/generators/public_activity/migration/migration_generator.rb
198
210
  - lib/generators/public_activity/migration/templates/migration.rb
199
211
  - lib/generators/public_activity/migration_upgrade/migration_upgrade_generator.rb
@@ -255,7 +267,7 @@ homepage: https://github.com/pokonski/public_activity
255
267
  licenses:
256
268
  - MIT
257
269
  metadata: {}
258
- post_install_message:
270
+ post_install_message:
259
271
  rdoc_options: []
260
272
  require_paths:
261
273
  - lib
@@ -263,16 +275,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
263
275
  requirements:
264
276
  - - ">="
265
277
  - !ruby/object:Gem::Version
266
- version: 1.9.2
278
+ version: 2.5.0
267
279
  required_rubygems_version: !ruby/object:Gem::Requirement
268
280
  requirements:
269
281
  - - ">="
270
282
  - !ruby/object:Gem::Version
271
283
  version: '0'
272
284
  requirements: []
273
- rubyforge_project:
274
- rubygems_version: 2.7.6.2
275
- signing_key:
285
+ rubygems_version: 3.3.13
286
+ signing_key:
276
287
  specification_version: 4
277
288
  summary: Easy activity tracking for ActiveRecord models
278
289
  test_files:
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'generators/public_activity'
4
- require 'rails/generators/active_record'
5
-
6
- module PublicActivity
7
- module Generators
8
- # Activity generator that creates activity model file from template
9
- class ActivityGenerator < ActiveRecord::Generators::Base
10
- extend Base
11
-
12
- argument :name, :type => :string, :default => 'activity'
13
- # Create model in project's folder
14
- def generate_files
15
- copy_file 'activity.rb', "app/models/#{name}.rb"
16
- end
17
- end
18
- end
19
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Activity model for customisation & custom methods
4
- class Activity < PublicActivity::Activity
5
- end