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

greenletters

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

greenletters

  • 0.3.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

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

Configuration:

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

#+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.

FAQs

Package last updated on 28 Dec 2012

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