opal 0.6.3 → 0.7.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.spectator +2 -0
- data/.spectator-mspec +3 -0
- data/.travis.yml +8 -11
- data/CHANGELOG.md +33 -0
- data/CONTRIBUTING.md +8 -43
- data/Gemfile +15 -4
- data/Guardfile +77 -0
- data/README.md +15 -9
- data/Rakefile +36 -12
- data/benchmarks/operators.rb +11 -0
- data/bin/opal +10 -13
- data/bin/opal-build +4 -4
- data/bin/opal-mspec +10 -0
- data/bin/opal-repl +4 -3
- data/examples/sinatra/Gemfile +1 -1
- data/examples/sinatra/config.ru +3 -3
- data/lib/mspec/opal/main.rb.erb +2 -2
- data/lib/mspec/opal/rake_task.rb +31 -24
- data/lib/mspec/opal/runner.rb +18 -1
- data/lib/mspec/opal/sprockets.js +17 -0
- data/lib/opal.rb +1 -34
- data/lib/opal/builder.rb +92 -58
- data/lib/opal/builder_processors.rb +165 -0
- data/lib/opal/cli.rb +85 -144
- data/lib/opal/cli_options.rb +136 -90
- data/lib/opal/cli_runners.rb +10 -0
- data/lib/opal/cli_runners/nodejs.rb +56 -0
- data/lib/opal/cli_runners/phantom.js +35 -0
- data/lib/opal/cli_runners/phantomjs.rb +28 -0
- data/lib/opal/cli_runners/server.rb +54 -0
- data/lib/opal/compiler.rb +35 -16
- data/lib/opal/erb.rb +29 -15
- data/lib/opal/hike_path_finder.rb +18 -0
- data/lib/opal/nodes.rb +1 -0
- data/lib/opal/nodes/call.rb +107 -26
- data/lib/opal/nodes/call_special.rb +31 -6
- data/lib/opal/nodes/class.rb +2 -2
- data/lib/opal/nodes/constants.rb +5 -20
- data/lib/opal/nodes/def.rb +4 -4
- data/lib/opal/nodes/defined.rb +3 -3
- data/lib/opal/nodes/definitions.rb +1 -1
- data/lib/opal/nodes/for.rb +35 -0
- data/lib/opal/nodes/helpers.rb +2 -2
- data/lib/opal/nodes/iter.rb +3 -3
- data/lib/opal/nodes/literal.rb +10 -2
- data/lib/opal/nodes/masgn.rb +2 -2
- data/lib/opal/nodes/module.rb +2 -2
- data/lib/opal/nodes/scope.rb +1 -0
- data/lib/opal/nodes/singleton_class.rb +2 -2
- data/lib/opal/nodes/super.rb +2 -2
- data/lib/opal/nodes/top.rb +30 -3
- data/lib/opal/parser.rb +15 -1
- data/lib/opal/parser/grammar.rb +2571 -2452
- data/lib/opal/parser/grammar.y +37 -5
- data/lib/opal/parser/keywords.rb +2 -0
- data/lib/opal/parser/lexer.rb +21 -11
- data/lib/opal/path_reader.rb +28 -0
- data/lib/opal/paths.rb +38 -0
- data/lib/opal/source_map.rb +32 -15
- data/lib/opal/sprockets/environment.rb +9 -2
- data/lib/opal/sprockets/erb.rb +1 -2
- data/lib/opal/sprockets/path_reader.rb +34 -0
- data/lib/opal/sprockets/processor.rb +40 -39
- data/lib/opal/sprockets/server.rb +47 -33
- data/lib/opal/version.rb +1 -1
- data/opal.gemspec +10 -5
- data/opal/README.md +6 -0
- data/opal/corelib/array.rb +36 -4
- data/opal/corelib/array/inheritance.rb +6 -6
- data/opal/corelib/basic_object.rb +9 -9
- data/opal/corelib/boolean.rb +1 -1
- data/opal/corelib/class.rb +12 -12
- data/opal/corelib/dir.rb +20 -0
- data/opal/corelib/enumerable.rb +42 -42
- data/opal/corelib/enumerator.rb +1 -1
- data/opal/corelib/error.rb +2 -2
- data/opal/corelib/file.rb +56 -0
- data/opal/corelib/hash.rb +5 -5
- data/opal/corelib/helpers.rb +3 -3
- data/opal/corelib/io.rb +13 -10
- data/opal/corelib/kernel.rb +44 -68
- data/opal/corelib/method.rb +1 -1
- data/opal/corelib/module.rb +89 -114
- data/opal/corelib/nil_class.rb +1 -1
- data/opal/corelib/numeric.rb +27 -23
- data/opal/corelib/proc.rb +5 -5
- data/opal/corelib/range.rb +8 -4
- data/opal/corelib/regexp.rb +5 -5
- data/opal/corelib/runtime.js +589 -272
- data/opal/corelib/string.rb +52 -37
- data/opal/corelib/string/inheritance.rb +5 -5
- data/opal/corelib/time.rb +102 -52
- data/opal/corelib/variables.rb +3 -3
- data/opal/opal.rb +2 -0
- data/package.json +9 -0
- data/spec/filters/bugs/array.rb +0 -6
- data/spec/filters/bugs/language.rb +4 -0
- data/spec/filters/bugs/numeric.rb +7 -6
- data/spec/filters/bugs/opal.rb +2 -0
- data/spec/filters/bugs/regexp.rb +4 -0
- data/spec/filters/bugs/string.rb +0 -7
- data/spec/filters/bugs/stringscanner.rb +4 -1
- data/spec/filters/unsupported/private_methods.rb +2 -0
- data/spec/lib/builder_processors_spec.rb +27 -0
- data/spec/lib/builder_spec.rb +66 -0
- data/spec/{cli → lib}/cli_spec.rb +60 -5
- data/spec/{cli → lib}/compiler_spec.rb +66 -5
- data/spec/{cli → lib}/dependency_resolver_spec.rb +1 -1
- data/spec/lib/fixtures/no_requires.rb +1 -0
- data/spec/{cli → lib}/fixtures/opal_file.rb +0 -0
- data/spec/lib/fixtures/require_tree_test.rb +3 -0
- data/spec/lib/fixtures/required_tree_test/required_file1.rb +1 -0
- data/spec/lib/fixtures/required_tree_test/required_file2.rb +1 -0
- data/spec/lib/fixtures/requires.rb +7 -0
- data/spec/{cli → lib}/fixtures/sprockets_file.js.rb +0 -0
- data/spec/lib/fixtures/sprockets_require_tree_test.rb +3 -0
- data/spec/lib/hike_path_finder_spec.rb +23 -0
- data/spec/{cli → lib}/lexer_spec.rb +1 -1
- data/spec/{cli → lib}/parser/alias_spec.rb +1 -1
- data/spec/{cli → lib}/parser/and_spec.rb +1 -1
- data/spec/{cli → lib}/parser/attrasgn_spec.rb +1 -1
- data/spec/{cli → lib}/parser/begin_spec.rb +1 -1
- data/spec/{cli → lib}/parser/block_spec.rb +1 -1
- data/spec/{cli → lib}/parser/break_spec.rb +1 -1
- data/spec/{cli → lib}/parser/call_spec.rb +1 -1
- data/spec/{cli → lib}/parser/class_spec.rb +1 -1
- data/spec/{cli → lib}/parser/comments_spec.rb +1 -1
- data/spec/{cli → lib}/parser/def_spec.rb +1 -1
- data/spec/{cli → lib}/parser/if_spec.rb +1 -1
- data/spec/{cli → lib}/parser/iter_spec.rb +1 -1
- data/spec/{cli → lib}/parser/lambda_spec.rb +1 -1
- data/spec/{cli → lib}/parser/literal_spec.rb +1 -1
- data/spec/{cli → lib}/parser/masgn_spec.rb +1 -1
- data/spec/{cli → lib}/parser/module_spec.rb +1 -1
- data/spec/{cli → lib}/parser/not_spec.rb +1 -1
- data/spec/{cli → lib}/parser/op_asgn1_spec.rb +1 -1
- data/spec/{cli → lib}/parser/op_asgn2_spec.rb +1 -1
- data/spec/{cli → lib}/parser/or_spec.rb +1 -1
- data/spec/{cli → lib}/parser/return_spec.rb +1 -1
- data/spec/{cli → lib}/parser/sclass_spec.rb +1 -1
- data/spec/{cli → lib}/parser/string_spec.rb +8 -1
- data/spec/{cli → lib}/parser/super_spec.rb +1 -1
- data/spec/lib/parser/unary_spec.rb +48 -0
- data/spec/{cli → lib}/parser/undef_spec.rb +1 -1
- data/spec/{cli → lib}/parser/unless_spec.rb +1 -1
- data/spec/{cli → lib}/parser/variables_spec.rb +1 -1
- data/spec/{cli → lib}/parser/while_spec.rb +1 -1
- data/spec/{cli → lib}/parser/yield_spec.rb +1 -1
- data/spec/lib/path_reader_spec.rb +24 -0
- data/spec/lib/shared/path_finder_shared.rb +19 -0
- data/spec/lib/shared/path_reader_shared.rb +31 -0
- data/spec/lib/spec_helper.rb +9 -0
- data/spec/lib/sprockets/environment_spec.rb +30 -0
- data/spec/{cli → lib}/sprockets/erb_spec.rb +1 -1
- data/spec/lib/sprockets/path_reader_spec.rb +25 -0
- data/spec/{cli → lib}/sprockets/processor_spec.rb +9 -2
- data/spec/lib/sprockets/server_spec.rb +20 -0
- data/spec/opal/compiler/irb_spec.rb +11 -11
- data/spec/opal/core/fixtures/require_tree_files/file 1.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/file 2.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/file 3.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/file 4.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/file 5.rb +1 -0
- data/spec/opal/core/kernel/require_tree_spec.rb +7 -0
- data/spec/opal/core/kernel/respond_to_spec.rb +2 -2
- data/spec/opal/core/runtime/method_missing_spec.rb +19 -0
- data/spec/opal/core/source_map_spec.rb +2 -2
- data/spec/opal/core/string_spec.rb +11 -0
- data/spec/opal/stdlib/erb/erb_spec.rb +0 -1
- data/spec/opal/stdlib/thread/mutex_spec.rb +40 -0
- data/spec/opal/stdlib/thread/thread_queue_spec.rb +32 -0
- data/spec/opal/stdlib/thread/thread_spec.rb +60 -0
- data/spec/rubyspecs +54 -11
- data/spec/spec_helper.rb +18 -3
- data/spec/support/mspec_rspec_adapter.rb +33 -0
- data/spec/{cli/spec_helper.rb → support/parser_helpers.rb} +10 -10
- data/stdlib/README.md +3 -0
- data/stdlib/benchmark.rb +10 -0
- data/stdlib/date.rb +2 -2
- data/stdlib/dir.rb +1 -5
- data/stdlib/file.rb +1 -7
- data/stdlib/json.rb +10 -1
- data/stdlib/native.rb +5 -5
- data/stdlib/nodejs.rb +5 -0
- data/stdlib/nodejs/dir.rb +13 -0
- data/stdlib/nodejs/file.rb +98 -0
- data/stdlib/nodejs/fileutils.rb +26 -0
- data/stdlib/nodejs/io.rb +2 -0
- data/stdlib/nodejs/irb.rb +45 -0
- data/stdlib/nodejs/process.rb +16 -0
- data/stdlib/nodejs/require.rb +32 -0
- data/stdlib/nodejs/rubygems.rb +68 -0
- data/stdlib/nodejs/runtime.rb +25 -0
- data/stdlib/nodejs/yaml.rb +11 -0
- data/stdlib/opal-parser.rb +1 -2
- data/stdlib/opal-source-maps.rb +2 -0
- data/stdlib/phantomjs.rb +8 -0
- data/stdlib/process.rb +10 -0
- data/stdlib/promise.rb +12 -4
- data/stdlib/set.rb +27 -0
- data/stdlib/source_map.rb +5 -63
- data/stdlib/source_map/map.rb +220 -0
- data/stdlib/source_map/mapping.rb +26 -0
- data/stdlib/source_map/offset.rb +88 -0
- data/stdlib/source_map/version.rb +3 -0
- data/stdlib/source_map/vlq.rb +77 -101
- data/stdlib/sourcemap.rb +1 -0
- data/stdlib/strscan.rb +7 -1
- data/stdlib/template.rb +1 -1
- data/stdlib/thread.rb +147 -7
- metadata +238 -104
- data/lib/mspec/opal/mspec_fixes.rb +0 -87
- data/spec/cli/sprockets/environment_spec.rb +0 -14
- data/spec/filters/bugs/symbol.rb +0 -5
- data/spec/opal/core/kernel/warn_spec.rb +0 -83
- data/spec/opal/core/language/numbers_spec.rb +0 -60
- data/stdlib/opal-source-maps.js.erb +0 -2
- data/stdlib/source_map/generator.rb +0 -251
- data/stdlib/source_map/parser.rb +0 -102
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d851c3be15f64dbfc7a60b48889722334c757c0
|
4
|
+
data.tar.gz: e4e5a13810d7e30f2291aea3b5138e32e72ed15e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6673321f15d3acdd817b9eeeefffc87a5cd2e9d9c0a8564ab272fb6096a295415a0243f8e079f10227d4c593ebd022b2b681c17abce715de50b19ebca5c77b08
|
7
|
+
data.tar.gz: 3ac4adb02d69f45cfa9396cab5814ae4b527dfbdb60b68d42a93c50dcb887d0b1d83c70d78800092e040eeb9f85235100db5b28a316bf1ba7f27c1e62c5631f9
|
data/.gitignore
CHANGED
data/.spectator
ADDED
data/.spectator-mspec
ADDED
data/.travis.yml
CHANGED
@@ -6,12 +6,9 @@ matrix:
|
|
6
6
|
fast_finish: true
|
7
7
|
|
8
8
|
include:
|
9
|
-
- rvm: 2.1.
|
9
|
+
- rvm: 2.1.1
|
10
10
|
env: RUN=default
|
11
11
|
|
12
|
-
- rvm: 1.8.7
|
13
|
-
env: RUN=rspec
|
14
|
-
|
15
12
|
- rvm: 1.9.3
|
16
13
|
env: RUN=rspec
|
17
14
|
|
@@ -31,18 +28,18 @@ matrix:
|
|
31
28
|
- rvm: rbx
|
32
29
|
- rvm: jruby
|
33
30
|
|
31
|
+
# Setting TimeZone. We'll need to do this in order to
|
32
|
+
# have the TZ related failures surface on Travis CI.
|
33
|
+
# http://stackoverflow.com/a/23374438/601782
|
34
34
|
before_install:
|
35
35
|
- git submodule update --init
|
36
36
|
|
37
|
-
# Fix waiting for rubygems v2.2.1 to be released and active on travis
|
38
|
-
# https://github.com/rubygems/rubygems/commit/f8e0f1d5f67cfc4e1966cc1e2db367aebf8a09e4
|
39
|
-
- gem update bundler
|
40
|
-
- bundle --version
|
41
|
-
- gem update --system 2.1.11
|
42
|
-
- gem --version
|
43
|
-
|
44
37
|
script:
|
45
38
|
- "bundle exec rake $RUN"
|
46
39
|
|
47
40
|
notifications:
|
48
41
|
irc: "irc.freenode.org#opal"
|
42
|
+
webhooks:
|
43
|
+
urls:
|
44
|
+
- https://webhooks.gitter.im/e/2ea12333adebda0c2289
|
45
|
+
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,36 @@
|
|
1
|
+
## edge (upcoming 0.7)
|
2
|
+
|
3
|
+
* Fixed `-@` unary op. precedence with a numeric and followed by a method call (e.g. `-1.foo` was parsed as `-(1.foo)`)
|
4
|
+
|
5
|
+
* `require_relative` (with strings) is now preprocessed, expanded and added to `Compiler#requires`
|
6
|
+
|
7
|
+
* Rewritten the require system to respect requires position (previously all the requires were stacked up at the top of the file)
|
8
|
+
|
9
|
+
* Implement for-loop syntax
|
10
|
+
|
11
|
+
* Add Array#|
|
12
|
+
|
13
|
+
* Fix Range.new to raise `ArgumentError` on contructor values that cannot
|
14
|
+
be compared
|
15
|
+
|
16
|
+
* Fix compiler bug where Contiguous strings were not getting concatenated.
|
17
|
+
|
18
|
+
* Cleanup generated code for constant access. All constant lookups now go through `$scope.get('CONST_NAME')` to produce cleaner code and a unified place for const missing dispatch.
|
19
|
+
|
20
|
+
* Remove `const_missing` option from compiler. All constant lookups are now strict.
|
21
|
+
|
22
|
+
* Add initial support for Module#autoload.
|
23
|
+
|
24
|
+
## 0.6.2 2014-04-25
|
25
|
+
|
26
|
+
* Added Range#size
|
27
|
+
|
28
|
+
* `opal` executable now reads STDIN when no file or `-e` are passed
|
29
|
+
|
30
|
+
* `opal` executable doesn't exit after showing version on `-v` if other options are passed
|
31
|
+
|
32
|
+
* (Internal) improved the mspec runner
|
33
|
+
|
1
34
|
## 0.6.1 2014-04-15
|
2
35
|
|
3
36
|
* Updated RubySpecs to master and added `rubysl-*` specs. Thanks to Mike Owens (@mieko)
|
data/CONTRIBUTING.md
CHANGED
@@ -8,12 +8,14 @@ FreeNode.
|
|
8
8
|
|
9
9
|
## Contributing
|
10
10
|
|
11
|
-
|
12
|
-
ones.
|
11
|
+
1. Before opening a new issue, search for previous discussions including closed
|
12
|
+
ones. Add comments there if a similar issue is found.
|
13
13
|
|
14
|
-
|
14
|
+
2. Please report the version on which the issue is found.
|
15
15
|
|
16
|
-
|
16
|
+
3. Before sending pull requests make sure all tests run and pass (see below).
|
17
|
+
|
18
|
+
4. Make sure to use a similar coding style to the rest of the code base. In ruby
|
17
19
|
and javascript code we use 2 spaces (no tabs).
|
18
20
|
|
19
21
|
## Quick Start
|
@@ -30,47 +32,10 @@ Get dependencies:
|
|
30
32
|
$ bundle
|
31
33
|
```
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
### Runtime
|
36
|
-
|
37
|
-
Some opal specific tests are found inside `spec/`, but the majority of our
|
38
|
-
runtime tests now come from rubyspec. Rubyspec is included as a git submodule.
|
39
|
-
To get our latest referenced checkout, just run:
|
40
|
-
|
41
|
-
```
|
42
|
-
$ git submodule update --init
|
43
|
-
```
|
44
|
-
|
45
|
-
You need phantomjs installed to run tests. To build opal, its dependencies
|
46
|
-
and all specs, run:
|
47
|
-
|
48
|
-
```
|
49
|
-
$ bundle exec rake mspec
|
50
|
-
```
|
51
|
-
|
52
|
-
You can alternatively run tests in a browser using:
|
53
|
-
|
54
|
-
```
|
55
|
-
$ rackup
|
56
|
-
```
|
57
|
-
|
58
|
-
And then opening `http://127.0.0.1:9292` in a web browser.
|
59
|
-
|
60
|
-
### Gem/lib tests
|
61
|
-
|
62
|
-
We also include some tests for running under your standard ruby implementation
|
63
|
-
which are in `mri_spec/`. To run tests tests using rake, use:
|
64
|
-
|
65
|
-
```
|
66
|
-
$ bundle exec rake mri_spec
|
67
|
-
```
|
68
|
-
|
69
|
-
### All tests
|
70
|
-
|
71
|
-
To run all the tests together (which you should do while contributing), run:
|
35
|
+
Run the test suite:
|
72
36
|
|
73
37
|
```
|
74
38
|
$ bundle exec rake
|
75
39
|
```
|
76
40
|
|
41
|
+
See the [README](https://github.com/opal/opal/blob/master/README.md#running-tests) for further details.
|
data/Gemfile
CHANGED
@@ -2,15 +2,26 @@ source 'https://rubygems.org'
|
|
2
2
|
gemspec
|
3
3
|
|
4
4
|
# Stick with older racc until
|
5
|
-
# https://github.com/tenderlove/racc/issues/32
|
6
|
-
# and
|
7
5
|
# https://github.com/tenderlove/racc/issues/22
|
8
|
-
#
|
9
|
-
gem 'racc', '< 1.4.10' if
|
6
|
+
# is solved.
|
7
|
+
gem 'racc', '< 1.4.10' if RUBY_ENGINE == 'jruby'
|
10
8
|
gem 'json', '< 1.8.1' if RUBY_VERSION.to_f == 2.1 and RUBY_ENGINE == 'ruby'
|
11
9
|
gem 'rubysl', :platform => :rbx
|
10
|
+
gem 'thin', platform: :mri
|
11
|
+
|
12
|
+
# Uncomment to try with sprockets 3.0:
|
13
|
+
#
|
14
|
+
# gem 'sprockets', '~> 3.0.0.beta'
|
12
15
|
|
13
16
|
group :repl do
|
14
17
|
gem 'therubyracer', :platform => :mri, :require => 'v8'
|
15
18
|
gem 'therubyrhino', :platform => :jruby
|
16
19
|
end
|
20
|
+
|
21
|
+
unless ENV['CI']
|
22
|
+
gem 'rb-fsevent'
|
23
|
+
gem 'guard', require: false
|
24
|
+
gem 'terminal-notifier-guard'
|
25
|
+
end
|
26
|
+
|
27
|
+
gem 'mspec', github: 'opal/mspec'
|
data/Guardfile
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'guard/plugin'
|
2
|
+
|
3
|
+
class ::Guard::Opal < Plugin
|
4
|
+
def mspec *paths
|
5
|
+
command = ['bundle', 'exec', './bin/opal-mspec', *paths.flatten]
|
6
|
+
result = time(:mspec, *paths) { system *command }
|
7
|
+
notify 'MSpec', result
|
8
|
+
end
|
9
|
+
|
10
|
+
def rspec *paths
|
11
|
+
command = ['bundle', 'exec', 'rspec', *paths.flatten]
|
12
|
+
result = time(:rspec, *paths) { system *command }
|
13
|
+
notify 'RSpec', result
|
14
|
+
end
|
15
|
+
|
16
|
+
def notify lib, result
|
17
|
+
if result
|
18
|
+
::Guard::Notifier.notify(
|
19
|
+
'Success ♥︎', title: "#{lib} results", image: :success, priority: 1
|
20
|
+
)
|
21
|
+
else
|
22
|
+
::Guard::Notifier.notify(
|
23
|
+
'Failed ♠︎', title: "#{lib} results", image: :failed, priority: 1
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def color *args
|
29
|
+
Guard::UI.send :color, *args
|
30
|
+
end
|
31
|
+
|
32
|
+
def terminal_columns
|
33
|
+
cols = `tput cols 2> /dev/tty`.strip.to_i
|
34
|
+
($?.success? && cols.nonzero?) ? cols : 80
|
35
|
+
end
|
36
|
+
|
37
|
+
def time *titles
|
38
|
+
columns = terminal_columns
|
39
|
+
puts color("=== running: #{titles.join(' ')} ".ljust(columns,'='), :cyan)
|
40
|
+
s = Time.now
|
41
|
+
result = yield
|
42
|
+
t = (Time.now - s).to_f
|
43
|
+
puts color("=== time: #{t} seconds ".ljust(columns, '='), :cyan)
|
44
|
+
result
|
45
|
+
end
|
46
|
+
|
47
|
+
def run_on_changes(changes)
|
48
|
+
m = changes
|
49
|
+
path = m[0]
|
50
|
+
puts color("Searching specs for #{m[0]}...", :yellow)
|
51
|
+
case path
|
52
|
+
when %r{grammar\.y$} then system 'rake racc'
|
53
|
+
when %r{^spec/lib} then rspec path
|
54
|
+
when %r{^spec/corelib} then mspec path
|
55
|
+
when %r{^opal/corelib}
|
56
|
+
name = File.basename(path, '.rb')
|
57
|
+
mspec "spec/corelib/core/#{name}/**/*_spec.rb"
|
58
|
+
when %r{^lib/opal/(.*)\.rb$}
|
59
|
+
name = $1
|
60
|
+
specs = Dir["spec/lib/#{name}_spec.rb"]
|
61
|
+
rspec *specs
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def run_all
|
66
|
+
time(:all) { system 'bundle', 'exec', 'rake' }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
guard :opal do
|
71
|
+
ignore %r{^(tmp|tasks|pkg|cdn|build|node_modules|grammar.rb)}
|
72
|
+
watch %r{^spec/.*}
|
73
|
+
watch %r{^lib/.*}
|
74
|
+
watch %r{^bin/.*}
|
75
|
+
watch %r{^opal/.*}
|
76
|
+
watch %r{^stdlib/.*}
|
77
|
+
end
|
data/README.md
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
# Opal
|
2
2
|
|
3
|
-
[![Build Status](
|
4
|
-
[![Gem Version](
|
5
|
-
[![Code Climate](http://img.shields.io/codeclimate/github/opal/opal.svg)](https://codeclimate.com/github/opal/opal)
|
3
|
+
[![Build Status](http://img.shields.io/travis/opal/opal/master.svg?style=flat)](http://travis-ci.org/opal/opal)
|
4
|
+
[![Gem Version](http://img.shields.io/gem/v/opal.svg?style=flat)](http://badge.fury.io/rb/opal)
|
5
|
+
[![Code Climate](http://img.shields.io/codeclimate/github/opal/opal.svg?style=flat)](https://codeclimate.com/github/opal/opal)
|
6
6
|
|
7
7
|
Opal is a ruby to javascript source-to-source compiler. It also has an
|
8
8
|
implementation of the ruby corelib.
|
9
9
|
|
10
10
|
Opal is [hosted on github](http://github.com/opal/opal), and there
|
11
11
|
is a Freenode IRC channel at [#opal](http://webchat.freenode.net/?channels=opal),
|
12
|
-
ask questions on [stackoverflow#opalrb](http://stackoverflow.com/questions/ask?tags=opalrb).
|
12
|
+
ask questions on [stackoverflow (tag #opalrb)](http://stackoverflow.com/questions/ask?tags=opalrb).
|
13
|
+
|
14
|
+
[![Stack Overflow](http://img.shields.io/badge/stackoverflow-%23opalrb-orange.svg?style=flat)](http://stackoverflow.com/questions/ask?tags=opalrb)
|
15
|
+
[![API doc](http://img.shields.io/badge/doc-api-blue.svg?style=flat)](http://opalrb.org/docs/api)
|
16
|
+
[![Gitter chat](http://img.shields.io/badge/gitter-opal%2Fopal-009966.svg?style=flat)](https://gitter.im/opal/opal)
|
13
17
|
|
14
18
|
|
15
19
|
|
@@ -68,6 +72,12 @@ The test suite can be run using (requires [phantomjs][]):
|
|
68
72
|
|
69
73
|
This will command will run all RSpec and MSpec examples in sequence.
|
70
74
|
|
75
|
+
#### Automated runs
|
76
|
+
|
77
|
+
A `Guardfile` with decent mappings between specs and lib/corelib/stdlib files is in place.
|
78
|
+
Run `bundle exec guard -i` to have it started.
|
79
|
+
|
80
|
+
|
71
81
|
### MSpec
|
72
82
|
|
73
83
|
[MSpec][] tests can be run with:
|
@@ -77,16 +87,13 @@ This will command will run all RSpec and MSpec examples in sequence.
|
|
77
87
|
Alternatively, you can just load up a rack instance using `rackup spec/config.ru`, and
|
78
88
|
visit `http://localhost:9292/` in any web browser.
|
79
89
|
|
90
|
+
|
80
91
|
### Rspec
|
81
92
|
|
82
93
|
[RSpec][] tests can be run with
|
83
94
|
|
84
95
|
$ rake rspec
|
85
96
|
|
86
|
-
Alternatively [spectator][] can be used in an autotest fashion with this command:
|
87
|
-
|
88
|
-
BASE_DIR_GLOB='lib/opal' SPEC_DIR_GLOB='spec/cli' spectator
|
89
|
-
|
90
97
|
|
91
98
|
## Code Overview
|
92
99
|
|
@@ -167,6 +174,5 @@ THE SOFTWARE.
|
|
167
174
|
|
168
175
|
|
169
176
|
[phantomjs]: http://phantomjs.org
|
170
|
-
[spectator]: https://github.com/elia/spectator#readme
|
171
177
|
[MSpec]: https://github.com/rubyspec/mspec#readme
|
172
178
|
[RSpec]: https://github.com/rspec/rspec#readme
|
data/Rakefile
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# FIXME: there must be a better way
|
2
|
+
Encoding.default_external = 'utf-8'
|
3
|
+
|
1
4
|
require 'bundler'
|
2
5
|
Bundler.require
|
3
6
|
Bundler::GemHelper.install_tasks
|
@@ -6,7 +9,7 @@ import 'tasks/github.rake'
|
|
6
9
|
|
7
10
|
require 'rspec/core/rake_task'
|
8
11
|
RSpec::Core::RakeTask.new(:rspec) do |t|
|
9
|
-
t.pattern = 'spec/
|
12
|
+
t.pattern = 'spec/lib/**/*_spec.rb'
|
10
13
|
end
|
11
14
|
|
12
15
|
require 'mspec/opal/rake_task'
|
@@ -27,12 +30,14 @@ and the destination dir with the DIR env var.
|
|
27
30
|
|
28
31
|
Example: rake dist DIR=/tmp/foo FILES='opal.rb,base64.rb'
|
29
32
|
Example: rake dist DIR=cdn/opal/#{Opal::VERSION}
|
33
|
+
Example: rake dist DIR=cdn/opal/master
|
30
34
|
DESC
|
31
35
|
task :dist do
|
32
36
|
require 'opal/util'
|
33
37
|
|
34
38
|
Opal::Processor.arity_check_enabled = false
|
35
39
|
Opal::Processor.const_missing_enabled = false
|
40
|
+
Opal::Processor.dynamic_require_severity = :warning
|
36
41
|
env = Opal::Environment.new
|
37
42
|
|
38
43
|
build_dir = ENV['DIR'] || 'build'
|
@@ -73,19 +78,38 @@ task :clobber do
|
|
73
78
|
end
|
74
79
|
|
75
80
|
namespace :doc do
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
81
|
+
doc_repo = Pathname(ENV['DOC_REPO'] || 'gh-pages')
|
82
|
+
doc_base = doc_repo.join('doc')
|
83
|
+
current_git_release = -> { `git rev-parse --abbrev-ref HEAD`.chomp }
|
84
|
+
template_option = "--template opal --template-path #{doc_repo.join('yard-templates')}"
|
85
|
+
|
86
|
+
directory doc_repo.to_s do
|
87
|
+
remote = ENV['DOC_REPO_REMOTE'] || '.'
|
88
|
+
sh 'git', 'clone', '-b', 'gh-pages', '--', remote, doc_repo.to_s
|
89
|
+
end
|
90
|
+
|
91
|
+
task :corelib => doc_repo.to_s do
|
92
|
+
git = current_git_release.call
|
93
|
+
name = 'corelib'
|
94
|
+
glob = 'opal/**/*.rb'
|
95
|
+
|
96
|
+
command = "doxx --template #{doc_repo.join('doxx-templates/opal.jade')} "\
|
97
|
+
"--source opal/corelib --target #{doc_base}/#{git}/#{name} "\
|
98
|
+
"--title \"Opal runtime.js Documentation\" --readme opal/README.md"
|
99
|
+
puts command; system command or $stderr.puts "Please install doxx with: npm install"
|
100
|
+
|
101
|
+
command = "yard doc #{glob} #{template_option} "\
|
102
|
+
"--readme opal/README.md -o #{doc_base}/#{git}/#{name}"
|
103
|
+
puts command; system command
|
85
104
|
end
|
86
105
|
|
87
|
-
task :stdlib do
|
88
|
-
|
106
|
+
task :stdlib => doc_repo do
|
107
|
+
git = current_git_release.call
|
108
|
+
name = 'stdlib'
|
109
|
+
glob = '{stdlib/**/*,opal/compiler,opal/erb,opal/version}.rb'
|
110
|
+
command = "yard doc #{glob} #{template_option} "\
|
111
|
+
"--readme stdlib/README.md -o gh-pages/doc/#{git}/#{name}"
|
112
|
+
puts command; system command
|
89
113
|
end
|
90
114
|
end
|
91
115
|
|
data/bin/opal
CHANGED
@@ -1,25 +1,22 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
# Error codes are taken from /usr/include/sysexits.h
|
4
|
+
|
3
5
|
require 'opal/cli_options'
|
4
6
|
options = Opal::CLIOptions.new
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
exit
|
11
|
-
else
|
12
|
-
options.options[:evals] ||= []
|
13
|
-
options.options[:evals] << gets(nil)
|
14
|
-
end
|
7
|
+
begin
|
8
|
+
options.parse!
|
9
|
+
rescue OptionParser::InvalidOption => e
|
10
|
+
$stderr.puts "#{$0}: #{e.message} (-h will show valid options)"
|
11
|
+
exit 64
|
15
12
|
end
|
16
13
|
|
17
14
|
require 'opal/cli'
|
18
|
-
cli = Opal::CLI.new options.options.merge(:
|
15
|
+
cli = Opal::CLI.new options.options.merge(:file => ARGF.file, :argv => ARGV.dup)
|
19
16
|
|
20
17
|
begin
|
21
18
|
cli.run
|
22
|
-
rescue Opal::
|
19
|
+
rescue Opal::CliRunners::RunnerError => e
|
23
20
|
$stderr.puts e.message
|
24
|
-
exit
|
21
|
+
exit 72
|
25
22
|
end
|