{"id":15405579,"url":"https://github.com/krisleech/chalk_dust","last_synced_at":"2025-04-17T01:52:29.823Z","repository":{"id":7843233,"uuid":"9214893","full_name":"krisleech/chalk_dust","owner":"krisleech","description":"Subscriptions connect models, events build activity feeds.","archived":false,"fork":false,"pushed_at":"2014-01-05T16:09:49.000Z","size":623,"stargazers_count":47,"open_issues_count":2,"forks_count":9,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-13T03:06:52.213Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/krisleech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-04T09:26:30.000Z","updated_at":"2024-01-22T22:50:44.000Z","dependencies_parsed_at":"2022-09-13T10:50:23.202Z","dependency_job_id":null,"html_url":"https://github.com/krisleech/chalk_dust","commit_stats":null,"previous_names":["krisleech/chalk-dust"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fchalk_dust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fchalk_dust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fchalk_dust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fchalk_dust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krisleech","download_url":"https://codeload.github.com/krisleech/chalk_dust/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249299673,"owners_count":21246875,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T16:17:13.918Z","updated_at":"2025-04-17T01:52:29.806Z","avatar_url":"https://github.com/krisleech.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# ChalkDust\n\nSubscriptions connect models, events build activity feeds.\n\nDesigned to scale.\n\nChalkDust can be used to build activty feeds such as followings and friendships\nby allowing models to subscribe to activity feeds published by other models.\n\nEvery time an activity occurs it is copied to all subscribers of the target of\nthat activity. This creates an activity feed per subscriber. This results in\nmore data but scales better and allows additional features such as the ability\nof the subscriber to delete/hide activity items.\n\nEach publisher can create multiple feeds by means of topics. For example a\nuser might publish activities with topics of 'family' or 'work'.\n\n[![Code Climate](https://codeclimate.com/github/krisleech/chalk_dust.png)](https://codeclimate.com/github/krisleech/chalk_dust)\n[![Build Status](https://travis-ci.org/krisleech/chalk_dust.png?branch=master)](https://travis-ci.org/krisleech/chalk_dust)\n[![endorse](https://api.coderwall.com/krisleech/endorsecount.png)](https://coderwall.com/krisleech)\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/krisleech/chalk_dust/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'chalk_dust'\n```\n\nChalkDust has a dependency on ActiveRecord (3.0 or 4.0) and a soft dependency\non Rails. If you are using Rails you can install the migrations as follows:\n\n```\nrails generate chalk_dust:install_migrations\n```\n\n## Usage\n\n### Subscribing\n\nA subscription connects two objects, e.g \"Sam\" follows \"My first blog post\"\n\n```ruby\nChalkDust.subscribe(user, :to =\u003e post)\n```\n\n```ruby\nChalkDust.subscribers_of(post) # =\u003e [user]\n```\n\n#### Self-subscribing\n\nTypically you will want to self-subscribe models on creation to themseleves so\nan activity feed is built for the model itself.\n\n```ruby\nChalkDust.self_subscribe(user)\n# or\nChalkDust.subscribe(user, :to =\u003e user)\n```\n\n#### Undirected subscriptions\n\nAll subscriptions are directed. You can create a two way subscription, e.g a\nfriendship, as follows:\n\n```ruby\nChalkDust.subscribe(bob,   :to =\u003e alice, :undirected =\u003e true)\n# or\nChalkDust.subscribe(bob,   :to =\u003e alice)\nChalkDust.subscribe(alice, :to =\u003e bob)\n```\n\n#### Topics\n\nIf you want the subscription to only apply to activities with a particular\ntopic you can do so as follows:\n\n```ruby\nChalkDust.subscribe(alice, :to =\u003e bob, :topic =\u003e 'work')\nChalkDust.subscribe(alice, :to =\u003e bob, :topic =\u003e 'family')\n```\n\nThis is useful if you need to publish multiple activity feeds for an object.\n\nExample uses for this would be seperate public and private activity streams\nfor an object, or something like circles.\n\n### Publishing activity\n\nDescribes an event where X (performer) did Y (activity) to Z (target).\n\n```ruby\nChalkDust.publish_event(user, 'added', comment)\n```\n\nIf the activity should be published to the feed of an object other than the\ntarget then it can be either be passed with the `:root` argument:\n\n```ruby\nChalkDust.publish_event(user, 'added', comment, :root =\u003e comment.post)\n```\n\n#### Topics\n\nOptionally publish an event to a specific topic:\n\n```ruby\nChalkDust.publish_event(user, 'uploaded', photo, :root =\u003e user,\n                                                 :topic =\u003e 'family')\n```\n\n### Activity Feeds\n\n```ruby\nChalkDust.activity_feed_for(user, :since =\u003e 2.weeks.ago)\nChalkDust.activity_feed_for(post, :since =\u003e 2.weeks.ago)\n```\n\n#### Topics\n\nFetch an activity feed for a specific topic:\n\n```ruby\nChalkDust.activity_feed_for(user, :topic =\u003e 'family')\n```\n\nIf you do not specify a topic you will only get activities which where not\npublished with a topic. To get all activities (those with and without a topic)\npass `:all` to `:topic`:\n\n```ruby\nChalkDust.activity_feed_for(user, :topic =\u003e :all)\n```\n\nYou can still use `'all'` as a regular topic, but you can not specify it as a\nsymbol as you can with other topics.\n\n### Unsubscribing\n\n```ruby\nChalkDust.unsubscribe(user, :from =\u003e post)\nChalkDust.unsubscribe(user, :from =\u003e post, :topic =\u003e 'work')\nChalkDust.unsubscribe(user, :from =\u003e post, :topic =\u003e :all)\n```\n\n## Compatibility\n\nTested with MRI 1.9.x, MRI 2.0.0, JRuby (1.9 and 2.0 mode) against both\nActiveRecord 3.0 and 4.0.\n\nSee the [build status](https://travis-ci.org/krisleech/chalk_dust) for details.\n\n## Contributing\n\nContributions welcome, please fork and send a pull request.\n\n## Running Specs\n\nTo run the specs for all supported combinations of Ruby and ActiveRecord:\n\n```\nwwtd\n```\n\nTo run the specs for a specific version of ActiveRecord:\n\n```\nenv BUNDLE_GEMFILE=$PWD/gemfiles/activerecord-3.0 bundle exec rspec spec\nenv BUNDLE_GEMFILE=$PWD/gemfiles/activerecord-4.0 bundle exec rspec spec\n```\n\n## Thanks\n\nThanks to Igor @ Lifetrip Limited for allowing this code to be open sourced.\n\n## License\n\nCopyright (c) 2013 Lifetrip Limited\n\nMIT License\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrisleech%2Fchalk_dust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrisleech%2Fchalk_dust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrisleech%2Fchalk_dust/lists"}