ichabod 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +20 -0
- data/README.md +54 -0
- data/Rakefile +37 -0
- data/bin/ichabod +39 -0
- data/examples/index.html +25 -0
- data/examples/jasmine/index.html +25 -0
- data/examples/jasmine/klass.js +52 -0
- data/examples/jasmine/lib/MIT.LICENSE +20 -0
- data/examples/jasmine/lib/jasmine-html.js +188 -0
- data/examples/jasmine/lib/jasmine.css +166 -0
- data/examples/jasmine/lib/jasmine.js +2421 -0
- data/examples/jasmine/model.js +206 -0
- data/examples/jasmine/model.spec.js +34 -0
- data/lib/ichabod/coercion.rb +61 -0
- data/lib/ichabod/delegate/load.rb +28 -0
- data/lib/ichabod/delegate/ui.rb +18 -0
- data/lib/ichabod/repl.rb +47 -0
- data/lib/ichabod/runtime.rb +58 -0
- data/lib/ichabod/script_object/ichabod.rb +35 -0
- data/lib/ichabod/script_object/ruby.rb +43 -0
- data/lib/ichabod/tests.rb +20 -0
- data/lib/ichabod/version.rb +9 -0
- data/lib/ichabod.rb +38 -0
- data/lib/js/jasmine.js +107 -0
- data/lib/js/qunit.js +10 -0
- metadata +80 -0
    
        data/MIT-LICENSE
    ADDED
    
    | @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            Copyright (c) 2011 Chris Wanstrath, Alex MacCaw
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 4 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 5 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 6 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 7 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 8 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 9 | 
            +
            the following conditions:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 12 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 15 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 16 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 17 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 18 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 19 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,54 @@ | |
