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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cbd00213b63afb3d4d25559eaa07f4055e6399a6970a6787ae39fb15836ea47
4
- data.tar.gz: 55cc1dd443c1a269660177a6d97c369c22c6b9a312ac8f7e5214358843382d9a
3
+ metadata.gz: f32379b025f2eecaca909f9ea2fa6289cd353f480141fe8494e4179f339254b8
4
+ data.tar.gz: be503eaf4cbf750cd66ab8eab07323050d6fee1e172e7eb5d01678418969cb0f
5
5
  SHA512:
6
- metadata.gz: dfa7ac68afbba0acee383721b9409add97fe339ecb37958d13d136fa0fff0d63589153f77f01805bca11faa0914eef2fe0e9ae44c66ef71eafad3145be9a2eff
7
- data.tar.gz: 3a0ed275fcbd798ff021cc2689e0c54b5dc43cd1f212dd28f149cb3ef619ff394d126388408c31bc00625762bf266c1b7aef194f3866b8a8d9828376cf2db183
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 heat-map–ready data.
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|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActsAsActive
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.3"
5
5
  end
@@ -6,5 +6,4 @@ require "acts_as_active/railtie" if defined?(Rails)
6
6
 
7
7
  module ActsAsActive
8
8
  class Error < StandardError; end
9
- # Your code goes here...
10
9
  end
@@ -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
- class Activity < ApplicationRecord
24
- belongs_to :trackable, polymorphic: true, class_name: "Activity"
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 :activities do |t|
4
- t.string :trackable_type, null: false
5
- t.bigint :trackable_id, null: false
6
- t.date :occurred_on, null: false
7
- t.integer :count, null: false, default: 0
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 :activities, [:trackable_type, :trackable_id, :occurred_on], unique: true, name: "index_activities_on_trackable_and_occurred_on"
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.0
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-08 00:00:00.000000000 Z
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://github.com/amitleshed/acts_as_active
74
+ homepage: https://www.amitleshed.com
75
75
  licenses:
76
76
  - MIT
77
77
  metadata:
78
- homepage_uri: https://github.com/amitleshed/acts_as_active
79
- source_code_uri: https://www.amitleshed.com
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: