Git Product home page Git Product logo

jig's Introduction

Jig
    by Gary R. Wright
    http://jig.rubyforge.org

== DESCRIPTION:
  
A jig is a data structure designed to facilitate construction and
manipulation of strings with an inherent hierarchical syntax.  The
idea is derived from the <bigwig> project (http://www.brics.dk/bigwig/)
and in particular the XML templating constructs described in the
paper: A Type System for Dynamic Web Documents
(http://www.brics.dk/bigwig/publications/dyndoc.pdf).  The name is
derived from woodworking where a jig is a template designed to guide
other tools.

A jig is an ordered sequence of objects (usually strings) and named
_gaps_.  When rendered as a string by Jig#to_s, the objects are
rendered calling #to_s on each object in order. The gaps are skipped.

A new jig may be constructed from an existing jig by 'plugging' one
or more of the named gaps.  The new jig shares the objects and their
ordering from the original jig but with the named gap replaced with
the 'plug'.  Gaps may be plugged by any object or sequence of
objects.  When a gap is plugged with another jig, the contents
(including gaps) are incorporated into the new jig.

Several subclasses (Jig::XML, Jig::XHTML, Jig::CSS) are defined to
help in the construction of XML, XHTML, and CSS documents.

This is a jig with a single gap named :alpha.
  Jig.new(:alpha)                         # => <#Jig: [:alpha]>
This is a jig with two objects, 'before' and 'after' separated by
a gap named :middle.
  j = Jig.new('before', :middle, 'after)  # => #<Jig: ["before", :middle, "after"]>
The plug operation derives a new jig from the old jig.
  j.plug(:middle, ", during, and")        # => #<Jig: ["before", ", during, and ", "after"]>
This operation doesn't change j.  It can be used again:
  j.plug(:middle, " and ")                # => #<Jig: ["before", " and ", "after"]>
There is a destructive version of plug that modifies
the jig in place:
  j.plug!(:middle, "filled")          # => #<Jig: ["before", "filled", "after"]>
  j                                   # => #<Jig: ["before", "filled", "after"]>
There are a number of ways to construct a Jig and many of
them insert an implicit gap into the Jig.  This gap is
identified as :___ and is used as the default gap
for plug operations when one isn't provided:

  puts Jig.new("A", :___, "C").plug("B")   # => ABC

In order to make Jig's more useful for HTML generation,
the Jig::XHTML class supports a variety of convenience methods;

  HT = Jig::XHTML
  puts b = HT.element("body")     # => <body></body>
  puts b.plug("text")             # => <body>text</body>

Method missing makes this even simpler:

  b = HT.span
  puts b.plug("text")             # => <span>text</span>

Attributes can be specified with a hash:

  summary = HT.p(:class => "summary")
  puts summary.plug("This is a summary") # => <p class="summary">This is a summary</p>

== REQUIREMENTS:

* Ruby 1.8

== INSTALL:

* sudo gem install jig

== LICENSE:

(The MIT License)

Copyright (c) 2007 Gary R. Wright

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.

jig's People

Contributors

gwright avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.