| 1 | 
            +
            #Ichabod
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Run JavaScript tests from the command line using a headless version of WebKit.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Features:
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              * [Jasmine](http://pivotal.github.com/jasmine) tests support
         | 
| 8 | 
            +
              <!-- * [QUnit](TODO) tests support -->
         | 
| 9 | 
            +
              * Use Ruby methods from JavaScript
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            ## Prerequisites
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            The only prerequisites are OSX and [macruby](http://www.macruby.org).
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            ## Usage
         | 
| 16 | 
            +
                
         | 
| 17 | 
            +
                ichabod ./your/file.html
         | 
| 18 | 
            +
                ichabod http://example.com
         | 
| 19 | 
            +
                
         | 
| 20 | 
            +
                ichabod --jasmine http://your-jasmine-test-page.html
         | 
| 21 | 
            +
            <!-- ichabod --qunit http://your-qunit-test-page.html -->
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                ichabod --jasmin ./local-qunit-path/index.html
         | 
| 24 | 
            +
                  xxxxxxxxxxxxxoxxxxxxxxxx
         | 
| 25 | 
            +
                  
         | 
| 26 | 
            +
                  - X failed because of xyz
         | 
| 27 | 
            +
                  
         | 
| 28 | 
            +
            ## More Usage
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                $ ichabod
         | 
| 31 | 
            +
                js> 1 + 1
         | 
| 32 | 
            +
                => 2
         | 
| 33 | 
            +
                js> function name() { return "ichabod!" }
         | 
| 34 | 
            +
                => undefined
         | 
| 35 | 
            +
                js> name
         | 
| 36 | 
            +
                => function name() { return "ichabod!" }
         | 
| 37 | 
            +
                js> name()
         | 
| 38 | 
            +
                => "ichabod!"
         | 
| 39 | 
            +
                js> Ruby.puts('Ruby, I presume.')
         | 
| 40 | 
            +
                Ruby, I presume.
         | 
| 41 | 
            +
                => undefined
         | 
| 42 | 
            +
                js> Ruby.File_read('hi.js')
         | 
| 43 | 
            +
                => "// this is hi.js\n"
         | 
| 44 | 
            +
                js> Ichabod.exit();
         | 
| 45 | 
            +
                
         | 
| 46 | 
            +
            ## Credit
         | 
| 47 | 
            +
             | 
| 48 | 
            +
            Credit should go to the real author behind this - [Chris Wanstrath](https://github.com/defunkt) who wrote [Lyndon](https://github.com/defunkt/lyndon). Most of the code follows his original ideas, I've extended that to add test support and enhancements to the WebKit WebView. 
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            And thanks to my [tweeps](http://twitter.com/maccman) who suggested the name: knewter, tiegz, enriclluelles.
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            ## Copyright
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            Copyright (c) 2011 Chris Wanstrath, Alex MacCaw under the MIT LICENSE.
         | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1,37 @@ | |
| 1 | 
            +
            begin
         | 
| 2 | 
            +
              require 'jeweler'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              # We're not putting VERSION or VERSION.yml in the root,
         | 
| 5 | 
            +
              # so we have to help Jeweler find our version.
         | 
| 6 | 
            +
              $LOAD_PATH.unshift File.dirname(__FILE__) + '/lib'
         | 
| 7 | 
            +
              require 'ichabod/version'
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              Ichabod::Version.instance_eval do
         | 
| 10 | 
            +
                def refresh
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              class Jeweler
         | 
| 15 | 
            +
                def version_helper
         | 
| 16 | 
            +
                  Ichabod::Version
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                def version_exists?
         | 
| 20 | 
            +
                  true
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              Jeweler::Tasks.new do |gemspec|
         | 
| 25 | 
            +
                gemspec.name = "ichabod"
         | 
| 26 | 
            +
                gemspec.summary = "Ichabod wraps JavaScript in a loving MacRuby embrace."
         | 
| 27 | 
            +
                gemspec.homepage = "http://github.com/maccman/ichabod"
         | 
| 28 | 
            +
                gemspec.description = "Ichabod wraps JavaScript in a loving MacRuby embrace."
         | 
| 29 | 
            +
                gemspec.license = "MIT"
         | 
| 30 | 
            +
                gemspec.email = "info@eribium.org"
         | 
| 31 | 
            +
                gemspec.authors = ["Alex MacCaw"]
         | 
| 32 | 
            +
                gemspec.has_rdoc = false
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
            rescue LoadError
         | 
| 35 | 
            +
              puts "Jeweler not available."
         | 
| 36 | 
            +
              puts "Install it with: gem install jeweler"
         | 
| 37 | 
            +
            end
         | 
    
        data/bin/ichabod
    ADDED
    
    | @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            #!/usr/bin/env macruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            __DIR__ = File.expand_path(File.dirname(__FILE__))
         | 
| 4 | 
            +
            $LOAD_PATH.unshift File.join(__DIR__, '..', 'lib')
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            require 'ichabod'
         | 
| 7 | 
            +
            require 'ichabod/repl'
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            if STDIN.stat.size > 0
         | 
| 10 | 
            +
              input = STDIN.read
         | 
| 11 | 
            +
              puts Ichabod.parse(input)
         | 
| 12 | 
            +
              exit
         | 
| 13 | 
            +
            end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            case ARGV.first
         | 
| 16 | 
            +
            when '-h', '--help'
         | 
| 17 | 
            +
              puts "Run it:"
         | 
| 18 | 
            +
              puts " $ ichabod -e '(string to eval)'"
         | 
| 19 | 
            +
              puts " $ ichabod -p '(string to eval; result will puts)'"
         | 
| 20 | 
            +
              puts " $ ichabod --jasmine '(http address/path to jasmine tests)'"
         | 
| 21 | 
            +
              puts " $ ichabod --qunit '(http address/path to qunit tests)'"
         | 
| 22 | 
            +
              puts " $ ichabod file.js"
         | 
| 23 | 
            +
              puts " $ ichabod file.html"
         | 
| 24 | 
            +
              puts " $ ichabod http://example.com"
         | 
| 25 | 
            +
              puts " $ cat file.html | ichabod"
         | 
| 26 | 
            +
              puts " $ ichabod"
         | 
| 27 | 
            +
            when '-e'
         | 
| 28 | 
            +
              Ichabod.eval(ARGV.last)
         | 
| 29 | 
            +
            when '-p'
         | 
| 30 | 
            +
              puts Ichabod.eval(ARGV.last)
         | 
| 31 | 
            +
            when '--jasmine', '-j'
         | 
| 32 | 
            +
              puts Ichabod::Tests.jasmine(ARGV.last)
         | 
| 33 | 
            +
            when '--qunit', '-q'
         | 
| 34 | 
            +
              puts Ichabod::Tests.qunit(ARGV.last)
         | 
| 35 | 
            +
            when nil
         | 
| 36 | 
            +
              Ichabod::Repl.start
         | 
| 37 | 
            +
            else
         | 
| 38 | 
            +
              ARGV[-1][/\.js$/] ? Ichabod.eval_file(ARGV.last) : Ichabod.open(ARGV.last)
         | 
| 39 | 
            +
            end
         | 
    
        data/examples/index.html
    ADDED
    
    | @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            <!DOCTYPE html>
         | 
| 2 | 
            +
            <html>
         | 
| 3 | 
            +
              <head>
         | 
| 4 | 
            +
                <title>Ichabod Test!</title>
         | 
| 5 | 
            +
                <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
         | 
| 6 | 
            +
                <script>
         | 
| 7 | 
            +
                  $(function() {
         | 
| 8 | 
            +
                    $('#content').append('<div id="hi">Hello world!</div>')
         | 
| 9 | 
            +
                    $('script').remove()
         | 
| 10 | 
            +
                    document.title = 'It worked!'
         | 
| 11 | 
            +
                    
         | 
| 12 | 
            +
                    Ruby.puts("indeed it worked!");
         | 
| 13 | 
            +
                    
         | 
| 14 | 
            +
                    setTimeout(function(){
         | 
| 15 | 
            +
                      console.log("Exiting");
         | 
| 16 | 
            +
                      Ichabod.exit();
         | 
| 17 | 
            +
                    }, 3000)
         | 
| 18 | 
            +
                  });
         | 
| 19 | 
            +
                </script>
         | 
| 20 | 
            +
              </head>
         | 
| 21 | 
            +
              <body>
         | 
| 22 | 
            +
                <div id="content">
         | 
| 23 | 
            +
                </div>
         | 
| 24 | 
            +
              </body>
         | 
| 25 | 
            +
            </html>
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
         | 
| 2 | 
            +
              "http://www.w3.org/TR/html4/loose.dtd">
         | 
| 3 | 
            +
            <html>
         | 
| 4 | 
            +
            <head>
         | 
| 5 | 
            +
              <title>Jasmine Test Runner</title>
         | 
| 6 | 
            +
              <link rel="stylesheet" type="text/css" href="lib/jasmine.css">
         | 
| 7 | 
            +
              <script type="text/javascript" src="lib/jasmine.js"></script>
         | 
| 8 | 
            +
              <script type="text/javascript" src="lib/jasmine-html.js"></script>
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              <!-- include source files here... -->
         | 
| 11 | 
            +
            	<script src="klass.js" type="text/javascript" charset="utf-8"></script>
         | 
| 12 | 
            +
            	<script src="model.js" type="text/javascript" charset="utf-8"></script>
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              <!-- include spec files here... -->
         | 
| 15 | 
            +
            	<script src="model.spec.js" type="text/javascript" charset="utf-8"></script>
         | 
| 16 | 
            +
            </head>
         | 
| 17 | 
            +
            <body>
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            <script type="text/javascript">
         | 
| 20 | 
            +
              jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
         | 
| 21 | 
            +
              jasmine.getEnv().execute();
         | 
| 22 | 
            +
            </script>
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            </body>
         | 
| 25 | 
            +
            </html>
         | 
| @@ -0,0 +1,52 @@ | |
| 1 | 
            +
            if (typeof Object.create !== "function")
         | 
| 2 | 
            +
                Object.create = function(o) {
         | 
| 3 | 
            +
                  function F() {}
         | 
| 4 | 
            +
                  F.prototype = o;
         | 
| 5 | 
            +
                  return new F();
         | 
| 6 | 
            +
                };
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            var Klass = {
         | 
| 9 | 
            +
              init: function(){},
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              prototype: {
         | 
| 12 | 
            +
                init: function(){}
         | 
| 13 | 
            +
              },
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              create: function(){
         | 
| 16 | 
            +
                var object = Object.create(this);
         | 
| 17 | 
            +
                object.parent = this;
         | 
| 18 | 
            +
                object.init.apply(object, arguments);
         | 
| 19 | 
            +
                return object;
         | 
| 20 | 
            +
              },
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              inst: function(){
         | 
| 23 | 
            +
                var instance = Object.create(this.prototype);
         | 
| 24 | 
            +
                instance.parent = this;
         | 
| 25 | 
            +
                instance.init.apply(instance, arguments);
         | 
| 26 | 
            +
                return instance;
         | 
| 27 | 
            +
              },
         | 
| 28 | 
            +
              
         | 
| 29 | 
            +
              proxy: function(func){
         | 
| 30 | 
            +
                var thisObject = this;
         | 
| 31 | 
            +
                return(function(){ 
         | 
| 32 | 
            +
                  return func.apply(thisObject, arguments); 
         | 
| 33 | 
            +
                });
         | 
| 34 | 
            +
              },
         | 
| 35 | 
            +
              
         | 
| 36 | 
            +
              include: function(obj){
         | 
| 37 | 
            +
                var included = obj.included || obj.setup;
         | 
| 38 | 
            +
                for(var i in obj)
         | 
| 39 | 
            +
                  this.fn[i] = obj[i];
         | 
| 40 | 
            +
                if (included) included(this);
         | 
| 41 | 
            +
              },
         | 
| 42 | 
            +
              
         | 
| 43 | 
            +
              extend: function(obj){
         | 
| 44 | 
            +
                var extended = obj.extended || obj.setup;
         | 
| 45 | 
            +
                for(var i in obj)
         | 
| 46 | 
            +
                  this[i] = obj[i];
         | 
| 47 | 
            +
                if (extended) extended(this);
         | 
| 48 | 
            +
              }
         | 
| 49 | 
            +
            };
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            Klass.fn = Klass.prototype;
         | 
| 52 | 
            +
            Klass.fn.proxy = Klass.proxy;
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            Copyright (c) 2008-2010 Pivotal Labs
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 4 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 5 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 6 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 7 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 8 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 9 | 
            +
            the following conditions:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 12 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 15 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 16 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 17 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 18 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 19 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| @@ -0,0 +1,188 @@ | |
| 1 | 
            +
            jasmine.TrivialReporter = function(doc) {
         | 
| 2 | 
            +
              this.document = doc || document;
         | 
| 3 | 
            +
              this.suiteDivs = {};
         | 
| 4 | 
            +
              this.logRunningSpecs = false;
         | 
| 5 | 
            +
            };
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
         | 
| 8 | 
            +
              var el = document.createElement(type);
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              for (var i = 2; i < arguments.length; i++) {
         | 
| 11 | 
            +
                var child = arguments[i];
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                if (typeof child === 'string') {
         | 
| 14 | 
            +
                  el.appendChild(document.createTextNode(child));
         | 
| 15 | 
            +
                } else {
         | 
| 16 | 
            +
                  if (child) { el.appendChild(child); }
         | 
| 17 | 
            +
                }
         | 
| 18 | 
            +
              }
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              for (var attr in attrs) {
         | 
| 21 | 
            +
                if (attr == "className") {
         | 
| 22 | 
            +
                  el[attr] = attrs[attr];
         | 
| 23 | 
            +
                } else {
         | 
| 24 | 
            +
                  el.setAttribute(attr, attrs[attr]);
         | 
| 25 | 
            +
                }
         | 
| 26 | 
            +
              }
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              return el;
         | 
| 29 | 
            +
            };
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
         | 
| 32 | 
            +
              var showPassed, showSkipped;
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
         | 
| 35 | 
            +
                  this.createDom('div', { className: 'banner' },
         | 
| 36 | 
            +
                    this.createDom('div', { className: 'logo' },
         | 
| 37 | 
            +
                        this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"),
         | 
| 38 | 
            +
                        this.createDom('span', { className: 'version' }, runner.env.versionString())),
         | 
| 39 | 
            +
                    this.createDom('div', { className: 'options' },
         | 
| 40 | 
            +
                        "Show ",
         | 
| 41 | 
            +
                        showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
         | 
| 42 | 
            +
                        this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
         | 
| 43 | 
            +
                        showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
         | 
| 44 | 
            +
                        this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
         | 
| 45 | 
            +
                        )
         | 
| 46 | 
            +
                      ),
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  this.runnerDiv = this.createDom('div', { className: 'runner running' },
         | 
| 49 | 
            +
                      this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
         | 
| 50 | 
            +
                      this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
         | 
| 51 | 
            +
                      this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
         | 
| 52 | 
            +
                  );
         | 
| 53 | 
            +
             | 
| 54 | 
            +
              this.document.body.appendChild(this.outerDiv);
         | 
| 55 | 
            +
             | 
| 56 | 
            +
              var suites = runner.suites();
         | 
| 57 | 
            +
              for (var i = 0; i < suites.length; i++) {
         | 
| 58 | 
            +
                var suite = suites[i];
         | 
| 59 | 
            +
                var suiteDiv = this.createDom('div', { className: 'suite' },
         | 
| 60 | 
            +
                    this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
         | 
| 61 | 
            +
                    this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
         | 
| 62 | 
            +
                this.suiteDivs[suite.id] = suiteDiv;
         | 
| 63 | 
            +
                var parentDiv = this.outerDiv;
         | 
| 64 | 
            +
                if (suite.parentSuite) {
         | 
| 65 | 
            +
                  parentDiv = this.suiteDivs[suite.parentSuite.id];
         | 
| 66 | 
            +
                }
         | 
| 67 | 
            +
                parentDiv.appendChild(suiteDiv);
         | 
| 68 | 
            +
              }
         | 
| 69 | 
            +
             | 
| 70 | 
            +
              this.startedAt = new Date();
         | 
| 71 | 
            +
             | 
| 72 | 
            +
              var self = this;
         | 
| 73 | 
            +
              showPassed.onclick = function(evt) {
         | 
| 74 | 
            +
                if (showPassed.checked) {
         | 
| 75 | 
            +
                  self.outerDiv.className += ' show-passed';
         | 
| 76 | 
            +
                } else {
         | 
| 77 | 
            +
                  self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
         | 
| 78 | 
            +
                }
         | 
| 79 | 
            +
              };
         | 
| 80 | 
            +
             | 
| 81 | 
            +
              showSkipped.onclick = function(evt) {
         | 
| 82 | 
            +
                if (showSkipped.checked) {
         | 
| 83 | 
            +
                  self.outerDiv.className += ' show-skipped';
         | 
| 84 | 
            +
                } else {
         | 
| 85 | 
            +
                  self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
         | 
| 86 | 
            +
                }
         | 
| 87 | 
            +
              };
         | 
| 88 | 
            +
            };
         | 
| 89 | 
            +
             | 
| 90 | 
            +
            jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
         | 
| 91 | 
            +
              var results = runner.results();
         | 
| 92 | 
            +
              var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
         | 
| 93 | 
            +
              this.runnerDiv.setAttribute("class", className);
         | 
| 94 | 
            +
              //do it twice for IE
         | 
| 95 | 
            +
              this.runnerDiv.setAttribute("className", className);
         | 
| 96 | 
            +
              var specs = runner.specs();
         | 
| 97 | 
            +
              var specCount = 0;
         | 
| 98 | 
            +
              for (var i = 0; i < specs.length; i++) {
         | 
| 99 | 
            +
                if (this.specFilter(specs[i])) {
         | 
| 100 | 
            +
                  specCount++;
         | 
| 101 | 
            +
                }
         | 
| 102 | 
            +
              }
         | 
| 103 | 
            +
              var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
         | 
| 104 | 
            +
              message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
         | 
| 105 | 
            +
              this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
         | 
| 106 | 
            +
             | 
| 107 | 
            +
              this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
         | 
| 108 | 
            +
            };
         | 
| 109 | 
            +
             | 
| 110 | 
            +
            jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
         | 
| 111 | 
            +
              var results = suite.results();
         | 
| 112 | 
            +
              var status = results.passed() ? 'passed' : 'failed';
         | 
| 113 | 
            +
              if (results.totalCount == 0) { // todo: change this to check results.skipped
         | 
| 114 | 
            +
                status = 'skipped';
         | 
| 115 | 
            +
              }
         | 
| 116 | 
            +
              this.suiteDivs[suite.id].className += " " + status;
         | 
| 117 | 
            +
            };
         | 
| 118 | 
            +
             | 
| 119 | 
            +
            jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
         | 
| 120 | 
            +
              if (this.logRunningSpecs) {
         | 
| 121 | 
            +
                this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
         | 
| 122 | 
            +
              }
         | 
| 123 | 
            +
            };
         | 
