seaweed 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/seaweed +55 -0
- data/lib/Spec.coffee +308 -0
- data/lib/required_files.rb +58 -0
- data/lib/spec.rb +42 -0
- data/server/public/jquery-1.5.js +8176 -0
- data/server/public/spec.css +9 -0
- data/server/server.rb +65 -0
- data/server/views/index.slim +11 -0
- metadata +157 -0
data/server/server.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'sinatra'
|
3
|
+
require 'slim'
|
4
|
+
require 'coffee-script'
|
5
|
+
|
6
|
+
module Sinatra
|
7
|
+
module Templates
|
8
|
+
def slim(template, options={}, locals={})
|
9
|
+
render :slim, template, options, locals
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
Slim::Engine.set_default_options :pretty => true
|
15
|
+
|
16
|
+
def compile source, target
|
17
|
+
begin
|
18
|
+
mtime = File.mtime source
|
19
|
+
|
20
|
+
return File.read target if File.exists?(target) && File.mtime(target) == mtime
|
21
|
+
|
22
|
+
dir = target.sub /\/[^\/]+$/, ''
|
23
|
+
Dir.mkdir dir unless File.exists? dir
|
24
|
+
File.open target, 'w' do |f|
|
25
|
+
f.write CoffeeScript.compile(File.read source)
|
26
|
+
end
|
27
|
+
File.utime mtime, mtime, target
|
28
|
+
|
29
|
+
File.read target
|
30
|
+
rescue CoffeeScript::CompilationError => e
|
31
|
+
message = if e.message.match /^SyntaxError: (.*) on line (\d+)\D*$/
|
32
|
+
"#{source}:#{$2}".ljust(40) + " #{$1}"
|
33
|
+
elsif e.message.match /^Parse error on line (\d+): (.*)$/
|
34
|
+
"#{source}:#{$1}".ljust(40) + " #{$2}"
|
35
|
+
else
|
36
|
+
"#{source} - #{e.message}"
|
37
|
+
end
|
38
|
+
puts "\e[31m#{message}\e[0m"
|
39
|
+
html = "<pre class=\"failed\">#{message}</pre>"
|
40
|
+
"$(function(){$(document.body).prepend(#{html.to_json});});"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
get "/Spec.js" do
|
45
|
+
compile File.expand_path('../../lib/Spec.coffee', __FILE__), "compiled/spec.js"
|
46
|
+
end
|
47
|
+
|
48
|
+
get %r{^/lib/(.+)\.js$} do |file|
|
49
|
+
compile "lib/#{file}.coffee", "compiled/#{file}.js"
|
50
|
+
end
|
51
|
+
|
52
|
+
get %r{^/spec/(.+)\.js$} do |file|
|
53
|
+
compile "spec/#{file}.coffee", "compiled/#{file}.js"
|
54
|
+
end
|
55
|
+
|
56
|
+
get "/" do
|
57
|
+
requirements = RequiredFiles.new
|
58
|
+
requirements.paths = ['spec', 'lib']
|
59
|
+
Dir['spec/**/*.spec.coffee'].each do |file|
|
60
|
+
requirements.add $1 if file.match /^spec\/(.*).coffee$/
|
61
|
+
end
|
62
|
+
@scripts = requirements.sorted_files
|
63
|
+
|
64
|
+
slim :index
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: seaweed
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Tobias Cohen
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-03-17 00:00:00 +11:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: coffee-script
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: json
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: celerity
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :runtime
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: sinatra
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
type: :runtime
|
76
|
+
version_requirements: *id004
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: slim
|
79
|
+
prerelease: false
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
type: :runtime
|
90
|
+
version_requirements: *id005
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: watchr
|
93
|
+
prerelease: false
|
94
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
hash: 3
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
103
|
+
type: :runtime
|
104
|
+
version_requirements: *id006
|
105
|
+
description: Seaweed is Coffeescript behavioral testing framework, with a command line tool that can be used to run specs automatically.
|
106
|
+
email: me@tobiascohen.com
|
107
|
+
executables:
|
108
|
+
- seaweed
|
109
|
+
extensions: []
|
110
|
+
|
111
|
+
extra_rdoc_files: []
|
112
|
+
|
113
|
+
files:
|
114
|
+
- bin/seaweed
|
115
|
+
- server/public/jquery-1.5.js
|
116
|
+
- server/public/spec.css
|
117
|
+
- server/server.rb
|
118
|
+
- server/views/index.slim
|
119
|
+
- lib/required_files.rb
|
120
|
+
- lib/Spec.coffee
|
121
|
+
- lib/spec.rb
|
122
|
+
has_rdoc: true
|
123
|
+
homepage: https://github.com/tobico/seaweed
|
124
|
+
licenses:
|
125
|
+
- MIT
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
hash: 3
|
137
|
+
segments:
|
138
|
+
- 0
|
139
|
+
version: "0"
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
none: false
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
hash: 3
|
146
|
+
segments:
|
147
|
+
- 0
|
148
|
+
version: "0"
|
149
|
+
requirements: []
|
150
|
+
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 1.3.7
|
153
|
+
signing_key:
|
154
|
+
specification_version: 3
|
155
|
+
summary: Coffeescript testing framework
|
156
|
+
test_files: []
|
157
|
+
|