greenletters

0.3.0last stable release 12 years ago
Complexity Score
Low
Open Issues
8
Dependent Projects
4
Weekly Downloadsglobal
75

Downloads

Readme

#+Title: Greenletters README #+AUTHOR: Avdi Grimm #+EMAIL: avdi@avdi.org

Configuration:

#+STARTUP: odd #+STARTUP: hi #+STARTUP: hidestars

  • Synopsis

    See introductory blog post [[http://avdi.org/devblog/2010/07/19/greenletters-painless-automation-and-testing-for-command-line-applications/][HERE]].

#+BEGIN_SRC ruby require ‘greenletters’

adv = Greenletters::Process.new(“adventure”, :transcript => $stdout)

Install a handler which may be triggered at any time

adv.on(:output, /welcome to adventure/i) do |process, match_data| adv << “no\n” end

puts “Starting adventure…” adv.start!

Wait for the specified pattern before proceeding

adv.wait_for(:output, /you are standing at the end of a road/i) adv << “east\n” adv.wait_for(:output, /inside a building/i) adv << “quit\n” adv.wait_for(:output, /really want to quit/i) adv << “yes\n” adv.wait_for(:exit) puts “Adventure has exited.” #+END_SRC

Or, in Cucumber format:

#+BEGIN_SRC Given process activity is logged to “greenletters.log” Given a process “adventure” from command “adventure” Given I reply “no” to output “Would you like instructions?” from process “adventure” Given I reply “yes” to output “Do you really want to quit” from process “adventure” When I execute the process “adventure” Then I should see the following output from process “adventure”: “”” You are standing at the end of a road before a small brick building. Around you is a forest. A small stream flows out of the building and down a gully. “”” When I enter “east” into process “adventure” Then I should see the following output from process “adventure”: “”” You are inside a building, a well house for a large spring. “”” #+END_SRC

  • What

    Greenletters is a console interaction automation library similar to [[http://directory.fsf.org/project/expect/][GNU Expect]]. You can use it to script interactions with command-line programs.

  • Why Because Ruby’s built-in expect.rb is pretty underpowered and I wanted to drive command-line applications from Ruby, not TCL.

  • Who Greenletters is by [[mailto:avdi@avdi.org][Avdi Grimm]].

  • Where http://github.com/avdi/greenletters

  • How Greenletters uses the pty.rb library under the covers to create a UNIX pseudoterminal under Ruby’s control. Of course, this means that it is MacOSX/Linux/*NIX-only; Windows users need not apply.

    The advantage of using a PTY is that any output - including output written to the console instead of STDOUT/STDERR - will be captured by Greenletters.

  • Cucumber To use the Cucumber steps in your own feature files, put the following in your env.rb:

#+BEGIN_SRC ruby require ‘greenletters’ require ‘greenletters/cucumber_steps’ #+END_SRC

  • LICENSE

(The MIT License)

Copyright (c) 2010 Avdi Grimm

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.

Dependencies

No runtime dependency information found for this package.

CVE IssuesActive
0
Scorecards Score
No Data
Test Coverage
No Data
Follows Semver
Yes
Github Stars
116
Dependenciestotal
1
DependenciesOutdated
0
DependenciesDeprecated
0
Threat Modelling
No
Repo Audits
No

Learn how to distribute greenletters in your own private RubyGems registry

gem install greenletters
Processing...
Done

4 Releases

RubyGems on Cloudsmith

Getting started with RubyGems on Cloudsmith is fast and easy.