| 124 | 
            +
             | 
| 125 | 
            +
            jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
         | 
| 126 | 
            +
              var results = spec.results();
         | 
| 127 | 
            +
              var status = results.passed() ? 'passed' : 'failed';
         | 
| 128 | 
            +
              if (results.skipped) {
         | 
| 129 | 
            +
                status = 'skipped';
         | 
| 130 | 
            +
              }
         | 
| 131 | 
            +
              var specDiv = this.createDom('div', { className: 'spec '  + status },
         | 
| 132 | 
            +
                  this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
         | 
| 133 | 
            +
                  this.createDom('a', {
         | 
| 134 | 
            +
                    className: 'description',
         | 
| 135 | 
            +
                    href: '?spec=' + encodeURIComponent(spec.getFullName()),
         | 
| 136 | 
            +
                    title: spec.getFullName()
         | 
| 137 | 
            +
                  }, spec.description));
         | 
| 138 | 
            +
             | 
| 139 | 
            +
             | 
| 140 | 
            +
              var resultItems = results.getItems();
         | 
| 141 | 
            +
              var messagesDiv = this.createDom('div', { className: 'messages' });
         | 
| 142 | 
            +
              for (var i = 0; i < resultItems.length; i++) {
         | 
| 143 | 
            +
                var result = resultItems[i];
         | 
| 144 | 
            +
             | 
| 145 | 
            +
                if (result.type == 'log') {
         | 
| 146 | 
            +
                  messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
         | 
| 147 | 
            +
                } else if (result.type == 'expect' && result.passed && !result.passed()) {
         | 
| 148 | 
            +
                  messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
         | 
| 149 | 
            +
             | 
| 150 | 
            +
                  if (result.trace.stack) {
         | 
| 151 | 
            +
                    messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
         | 
| 152 | 
            +
                  }
         | 
| 153 | 
            +
                }
         | 
| 154 | 
            +
              }
         | 
