Permalink
Browse files

Remove BUST code.

The BUST code has some problems, per recent bloom-lang discussion; it can be
reimplemented, but doesn't need to be part of the core Bud runtime.  This also
avoids the need to depend on nestful, json and activesupport.
  • Loading branch information...
1 parent 45e5b09 commit f08cb0e147bb2e6cee945350fc2048fff1ee2db4 @neilconway neilconway committed Apr 2, 2012
View
@@ -20,9 +20,7 @@ Gem::Specification.new do |s|
s.add_dependency 'gchart'
s.add_dependency 'getopt'
s.add_dependency 'i18n'
- s.add_dependency 'json'
s.add_dependency 'msgpack'
- s.add_dependency 'nestful'
s.add_dependency 'ruby-graphviz'
s.add_dependency 'ruby2ruby', '< 1.3.1'
s.add_dependency 'ruby_parser'
View
@@ -1,83 +0,0 @@
-BUST stands for BUd State Transfer and it is a REST interface to Bud. BUST consists of a Bud implementation of a client and server. The client implements bindings to a subset of the Ruby Nestful library, and the server is a lightweight HTTP server written in Ruby. Note that the BUST server currently sets the "Access-Control-Allow-Origin: *" HTTP header to override web browsers' same-origin policy.
-
-Right now BUST supports "GET" and "POST" requests, and may support "DELETE" and "PUT" requests in the future.
-
-# BUST Server
-
-For the BUST server, a "GET" request corresponds to retrieving a subset of rows of a table, and a "POST" request corresponds to inserting a row into a table. For example, the following "GET" request (assuming BUST is running on port 8080):
-
- GET localhost:8080/foo?bar=hello&baz=world
-
-would retrieve all rows in table "foo" where named schema attribute "bar" is equal to the string "hello", and named schema attribute "baz" is equal to the string "world". Right now, one limitation of BUST is that only strings are supported.
-
-To use BUST in your program, ensure you have the json gem installed. Add the "require" line for BUST:
-
- require "bud/bust/bust"
-
-In your class, make sure to:
-
- include Bust
-
-That's it! Now a BUST server will be started up when your class is instantiated. This server will listen on an open port; it will print out "Bust server listening on port xxxxx" to let you know which port it has selected. But you can select a specific port by passing a port via the "bust_port" option when you instantiate your class.
-
-You can test out the BUST server using Ruby's "net/http" library if you want, and you can also check out "BUST Inspector", a sample AJAX application that allows you to view the state of a bud instance.
-
-## net/http Example
-
-Try running "bustserver-example.rb" in the "examples/bust" directory:
-
- ruby bustserver-example.rb
-
-Now, let's interact with our example using "net/http" from within IRB. Start up an IRB instance:
-
- irb
- irb(main):001:0> require 'net/http'
- => true
-
-bustexample.rb defines a single relation called "foo":
-
- table :foo, [:bar, :baz, :qux]
-
-Let's fire off some requests. First, let's put a new foo fact in:
-
- irb(main):002:0> res = Net::HTTP.post_form(URI.parse('http://localhost:8080/foo'), {:bar => "a", :baz => "b", :qux => "c"})
- => #<Net::HTTPOK 200 /OK readbody=true>
-
-Now, let's retrieve all foo facts where the "qux" attribute is "c", and the "baz" attribute is "b":
-
- irb(main):003:0> res = Net::HTTP.get(URI.parse('http://localhost:8080/foo?qux=c&baz=b'))
- => "[[\"a\",\"b\",\"c\"]]"
-
-Note that the response is a JSON array.
-
-
-## BUST Inspector
-
-BUST Inspector -- an example app that uses XMLHttpRequests to inspect state in a Bud program using BUST is included -- (bust/bustinspector.html). Right now, it assumes that the Bud instance you're trying to inspect is listening on "localhost" at port "8080". BUST Inspector is tested to work in Firefox, and may or may not work in other browsers. BUST Inspector will query your Bud instance every second for metadata describing the tables and their schema. It will display a list of the tables in a pane on the left of the screen, with a checkbox next to each table. Selecting a checkbox renders the current table contents in the right pane (these are also updated every second while the box is checked).
-
-
-# BUST Client
-
-The BUST client (located in the "bust/client" folder) allows Bud applications to access REST services (including a Bud client hosting a BUST instance). The REST client is basically a wrapper for the Ruby nestful library. You'll need to ensure you have the "nestful" gem installed before you can use the REST client. To use it in your application, you need to put the require line:
-
- require 'bud/bust/client/restclient'
-
-and the include line:
-
- include RestClient
-
-To make requests, insert into the rest_req interface, whose definition is reproduced below:
-
- interface input, :rest_req, [:rid, :verb, :form, :url, :params]
-
-"rid" is a unique ID for the request, "verb" is one of ":get" or ":post", "form" is the format of the request, for example, you might use ":json", or if you're doing a form post, you'd use "form". If set to nil, "form" defaults to ":form" for ":post", and is omitted from a ":get". For ":get" requests, the "form" parameter seems to be appended onto the end of "url". For example, if you do a ":get" for "http://example.com/ex" with "form" set to ":json", the library sends an HTTP GET to "http://example.com/ex.json". "params" is a hash, which comprises the query string for a ":get", and the contents of the body in a ":post" with "form" set to ":form".
-
-The output interface is:
-
- interface output, :rest_response, [:rid, :resp, :exception]
-
-"rid" is the unique ID supplied when the request was made, "resp" is the parsed response from the server. For example, if you do a ":json" ":get", then "resp" will contain whatever JSON object was returned converted into a Ruby object, e.g., array, hash, etc. If there is an exception, then "resp" will contain a string describing the exception, and "exception" will be set to true; otherwise, "exception" will be set to false.
-
-A simple example is included (bustclient-example.rb) that does an HTTP GET on Twitter's public timeline, returning the most recent statuses, and prints them to stdout. The example is in "examples/bust/client".
-
-The BUST client does not yet support OAuth. Also unsupported so far is HTTP DELETE and PUT.
View
@@ -1,9 +0,0 @@
-To run the bust twitter example client, do the following:
-
- # ruby bustclient-example.rb
-
-To test out bust inspector, do the following:
-
- # ruby bustserver-example.rb
-
-Then, launch bustinspector.html in a web browser (only Firefox 4 has been tested thus far) on either the computer where you launched bustserver-example.rb, or any computer that has TCP port 8080 forwarded to the computer where you launched bustserver-example.rb.
@@ -1,23 +0,0 @@
-require 'rubygems'
-require 'bud'
-require 'bud/bust/client/restclient'
-
-class TwitterExample # :nodoc: all
- include Bud
- include RestClient
-
- bootstrap do
- # get the 20 most recent tweets from twitter
- rest_req <= [[1, :get, :json,
- 'http://api.twitter.com/1/statuses/public_timeline']]
- end
-
- bloom :print_recent_tweets do
- # print the tweets with user screen names
- stdio <~ rest_response do |r|
- [r.resp.map {|s| s["user"]["screen_name"] + ": " + s["text"]}] if r.rid==1
- end
- end
-end
-
-TwitterExample.new.run_fg
@@ -1,135 +0,0 @@
-<html>
-<head>
-<title>BUST Inspector</title>
-
-<script type="text/javascript">
-function pollState()
-{
-
-// 1. GET the list of tables
-var xmlhttp = new XMLHttpRequest();
-xmlhttp.open("GET","http://localhost:8080/t_table_info",false);
-xmlhttp.send();
-
-if (xmlhttp.readyState==4) {
-if (xmlhttp.status == 404){
-alert("error fetching 't_table_info'");
-}
-if (xmlhttp.status == 200){
-tableArray = JSON.parse(xmlhttp.responseText);
-
-var tablenames = document.getElementById("tablenames");
-
-for (var i = 0; i < tableArray.length; i++) {
-var tablename = tableArray[i][0]
-// if the collection is new
-if (!document.getElementById("coll_" + tablename)) {
-var newspan = document.createElement("span");
-newspan.innerHTML = '<input type="checkbox" id="coll_' + tablename + '"/>' + tablename + '(<small><b>' + tableArray[i][1] + '</b></small>) <br/>'
-while (newspan.firstChild) {
-tablenames.appendChild(newspan.firstChild);
-}
-}
-}
-
-}
-}
-
-
-// 2. GET the schema table
-var schemareq = new XMLHttpRequest();
-schemareq.open("GET","http://localhost:8080/t_table_schema",false);
-schemareq.send();
-
-if (schemareq.status == 404) {
-alert("error fetching schema info");
-}
-if (schemareq.status == 200) {
-schemaArray = JSON.parse(schemareq.responseText)
-}
-
-
-// 3. GET the list of checked tables
-form_elts = document.forms[0].elements
-for (var i = 0; i < form_elts.length; i++) {
-var tablename = form_elts[i].id.substr(5);
-
-//look it up in the schema
-var schemaIdx;
-var found = false;
-for (schemaIdx = 0; schemaIdx < schemaArray.length; schemaIdx++) {
-if (schemaArray[schemaIdx][0] == tablename) {
-found = true;
-break;
-}
-}
-if (!found) {
-alert ("no schema information for table " + tablename);
-}
-
-var ourSchema = schemaArray[schemaIdx][1];
-
-if (form_elts[i].checked) {
-var tablereq = new XMLHttpRequest();
-tablereq.open("GET","http://localhost:8080/"+tablename,false);
-tablereq.send();
-
-if (tablereq.status == 404){
-alert("error fetching table " + tablename);
-}
-if (tablereq.status == 200){
-responseArray = JSON.parse(tablereq.responseText)
-
-//schema
-tableText = "<table style='border-width: 1px; border-spacing: 2px; border-style: outset; border-color: gray; border-collapse: separate;'><tr>";
-for (var j = 0; j < ourSchema.length; j++) {
-tableText += "<td style='border-width: 1px; padding: 1px; border-style: inset; border-color: gray;'><b>" + ourSchema[j] + "</b></td>";
-}
-tableText += "</tr>";
-
-//data
-for (var k = 0; k < responseArray.length; k++) {
-tableText += "<tr>";
-for (var l = 0; l < responseArray[k].length; l++) {
-tableText += "<td style='border-width: 1px; padding: 1px; border-style: inset; border-color: gray;'>" + responseArray[k][l] + "</td>";
-}
-tableText += "</tr>";
-}
-tableText += "</table>";
-
-if (!document.getElementById("disp_" + tablename)) {
-document.getElementById("tabledisplay").innerHTML += '<div style="border: 1px solid black; float:left; padding: 0px; margin:5px;" id="disp_' + tablename + '"><h4 style="margin-top:0px;">' + tablename + '</h4>' + tableText + '</div>';
-} else {
-document.getElementById("disp_" + tablename).innerHTML = '<h4 style="margin-top:0px;">' + tablename + '</h4>' + tableText;
-}
-}
-} else { //if not checked
-if (document.getElementById("disp_" + tablename)) {
-document.getElementById("tabledisplay").removeChild(document.getElementById("disp_" + tablename))
-}
-}
-
-} //end for
-
-
-setTimeout('pollState()', 1000);
-}
-
-</script>
-
-</head>
-
-<body onLoad="setTimeout('pollState()', 1000);">
-
- <div style="width:100%;"><h3>BUST Inspector</h3></div>
- <div style="height:100%; border: 1px solid black; float:left; padding:0px; margin:5px;">
- <h4 style="margin-top:0px;">Collections</h4>
- <form id="tableform">
- <span id="tablenames">
- </span>
- </form>
- </div>
- <span id="tabledisplay">
- </span>
-</body>
-</html>
@@ -1,18 +0,0 @@
-require 'rubygems'
-require 'bud'
-require 'bud/bust/bust'
-
-class BustExample # :nodoc: all
- include Bud
- include Bust
-
- state do
- table :foo, [:bar, :baz, :qux]
- end
-
- bloom do
- stdio <~ foo {|t| [t.inspect]}
- end
-end
-
-BustExample.new(:bust_port => 8080).run_fg
View
@@ -75,7 +75,6 @@ module Bud
# * <tt>:port</tt> port number for this instance
# * <tt>:ext_ip</tt> IP address at which external nodes can contact this instance
# * <tt>:ext_port</tt> port number to go with <tt>:ext_ip</tt>
- # * <tt>:bust_port</tt> port number for the restful HTTP messages
# * operating system interaction
# * <tt>:stdin</tt> if non-nil, reading from the +stdio+ collection results in reading from this +IO+ handle
# * <tt>:stdout</tt> writing to the +stdio+ collection results in writing to this +IO+ handle; defaults to <tt>$stdout</tt>
Oops, something went wrong.

0 comments on commit f08cb0e

Please sign in to comment.