harmony 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/LICENSE +19 -0
- data/Manifest +117 -0
- data/README.md +155 -0
- data/Rakefile +39 -0
- data/docs.watchr +25 -0
- data/harmony.gemspec +18 -0
- data/lib/harmony.rb +5 -0
- data/lib/harmony/page.rb +123 -0
- data/specs.watchr +36 -0
- data/test/harmony_test.rb +8 -0
- data/test/page_test.rb +73 -0
- data/test/test_helper.rb +13 -0
- data/vendor/README +1 -0
- data/vendor/envjs/README +36 -0
- data/vendor/envjs/bin/envjsrb +255 -0
- data/vendor/envjs/bin/jquery-1.2.6-test.js +33 -0
- data/vendor/envjs/bin/jquery-1.3.1-test.js +33 -0
- data/vendor/envjs/bin/jquery-1.3.2-test.js +106 -0
- data/vendor/envjs/bin/prototype-1.6.0.3-test.js +82 -0
- data/vendor/envjs/bin/prototype_1.6.0.3_tmpl.txt +27 -0
- data/vendor/envjs/bin/test-jquery.sh +58 -0
- data/vendor/envjs/bin/test-prototype.sh +54 -0
- data/vendor/envjs/bin/tidy +0 -0
- data/vendor/envjs/lib/envjs.rb +23 -0
- data/vendor/envjs/lib/envjs/env.js +21665 -0
- data/vendor/envjs/lib/envjs/net.rb +3 -0
- data/vendor/envjs/lib/envjs/net/cgi.rb +94 -0
- data/vendor/envjs/lib/envjs/net/file.rb +75 -0
- data/vendor/envjs/lib/envjs/options.rb +11 -0
- data/vendor/envjs/lib/envjs/runtime.rb +351 -0
- data/vendor/envjs/lib/envjs/tempfile.rb +24 -0
- data/vendor/envjs/test/base64.js +80 -0
- data/vendor/envjs/test/call-load-test.js +15 -0
- data/vendor/envjs/test/data.js +45 -0
- data/vendor/envjs/test/debug.js +53 -0
- data/vendor/envjs/test/firebug/errorIcon.png +0 -0
- data/vendor/envjs/test/firebug/firebug.css +209 -0
- data/vendor/envjs/test/firebug/firebug.html +23 -0
- data/vendor/envjs/test/firebug/firebug.js +672 -0
- data/vendor/envjs/test/firebug/firebugx.js +10 -0
- data/vendor/envjs/test/firebug/infoIcon.png +0 -0
- data/vendor/envjs/test/firebug/warningIcon.png +0 -0
- data/vendor/envjs/test/fixtures/html/events.html +171 -0
- data/vendor/envjs/test/fixtures/html/iframe1.html +46 -0
- data/vendor/envjs/test/fixtures/html/iframe1a.html +46 -0
- data/vendor/envjs/test/fixtures/html/iframe2.html +45 -0
- data/vendor/envjs/test/fixtures/html/iframe3.html +28 -0
- data/vendor/envjs/test/fixtures/html/iframeN.html +57 -0
- data/vendor/envjs/test/fixtures/html/malformed.html +181 -0
- data/vendor/envjs/test/fixtures/html/scope.html +81 -0
- data/vendor/envjs/test/fixtures/html/trivial.html +19 -0
- data/vendor/envjs/test/fixtures/html/with_js.html +26 -0
- data/vendor/envjs/test/fixtures/images/icon-blue.png +0 -0
- data/vendor/envjs/test/fixtures/js/external_script.js +1 -0
- data/vendor/envjs/test/fixtures/js/script.js +1 -0
- data/vendor/envjs/test/fixtures/js/script_error.js +2 -0
- data/vendor/envjs/test/html/events.html +171 -0
- data/vendor/envjs/test/html/iframe1.html +46 -0
- data/vendor/envjs/test/html/iframe1a.html +46 -0
- data/vendor/envjs/test/html/iframe2.html +45 -0
- data/vendor/envjs/test/html/iframe3.html +30 -0
- data/vendor/envjs/test/html/iframeN.html +57 -0
- data/vendor/envjs/test/html/malformed.html +181 -0
- data/vendor/envjs/test/html/scope.html +87 -0
- data/vendor/envjs/test/html/script.js +1 -0
- data/vendor/envjs/test/html/trivial.html +19 -0
- data/vendor/envjs/test/html/with_js.html +26 -0
- data/vendor/envjs/test/index.html +328 -0
- data/vendor/envjs/test/java-prototype.js +9 -0
- data/vendor/envjs/test/primary-tests.js +24 -0
- data/vendor/envjs/test/prototype-test.js +13 -0
- data/vendor/envjs/test/qunit.js +61 -0
- data/vendor/envjs/test/qunit/qunit/qunit.css +17 -0
- data/vendor/envjs/test/qunit/qunit/qunit.js +997 -0
- data/vendor/envjs/test/scope.rb +25 -0
- data/vendor/envjs/test/specs/dist/env.spec.js +1534 -0
- data/vendor/envjs/test/specs/envjs.spec.css +46 -0
- data/vendor/envjs/test/specs/parser/html.js +31 -0
- data/vendor/envjs/test/specs/parser/spec.html +40 -0
- data/vendor/envjs/test/specs/parser/xml.js +31 -0
- data/vendor/envjs/test/specs/qunit.bdd.js +210 -0
- data/vendor/envjs/test/specs/qunit.css +17 -0
- data/vendor/envjs/test/specs/qunit.js +997 -0
- data/vendor/envjs/test/specs/template/spec-0.js +31 -0
- data/vendor/envjs/test/specs/template/spec-1.js +31 -0
- data/vendor/envjs/test/specs/template/spec.html +40 -0
- data/vendor/envjs/test/specs/window/css.js +23 -0
- data/vendor/envjs/test/specs/window/dialog.js +25 -0
- data/vendor/envjs/test/specs/window/document.js +23 -0
- data/vendor/envjs/test/specs/window/event.js +25 -0
- data/vendor/envjs/test/specs/window/history.js +34 -0
- data/vendor/envjs/test/specs/window/location.js +34 -0
- data/vendor/envjs/test/specs/window/navigator.js +71 -0
- data/vendor/envjs/test/specs/window/screen.js +42 -0
- data/vendor/envjs/test/specs/window/spec.html +48 -0
- data/vendor/envjs/test/specs/window/timer.js +26 -0
- data/vendor/envjs/test/specs/window/window.js +53 -0
- data/vendor/envjs/test/specs/xhr/spec.html +47 -0
- data/vendor/envjs/test/specs/xhr/xhr.js +31 -0
- data/vendor/envjs/test/test.js +10 -0
- data/vendor/envjs/test/unit/dom.js +44 -0
- data/vendor/envjs/test/unit/elementmembers.js +60 -0
- data/vendor/envjs/test/unit/events.js +195 -0
- data/vendor/envjs/test/unit/fixtures/external_script.js +1 -0
- data/vendor/envjs/test/unit/iframe.js +234 -0
- data/vendor/envjs/test/unit/multi-window.js +212 -0
- data/vendor/envjs/test/unit/nu.validator.js +34 -0
- data/vendor/envjs/test/unit/onload.js +90 -0
- data/vendor/envjs/test/unit/parser.js +121 -0
- data/vendor/envjs/test/unit/prototypecompat.js +22 -0
- data/vendor/envjs/test/unit/proxy.js +6 -0
- data/vendor/envjs/test/unit/scope.js +209 -0
- data/vendor/envjs/test/unit/timer.js +115 -0
- data/vendor/envjs/test/unit/window.js +41 -0
- data/vendor/envjs/test/vendor/jQuery/README +2 -0
- data/vendor/envjs/test/vendor/prototype-1.6.0.3.js +4320 -0
- metadata +200 -0
data/specs.watchr
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Run me with:
|
2
|
+
# $ watchr specs.watchr
|
3
|
+
|
4
|
+
# --------------------------------------------------
|
5
|
+
# Rules
|
6
|
+
# --------------------------------------------------
|
7
|
+
watch( '^test.*/.*_test\.rb' ) {|m| ruby m[0] }
|
8
|
+
watch( '^lib/(.*)\.rb' ) {|m| ruby "test/#{m[1]}_test.rb" }
|
9
|
+
watch( '^lib/harmony/(.*)\.rb' ) {|m| ruby "test/#{m[1]}_test.rb" }
|
10
|
+
watch( '^test/test_helper\.rb' ) { ruby tests }
|
11
|
+
|
12
|
+
# --------------------------------------------------
|
13
|
+
# Signal Handling
|
14
|
+
# --------------------------------------------------
|
15
|
+
Signal.trap('QUIT') { ruby tests } # Ctrl-\
|
16
|
+
Signal.trap('INT' ) { abort("\n") } # Ctrl-C
|
17
|
+
|
18
|
+
# --------------------------------------------------
|
19
|
+
# Helpers
|
20
|
+
# --------------------------------------------------
|
21
|
+
def ruby(*paths)
|
22
|
+
run "ruby #{gem_opt} -I.:lib:test -e'%w( #{paths.flatten.join(' ')} ).each {|p| require p }'"
|
23
|
+
end
|
24
|
+
|
25
|
+
def tests
|
26
|
+
Dir['test/**/*_test.rb']
|
27
|
+
end
|
28
|
+
|
29
|
+
def run( cmd )
|
30
|
+
puts cmd
|
31
|
+
system cmd
|
32
|
+
end
|
33
|
+
|
34
|
+
def gem_opt
|
35
|
+
defined?(Gem) ? "-rubygems" : ""
|
36
|
+
end
|
data/test/page_test.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'test/test_helper'
|
2
|
+
|
3
|
+
class PageTest < MiniTest::Unit::TestCase
|
4
|
+
include Harmony
|
5
|
+
|
6
|
+
PAGE = Page.new
|
7
|
+
|
8
|
+
test "api" do
|
9
|
+
assert_respond_to Page, :fetch
|
10
|
+
assert_respond_to Page, :new
|
11
|
+
assert_respond_to PAGE, :window
|
12
|
+
assert_respond_to PAGE, :document
|
13
|
+
assert_respond_to PAGE, :execute_js
|
14
|
+
assert_respond_to PAGE, :x
|
15
|
+
assert_respond_to PAGE, :to_s
|
16
|
+
end
|
17
|
+
|
18
|
+
test "document shortcut" do
|
19
|
+
assert_equal PAGE.window.document, PAGE.document
|
20
|
+
end
|
21
|
+
|
22
|
+
test "executes javascript" do
|
23
|
+
assert_equal 7, PAGE.x('5+2')
|
24
|
+
end
|
25
|
+
|
26
|
+
test "excutes DOM-accessing javascript" do
|
27
|
+
page = Page.new(<<-HTML)
|
28
|
+
<html>
|
29
|
+
<head>
|
30
|
+
<title>Harmony</title>
|
31
|
+
</head>
|
32
|
+
<body>
|
33
|
+
<div></div>
|
34
|
+
<div></div>
|
35
|
+
</body>
|
36
|
+
</html>
|
37
|
+
HTML
|
38
|
+
assert_equal 'Harmony', page.document.title
|
39
|
+
assert_equal 2, page.x(<<-JS)
|
40
|
+
document.getElementsByTagName('div').length
|
41
|
+
JS
|
42
|
+
end
|
43
|
+
|
44
|
+
test "fetches remote document" do
|
45
|
+
path = tempfile(<<-HTML)
|
46
|
+
<html><head><title>foo</title></head><body></body></html>
|
47
|
+
HTML
|
48
|
+
page = Page.fetch("file://#{path}")
|
49
|
+
assert_equal 'foo', page.document.title
|
50
|
+
end
|
51
|
+
|
52
|
+
test "default window" do
|
53
|
+
assert_empty Page.new.document.title
|
54
|
+
end
|
55
|
+
|
56
|
+
test "casting to string" do
|
57
|
+
assert_equal "<html><head><title></title></head><body></body></html>", Page.new.to_s
|
58
|
+
end
|
59
|
+
|
60
|
+
test "loads javascript file" do
|
61
|
+
path = tempfile(<<-HTML)
|
62
|
+
function foo() { return 'bar' };
|
63
|
+
HTML
|
64
|
+
page = Page.new.load(path)
|
65
|
+
assert_equal 'bar', page.x('foo()')
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
def tempfile(content)
|
70
|
+
Tempfile.open('abc') {|f| f << content; @__path = f.path }
|
71
|
+
@__path
|
72
|
+
end
|
73
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
3
|
+
begin require 'ruby-debug'; rescue LoadError; end
|
4
|
+
begin require 'redgreen' ; rescue LoadError; end
|
5
|
+
begin require 'phocus' ; rescue LoadError; end
|
6
|
+
|
7
|
+
require 'lib/harmony'
|
8
|
+
|
9
|
+
class MiniTest::Unit::TestCase
|
10
|
+
def self.test(name, &block)
|
11
|
+
define_method("test_#{name}".gsub(/\s/,'_'), &block)
|
12
|
+
end
|
13
|
+
end
|
data/vendor/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
vendoring specific envjs version (built from source) until changes are released
|
data/vendor/envjs/README
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
This is a fork of the env.js project (http://github.com/thatcher/env-js/). See that link for env.js details.
|
2
|
+
|
3
|
+
This fork is based on the Johnson Ruby gem (http://github.com/jbarnette/johnson) and will become obsolete when the Johnson support has been reintegrated into the master repo.
|
4
|
+
|
5
|
+
For now, you can install the envjs gem by installing Johnson:
|
6
|
+
|
7
|
+
gem install johnson --prerelease
|
8
|
+
|
9
|
+
(You'll need to manually install any prerequisites it asks for) and then installing the envjs gem with
|
10
|
+
|
11
|
+
gem install envjs
|
12
|
+
|
13
|
+
The envjs gem provides the envjsrb command, which functions as an extended version of the Johnson javascript shell. For example:
|
14
|
+
|
15
|
+
mbp:env-js smparkes$ envjsrb
|
16
|
+
js> this
|
17
|
+
=> [object Window 0]
|
18
|
+
js> window.location
|
19
|
+
=> about:blank
|
20
|
+
js> document.innerHTML
|
21
|
+
=> "<html><head><title></title></head><body></body></html>"
|
22
|
+
js>
|
23
|
+
|
24
|
+
It's also possible to embed the envjs interpreter similar to the way it's done in Johnson, e.g.,
|
25
|
+
|
26
|
+
require 'rubygems' # if necessary
|
27
|
+
require 'johnson/tramonkey'
|
28
|
+
require 'envjs/runtime'
|
29
|
+
|
30
|
+
envjs = Johnson::Runtime.new
|
31
|
+
envjs.extend Envjs::Runtime
|
32
|
+
window = envjs.evaluate("")
|
33
|
+
puts window.location.to_s # == "about:blank"
|
34
|
+
puts window.document.innerHTML # == "<html><head><title></title></head><body></body></html>"
|
35
|
+
|
36
|
+
Comments to http://groups.google.com/group/envjs or #envjs on freenode.
|
@@ -0,0 +1,255 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
require 'envjs/options'
|
7
|
+
|
8
|
+
require 'johnson/tracemonkey'
|
9
|
+
require 'johnson/cli'
|
10
|
+
require 'envjs/runtime'
|
11
|
+
|
12
|
+
RUNTIME = js = Johnson::Runtime.new
|
13
|
+
RUNTIME.extend Envjs::Runtime
|
14
|
+
|
15
|
+
# RUNTIME.load Envjs::ENVJS
|
16
|
+
|
17
|
+
EXIT_VERBS = [nil] + %w(exit quit)
|
18
|
+
|
19
|
+
prepped = false
|
20
|
+
ruby_readline = []
|
21
|
+
js_readline = []
|
22
|
+
local_binding = binding
|
23
|
+
mode = nil
|
24
|
+
|
25
|
+
(class<<self; self; end).send :define_method, :prep do
|
26
|
+
|
27
|
+
return if prepped
|
28
|
+
prepped = true
|
29
|
+
|
30
|
+
require "readline"
|
31
|
+
require "johnson/cli"
|
32
|
+
|
33
|
+
RUNTIME.evaluate(Johnson::CLI::JS)
|
34
|
+
|
35
|
+
def copy_history
|
36
|
+
new_history = []
|
37
|
+
until Readline::HISTORY.empty?
|
38
|
+
new_history.push(Readline::HISTORY.pop)
|
39
|
+
end
|
40
|
+
new_history
|
41
|
+
end
|
42
|
+
|
43
|
+
def paste_history(old_history)
|
44
|
+
until old_history.empty?
|
45
|
+
Readline::HISTORY << old_history.pop
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def handle_exit(input)
|
50
|
+
return EXIT_VERBS.include?(input)
|
51
|
+
end
|
52
|
+
|
53
|
+
def rescued(&block)
|
54
|
+
yield
|
55
|
+
rescue Exception => e
|
56
|
+
exit if SystemExit === e
|
57
|
+
|
58
|
+
puts e.message
|
59
|
+
puts e.backtrace.reject { |l| l =~ /bin\/johnson/ }
|
60
|
+
end
|
61
|
+
|
62
|
+
def eval_in_js(expression,stream)
|
63
|
+
rescued do
|
64
|
+
v = RUNTIME.evaluate(expression, "(console)")
|
65
|
+
stream.result { "=> " + v.inspect }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def eval_in_ruby(expression, bind_to, stream)
|
70
|
+
rescued do
|
71
|
+
v = eval(expression, bind_to)
|
72
|
+
stream.result { "=> " + v.inspect }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
(class<<self; self; end).send :define_method, :do_loop do |stream|
|
77
|
+
# def foo
|
78
|
+
|
79
|
+
catch "Breakout" do
|
80
|
+
loop do
|
81
|
+
mode = :js
|
82
|
+
input = stream.next("js> ")
|
83
|
+
input and input.chomp!
|
84
|
+
begin stream.exit(input); throw "Breakout" end if handle_exit(input)
|
85
|
+
|
86
|
+
if input =~ /^rb\s+(.+)$/
|
87
|
+
eval_in_ruby($1, local_binding, stream)
|
88
|
+
next
|
89
|
+
end
|
90
|
+
|
91
|
+
if input == "rb"
|
92
|
+
js_readline = copy_history
|
93
|
+
paste_history(ruby_readline)
|
94
|
+
|
95
|
+
loop do
|
96
|
+
mode = :rb
|
97
|
+
# input = Readline.readline("rb> ", true)
|
98
|
+
input = stream.next("rb> ")
|
99
|
+
begin stream.exit(input); throw "Breakout" end if handle_exit(input)
|
100
|
+
|
101
|
+
break if input == "js"
|
102
|
+
|
103
|
+
if input =~ /^js\s+(.+)$/
|
104
|
+
eval_in_js($1)
|
105
|
+
next
|
106
|
+
end
|
107
|
+
|
108
|
+
eval_in_ruby(input, local_binding, stream)
|
109
|
+
end
|
110
|
+
|
111
|
+
ruby_readline = copy_history
|
112
|
+
paste_history(js_readline)
|
113
|
+
next
|
114
|
+
end
|
115
|
+
|
116
|
+
eval_in_js(input, stream)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
if ARGV.length > 0
|
123
|
+
|
124
|
+
begin
|
125
|
+
about_blank = true
|
126
|
+
ARGV.each do |file|
|
127
|
+
|
128
|
+
uri = URI.parse file
|
129
|
+
|
130
|
+
if uri.scheme == nil
|
131
|
+
uri.scheme = "file"
|
132
|
+
begin
|
133
|
+
uri.path = Pathname.new(uri.path).realpath.to_s
|
134
|
+
rescue Errno::ENOENT; end
|
135
|
+
uri = URI.parse uri.to_s
|
136
|
+
end
|
137
|
+
|
138
|
+
uri_s = uri.to_s.sub %r(^file:/([^/])), 'file:///\1'
|
139
|
+
|
140
|
+
if uri.scheme == "about" and uri.opaque == "blank"
|
141
|
+
RUNTIME.wait
|
142
|
+
RUNTIME.evaluate("window.location = 'about:blank'", "(comand line)", 1)
|
143
|
+
about_blank = true
|
144
|
+
elsif uri.path =~ /\.x?html?$/ || uri.scheme =~ %r(^https?)
|
145
|
+
|
146
|
+
# this might want to go alway; jazrb does it manually now, which I think was the use case
|
147
|
+
# that wanted this
|
148
|
+
if !about_blank
|
149
|
+
RUNTIME.wait
|
150
|
+
RUNTIME.evaluate("window.location = 'about:blank'", "(comand line)", 1)
|
151
|
+
end
|
152
|
+
|
153
|
+
RUNTIME.wait
|
154
|
+
# RUNTIME.evaluate("window.location = 'file://#{Pathname.new(file).realpath}'", file, 1)
|
155
|
+
RUNTIME.evaluate("window.location = '#{uri_s}'", file, 1)
|
156
|
+
about_blank = false
|
157
|
+
else
|
158
|
+
RUNTIME.become_first_script_window
|
159
|
+
RUNTIME.top_level_load uri_s
|
160
|
+
RUNTIME.load uri_s
|
161
|
+
end
|
162
|
+
end
|
163
|
+
rescue Johnson::Error => je
|
164
|
+
if je.message.match /<SystemExit: exit>/
|
165
|
+
exit
|
166
|
+
end
|
167
|
+
raise je
|
168
|
+
end
|
169
|
+
|
170
|
+
RUNTIME.wait
|
171
|
+
|
172
|
+
else
|
173
|
+
|
174
|
+
prep
|
175
|
+
|
176
|
+
if !(files = Dir[".envjsrbrc",File.join(ENV["HOME"],".envjsrbrc")]).empty?
|
177
|
+
file = Class.new do
|
178
|
+
def initialize f
|
179
|
+
@file = open f
|
180
|
+
end
|
181
|
+
def next prompt
|
182
|
+
@file.gets
|
183
|
+
end
|
184
|
+
def result &block
|
185
|
+
end
|
186
|
+
def exit v; end
|
187
|
+
end.new files[0]
|
188
|
+
|
189
|
+
do_loop file
|
190
|
+
end
|
191
|
+
|
192
|
+
options = Johnson::CLI::Options.parse!(ARGV)
|
193
|
+
|
194
|
+
options.load_paths.each { |d| $LOAD_PATH << d }
|
195
|
+
options.paths_to_require.each { |p| RUNTIME.evaluate("Johnson.require('#{p}')") }
|
196
|
+
options.files_to_preload.each { |f| RUNTIME.load(f) }
|
197
|
+
|
198
|
+
unless options.expressions.empty?
|
199
|
+
options.expressions.each { |e| RUNTIME.evaluate(e, '-e') }
|
200
|
+
exit if options.files_to_evaluate.empty?
|
201
|
+
end
|
202
|
+
|
203
|
+
unless options.files_to_evaluate.empty?
|
204
|
+
RUNTIME[:arguments] = options.arguments
|
205
|
+
|
206
|
+
options.files_to_evaluate.each do |file|
|
207
|
+
RUNTIME.load(file)
|
208
|
+
end
|
209
|
+
|
210
|
+
exit
|
211
|
+
end
|
212
|
+
|
213
|
+
reader = Class.new do
|
214
|
+
def next prompt
|
215
|
+
Readline.readline(prompt, true)
|
216
|
+
end
|
217
|
+
def result
|
218
|
+
puts yield
|
219
|
+
end
|
220
|
+
def exit v; puts if v.nil?; end
|
221
|
+
end.new
|
222
|
+
|
223
|
+
begin
|
224
|
+
open(File.join(ENV["HOME"],".envjsrb.js")) do |f|
|
225
|
+
js_readline = f.read.split("\n")
|
226
|
+
end
|
227
|
+
rescue; end
|
228
|
+
|
229
|
+
begin
|
230
|
+
open(File.join(ENV["HOME"],".envjsrb.ruby")) do |f|
|
231
|
+
ruby_readline = f.read.split("\n")
|
232
|
+
end
|
233
|
+
rescue; end
|
234
|
+
|
235
|
+
case mode
|
236
|
+
when :js; paste_history js_readline
|
237
|
+
when :rb; paste_history ruby_readline
|
238
|
+
end
|
239
|
+
|
240
|
+
do_loop reader
|
241
|
+
|
242
|
+
case mode
|
243
|
+
when :js; js_readline = copy_history
|
244
|
+
when :rb; ruby_readline = copy_history
|
245
|
+
end
|
246
|
+
|
247
|
+
open(File.join(ENV["HOME"],".envjsrb.js"),"w") do |f|
|
248
|
+
f.write js_readline[0..100].join("\n")+"\n"
|
249
|
+
end
|
250
|
+
|
251
|
+
open(File.join(ENV["HOME"],".envjsrb.ruby"),"w") do |f|
|
252
|
+
f.write ruby_readline[0..100].join("\n")+"\n"
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
// Init
|
2
|
+
load("build/runtest/env.js");
|
3
|
+
|
4
|
+
var isLocal;
|
5
|
+
window.onload = function(){
|
6
|
+
isLocal = !!(window.location.protocol == 'file:');
|
7
|
+
|
8
|
+
// Load the test runner
|
9
|
+
load("dist/jquery.js",
|
10
|
+
"build/runtest/testrunner.js");
|
11
|
+
|
12
|
+
// Load the tests
|
13
|
+
load(
|
14
|
+
"test/unit/core.js",
|
15
|
+
"test/unit/selector.js",
|
16
|
+
"test/unit/event.js",
|
17
|
+
"test/unit/fx.js",
|
18
|
+
"test/unit/dimensions.js",
|
19
|
+
|
20
|
+
// offset relies on window.open, which is currently unimplemented in env.js
|
21
|
+
//"test/unit/offset.js",
|
22
|
+
|
23
|
+
// these tests require hitting a server, so we will need some clever env.js
|
24
|
+
// way of testing them
|
25
|
+
// by defining isLocal we can still load the test
|
26
|
+
"test/unit/ajax.js"
|
27
|
+
);
|
28
|
+
|
29
|
+
// Display the results
|
30
|
+
results();
|
31
|
+
};
|
32
|
+
|
33
|
+
window.location = "test/index.html";
|