| 155 | 
            +
             | 
| 156 | 
            +
              if (messagesDiv.childNodes.length > 0) {
         | 
| 157 | 
            +
                specDiv.appendChild(messagesDiv);
         | 
| 158 | 
            +
              }
         | 
| 159 | 
            +
             | 
| 160 | 
            +
              this.suiteDivs[spec.suite.id].appendChild(specDiv);
         | 
| 161 | 
            +
            };
         | 
| 162 | 
            +
             | 
| 163 | 
            +
            jasmine.TrivialReporter.prototype.log = function() {
         | 
| 164 | 
            +
              var console = jasmine.getGlobal().console;
         | 
| 165 | 
            +
              if (console && console.log) {
         | 
| 166 | 
            +
                if (console.log.apply) {
         | 
| 167 | 
            +
                  console.log.apply(console, arguments);
         | 
| 168 | 
            +
                } else {
         | 
| 169 | 
            +
                  console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
         | 
| 170 | 
            +
                }
         | 
| 171 | 
            +
              }
         | 
| 172 | 
            +
            };
         | 
| 173 | 
            +
             | 
| 174 | 
            +
            jasmine.TrivialReporter.prototype.getLocation = function() {
         | 
| 175 | 
            +
              return this.document.location;
         | 
| 176 | 
            +
            };
         | 
