opal 0.3.6 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +69 -97
- data/bin/opal +2 -2
- data/{lib/core → corelib}/array.rb +85 -56
- data/corelib/boolean.rb +20 -0
- data/corelib/class.rb +58 -0
- data/{lib → corelib}/core.rb +2 -50
- data/corelib/dir.rb +22 -0
- data/{lib/core → corelib}/enumerable.rb +0 -0
- data/corelib/error.rb +19 -0
- data/{lib/core → corelib}/file.rb +7 -9
- data/{lib/core → corelib}/hash.rb +104 -144
- data/{lib/core → corelib}/kernel.rb +38 -44
- data/corelib/load_order +21 -0
- data/{lib/core → corelib}/match_data.rb +0 -0
- data/{lib/core → corelib}/module.rb +12 -8
- data/{lib/core → corelib}/nil_class.rb +2 -2
- data/{lib/core → corelib}/numeric.rb +37 -100
- data/corelib/object.rb +37 -0
- data/{lib/core → corelib}/proc.rb +3 -3
- data/corelib/range.rb +27 -0
- data/{lib/core → corelib}/regexp.rb +1 -1
- data/{lib/core → corelib}/string.rb +16 -107
- data/{lib/core → corelib}/top_self.rb +0 -0
- data/lib/opal.rb +7 -0
- data/lib/opal/browserify.rb +34 -0
- data/{opal_lib → lib}/opal/builder.rb +70 -24
- data/lib/opal/command.rb +52 -0
- data/lib/opal/context.rb +197 -0
- data/{opal_lib/opal/ruby/parser.rb → lib/opal/lexer.rb} +20 -4
- data/{opal_lib/opal/ruby → lib/opal}/nodes.rb +238 -127
- data/lib/opal/parser.rb +4894 -0
- data/{opal_lib/opal/ruby/ruby_parser.y → lib/opal/parser.y} +38 -18
- data/lib/rbp.rb +2 -0
- data/lib/rbp/package.rb +49 -0
- data/runtime/class.js +216 -189
- data/runtime/fs.js +2 -2
- data/runtime/init.js +242 -244
- data/runtime/loader.js +78 -99
- data/runtime/module.js +34 -40
- data/runtime/post.js +2 -2
- data/runtime/pre.js +1 -1
- data/runtime/runtime.js +129 -135
- data/{lib → stdlib}/dev.rb +10 -10
- data/{lib → stdlib}/racc/parser.rb +0 -6
- data/{lib → stdlib}/strscan.rb +4 -4
- metadata +57 -105
- data/lib/core/basic_object.rb +0 -51
- data/lib/core/class.rb +0 -38
- data/lib/core/dir.rb +0 -26
- data/lib/core/error.rb +0 -75
- data/lib/core/false_class.rb +0 -81
- data/lib/core/object.rb +0 -6
- data/lib/core/range.rb +0 -27
- data/lib/core/symbol.rb +0 -42
- data/lib/core/true_class.rb +0 -41
- data/lib/ospec.rb +0 -7
- data/lib/ospec/autorun.rb +0 -8
- data/lib/ospec/dsl.rb +0 -15
- data/lib/ospec/example.rb +0 -11
- data/lib/ospec/example/before_and_after_hooks.rb +0 -56
- data/lib/ospec/example/errors.rb +0 -17
- data/lib/ospec/example/example_group.rb +0 -12
- data/lib/ospec/example/example_group_factory.rb +0 -18
- data/lib/ospec/example/example_group_hierarchy.rb +0 -21
- data/lib/ospec/example/example_group_methods.rb +0 -100
- data/lib/ospec/example/example_group_proxy.rb +0 -15
- data/lib/ospec/example/example_methods.rb +0 -46
- data/lib/ospec/example/example_proxy.rb +0 -18
- data/lib/ospec/expectations.rb +0 -19
- data/lib/ospec/expectations/errors.rb +0 -8
- data/lib/ospec/expectations/fail_with.rb +0 -9
- data/lib/ospec/expectations/handler.rb +0 -33
- data/lib/ospec/helpers/scratch.rb +0 -18
- data/lib/ospec/matchers.rb +0 -24
- data/lib/ospec/matchers/be.rb +0 -1
- data/lib/ospec/matchers/generated_descriptions.rb +0 -20
- data/lib/ospec/matchers/operator_matcher.rb +0 -54
- data/lib/ospec/matchers/raise_error.rb +0 -38
- data/lib/ospec/runner.rb +0 -90
- data/lib/ospec/runner/example_group_runner.rb +0 -41
- data/lib/ospec/runner/formatter/html_formatter.rb +0 -139
- data/lib/ospec/runner/formatter/terminal_formatter.rb +0 -48
- data/lib/ospec/runner/options.rb +0 -34
- data/lib/ospec/runner/reporter.rb +0 -82
- data/opal_lib/opal.rb +0 -16
- data/opal_lib/opal/build_methods.rb +0 -51
- data/opal_lib/opal/bundle.rb +0 -70
- data/opal_lib/opal/command.rb +0 -68
- data/opal_lib/opal/context.rb +0 -81
- data/opal_lib/opal/context/console.rb +0 -10
- data/opal_lib/opal/context/file_system.rb +0 -34
- data/opal_lib/opal/context/loader.rb +0 -135
- data/opal_lib/opal/gem.rb +0 -84
- data/opal_lib/opal/rake/builder_task.rb +0 -44
- data/opal_lib/opal/rake/spec_task.rb +0 -32
- data/opal_lib/opal/ruby/ruby_parser.rb +0 -4862
- data/opal_lib/opal/version.rb +0 -4
- data/runtime/debug.js +0 -84
@@ -1,46 +0,0 @@
|
|
1
|
-
module Spec
|
2
|
-
|
3
|
-
module Example
|
4
|
-
|
5
|
-
module ExampleMethods
|
6
|
-
|
7
|
-
include Spec::Matchers
|
8
|
-
|
9
|
-
def initialize(example_proxy, &implementation)
|
10
|
-
@example_proxy = example_proxy
|
11
|
-
@implementation = implementation
|
12
|
-
end
|
13
|
-
|
14
|
-
def before_each_example
|
15
|
-
run_before_each
|
16
|
-
end
|
17
|
-
|
18
|
-
def run_before_each
|
19
|
-
example_group_hierarchy.run_before_each self
|
20
|
-
end
|
21
|
-
|
22
|
-
def example_group_hierarchy
|
23
|
-
self.class.example_group_hierarchy
|
24
|
-
end
|
25
|
-
|
26
|
-
def description
|
27
|
-
@example_proxy.description
|
28
|
-
end
|
29
|
-
|
30
|
-
def execute(run_options, instance_variables)
|
31
|
-
run_options.reporter.example_started @example_proxy
|
32
|
-
execution_error = nil
|
33
|
-
|
34
|
-
begin
|
35
|
-
before_each_example
|
36
|
-
instance_eval(&@implementation)
|
37
|
-
rescue Exception => e
|
38
|
-
execution_error = e
|
39
|
-
end
|
40
|
-
|
41
|
-
run_options.reporter.example_finished @example_proxy.update(description), execution_error
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Spec
|
2
|
-
module Example
|
3
|
-
class ExampleProxy
|
4
|
-
|
5
|
-
attr_reader :description
|
6
|
-
|
7
|
-
def initialize(description, options = nil, location = nil)
|
8
|
-
@description = description
|
9
|
-
end
|
10
|
-
|
11
|
-
def update(description)
|
12
|
-
@description = description
|
13
|
-
self
|
14
|
-
end
|
15
|
-
end # ExampleProxy
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
data/lib/ospec/expectations.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'ospec/expectations/fail_with'
|
3
|
-
require 'ospec/expectations/handler'
|
4
|
-
require 'ospec/expectations/errors'
|
5
|
-
|
6
|
-
module Kernel
|
7
|
-
|
8
|
-
def should(matcher = nil, message = nil, &block)
|
9
|
-
r = Spec::Expectations::PositiveExpectationHandler.handle_matcher self,
|
10
|
-
matcher,
|
11
|
-
message
|
12
|
-
end
|
13
|
-
|
14
|
-
def should_not(matcher = nil, message = nil, &block)
|
15
|
-
Spec::Expectations::NegativeExpectationHandler.handle_matcher self,
|
16
|
-
matcher,
|
17
|
-
message
|
18
|
-
end
|
19
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Spec
|
2
|
-
module Expectations
|
3
|
-
|
4
|
-
class PositiveExpectationHandler
|
5
|
-
|
6
|
-
def self.handle_matcher(actual, matcher, message, &block)
|
7
|
-
Spec::Matchers.last_should = :should
|
8
|
-
Spec::Matchers.last_matcher = matcher
|
9
|
-
if matcher.nil?
|
10
|
-
return Spec::Matchers::PositiveOperatorMatcher.new actual
|
11
|
-
else
|
12
|
-
match = matcher.matches?(actual, &block)
|
13
|
-
return match if match
|
14
|
-
|
15
|
-
Spec::Expectations.fail_with matcher.failure_message_for_should
|
16
|
-
nil
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class NegativeExpectationHandler
|
22
|
-
|
23
|
-
def self.handle_matcher(actual, matcher, message, &block)
|
24
|
-
Spec::Matchers.last_should = :should_not
|
25
|
-
Spec::Matchers.last_matcher = matcher
|
26
|
-
if matcher.nil?
|
27
|
-
return Spec::Matchers::NegativeOperatorMatcher.new actual
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
data/lib/ospec/matchers.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'ospec/matchers/operator_matcher'
|
2
|
-
require 'ospec/matchers/be'
|
3
|
-
require 'ospec/matchers/generated_descriptions'
|
4
|
-
require 'ospec/matchers/raise_error'
|
5
|
-
|
6
|
-
module Spec
|
7
|
-
|
8
|
-
module Matchers
|
9
|
-
|
10
|
-
class Matcher
|
11
|
-
include Spec::Matchers
|
12
|
-
|
13
|
-
# attr_reader :expected, :actual
|
14
|
-
|
15
|
-
def initialize(name, expected, &declarations)
|
16
|
-
@name = name
|
17
|
-
@expected = expected
|
18
|
-
instance_exec expected, &declarations
|
19
|
-
end
|
20
|
-
|
21
|
-
end # Matcher
|
22
|
-
end # Matchers
|
23
|
-
end # Spec
|
24
|
-
|
data/lib/ospec/matchers/be.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Spec
|
2
|
-
module Matchers
|
3
|
-
|
4
|
-
def self.last_matcher
|
5
|
-
@last_matcher
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.last_matcher=(last_matcher)
|
9
|
-
@last_matcher = last_matcher
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.last_should
|
13
|
-
@last_should
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.last_should=(last_should)
|
17
|
-
@last_should = last_should
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
|
2
|
-
module Spec
|
3
|
-
|
4
|
-
module Matchers
|
5
|
-
|
6
|
-
class OperatorMatcher
|
7
|
-
|
8
|
-
def initialize(actual)
|
9
|
-
@actual = actual
|
10
|
-
end
|
11
|
-
|
12
|
-
[:==, :===, :=~, :>, :<, :>=, :<=].each do |op|
|
13
|
-
define_method(op) do |exp|
|
14
|
-
eval_match @actual, op, exp
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def eval_match(actual, operator, expected)
|
19
|
-
@operator = operator
|
20
|
-
@expected = expected
|
21
|
-
__delegate_operator actual, operator, expected
|
22
|
-
end
|
23
|
-
|
24
|
-
def fail_with_message(message)
|
25
|
-
Spec::Expectations.fail_with message, @expected, @actual
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
class PositiveOperatorMatcher < OperatorMatcher
|
30
|
-
|
31
|
-
def __delegate_operator(actual, operator, expected)
|
32
|
-
if actual.__send__ operator, expected
|
33
|
-
true
|
34
|
-
else
|
35
|
-
fail_with_message "expected: #{expected.inspect}, but got: #{actual.inspect} (using #{operator})"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
class NegativeOperatorMatcher < OperatorMatcher
|
41
|
-
|
42
|
-
def __delegate_operator(actual, operator, expected)
|
43
|
-
if actual.__send__ operator, expected
|
44
|
-
fail_with_message "expected not: #{expected.inspect}, and got: #{actual.inspect} (using #{operator})"
|
45
|
-
else
|
46
|
-
true
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module Spec
|
2
|
-
|
3
|
-
module Matchers
|
4
|
-
|
5
|
-
class RaiseError
|
6
|
-
|
7
|
-
def initialize(expected_error_or_message = Exception, expected_message = nil, &block)
|
8
|
-
@block = block
|
9
|
-
@actual_error = nil
|
10
|
-
@expected_exception = Exception
|
11
|
-
end
|
12
|
-
|
13
|
-
def matches?(given_proc)
|
14
|
-
@raised_expected_exception = false
|
15
|
-
@with_expected_message = false
|
16
|
-
|
17
|
-
begin
|
18
|
-
given_proc.call
|
19
|
-
rescue => e
|
20
|
-
@raised_expected_exception = true
|
21
|
-
end
|
22
|
-
|
23
|
-
@raised_expected_exception
|
24
|
-
end
|
25
|
-
|
26
|
-
def failure_message_for_should
|
27
|
-
"expected #{@expected_exception}, but nothing was raised"
|
28
|
-
end
|
29
|
-
end # RaiseError
|
30
|
-
|
31
|
-
def raise_error(error = Exception, message = nil, &block)
|
32
|
-
Spec::Matchers::RaiseError.new error, message, &block
|
33
|
-
end
|
34
|
-
|
35
|
-
alias_method :raise_exception, :raise_error
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
data/lib/ospec/runner.rb
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
require 'ospec/runner/options'
|
2
|
-
require 'ospec/runner/reporter'
|
3
|
-
require 'ospec/runner/example_group_runner'
|
4
|
-
|
5
|
-
require 'ospec/runner/formatter/html_formatter'
|
6
|
-
require 'ospec/runner/formatter/terminal_formatter'
|
7
|
-
|
8
|
-
module Spec
|
9
|
-
module Runner
|
10
|
-
|
11
|
-
def self.run
|
12
|
-
options.run_examples
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.options
|
16
|
-
@options ||= Options.new
|
17
|
-
@options
|
18
|
-
end
|
19
|
-
|
20
|
-
# Autorun for the browser. This differs from {.autorun} because it wraps
|
21
|
-
# itself in a setTimeout call to make sure the browser is ready as we
|
22
|
-
# start adding to the DOM as we run. This won't use rquery because its
|
23
|
-
# nice to keep everything independant, and someone might write a better
|
24
|
-
# DOM library. All the dom interactions are simply inline javascript.
|
25
|
-
def self.autorun_browser
|
26
|
-
`setTimeout(function() {`
|
27
|
-
specs = Dir["spec/**/*.{rb,js}"]
|
28
|
-
|
29
|
-
if specs.length == 0
|
30
|
-
puts "ospec: no input files given"
|
31
|
-
else
|
32
|
-
if File.exist? "spec/spec_helper.js"
|
33
|
-
require File.expand_path("spec/spec_helper.js")
|
34
|
-
end
|
35
|
-
|
36
|
-
specs.each do |spec|
|
37
|
-
require spec
|
38
|
-
end
|
39
|
-
# require specs[0]
|
40
|
-
# idx = 49
|
41
|
-
# puts idx
|
42
|
-
# `console.log(specs[idx]);`
|
43
|
-
# puts specs[idx]
|
44
|
-
# puts specs[idx]
|
45
|
-
# require specs[idx]
|
46
|
-
end
|
47
|
-
|
48
|
-
Spec::Runner.run
|
49
|
-
puts Spec::Runner.options.formatters
|
50
|
-
`}, 0);`
|
51
|
-
nil
|
52
|
-
end
|
53
|
-
|
54
|
-
# Autorun gem/node context
|
55
|
-
def self.autorun
|
56
|
-
puts "in here"
|
57
|
-
puts ARGV.inspect
|
58
|
-
if ARGV.length == 0
|
59
|
-
specs = Dir["spec/**/*.{rb,js}"]
|
60
|
-
|
61
|
-
if specs.length == 0
|
62
|
-
puts "ospec: no input files given"
|
63
|
-
else
|
64
|
-
|
65
|
-
if File.exist? "spec/spec_helper.rb"
|
66
|
-
require File.expand_path "spec/spec_helper.rb"
|
67
|
-
end
|
68
|
-
|
69
|
-
specs.each do |spec|
|
70
|
-
require spec
|
71
|
-
end
|
72
|
-
end
|
73
|
-
# return
|
74
|
-
end
|
75
|
-
|
76
|
-
ARGV.each do |spec|
|
77
|
-
puts "should try and load #{spec}"
|
78
|
-
if File.exist? spec
|
79
|
-
puts "loading: " + File.expand_path(spec)
|
80
|
-
require File.expand_path(spec)
|
81
|
-
else
|
82
|
-
raise "Bad spec to load (does not exist): #{spec}"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
Spec::Runner.run
|
87
|
-
end
|
88
|
-
|
89
|
-
end # Runner
|
90
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module Spec
|
2
|
-
module Runner
|
3
|
-
class ExampleGroupRunner
|
4
|
-
|
5
|
-
def initialize(options)
|
6
|
-
@options = options
|
7
|
-
end
|
8
|
-
|
9
|
-
def run
|
10
|
-
prepare
|
11
|
-
example_groups.each do |group|
|
12
|
-
group.run @options
|
13
|
-
end
|
14
|
-
finish
|
15
|
-
end
|
16
|
-
|
17
|
-
def example_groups
|
18
|
-
@options.example_groups
|
19
|
-
end
|
20
|
-
|
21
|
-
def prepare
|
22
|
-
rep = reporter
|
23
|
-
rep.start number_of_examples
|
24
|
-
end
|
25
|
-
|
26
|
-
def finish
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
def reporter
|
31
|
-
@options.reporter
|
32
|
-
end
|
33
|
-
|
34
|
-
def number_of_examples
|
35
|
-
0
|
36
|
-
end
|
37
|
-
|
38
|
-
end # ExampleGroupRunner
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|