Repository: f/guardian Branch: master Commit: 8c1f129b829c Files: 11 Total size: 5.2 KB Directory structure: gitextract_w7gqioyv/ ├── .github/ │ └── workflows/ │ └── crystal.yml ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── guardian.yml ├── install.sh ├── shard.yml ├── spec/ │ ├── guardian.cr │ └── spec_helper.cr └── src/ └── guardian.cr ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/workflows/crystal.yml ================================================ name: Crystal CI on: push: branches: [ master ] pull_request: branches: [ master ] schedule: - cron: '0 5 * * 0' jobs: build: runs-on: ubuntu-latest container: image: crystallang/crystal steps: - uses: actions/checkout@v2 - name: Install dependencies run: shards install - name: Run build run: crystal build src/guardian.cr ================================================ FILE: .gitignore ================================================ /doc/ /libs/ /.crystal/ /.shards/ guardian # Libraries don't need dependency lock # Dependencies will be locked in application that uses them /shard.lock ================================================ FILE: .travis.yml ================================================ language: crystal ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2016 Fatih Kadir Akın Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # 💂 Guardian.cr Guardian watches over your files and runs assigned tasks. ![Guardian](http://i.imgur.com/mUzv2DL.gif) ## Installation ### OS X ```bash brew tap f/guardian brew install guardian ``` ### Arch Linux Guardian is availabe as a package from the Arch User Repository called [guardian-git](https://aur.archlinux.org/packages/guardian-git/) ### From Source ```bash git clone https://github.com/f/guardian.git && cd guardian crystal build src/guardian.cr --release ``` ## Quickstart ### Crystal Libs Guardian works seamless with Crystal Projects. It automatically binds itself to library you use. ```bash $ crystal init lib yourlib $ cd yourlib $ guardian --init Created guardian.yml of ./src/yourlib.cr ``` ### Non-Crystal Libs You can use Guardian for other projects. ```bash $ guardian --init Created guardian.yml ``` ## Usage ```bash $ guardian --init ``` It will create a `guardian.yml` file to use by Guardian. ## `guardian.yml` `guardian.yml` is a simple YAML file. Simply it has **YAML documents** with seperated by `---` line and each document has `files` and `run` keys. `files` key needs a glob pattern, and `run` is a shell command what to run. ```yaml files: ./**/*.cr run: crystal build ./src/guardian.cr --- files: ./shard.yml run: shards install ``` ### `%file%` Variable Guardian replaces `%file%` variable in commands with the changed file. ```yaml files: ./**/*.txt run: echo "%file% is changed" ``` Think you have a `hello.txt` in your directory, and Guardian will run `echo "hello.txt is changed"` command when it's changed. ## Running Guardian ```bash $ guardian 💂 Guardian is on duty! ``` ## Contributing 1. Fork it ( https://github.com/f/guardian/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 - [f](https://github.com/f) Fatih Kadir Akın - creator, maintainer ================================================ FILE: guardian.yml ================================================ files: ./**/*.cr run: crystal build ./src/guardian.cr --- files: ./shard.yml run: shards install ================================================ FILE: install.sh ================================================ #!/bin/bash # for linux users cp ./guardian /usr/bin/guardian ================================================ FILE: shard.yml ================================================ name: guardian version: 0.0.6 authors: - Fatih Kadir Akın - f1refly targets: guardian: main: src/guardian.cr crystal: 0.35.1 license: MIT ================================================ FILE: spec/guardian.cr ================================================ require "./spec_helper" describe Guardian do # TODO: Write tests it "works" do true.should eq(true) end end ================================================ FILE: spec/spec_helper.cr ================================================ require "spec" require "../src/guardian" ================================================ FILE: src/guardian.cr ================================================ require "./guardian/*" require "option_parser" require "colorize" ignore_executables = true clear_on_action = false case ARGV[0]? when "init" puts "\"init\" has been deprecated please use: -i or --init" Guardian::Generator.new.generate exit else OptionParser.parse do |options| options.on "-i", "--init", "Generates the guardian.yml file" do Guardian::Generator.new.generate exit end options.on "-v", "--version", "Shows the version" do puts "Guardian (#{Guardian::VERSION})" exit end options.on "-h", "--help", "Shows the help" do puts options exit end options.on "-e", "--watch-executables", "Include files marked as executable" do ignore_executables = false end options.on "-nc", "--no-colour", "Disable coloring of text output" do Colorize.enabled = false end options.on "-c", "--clear", "Clear terminal before each action" do clear_on_action = true end options.invalid_option do puts options exit end end end Guardian::Watcher.new ignore_executables, clear_on_action