| 177 | 
            +
             | 
| 178 | 
            +
            jasmine.TrivialReporter.prototype.specFilter = function(spec) {
         | 
| 179 | 
            +
              var paramMap = {};
         | 
| 180 | 
            +
              var params = this.getLocation().search.substring(1).split('&');
         | 
| 181 | 
            +
              for (var i = 0; i < params.length; i++) {
         | 
| 182 | 
            +
                var p = params[i].split('=');
         | 
| 183 | 
            +
                paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
         | 
| 184 | 
            +
              }
         | 
| 185 | 
            +
             | 
| 186 | 
            +
              if (!paramMap["spec"]) return true;
         | 
| 187 | 
            +
              return spec.getFullName().indexOf(paramMap["spec"]) == 0;
         | 
| 188 | 
            +
            };
         | 
| @@ -0,0 +1,166 @@ | |
| 1 | 
            +
            body {
         | 
| 2 | 
            +
              font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
         | 
| 3 | 
            +
            }
         | 
| 4 | 
            +
             | 
| 5 | 
            +
             | 
| 6 | 
            +
            .jasmine_reporter a:visited, .jasmine_reporter a {
         | 
| 7 | 
            +
              color: #303; 
         | 
| 8 | 
            +
            }
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            .jasmine_reporter a:hover, .jasmine_reporter a:active {
         | 
| 11 | 
            +
              color: blue; 
         | 
| 12 | 
            +
            }
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            .run_spec {
         | 
| 15 | 
            +
              float:right;
         | 
| 16 | 
            +
              padding-right: 5px;
         | 
| 17 | 
            +
              font-size: .8em;
         | 
| 18 | 
            +
              text-decoration: none;
         | 
| 19 | 
            +
            }
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            .jasmine_reporter {
         | 
| 22 | 
            +
              margin: 0 5px;
         | 
| 23 | 
            +
            }
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            .banner {
         | 
| 26 | 
            +
              color: #303;
         | 
| 27 | 
            +
              background-color: #fef;
         | 
| 28 | 
            +
              padding: 5px;
         | 
| 29 | 
            +
            }
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            .logo {
         | 
| 32 | 
            +
              float: left;
         | 
| 33 | 
            +
              font-size: 1.1em;
         | 
| 34 | 
            +
              padding-left: 5px;
         | 
| 35 | 
            +
            }
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            .logo .version {
         | 
| 38 | 
            +
              font-size: .6em;
         | 
| 39 | 
            +
              padding-left: 1em;
         | 
| 40 | 
            +
            }
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            .runner.running {
         | 
| 43 | 
            +
              background-color: yellow;
         | 
| 44 | 
            +
            }
         | 
