Project

prolego

0.0
No commit activity in last 3 years
No release in over 3 years
Designed initially for UNM Informatics lab
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.7
~> 10.0
 Project Readme

Prolegomenon

"a critical or discursive introduction to a book"

Gem Version

This is a gem intended for UNM to interface Ruby with Prolog.

Installation

Add this line to your application's Gemfile:

gem 'prolego'

And then execute:

$ bundle

Or install it yourself as:

$ gem install prolego

Usage

Initiate a Prolog Query as a Ruby object. This expects a file to have some predicates defined that it can use from the command line.

prolog = Prolego::Query.new("Top.pl")

If you would like an exception to be thrown if Prolog fails, use whiny: true

prolog = Prolego::Query.new("Top.pl", whiny: true)

After initializing this, make queries against your Prolog file. Note this runs Prolog from the interactive mode, so no need to compile Prolog. The command method takes two arguments, the predicate name and the argument list. The argument list expects an array, so if you have arrays within your arguments, nest them.

prolog.command("ce",["BS",[["MATH 162","A"],["CE 160L","A"]]])

To get the output of the command, use the output method:

prolog.output

To get anything that went into STDERR (like warnings), use the error method:

prolog.error

We have a special method called epilog to get our formatted output. This splits our Prolog output for our application, based on the last command sent from the current Prolegomenon object. This expects lists to be returned. We are using writeq to do this, then the gem parses them using the JSON gem.

prolog.epilog

Contributing

  1. Fork it ( https://github.com/[my-github-username]/prolego/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

Inspired by Dr. Chris Lamb