
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Homepage / Report Issue / Source Code / IRC Channel
"Logic programming meets the build tool."
Ergo is a build tool that promotes continuous integration via logic programming. With Ergo, the Ruby developer defines rules and state conditions. The rules are applied when their state conditions are met. Through repetitive application, this allows a project to all but manage itself.
Ergo is not complicated. It goes not require a bazillion plug-ins. Although some external tools can be helpful and used with it, and it makes some procedures more convenient --for example it makes FileUtils methods directly available in the build script context, mostly it just trusts the developer to know how to write the build scripts they need.
Below you will find a brief "Hot Minute" guide for getting up and running with Ergo quickly. It's just enough to give you familiarity the basic ideas of Ergo and how to start putting it to good use. For more detailed instruction, explanation of terms and how the dickens does it work under-the-hood, please consider any of the following resources.
To install, either use RubyGems directly:
$ gem install ergo
Or add gem "ergo"
to your Gemfile and run:
$ bundle install
Create a .ergo
directory in your project.
$ mkdir .ergo
Edit the .ergo/script.rb
file.
$ vi .ergo/script.rb
And add the following example script to the file.
manifest = %w[bin/**/* lib/**/* *.md]
state :need_manifest? do
if File.exist?('MANIFEST')
files = manifest.map{ |d| Dir[d] }.flatten
saved = File.readlines('MANIFEST').map{ |f| f.strip }
files != saved
else
true
end
end
desc "update manifest"
rule need_manifest? do
files = manifest.map{ |d| Dir[d] }.flatten
File.open('MANIFEST', 'w'){ |f| f << files.join("\n") }
end
desc "run my minitests"
rule 'lib/**/*.rb' do |libs|
$: << 'lib'
files = Dir.glob('test/**/*_test.rb')
files.each{|file| require "./" + file}
end
Now run it with:
$ ergo
And there you go. Ergo, in a hot minute!
As the capable Ruby programmer, it probable doesn't require much explanation to understand the above code and what happened when you ran it. Just the same it can help to go over it with the proper terminology. Of course, the rules in our example are simplistic and they make some basic assumptions about a project, so you will want to modify these to suite your needs (or dispose of them and write fresh). Nonetheless, this example provides some clear examples of the basics of writing Ergo scripts.
In the example we first create a state called update_manifest?
. It
simply checks to see if the list of files in the project's MANIFEST
file matches the project files expected to be there. Notice it returns
a boolean value, true or false. Along with this state we create a rule
that uses the state by calling the update_manifest?
method. This method
was created by the state definition above. The rule procedure updates the
MANIFEST file whenever the state return true
, i.e. the manifest does
not have the expected content.
At the end of our example script we create an additional rule. This
one does not reference a defined state. Instead it create a file state
implicitly by passing a string argument to rule
. A file state has a
very simple and very useful definition. It returns true
whenever a
matching file has changed from one execution of ergo
to the next.
In other words, per this example, whenever a Ruby file in the lib
directory changes, Ergo is going to run the units tests in the test
directory.
Okay, so now we have a example rules script and have a basic grasp of
how it works. And we know we can run the rules simple by invoking the
ergo
command on command line. But if we want to have ergo run
automatically periodically, we can pass it the number of seconds to
wait between runs via the -a/--auto
option.
$ ergo -a 180
See it pays to read all the way to the end ;)
The Ergo repository is hosted on GitHub. If you would like to contribute to the project (and we would be over joyed if you did!) the rules of engagements are very simple.
Ergo is copyrighted open-source software.
Copyright (c) 2011 Rubyworks. All rights reserved.
It is modifiable and redistributable under the terms of the BSD-2-Clause license.
See the enclosed LICENSE.txt file for details.
(火)
FAQs
Unknown package
We found that ergo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.