| 45 | 
            +
             | 
| 46 | 
            +
             | 
| 47 | 
            +
            .options {
         | 
| 48 | 
            +
              text-align: right;
         | 
| 49 | 
            +
              font-size: .8em;
         | 
| 50 | 
            +
            }
         | 
| 51 | 
            +
             | 
| 52 | 
            +
             | 
| 53 | 
            +
             | 
| 54 | 
            +
             | 
| 55 | 
            +
            .suite {
         | 
| 56 | 
            +
              border: 1px outset gray;
         | 
| 57 | 
            +
              margin: 5px 0;
         | 
| 58 | 
            +
              padding-left: 1em;
         | 
| 59 | 
            +
            }
         | 
| 60 | 
            +
             | 
| 61 | 
            +
            .suite .suite {
         | 
| 62 | 
            +
              margin: 5px; 
         | 
| 63 | 
            +
            }
         | 
| 64 | 
            +
             | 
| 65 | 
            +
            .suite.passed {
         | 
| 66 | 
            +
              background-color: #dfd;
         | 
| 67 | 
            +
            }
         | 
| 68 | 
            +
             | 
| 69 | 
            +
            .suite.failed {
         | 
| 70 | 
            +
              background-color: #fdd;
         | 
| 71 | 
            +
            }
         | 
