{"id":13483151,"url":"https://github.com/faustinoaq/watcher","last_synced_at":"2025-05-12T22:02:34.323Z","repository":{"id":76219199,"uuid":"86591848","full_name":"faustinoaq/watcher","owner":"faustinoaq","description":"Crystal shard to watch file changes using File.stat","archived":false,"fork":false,"pushed_at":"2018-06-18T19:59:15.000Z","size":180,"stargazers_count":21,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-20T18:39:54.290Z","etag":null,"topics":["crystal","monitor"],"latest_commit_sha":null,"homepage":null,"language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/faustinoaq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-03-29T14:24:51.000Z","updated_at":"2024-04-19T07:51:38.000Z","dependencies_parsed_at":"2024-01-14T19:13:25.187Z","dependency_job_id":"5d951f87-ed06-41fe-933b-0bd77e4f201a","html_url":"https://github.com/faustinoaq/watcher","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faustinoaq%2Fwatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faustinoaq%2Fwatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faustinoaq%2Fwatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faustinoaq%2Fwatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/faustinoaq","download_url":"https://codeload.github.com/faustinoaq/watcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253830947,"owners_count":21971004,"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":["crystal","monitor"],"created_at":"2024-07-31T17:01:08.652Z","updated_at":"2025-05-12T22:02:34.282Z","avatar_url":"https://github.com/faustinoaq.png","language":"Crystal","funding_links":[],"categories":["Development Tools"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"logo/logotype_horizontal.png\" alt=\"watcher\" height=\"100px\"\u003e\u003c/p\u003e\n\n[![Build Status](https://travis-ci.org/faustinoaq/watcher.svg?branch=master)](https://travis-ci.org/faustinoaq/watcher)\n\nCrystal shard to watch file changes. This shard use the same code implemented [here (Guardian)](https://github.com/f/guardian/blob/master/src/guardian/watcher.cr#L45) and [here (Sentry)](https://github.com/samueleaton/sentry/blob/master/src/sentry.cr#L52).\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n  watcher:\n    github: faustinoaq/watcher\n```\n\n## Usage\n\nUse the keyword `watch` to watch files or file groups, for example:\n\n```crystal\nrequire \"watcher\"\n\nwatch \"src/assets/js/*.js\" do |event|\n  event.on_change do |files|\n    files.each do |file, {first, timestamp}|\n      puts \"File #{file} has changed at #{timestamp}\"\n    end\n    # ...\n  end\nend\n```\n\nAlso you can have more than one watcher, just use `spawn`\n\n```crystal\nspawn do\n  watch [\"src/assets/*.css\", \"src/views/*.html\"] do |event|\n    event.on_change do\n      # ...\n    end\n  end\nend\n\n# Other watcher\nwatch ... do |event|\n #...\nend\n```\n\nAnd you can change time interval for a watcher.\n\n```crystal\nwatch \"public/*.json\", interval: 0.5 do |event|\n  event.on_change do\n    # ...\n  end\nend\n```\n\nAlso you can use `Watcher.watch` instead of `watch`.\n\n# How does it work?\n\nWatcher uses timestamps to check file changes every second, if you want some more advanced then you can use [Watchbird](https://github.com/agatan/watchbird) that uses `libnotify` to check events like modify, access and delete but just work in Linux for now.\n\n## Contributing\n\n1. Fork it ( https://github.com/faustinoaq/watcher/fork )\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n\n## Contributors\n\n- [faustinoaq](https://github.com/faustinoaq) Faustino Aguilar - creator, maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaustinoaq%2Fwatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffaustinoaq%2Fwatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaustinoaq%2Fwatcher/lists"}