acts_as_active 0.1.0 → 0.1.3
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 +4 -4
- data/README.md +9 -1
- data/lib/acts_as_active/activable.rb +1 -1
- data/lib/acts_as_active/version.rb +1 -1
- data/lib/acts_as_active.rb +0 -1
- data/lib/generators/acts_as_active/install_generator.rb +8 -3
- data/lib/generators/acts_as_active/templates/create_activities.rb +7 -6
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f32379b025f2eecaca909f9ea2fa6289cd353f480141fe8494e4179f339254b8
|
|
4
|
+
data.tar.gz: be503eaf4cbf750cd66ab8eab07323050d6fee1e172e7eb5d01678418969cb0f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a546e8ca4ba37b06556559b763fae3433a8a23fa7eb1e2d2a5e3c845cd3b8072b95226463c3329cb390fbde29484f86a834932555cdc4be98aa1f775896411bb
|
|
7
|
+
data.tar.gz: dfaae1ec7b0ce78e65bd218dcd01eac9e8048f90ec8597feeaea9ecbc311b397a303d11714b62ca4d2910563e9d573017cf73775525efefabec7b0e2b1e383f0
|
data/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# ActsAsActive
|
|
2
2
|
|
|
3
|
-
Acts As Active adds plug-and-play activity tracking to any ActiveRecord model, giving you instant daily stats, streak analytics, and
|
|
3
|
+
Acts As Active adds plug-and-play activity tracking to any ActiveRecord model, giving you instant daily stats, streak analytics, and heatmap-ready data.
|
|
4
|
+
|
|
5
|
+
It works by automatically establishing a polymorphic association with your model and generating an Activity record for each specified lifecycle event.
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
@@ -44,6 +46,12 @@ record.longest_streak # => 3 (e.g. active 1-3 Aug)
|
|
|
44
46
|
record.current_streak # => 2 (e.g. active 5-6 Aug, still “on a streak” today)
|
|
45
47
|
```
|
|
46
48
|
|
|
49
|
+
## Run Tests
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
ruby -Ilib:ruby test/test_acts_as_active.rb
|
|
53
|
+
```
|
|
54
|
+
|
|
47
55
|
## Contributing
|
|
48
56
|
|
|
49
57
|
Bug reports and pull requests are welcome on GitHub at https://github.com/amitleshed/acts_as_active. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/amitleshed/acts_as_active/blob/main/CODE_OF_CONDUCT.md).
|
|
@@ -12,7 +12,7 @@ module ActsAsActive
|
|
|
12
12
|
SUPPORTED_EVENTS = %i[create update destroy].freeze
|
|
13
13
|
|
|
14
14
|
def acts_as_active(options = {})
|
|
15
|
-
has_many :activities, as: :trackable, class_name: "Activity"
|
|
15
|
+
has_many :activities, as: :trackable, class_name: "ActsAsActive::Activity"
|
|
16
16
|
|
|
17
17
|
events = Array(options[:on] || SUPPORTED_EVENTS) & SUPPORTED_EVENTS
|
|
18
18
|
events.each do |ev|
|
data/lib/acts_as_active.rb
CHANGED
|
@@ -19,9 +19,14 @@ module ActsAsActive
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def create_model
|
|
22
|
-
create_file "app/models/activity.rb", <<~RUBY
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
create_file "app/models/acts_as_active/activity.rb", <<~RUBY
|
|
23
|
+
module ActsAsActive
|
|
24
|
+
class Activity < ApplicationRecord
|
|
25
|
+
self.table_name = "acts_as_active_activities"
|
|
26
|
+
|
|
27
|
+
belongs_to :trackable, polymorphic: true
|
|
28
|
+
belongs_to :actor, polymorphic: true, optional: true
|
|
29
|
+
end
|
|
25
30
|
end
|
|
26
31
|
RUBY
|
|
27
32
|
end
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
class CreateActivities < ActiveRecord::Migration[7.1]
|
|
2
2
|
def change
|
|
3
|
-
create_table :
|
|
4
|
-
t.string
|
|
5
|
-
t.bigint
|
|
6
|
-
t.
|
|
7
|
-
t.
|
|
3
|
+
create_table :acts_as_active_activities do |t|
|
|
4
|
+
t.string :trackable_type, null: false
|
|
5
|
+
t.bigint :trackable_id, null: false
|
|
6
|
+
t.references :actor, polymorphic: true, null: true
|
|
7
|
+
t.date :occurred_on, null: false
|
|
8
|
+
t.integer :count, null: false, default: 0
|
|
8
9
|
|
|
9
10
|
t.timestamps
|
|
10
11
|
end
|
|
11
12
|
|
|
12
|
-
add_index :
|
|
13
|
+
add_index :acts_as_active_activities, [:trackable_type, :trackable_id, :occurred_on], unique: true, name: "index_activities_on_trackable_and_occurred_on"
|
|
13
14
|
end
|
|
14
15
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: acts_as_active
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Amit Leshed
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-08-
|
|
11
|
+
date: 2025-08-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -71,12 +71,12 @@ files:
|
|
|
71
71
|
- lib/generators/acts_as_active/install_generator.rb
|
|
72
72
|
- lib/generators/acts_as_active/templates/create_activities.rb
|
|
73
73
|
- sig/acts_as_active.rbs
|
|
74
|
-
homepage: https://
|
|
74
|
+
homepage: https://www.amitleshed.com
|
|
75
75
|
licenses:
|
|
76
76
|
- MIT
|
|
77
77
|
metadata:
|
|
78
|
-
homepage_uri: https://
|
|
79
|
-
source_code_uri: https://
|
|
78
|
+
homepage_uri: https://www.amitleshed.com
|
|
79
|
+
source_code_uri: https://github.com/amitleshed/acts_as_active
|
|
80
80
|
post_install_message:
|
|
81
81
|
rdoc_options: []
|
|
82
82
|
require_paths:
|