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
data/lib/core/false_class.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
# Instances of `FalseClass` represent logically false values. There may
|
2
|
-
# only be one instance of `FalseClass`, which is the global value
|
3
|
-
# `false`. Attempts to create a new instance will yield an error.
|
4
|
-
# `FalseClass` provides methods to perform logical operations with other
|
5
|
-
# ruby objects.
|
6
|
-
#
|
7
|
-
# Implementation details
|
8
|
-
# ----------------------
|
9
|
-
#
|
10
|
-
# Due to the way messages are passed inside opal, `false` is not
|
11
|
-
# actually toll-free bridged onto the native javascript `false` value.
|
12
|
-
# In javascript, `false` and `true` are both instances of the Boolean
|
13
|
-
# type, which means they would need to share the same method_table in
|
14
|
-
# opal, which would remove their ability to be true instances of Rubys'
|
15
|
-
# `TrueClass` or `FalseClass`.
|
16
|
-
#
|
17
|
-
# As javascripts `false` is not actually the value used in opal, passing
|
18
|
-
# the native `false` value will cause errors when messages are sent to
|
19
|
-
# it. Within a file directly loaded by opal, `Qfalse` is a free variable
|
20
|
-
# that points to the actualy ruby instance of this class. This variable
|
21
|
-
# may be passed around freely.
|
22
|
-
class FalseClass
|
23
|
-
|
24
|
-
# Returns a string representation of `false`, which is simply
|
25
|
-
# `"false"`.
|
26
|
-
#
|
27
|
-
# @example
|
28
|
-
#
|
29
|
-
# false.to_s # => "false"
|
30
|
-
#
|
31
|
-
# @return [String]
|
32
|
-
def to_s
|
33
|
-
"false"
|
34
|
-
end
|
35
|
-
|
36
|
-
# And; This always returns `false`.
|
37
|
-
#
|
38
|
-
# @example
|
39
|
-
#
|
40
|
-
# false & true # => false
|
41
|
-
# false & nil # => false
|
42
|
-
# false & false # => false
|
43
|
-
#
|
44
|
-
# @return [false]
|
45
|
-
def &(other)
|
46
|
-
false
|
47
|
-
end
|
48
|
-
|
49
|
-
# Or; If `other` is `false` or `nil`, returns `false`, otherwise
|
50
|
-
# returns `true`.
|
51
|
-
#
|
52
|
-
# @example
|
53
|
-
#
|
54
|
-
# false & false # => false
|
55
|
-
# false & nil # => false
|
56
|
-
# false & true # => true
|
57
|
-
# false & [1, 2, 3] # => true
|
58
|
-
#
|
59
|
-
# @return [true, false]
|
60
|
-
def |(other)
|
61
|
-
`return other.$r ? Qtrue : Qfalse;`
|
62
|
-
end
|
63
|
-
|
64
|
-
# Exclusive Or; If `other` is `false` or `nil`, then it returns
|
65
|
-
# `false`, otherwise returns `true`.
|
66
|
-
#
|
67
|
-
# @example
|
68
|
-
#
|
69
|
-
# false & false # => false
|
70
|
-
# false & nil # => false
|
71
|
-
# false & true # => true
|
72
|
-
# false & [1, 2, 3] # => true
|
73
|
-
#
|
74
|
-
# @return [true, false]
|
75
|
-
def ^(other)
|
76
|
-
`return other.$r ? Qtrue : Qfalse;`
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
FALSE = false
|
81
|
-
|
data/lib/core/object.rb
DELETED
data/lib/core/range.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
class Range
|
2
|
-
|
3
|
-
def begin
|
4
|
-
`return self.$beg;`
|
5
|
-
end
|
6
|
-
|
7
|
-
alias_method :first, :begin
|
8
|
-
|
9
|
-
def end
|
10
|
-
`return self.$end;`
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_s
|
14
|
-
`var str = #{`self.$beg`.to_s};
|
15
|
-
var str2 = #{`self.$end`.to_s};
|
16
|
-
var join = self.$exc ? '...' : '..';
|
17
|
-
return str + join + str2;`
|
18
|
-
end
|
19
|
-
|
20
|
-
def inspect
|
21
|
-
`var str = #{`self.$beg`.inspect};
|
22
|
-
var str2 = #{`self.$end`.inspect};
|
23
|
-
var join = self.$exc ? '...' : '..';
|
24
|
-
return str + join + str2;`
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
data/lib/core/symbol.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
# `Symbols` are used to represent names and can often be used in place
|
2
|
-
# of enum variables used in other languages. Symbols can be constructed
|
3
|
-
# using their literal syntax or one of the various `to_sym` methods
|
4
|
-
# found in the standard library:
|
5
|
-
#
|
6
|
-
# :some_symbol # => :some_symbol
|
7
|
-
# "a_string".to_sym # => :a_string
|
8
|
-
#
|
9
|
-
# It is important to note that regardless of the context that created
|
10
|
-
# them, two symbols with the same name will always be the exact same
|
11
|
-
# object. The opal runtime guarantees this as it creates them. If one
|
12
|
-
# exists already with the required name, it will be returned instead of
|
13
|
-
# creating a new one.
|
14
|
-
#
|
15
|
-
# Implementation details
|
16
|
-
# ----------------------
|
17
|
-
#
|
18
|
-
# Internally, symbols are just javascript strings. They are constructed
|
19
|
-
# with the javascript `new String(symbol_name)` syntax. Once created,
|
20
|
-
# they have their class and method tables altered to point towards the
|
21
|
-
# {Symbol} class. This avoids them conflicting with regular strings.
|
22
|
-
#
|
23
|
-
# Symbols are implemented as strings for performance. They are only
|
24
|
-
# created once per name, so past the initial creation phase, which
|
25
|
-
# happends just the once, they perform as quickly as just passig them
|
26
|
-
# between method calls, and as strings their native prototype offers all
|
27
|
-
# the required functionality needed by the class.
|
28
|
-
class Symbol
|
29
|
-
|
30
|
-
def inspect
|
31
|
-
`return ':' + self.toString();`
|
32
|
-
end
|
33
|
-
|
34
|
-
def to_sym
|
35
|
-
self
|
36
|
-
end
|
37
|
-
|
38
|
-
def intern
|
39
|
-
self
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
data/lib/core/true_class.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# Instances of `TrueClass` represent logically true values. There may
|
2
|
-
# only be one instance of `TrueClass`, which is the global value
|
3
|
-
# `true`. Attempts to create a new instance will yield an error.
|
4
|
-
# `TrueClass` provides methods to perform logical operations with other
|
5
|
-
# ruby objects.
|
6
|
-
#
|
7
|
-
# Implementation details
|
8
|
-
# ----------------------
|
9
|
-
#
|
10
|
-
# Due to the way messages are passed inside opal, `true` is not
|
11
|
-
# actually toll-free bridged onto the native javascript `true` value.
|
12
|
-
# In javascript, `true` and `true` are both instances of the Boolean
|
13
|
-
# type, which means they would need to share the same method_table in
|
14
|
-
# opal, which would remove their ability to be true instances of Rubys'
|
15
|
-
# `TrueClass` or `FalseClass`.
|
16
|
-
#
|
17
|
-
# As javascripts `true` is not actually the value used in opal, passing
|
18
|
-
# the native `true` value will cause errors when messages are sent to
|
19
|
-
# it. Within a file directly loaded by opal, `Qtrue` is a free variable
|
20
|
-
# that points to the actualy ruby instance of this class. This variable
|
21
|
-
# may be passed around freely.
|
22
|
-
class TrueClass
|
23
|
-
def to_s
|
24
|
-
"true"
|
25
|
-
end
|
26
|
-
|
27
|
-
def &(other)
|
28
|
-
`return other.$r ? Qtrue : Qfalse;`
|
29
|
-
end
|
30
|
-
|
31
|
-
def |(other)
|
32
|
-
true
|
33
|
-
end
|
34
|
-
|
35
|
-
def ^(other)
|
36
|
-
`return other.$r ? Qfalse : Qtrue;`
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
TRUE = true
|
41
|
-
|
data/lib/ospec.rb
DELETED
data/lib/ospec/autorun.rb
DELETED
data/lib/ospec/dsl.rb
DELETED
data/lib/ospec/example.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'ospec/example/before_and_after_hooks'
|
3
|
-
require 'ospec/example/example_group_proxy'
|
4
|
-
require 'ospec/example/example_proxy'
|
5
|
-
require 'ospec/example/example_group_methods'
|
6
|
-
require 'ospec/example/example_group_factory'
|
7
|
-
require 'ospec/example/example_group_hierarchy'
|
8
|
-
require 'ospec/example/example_methods'
|
9
|
-
require 'ospec/example/example_group'
|
10
|
-
require 'ospec/example/errors'
|
11
|
-
|
@@ -1,56 +0,0 @@
|
|
1
|
-
|
2
|
-
module Spec
|
3
|
-
module Example
|
4
|
-
|
5
|
-
module BeforeAndAfterHooks
|
6
|
-
|
7
|
-
def before(scope = :each, &block)
|
8
|
-
before_parts(scope) << block
|
9
|
-
end
|
10
|
-
|
11
|
-
alias_method :append_before, :before
|
12
|
-
|
13
|
-
def before_each_parts
|
14
|
-
@before_each_parts ||= []
|
15
|
-
end
|
16
|
-
|
17
|
-
def before_all_parts
|
18
|
-
@before_all_parts ||= []
|
19
|
-
end
|
20
|
-
|
21
|
-
def before_parts(scope)
|
22
|
-
if scope == :each
|
23
|
-
before_each_parts
|
24
|
-
elsif scope == :all
|
25
|
-
before_all_parts
|
26
|
-
else
|
27
|
-
[]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
def after(scope = :each, &block)
|
33
|
-
after_parts(scope) << block
|
34
|
-
end
|
35
|
-
|
36
|
-
def after_each_parts
|
37
|
-
@after_each_parts ||= []
|
38
|
-
end
|
39
|
-
|
40
|
-
def after_all_parts
|
41
|
-
@after_all_parts ||= []
|
42
|
-
end
|
43
|
-
|
44
|
-
def after_parts(scope)
|
45
|
-
if scope == :each
|
46
|
-
after_each_parts
|
47
|
-
elsif scope == :all
|
48
|
-
after_all_parts
|
49
|
-
else
|
50
|
-
[]
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
data/lib/ospec/example/errors.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
|
2
|
-
module Spec
|
3
|
-
|
4
|
-
module Example
|
5
|
-
|
6
|
-
class ExampleGroupFactory
|
7
|
-
|
8
|
-
def self.register_example_group klass
|
9
|
-
Spec::Runner.options.add_example_group klass
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.create_example_group(group_name, &block)
|
13
|
-
ExampleGroup.describe group_name, &block
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
@@ -1,21 +0,0 @@
|
|
1
|
-
|
2
|
-
module Spec
|
3
|
-
|
4
|
-
module Example
|
5
|
-
|
6
|
-
class ExampleGroupHierarchy
|
7
|
-
|
8
|
-
def initialize(example_group_class)
|
9
|
-
@example_group_class = example_group_class
|
10
|
-
end
|
11
|
-
|
12
|
-
def run_before_each(example)
|
13
|
-
@example_group_class.before_each_parts.each do |part|
|
14
|
-
# puts "in each part before"
|
15
|
-
example.instance_eval &part
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
module Spec
|
2
|
-
module Example
|
3
|
-
module ExampleGroupMethods
|
4
|
-
|
5
|
-
include Spec::Example::BeforeAndAfterHooks
|
6
|
-
|
7
|
-
def describe group_name, &group_block
|
8
|
-
subclass group_name, &group_block
|
9
|
-
end
|
10
|
-
|
11
|
-
def subclass group_name, &group_block
|
12
|
-
@class_count ||= 0
|
13
|
-
klass = const_set "Subclass#{@class_count}", Class.new(self)
|
14
|
-
klass.description = group_name
|
15
|
-
Spec::Example::ExampleGroupFactory.register_example_group klass
|
16
|
-
klass.module_eval(&group_block)
|
17
|
-
klass
|
18
|
-
end
|
19
|
-
|
20
|
-
def example(example_name, &implementation)
|
21
|
-
example_proxy = Spec::Example::ExampleProxy.new example_name
|
22
|
-
example_proxies << example_proxy
|
23
|
-
example_implementations[example_proxy] = implementation || pending_implementation
|
24
|
-
example_proxy
|
25
|
-
end
|
26
|
-
|
27
|
-
alias_method :it, :example
|
28
|
-
alias_method :specify, :example
|
29
|
-
|
30
|
-
def description
|
31
|
-
@description ||= "PLACEHOLDER DESCRIPTION"
|
32
|
-
end
|
33
|
-
|
34
|
-
def description=(description)
|
35
|
-
@description = description
|
36
|
-
self
|
37
|
-
end
|
38
|
-
|
39
|
-
def pending_implementation
|
40
|
-
proc {
|
41
|
-
raise Spec::Example::NotYetImplementedError.new
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
def run(run_options)
|
46
|
-
examples = examples_to_run run_options
|
47
|
-
notify run_options.reporter
|
48
|
-
success = true
|
49
|
-
before_all_instance_variables = nil
|
50
|
-
|
51
|
-
run_before_all run_options
|
52
|
-
run_examples success, before_all_instance_variables, examples, run_options
|
53
|
-
run_after_all run_options
|
54
|
-
end
|
55
|
-
|
56
|
-
def run_examples(success, instance_variables, examples, run_options)
|
57
|
-
examples.each do |example|
|
58
|
-
example_group_instance = new example,
|
59
|
-
&example_implementations[example]
|
60
|
-
|
61
|
-
example_group_instance.execute run_options, instance_variables
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def run_before_all(run_options)
|
66
|
-
before_all_parts.each do |part|
|
67
|
-
part.call
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def run_after_all(run_options)
|
72
|
-
after_all_parts.each do |part|
|
73
|
-
part.call
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def notify(reporter)
|
78
|
-
reporter.example_group_started Spec::Example::ExampleGroupProxy.new(self)
|
79
|
-
end
|
80
|
-
|
81
|
-
def examples_to_run(run_options)
|
82
|
-
example_proxies
|
83
|
-
end
|
84
|
-
|
85
|
-
def example_proxies
|
86
|
-
@example_proxies ||= []
|
87
|
-
end
|
88
|
-
|
89
|
-
def example_implementations
|
90
|
-
@example_implementations ||= {}
|
91
|
-
@example_implementations
|
92
|
-
end
|
93
|
-
|
94
|
-
def example_group_hierarchy
|
95
|
-
@example_group_hierarchy ||= Spec::Example::ExampleGroupHierarchy.new self
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|