coffeescript-router 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/.gitignore +3 -0
- data/Cakefile +122 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/LICENSE.txt +19 -0
- data/README.md +18 -0
- data/Rakefile +2 -0
- data/SpecRunner.html +25 -0
- data/coffeescript-router.gemspec +19 -0
- data/lib/CoffeeScript.png +0 -0
- data/lib/coffeescript-router/version.rb +5 -0
- data/lib/jasmine-1.0.2/MIT.LICENSE +20 -0
- data/lib/jasmine-1.0.2/jasmine-html.js +188 -0
- data/lib/jasmine-1.0.2/jasmine.css +166 -0
- data/lib/jasmine-1.0.2/jasmine.js +2421 -0
- data/node_modules/.bin/cake +7 -0
- data/node_modules/.bin/coffee +7 -0
- data/node_modules/.bin/uglifyjs +212 -0
- data/node_modules/coffee-script/.npmignore +11 -0
- data/node_modules/coffee-script/LICENSE +22 -0
- data/node_modules/coffee-script/README +48 -0
- data/node_modules/coffee-script/Rakefile +78 -0
- data/node_modules/coffee-script/bin/cake +7 -0
- data/node_modules/coffee-script/bin/coffee +7 -0
- data/node_modules/coffee-script/lib/browser.js +75 -0
- data/node_modules/coffee-script/lib/cake.js +76 -0
- data/node_modules/coffee-script/lib/coffee-script.js +107 -0
- data/node_modules/coffee-script/lib/command.js +274 -0
- data/node_modules/coffee-script/lib/grammar.js +591 -0
- data/node_modules/coffee-script/lib/helpers.js +66 -0
- data/node_modules/coffee-script/lib/index.js +8 -0
- data/node_modules/coffee-script/lib/lexer.js +650 -0
- data/node_modules/coffee-script/lib/nodes.js +2230 -0
- data/node_modules/coffee-script/lib/optparse.js +111 -0
- data/node_modules/coffee-script/lib/parser.js +676 -0
- data/node_modules/coffee-script/lib/repl.js +114 -0
- data/node_modules/coffee-script/lib/rewriter.js +359 -0
- data/node_modules/coffee-script/lib/scope.js +120 -0
- data/node_modules/coffee-script/package.json +27 -0
- data/node_modules/growl/History.md +16 -0
- data/node_modules/growl/Readme.md +74 -0
- data/node_modules/growl/lib/growl.js +82 -0
- data/node_modules/growl/package.json +6 -0
- data/node_modules/growl/test.js +17 -0
- data/node_modules/uglify-js/.gitignore +4 -0
- data/node_modules/uglify-js/README.html +825 -0
- data/node_modules/uglify-js/README.org +431 -0
- data/node_modules/uglify-js/bin/uglifyjs +212 -0
- data/node_modules/uglify-js/docstyle.css +75 -0
- data/node_modules/uglify-js/lib/parse-js.js +1319 -0
- data/node_modules/uglify-js/lib/process.js +1614 -0
- data/node_modules/uglify-js/lib/squeeze-more.js +22 -0
- data/node_modules/uglify-js/package.json +22 -0
- data/node_modules/uglify-js/test/beautify.js +28 -0
- data/node_modules/uglify-js/test/testparser.js +402 -0
- data/node_modules/uglify-js/test/unit/compress/expected/array1.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/array2.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/array3.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/array4.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/assignment.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/concatstring.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/const.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/empty-blocks.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/forstatement.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/if.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/ifreturn.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue10.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue11.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue13.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue14.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue16.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue17.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue20.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue21.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue25.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue27.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue28.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue29.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue30.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue34.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue4.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue48.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue50.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue53.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue54.1.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue68.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue69.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/issue9.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/strict-equals.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/expected/var.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/array1.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/array2.js +4 -0
- data/node_modules/uglify-js/test/unit/compress/test/array3.js +4 -0
- data/node_modules/uglify-js/test/unit/compress/test/array4.js +6 -0
- data/node_modules/uglify-js/test/unit/compress/test/assignment.js +20 -0
- data/node_modules/uglify-js/test/unit/compress/test/concatstring.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/const.js +5 -0
- data/node_modules/uglify-js/test/unit/compress/test/empty-blocks.js +4 -0
- data/node_modules/uglify-js/test/unit/compress/test/forstatement.js +10 -0
- data/node_modules/uglify-js/test/unit/compress/test/if.js +6 -0
- data/node_modules/uglify-js/test/unit/compress/test/ifreturn.js +9 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue10.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue11.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue13.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue14.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue16.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue17.js +4 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue20.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue21.js +6 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue25.js +7 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue27.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue28.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue29.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue30.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue34.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue4.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue48.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue50.js +9 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue53.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue54.1.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue68.js +5 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue69.js +1 -0
- data/node_modules/uglify-js/test/unit/compress/test/issue9.js +4 -0
- data/node_modules/uglify-js/test/unit/compress/test/strict-equals.js +3 -0
- data/node_modules/uglify-js/test/unit/compress/test/var.js +3 -0
- data/node_modules/uglify-js/test/unit/scripts.js +46 -0
- data/node_modules/uglify-js/uglify-js.js +2 -0
- data/src/coffeescript/coffeescript-router.js.coffee +31 -0
- data/test/coffeescript/routerSpec.coffee +47 -0
- data/vendor/assets/javascripts/coffeescript-router.min.js +1 -0
- metadata +187 -0
data/.gitignore
ADDED
data/Cakefile
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
fs = require 'fs'
|
|
2
|
+
{exec} = require 'child_process'
|
|
3
|
+
util = require 'util'
|
|
4
|
+
uglify = require './node_modules/uglify-js'
|
|
5
|
+
|
|
6
|
+
prodSrcCoffeeDir = 'src/coffeescript'
|
|
7
|
+
testSrcCoffeeDir = 'test/coffeescript'
|
|
8
|
+
|
|
9
|
+
prodTargetJsDir = 'vendor/assets/javascripts'
|
|
10
|
+
testTargetJsDir = 'test/js'
|
|
11
|
+
|
|
12
|
+
prodTargetFileName = 'coffeescript-router'
|
|
13
|
+
prodTargetCoffeeFile = "#{prodSrcCoffeeDir}/#{prodTargetFileName}.coffee"
|
|
14
|
+
prodTargetJsFile = "#{prodTargetJsDir}/#{prodTargetFileName}.js"
|
|
15
|
+
prodTargetJsMinFile = "#{prodTargetJsDir}/#{prodTargetFileName}.min.js"
|
|
16
|
+
|
|
17
|
+
prodCoffeeOpts = "--bare --output #{prodTargetJsDir} --compile #{prodTargetCoffeeFile}"
|
|
18
|
+
testCoffeeOpts = "--output #{testTargetJsDir}"
|
|
19
|
+
|
|
20
|
+
prodCoffeeFiles = [
|
|
21
|
+
'coffeescript-router.js'
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
task 'watch:all', 'Watch production and test CoffeeScript', ->
|
|
25
|
+
invoke 'watch:test'
|
|
26
|
+
invoke 'watch'
|
|
27
|
+
|
|
28
|
+
task 'build:all', 'Build production and test CoffeeScript', ->
|
|
29
|
+
invoke 'build:test'
|
|
30
|
+
invoke 'build'
|
|
31
|
+
|
|
32
|
+
task 'watch', 'Watch prod source files and build changes', ->
|
|
33
|
+
invoke 'build'
|
|
34
|
+
util.log "Watching for changes in #{prodSrcCoffeeDir}"
|
|
35
|
+
|
|
36
|
+
for file in prodCoffeeFiles then do (file) ->
|
|
37
|
+
fs.watchFile "#{prodSrcCoffeeDir}/#{file}.coffee", (curr, prev) ->
|
|
38
|
+
if +curr.mtime isnt +prev.mtime
|
|
39
|
+
util.log "Saw change in #{prodSrcCoffeeDir}/#{file}.coffee"
|
|
40
|
+
invoke 'build'
|
|
41
|
+
|
|
42
|
+
task 'build', 'Build a single JavaScript file from prod files', ->
|
|
43
|
+
util.log "Building #{prodTargetJsFile}"
|
|
44
|
+
appContents = new Array remaining = prodCoffeeFiles.length
|
|
45
|
+
util.log "Appending #{prodCoffeeFiles.length} files to #{prodTargetCoffeeFile}"
|
|
46
|
+
|
|
47
|
+
for file, index in prodCoffeeFiles then do (file, index) ->
|
|
48
|
+
fs.readFile "#{prodSrcCoffeeDir}/#{file}.coffee"
|
|
49
|
+
, 'utf8'
|
|
50
|
+
, (err, fileContents) ->
|
|
51
|
+
handleError(err) if err
|
|
52
|
+
|
|
53
|
+
appContents[index] = fileContents
|
|
54
|
+
util.log "[#{index + 1}] #{file}.coffee"
|
|
55
|
+
process() if --remaining is 0
|
|
56
|
+
|
|
57
|
+
process = ->
|
|
58
|
+
fs.writeFile prodTargetCoffeeFile
|
|
59
|
+
, appContents.join('\n\n')
|
|
60
|
+
, 'utf8'
|
|
61
|
+
, (err) ->
|
|
62
|
+
handleError(err) if err
|
|
63
|
+
|
|
64
|
+
exec "coffee #{prodCoffeeOpts}", (err, stdout, stderr) ->
|
|
65
|
+
handleError(err) if err
|
|
66
|
+
message = "Compiled #{prodTargetJsFile}"
|
|
67
|
+
util.log message
|
|
68
|
+
displayNotification message
|
|
69
|
+
fs.unlink prodTargetCoffeeFile, (err) -> handleError(err) if err
|
|
70
|
+
invoke 'uglify'
|
|
71
|
+
|
|
72
|
+
task 'watch:test', 'Watch test specs and build changes', ->
|
|
73
|
+
invoke 'build:test'
|
|
74
|
+
util.log "Watching for changes in #{testSrcCoffeeDir}"
|
|
75
|
+
|
|
76
|
+
fs.readdir testSrcCoffeeDir, (err, files) ->
|
|
77
|
+
handleError(err) if err
|
|
78
|
+
for file in files then do (file) ->
|
|
79
|
+
fs.watchFile "#{testSrcCoffeeDir}/#{file}", (curr, prev) ->
|
|
80
|
+
if +curr.mtime isnt +prev.mtime
|
|
81
|
+
coffee testCoffeeOpts, "#{testSrcCoffeeDir}/#{file}"
|
|
82
|
+
|
|
83
|
+
task 'build:test', 'Build individual test specs', ->
|
|
84
|
+
util.log 'Building test specs'
|
|
85
|
+
fs.readdir testSrcCoffeeDir, (err, files) ->
|
|
86
|
+
handleError(err) if err
|
|
87
|
+
for file in files then do (file) ->
|
|
88
|
+
coffee testCoffeeOpts, "#{testSrcCoffeeDir}/#{file}"
|
|
89
|
+
|
|
90
|
+
task 'uglify', 'Minify and obfuscate', ->
|
|
91
|
+
jsp = uglify.parser
|
|
92
|
+
pro = uglify.uglify
|
|
93
|
+
|
|
94
|
+
fs.readFile prodTargetJsFile, 'utf8', (err, fileContents) ->
|
|
95
|
+
ast = jsp.parse fileContents # parse code and get the initial AST
|
|
96
|
+
ast = pro.ast_mangle ast # get a new AST with mangled names
|
|
97
|
+
ast = pro.ast_squeeze ast # get an AST with compression optimizations
|
|
98
|
+
final_code = pro.gen_code ast # compressed code here
|
|
99
|
+
|
|
100
|
+
fs.writeFile prodTargetJsMinFile, final_code
|
|
101
|
+
fs.unlink prodTargetJsFile, (err) -> handleError(err) if err
|
|
102
|
+
|
|
103
|
+
message = "Uglified #{prodTargetJsMinFile}"
|
|
104
|
+
util.log message
|
|
105
|
+
displayNotification message
|
|
106
|
+
|
|
107
|
+
coffee = (options = "", file) ->
|
|
108
|
+
util.log "Compiling #{file}"
|
|
109
|
+
exec "coffee #{options} --compile #{file}", (err, stdout, stderr) ->
|
|
110
|
+
handleError(err) if err
|
|
111
|
+
displayNotification "Compiled #{file}"
|
|
112
|
+
|
|
113
|
+
handleError = (error) ->
|
|
114
|
+
util.log error
|
|
115
|
+
displayNotification error
|
|
116
|
+
|
|
117
|
+
displayNotification = (message = '') ->
|
|
118
|
+
options = {
|
|
119
|
+
title: 'CoffeeScript'
|
|
120
|
+
image: 'lib/CoffeeScript.png'
|
|
121
|
+
}
|
|
122
|
+
try require('./node_modules/growl').notify message, options
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2012 Tim Bugai
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2011 Kris Molendyke
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# CoffeeScript Router
|
|
2
|
+
|
|
3
|
+
A standalone router written in CoffeeScript that anyone can use in their web apps. It uses Ruby on Rails like human readable routes with named parameters instead of ugly regular expresssions.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
From project root:
|
|
8
|
+
|
|
9
|
+
cake build:all
|
|
10
|
+
|
|
11
|
+
Include the resulting minified javascript file in your webpage
|
|
12
|
+
|
|
13
|
+
<javascript src="coffeescript-router.min.js"></javascript>
|
|
14
|
+
|
|
15
|
+
## More Info
|
|
16
|
+
|
|
17
|
+
The original blog post about this project can be found here:
|
|
18
|
+
* [Standalone Javascript Router](http://collectiveidea.com/blog)
|
data/Rakefile
ADDED
data/SpecRunner.html
ADDED
|
@@ -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-1.0.2/jasmine.css">
|
|
7
|
+
<script type="text/javascript" src="lib/jasmine-1.0.2/jasmine.js"></script>
|
|
8
|
+
<script type="text/javascript" src="lib/jasmine-1.0.2/jasmine-html.js"></script>
|
|
9
|
+
|
|
10
|
+
<!-- include source files here... -->
|
|
11
|
+
<script type="text/javascript" src="vendor/assets/javascripts/coffeescript-router.min.js"></script>
|
|
12
|
+
|
|
13
|
+
<!-- include spec files here... -->
|
|
14
|
+
<script type="text/javascript" src="test/js/routerSpec.js"></script>
|
|
15
|
+
|
|
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,19 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
require File.expand_path('../lib/coffeescript-router/version', __FILE__)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |gem|
|
|
5
|
+
gem.authors = ["Tim Bugai"]
|
|
6
|
+
gem.email = ["tim@collectiveidea.com"]
|
|
7
|
+
gem.description = %q{Standalone CoffeeScript Router w/ Rails style named parameters}
|
|
8
|
+
gem.summary = %q{Standalone CoffeeScript Router}
|
|
9
|
+
gem.homepage = "http://github.com/tbugai/coffeescript-router"
|
|
10
|
+
|
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
14
|
+
gem.name = "coffeescript-router"
|
|
15
|
+
gem.require_paths = ["lib"]
|
|
16
|
+
gem.version = Coffeescript::Router::VERSION
|
|
17
|
+
|
|
18
|
+
gem.add_dependency "rails", ">= 3.1"
|
|
19
|
+
end
|
|
Binary file
|
|
@@ -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
|
+
};
|