| 72 | 
            +
             | 
| 73 | 
            +
            .spec {
         | 
| 74 | 
            +
              margin: 5px;
         | 
| 75 | 
            +
              padding-left: 1em;
         | 
| 76 | 
            +
              clear: both;
         | 
| 77 | 
            +
            }
         | 
| 78 | 
            +
             | 
| 79 | 
            +
            .spec.failed, .spec.passed, .spec.skipped {
         | 
| 80 | 
            +
              padding-bottom: 5px;
         | 
| 81 | 
            +
              border: 1px solid gray;
         | 
| 82 | 
            +
            }
         | 
| 83 | 
            +
             | 
| 84 | 
            +
            .spec.failed {
         | 
| 85 | 
            +
              background-color: #fbb;
         | 
| 86 | 
            +
              border-color: red;
         | 
| 87 | 
            +
            }
         | 
| 88 | 
            +
             | 
| 89 | 
            +
            .spec.passed {
         | 
| 90 | 
            +
              background-color: #bfb;
         | 
| 91 | 
            +
              border-color: green;
         | 
| 92 | 
            +
            }
         | 
| 93 | 
            +
             | 
| 94 | 
            +
            .spec.skipped {
         | 
| 95 | 
            +
              background-color: #bbb;
         | 
| 96 | 
            +
            }
         | 
