Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cuco

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cuco

  • 0.1.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Cuco

Gem Version GEM Downloads MIT License

Cuco watches files in a directory and take an action when they change.

Cuco is controlled by a user-supplied script file. Intermixed "watch" commands specify what to do for the particular modified files.

Cuco is:

  • Simple to use
  • Highly flexible
  • Evented ( uses gem listen )
  • Portable ( Ruby )

Most importantly it is agnostic to:

  • Test frameworks
  • Web frameworks

Installation

$ gem install cuco

Usage

$ cuco          # default script file is .watchr
 Or
$ cuco path/to/script/file

will monitor files in the current directory tree and react to events on those files in accordance with the script.

A simple example of a script file

This sample script is intended for testing purposes with Minitest. md is the match-data (see Ruby regular expressions).

watch( 'test/.*_test\.rb$' ) { |md| run_it(md[0]) }
watch( 'lib/(.*)\.rb$' )     { |md| run_it("test/#{md[1]}_test.rb") }

def run_it(file)
  system %(bundle exec ruby -I test #{file})
end

Signal.trap("QUIT") { system("bundle exec rake") } # Ctrl-\ or ctrl-4
Signal.trap("INT")  { abort("Interrupted\n") }     # Ctrl-C

Script

Scripts are pure Ruby.

Intermixed are "watch" rules that match observed files to an action. The matching is achieved by a pattern (a regular expression) parameter. The action is specified by a block (see above sample).

Updates to script files are picked up on the fly (no need to restart cuco) so experimenting is painless.

It's easy to see why cuco is so flexible, since the whole command is custom. The above actions could just as easily call "jruby", "ruby --rubygems", "ruby -I lib", etc. or any combination of these.

See directory scripts for samples.

Miscellaneous

Cuco is heavily inspired by:

  • gem watchr
  • gem observr (a follow-up of gem watchr)

Copyright (c) 2024 Dittmar Krall (www.matiq.com), released under the MIT license.

FAQs

Package last updated on 21 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc