• Stars
    star
    20
  • Rank 1,086,213 (Top 22 %)
  • Language
    Crystal
  • License
    MIT License
  • Created about 7 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Crystal shard to watch file changes using File.stat

watcher

Build Status

Crystal shard to watch file changes. This shard use the same code implemented here (Guardian) and here (Sentry).

Installation

Add this to your application's shard.yml:

dependencies:
  watcher:
    github: faustinoaq/watcher

Usage

Use the keyword watch to watch files or file groups, for example:

require "watcher"

watch "src/assets/js/*.js" do |event|
  event.on_change do |files|
    files.each do |file, {first, timestamp}|
      puts "File #{file} has changed at #{timestamp}"
    end
    # ...
  end
end

Also you can have more than one watcher, just use spawn

spawn do
  watch ["src/assets/*.css", "src/views/*.html"] do |event|
    event.on_change do
      # ...
    end
  end
end

# Other watcher
watch ... do |event|
 #...
end

And you can change time interval for a watcher.

watch "public/*.json", interval: 0.5 do |event|
  event.on_change do
    # ...
  end
end

Also you can use Watcher.watch instead of watch.

How does it work?

Watcher uses timestamps to check file changes every second, if you want some more advanced then you can use Watchbird that uses libnotify to check events like modify, access and delete but just work in Linux for now.

Contributing

  1. Fork it ( https://github.com/faustinoaq/watcher/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • faustinoaq Faustino Aguilar - creator, maintainer

More Repositories

1

crystal-windows-installer

Installer for Crystal on Bash on Windows
Inno Setup
37
star
2

ruby2crystal

A proof of concept tool to help porting gems to shards
Crystal
28
star
3

sswws

Super Simple Windows Web Server
Crystal
25
star
4

kemal-watcher

Kemal plugin to watch files and live-reload the browser
Crystal
19
star
5

vscode-lex-flex-yacc-bison

Syntax highlighting for Lex, Flex, Yacc and Bison in VSCode.
18
star
6

secrets

Useful to get input on noecho, secrets, passwords, token, hints
Crystal
12
star
7

sentry-run

Use Sentry shard for reload your app
Crystal
11
star
8

vscode-javac-linter

A Java linter for Visual Studio Code
TypeScript
10
star
9

interactive-crystal

Experiment with dynamic library loading
Crystal
8
star
10

vscode-mint-lang

VSCode extension for Mint Programming Language
6
star
11

ambrockets

Simple Websockets example using Amber
JavaScript
6
star
12

crystal-broadlink

Crystal shard for Broadlink IR controllers like remote controls, sensor platforms and smart plugs 📡
Crystal
4
star
13

pet-tracker

Amber Framework demo for Quick Start guide
Crystal
4
star
14

round-robin

Algoritmo de planificación por turnos (Round Robin)
Java
3
star
15

coscan

A project for scaning target sub-networks
Crystal
2
star
16

vector-matrix

Simulate matrix using vectors
Crystal
1
star
17

kemal-reuse-port

A kemal app using reuse port
Crystal
1
star
18

repo-intro-react-hls

JavaScript
1
star
19

amber-aur

AUR repository for Amber
Shell
1
star
20

vue-amber-recipe

An Amber Framework recipe using Vue.js
Crystal
1
star
21

huffman

An implementation of Huffman algorithm in Crystal for learning purposes
Crystal
1
star
22

macOS.qcow2

macOS VM in KVM with RX550 GPU passthrough
1
star
23

arreglos-c

Prácticas de arreglos en C
C
1
star