| 97 | 
            +
             | 
| 98 | 
            +
            .messages {
         | 
| 99 | 
            +
              border-left: 1px dashed gray;
         | 
| 100 | 
            +
              padding-left: 1em;
         | 
| 101 | 
            +
              padding-right: 1em;
         | 
| 102 | 
            +
            }
         | 
| 103 | 
            +
             | 
| 104 | 
            +
            .passed {
         | 
| 105 | 
            +
              background-color: #cfc;
         | 
| 106 | 
            +
              display: none;
         | 
| 107 | 
            +
            }
         | 
| 108 | 
            +
             | 
| 109 | 
            +
            .failed {
         | 
| 110 | 
            +
              background-color: #fbb;
         | 
| 111 | 
            +
            }
         | 
| 112 | 
            +
             | 
| 113 | 
            +
            .skipped {
         | 
| 114 | 
            +
              color: #777;
         | 
| 115 | 
            +
              background-color: #eee;
         | 
| 116 | 
            +
              display: none;
         | 
| 117 | 
            +
            }
         | 
| 118 | 
            +
             | 
| 119 | 
            +
             | 
| 120 | 
            +
            /*.resultMessage {*/
         | 
| 121 | 
            +
              /*white-space: pre;*/
         | 
| 122 | 
            +
            /*}*/
         | 
| 123 | 
            +
             | 
| 124 | 
            +
            .resultMessage span.result {
         | 
| 125 | 
            +
              display: block;
         | 
| 126 | 
            +
              line-height: 2em;
         | 
| 127 | 
            +
              color: black;
         | 
| 128 | 
            +
            }
         | 
| 129 | 
            +
             | 
| 130 | 
            +
            .resultMessage .mismatch {
         | 
| 131 | 
            +
              color: black;
         | 
| 132 | 
            +
            }
         | 
| 133 | 
            +
             | 
| 134 | 
            +
            .stackTrace {
         | 
| 135 | 
            +
              white-space: pre;
         | 
| 136 | 
            +
              font-size: .8em;
         | 
| 137 | 
            +
              margin-left: 10px;
         | 
| 138 | 
            +
              max-height: 5em;
         | 
| 139 | 
            +
              overflow: auto;
         | 
| 140 | 
            +
              border: 1px inset red;
         | 
| 141 | 
            +
              padding: 1em;
         | 
| 142 | 
            +
              background: #eef;
         | 
| 143 | 
            +
            }
         | 
| 144 | 
            +
             | 
| 145 | 
            +
            .finished-at {
         | 
| 146 | 
            +
              padding-left: 1em;
         | 
| 147 | 
            +
              font-size: .6em;
         | 
| 148 | 
            +
            }
         | 
| 149 | 
            +
             | 
| 150 | 
            +
            .show-passed .passed,
         | 
| 151 | 
            +
            .show-skipped .skipped {
         | 
| 152 | 
            +
              display: block;
         | 
| 153 | 
            +
            }
         | 
| 154 | 
            +
             | 
| 155 | 
            +
             | 
| 156 | 
            +
            #jasmine_content {
         | 
| 157 | 
            +
              position:fixed;
         | 
| 158 | 
            +
              right: 100%;
         | 
| 159 | 
            +
            }
         | 
| 160 | 
            +
             | 
| 161 | 
            +
            .runner {
         | 
| 162 | 
            +
              border: 1px solid gray;
         | 
| 163 | 
            +
              display: block;
         | 
| 164 | 
            +
              margin: 5px 0;
         | 
| 165 | 
            +
              padding: 2px 0 2px 10px;
         | 
| 166 | 
            +
            }
         |