Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit da853817c5211111d2119a6a3e6684176a4b6d71 @tenderlove committed Mar 25, 2012
Showing with 160 additions and 0 deletions.
  1. +8 −0 .autotest
  2. +6 −0 CHANGELOG.rdoc
  3. +7 −0 Manifest.txt
  4. +48 −0 README.rdoc
  5. +18 −0 Rakefile
  6. +3 −0 bin/spectacular
  7. +3 −0 lib/spectacular.rb
  8. +18 −0 lib/spectacular/index.html
  9. +41 −0 lib/spectacular/server.rb
  10. +8 −0 test/test_spectacular.rb
8 .autotest
@@ -0,0 +1,8 @@
+# -*- ruby -*-
+
+require 'autotest/restart'
+
+Autotest.add_hook :initialize do |at|
+ at.testlib = 'minitest/autorun'
+ at.find_directories = ARGV unless ARGV.empty?
+end
6 CHANGELOG.rdoc
@@ -0,0 +1,6 @@
+=== 1.0.0 / 2012-03-25
+
+* 1 major enhancement
+
+ * Birthday!
+
7 Manifest.txt
@@ -0,0 +1,7 @@
+History.txt
+Manifest.txt
+README.txt
+Rakefile
+bin/spectacular
+lib/spectacular.rb
+test/test_spectacular.rb
48 README.rdoc
@@ -0,0 +1,48 @@
+= spectacular
+
+* FIX (url)
+
+== DESCRIPTION:
+
+FIX (describe your package)
+
+== FEATURES/PROBLEMS:
+
+* FIX (list of features or problems)
+
+== SYNOPSIS:
+
+ FIX (code sample of usage)
+
+== REQUIREMENTS:
+
+* FIX (list of requirements)
+
+== INSTALL:
+
+* FIX (sudo gem install, anything else)
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2012 Aaron Patterson
+
+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.
18 Rakefile
@@ -0,0 +1,18 @@
+# -*- ruby -*-
+
+require 'rubygems'
+require 'hoe'
+
+Hoe.plugins.delete :rubyforge
+Hoe.plugin :minitest
+Hoe.plugin :gemspec # `gem install hoe-gemspec`
+Hoe.plugin :git # `gem install hoe-git`
+
+Hoe.spec 'spectacular' do
+ developer('Aaron Patterson', 'aaron@tenderlovemaking.com')
+ self.readme_file = 'README.rdoc'
+ self.history_file = 'CHANGELOG.rdoc'
+ self.extra_rdoc_files = FileList['*.rdoc']
+end
+
+# vim: syntax=ruby
3 bin/spectacular
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+
+abort "you need to write me"
3 lib/spectacular.rb
@@ -0,0 +1,3 @@
+class Spectacular
+ VERSION = '1.0.0'
+end
18 lib/spectacular/index.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script>
+ if (!!window.EventSource) {
+ var source = new EventSource('/events.json');
+ source.addEventListener('message', function(e) {
+ alert(e.data);
+ }, false);
+ } else {
+ alert('your browser is not supported');
+ }
+ </script>
+ </head>
+ <body>
+ <h1>HELLO WORLD</h1>
+ </body>
+</html>
41 lib/spectacular/server.rb
@@ -0,0 +1,41 @@
+require 'webrick'
+
+module Spectacular
+ module Server
+ dir = File.dirname __FILE__
+ INDEX = File.read File.expand_path File.join dir, 'index.html'
+
+ class Index < WEBrick::HTTPServlet::AbstractServlet
+ def do_GET request, response
+ response.status = 200
+ response['Content-Type'] = 'text/html'
+ response.body = INDEX
+ end
+ end
+
+ class Events < WEBrick::HTTPServlet::AbstractServlet
+ def do_GET request, response
+ response.status = 200
+ response['Content-Type'] = 'text/event-stream'
+ rd, rw = IO.pipe
+
+ response.body = rd
+
+ Thread.new {
+ rw.write "retry: 100000\n"
+ rw.write "data: omg lol\n"
+ rw.close
+ }
+ end
+ end
+ end
+end
+
+if $0 == __FILE__
+ server = WEBrick::HTTPServer.new :Port => 8080
+ server.mount '/', Spectacular::Server::Index
+ server.mount '/events.json', Spectacular::Server::Events
+
+ trap('INT') { server.shutdown }
+ server.start
+end
8 test/test_spectacular.rb
@@ -0,0 +1,8 @@
+require 'minitest/autorun'
+require 'spectacular'
+
+class TestSpectacular < MiniTest::Unit::TestCase
+ def test_sanity
+ flunk "write tests or I will kneecap you"
+ end
+end

0 comments on commit da85381

Please sign in to comment.