opal 0.7.2 → 0.8.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -1
  3. data/CHANGELOG.md +29 -0
  4. data/CONTRIBUTING.md +51 -4
  5. data/Gemfile +3 -0
  6. data/README.md +5 -5
  7. data/config.ru +1 -1
  8. data/examples/sinatra/Gemfile +1 -0
  9. data/examples/sinatra/config.ru +13 -3
  10. data/lib/mspec/opal/rake_task.rb +21 -30
  11. data/lib/mspec/opal/runner.rb +37 -0
  12. data/lib/mspec/opal/special_calls.rb +6 -0
  13. data/lib/opal/builder.rb +1 -0
  14. data/lib/opal/builder_processors.rb +5 -2
  15. data/lib/opal/cli_runners/phantom.js +10 -1
  16. data/lib/opal/compiler.rb +6 -3
  17. data/lib/opal/config.rb +48 -0
  18. data/lib/opal/nodes/call.rb +3 -2
  19. data/lib/opal/nodes/literal.rb +19 -2
  20. data/lib/opal/parser/grammar.rb +2224 -2196
  21. data/lib/opal/parser/grammar.y +25 -7
  22. data/lib/opal/parser/lexer.rb +12 -9
  23. data/lib/opal/path_reader.rb +1 -1
  24. data/lib/opal/sprockets/erb.rb +6 -20
  25. data/lib/opal/sprockets/path_reader.rb +4 -2
  26. data/lib/opal/sprockets/processor.rb +135 -80
  27. data/lib/opal/sprockets/server.rb +49 -78
  28. data/lib/opal/sprockets/source_map_header_patch.rb +41 -0
  29. data/lib/opal/sprockets/source_map_server.rb +115 -0
  30. data/lib/opal/version.rb +1 -1
  31. data/lib/tilt/opal.rb +48 -0
  32. data/opal.gemspec +1 -1
  33. data/opal/corelib/array.rb +179 -51
  34. data/opal/corelib/array/inheritance.rb +14 -0
  35. data/opal/corelib/boolean.rb +5 -0
  36. data/opal/corelib/hash.rb +1 -1
  37. data/opal/corelib/kernel.rb +660 -164
  38. data/opal/corelib/match_data.rb +44 -21
  39. data/opal/corelib/module.rb +83 -53
  40. data/opal/corelib/numeric.rb +15 -1
  41. data/opal/corelib/regexp.rb +31 -75
  42. data/opal/corelib/runtime.js +20 -8
  43. data/opal/corelib/string.rb +754 -243
  44. data/opal/corelib/string/inheritance.rb +20 -3
  45. data/opal/corelib/struct.rb +30 -6
  46. data/opal/corelib/variables.rb +2 -2
  47. data/spec/filters/bugs/array.rb +0 -39
  48. data/spec/filters/bugs/kernel.rb +10 -7
  49. data/spec/filters/bugs/module.rb +21 -0
  50. data/spec/filters/bugs/opal.rb +0 -5
  51. data/spec/filters/bugs/singleton.rb +0 -2
  52. data/spec/filters/bugs/string.rb +69 -315
  53. data/spec/filters/bugs/struct.rb +0 -16
  54. data/spec/filters/unsupported/encoding.rb +7 -0
  55. data/spec/filters/unsupported/float.rb +3 -0
  56. data/spec/filters/unsupported/integer_size.rb +52 -0
  57. data/spec/filters/unsupported/marshal.rb +4 -0
  58. data/spec/filters/unsupported/mutable_strings.rb +37 -0
  59. data/spec/filters/unsupported/private_methods.rb +11 -0
  60. data/spec/filters/unsupported/rational_numbers.rb +4 -0
  61. data/spec/filters/unsupported/regular_expressions.rb +47 -0
  62. data/spec/filters/unsupported/symbols.rb +7 -0
  63. data/spec/filters/unsupported/tainted.rb +23 -1
  64. data/spec/filters/unsupported/trusted.rb +5 -0
  65. data/spec/lib/fixtures/complex_sprockets.js.rb.erb +4 -0
  66. data/spec/lib/fixtures/jst_file.js.jst +1 -0
  67. data/spec/lib/parser/call_spec.rb +19 -0
  68. data/spec/lib/parser/def_spec.rb +6 -0
  69. data/spec/lib/sprockets/erb_spec.rb +17 -4
  70. data/spec/lib/sprockets/processor_spec.rb +50 -18
  71. data/spec/lib/sprockets/server_spec.rb +39 -11
  72. data/spec/lib/tilt/opal_spec.rb +19 -0
  73. data/spec/opal/core/kernel/format_spec.rb +10 -10
  74. data/spec/opal/core/language/predefined_spec.rb +10 -0
  75. data/spec/opal/core/object_id_spec.rb +56 -0
  76. data/spec/opal/core/runtime/bridged_classes_spec.rb +4 -4
  77. data/spec/opal/core/runtime_spec.rb +7 -0
  78. data/spec/opal/stdlib/native/native_class_spec.rb +1 -1
  79. data/spec/opal/stdlib/promise/always_spec.rb +30 -0
  80. data/spec/opal/stdlib/promise/then_spec.rb +8 -0
  81. data/spec/opal/stdlib/promise/trace_spec.rb +8 -0
  82. data/spec/rubyspecs +15 -104
  83. data/spec/spec_helper.rb +4 -0
  84. data/stdlib/native.rb +7 -18
  85. data/stdlib/nodejs/file.rb +1 -1
  86. data/stdlib/opal-parser.rb +1 -0
  87. data/stdlib/pp.rb +7 -5
  88. data/stdlib/promise.rb +53 -41
  89. data/tasks/testing.rake +8 -6
  90. metadata +28 -14
  91. data/spec/filters/bugs/match_data.rb +0 -13
  92. data/spec/filters/bugs/numeric.rb +0 -22
  93. data/spec/filters/bugs/regexp.rb +0 -9
  94. data/spec/filters/bugs/unknown.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4256a7bf8ec93bf946b468fcb3bbc9898f9943a0
4
- data.tar.gz: 61d122b4e553f31f2e1aab7f9075f45285dfcbdf
3
+ metadata.gz: 4a0a405fd05a0fa6b1f6efac707d0317c6d0ca57
4
+ data.tar.gz: c57f69d7c54f38d210cc3bfb139c98af5385505b
5
5
  SHA512:
6
- metadata.gz: b9060be07267f2b36a2c44a4cf3d006d4e53c1f3ff2df782375a7276a164536c273ada8906e462c22721f843a961b79efdfa6571ad1fc88713ceb2c5e5a55750
7
- data.tar.gz: 3fe8c046309b9cb7b19ee41ba0cb87e3d04e05c873fd9801528252aaf7b9afea9d85b72e1a528c394b026905e5635e769a68dadfd515c11970d3c9935c867952
6
+ metadata.gz: a2e4b8e88e96a05e3f5a284624571b6e8232594782cc72189ed48835d30ab3cd32ca0ab9d40e3cc93e2978fd1a1c0c4750408f8a57bf55a8aba07eee80278d50
7
+ data.tar.gz: 902b292438b1fe4893f45a52c3dc31429aa9eebefda5914cd18705c863d6e308ab36ea1323320ba2b9374f6360037a5a55dd9425488b7155b5aab97517a59324
data/.travis.yml CHANGED
@@ -12,6 +12,9 @@ matrix:
12
12
  - rvm: 2.2
13
13
  env: RUN=default TZ="/usr/share/zoneinfo/Pacific/Fiji"
14
14
 
15
+ - rvm: 2.2
16
+ env: RUN=default SPROCKETS_VERSION="~> 2.12.3"
17
+
15
18
  - rvm: 2.1
16
19
  env: RUN=rspec
17
20
 
@@ -33,13 +36,15 @@ matrix:
33
36
  allow_failures:
34
37
  - rvm: 1.8.7
35
38
  - rvm: 1.9.3
36
- - rvm: 2.0.0
37
39
  - rvm: rbx
38
40
  - rvm: jruby
39
41
  - rvm: jruby-head
40
42
 
41
43
 
42
44
  before_install:
45
+ # Keep track of which version of node and phantomjs we're running the specs against
46
+ - node -v
47
+ - phantomjs -v
43
48
  - git submodule update --init
44
49
 
45
50
  script:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,32 @@
1
+ ## edge (upcoming 0.8.0)
2
+
3
+ * Parser: Allow trailing comma in paren arglists, after normal args as
4
+ well as assoc args.
5
+
6
+ * Parser: Fix parsing of parens following divide operator without a
7
+ space.
8
+
9
+ * Parser: Fix bug where keyword arguments could not be parsed if
10
+ method definition did not have parens around arguments.
11
+
12
+ * Support calling `String#[]` and `String#slice` with a regexp argument
13
+
14
+ * `String#[]` and `String#slice` implementation fully compliant with rubyspec
15
+
16
+ * `Array#product` implementation fully compliant with rubyspec
17
+
18
+ * `Module#const_get` accepts a scoped constant name
19
+
20
+ * `String#succ` and `String#next` implementation fully compliant with rubyspec
21
+
22
+ * `String#===`, `String#==`, and `String#eql?` implementation fully compliant with rubyspec
23
+
24
+ * Add support for sprockets 3.0 while keeping compatibility with the 2.0 series
25
+
26
+ * Delegate dependency management directly to Sprockets (when used) making sourcemaps swift again.
27
+ This means code generated by sprockets will always need to be bootstrapped via `Opal.load` or `Opal.require`.
28
+ Luckily `Opal::Processor.load_asset_code(sprockets, name)` does just that in the right way.
29
+
1
30
  ## 0.7.2 2015-04-23
2
31
 
3
32
  * Remove Sprockets 3.0 support (focus moved to upcoming 0.8)
data/CONTRIBUTING.md CHANGED
@@ -20,16 +20,22 @@ and javascript code we use 2 spaces (no tabs).
20
20
 
21
21
  ## Quick Start
22
22
 
23
- Clone repo:
23
+ Fork https://github.com/opal/opal, then clone the fork to your machine:
24
24
 
25
25
  ```
26
- $ git clone git://github.com/opal/opal.git
26
+ $ git clone git://github.com/<Your GitHub Username>/opal.git
27
27
  ```
28
28
 
29
29
  Get dependencies:
30
30
 
31
31
  ```
32
- $ bundle
32
+ $ bundle install
33
+ ```
34
+
35
+ RubySpec related repos must be cloned as a git submodules:
36
+
37
+ ```
38
+ $ git submodule update --init
33
39
  ```
34
40
 
35
41
  Run the test suite:
@@ -38,4 +44,45 @@ Run the test suite:
38
44
  $ bundle exec rake
39
45
  ```
40
46
 
41
- See the [README](https://github.com/opal/opal/blob/master/README.md#running-tests) for further details.
47
+ You are now ready to make your first contribution to Opal! At a high level, your workflow will be to:
48
+
49
+ 1. Make changes to Opal source code
50
+ 2. Run the test suite to make sure it still passes
51
+ 3. Submit a pull request
52
+
53
+ ## Down The Rabbit Hole
54
+
55
+ Before making changes to Opal source, you need to understand a little about how the test suite works. Every spec that Opal test suite executes is listed in `spec/rubyspecs` file. Each line in that file is a path to either a spec file or a directory full of spec files. If it's a path to a directory, all spec files in that directory will be executed when you run the test suite. All paths are relative to the top-level `specs` directory. Let's follow one of these paths - `corelib/core/string/sub_spec` - and see where it goes.
56
+
57
+ Navigating to `spec/corelib/core` directory, you see that it contains multiple sub-directories, usually named after the Ruby class or module. Drilling further down into `spec/corelib/core/string` you see all the spec files for the various `String` behaviors under test, usually named by a method name followed by `_spec.rb`. Opening `spec/corelib/core/string/sub_spec.rb` you finally see the code that checks the correctness of Opal's implementation of `String#sub` method's behavior.
58
+
59
+ When you execute `$ bundle exec rake`, the code in this file is executed, along with all the other specs in the entire test suite. It's a good idea to run the entire test suite when you feel you reached a certain milestone in the course of making your changes (exactly what that means is up to you), and definitely do `$ bundle exec rake` before commiting your changes to make sure they have not introduced regressions or other unintended side effects.
60
+
61
+ But you will want to run tests as often as possible, after every small change, and running the entire test suite will slow you down. You need to be able to execute a single spec that is concerned with the feature you are currently working on. To accomplish this, just add `PATTERN` to your spec invocation command, like this:
62
+ ```
63
+ $ bundle exec rake mspec_node PATTERN=spec/corelib/core/string/sub_spec.rb
64
+ ```
65
+ This will make sure that only `spec/corelib/core/string/sub_spec.rb` is run, and no other specs are executed.
66
+
67
+ Another way to quickly validate ideas and play with your changes is to use `opal-repl`, a tool similar to `irb`. Running `opal-repl` drops you into an interactive environment with your current version of Opal loaded, including any changes you have made.
68
+ ```
69
+ $ bundle exec opal-repl
70
+ >> 2 + 2
71
+ => 4
72
+ >>
73
+ ```
74
+
75
+ When quickly iterating on an idea, even `opal-repl` may feel a bit too heavy, because after making a change in Opal, you must `exit` from `opal-repl` and do `$ bundle exec opal-repl` again to load Opal with your latest changes. In this case, you can run `opal` with the `-e` option, which executes a piece of code you pass to it once, then returns to the shell. This means that in order to run it again after making another adjustment to Opal, all you have to do is hit the up arrow key on your keyboard and press the enter key. This is the fastest way to go from making a change in Opal to seeing its effect.
76
+ ```
77
+ $ bundle exec opal -e "3.times {puts 'hello'}"
78
+ hello
79
+ hello
80
+ hello
81
+ $
82
+ ```
83
+
84
+ Let's recap what we covered so far. `spec/rubyspecs` is the "master list" of all the specs that get executed when you do `$ bundle exec rake`. You know where to find individual specs, inspect them, and execute them selectively or in bulk. But how do you know which specs to work on? You may be tempted to compare the contents of one of the directories in `spec/corelib/core` with the list of paths in `spec/rubyspecs`, add the missing paths to the "master list", run `$ bundle exec rake`, and start fixing the failures by implementing the missing features. However, chances are that as you are reading this, there are plenty of failing tests in the specs that are already listed in `spec/rubyspecs`. How can that be if `$ bundle exec rake` runs green? To understand this, you need to get acquainted with the concept of spec filters.
85
+
86
+ There are two types of spec filters in the Opal project: `spec/filters/bugs` and `spec/filters/unsupported`. Both filters have the same effect: any spec failures that are noted inside any of the files inside of these directories are ignored when running the spec suite, i.e. they are not reported as failures. Even though their effect is the same, the purpose of `bugs` and `unsupported` filters is different. As the name suggests, `unsupported` filters list _permanent_ failures, things that other Ruby implementations can do that Opal cannot and will never be able to do (by design and by virtue of being implemented on top of JavaScript running in the browser environment). `bugs` filters, on the other hand, are _temporary_ failures, problems that need to be worked on. Problems that Opal needs your help with. Think of the `bugs` directory and the files contained within it as your "TO DO" list for contributing to Opal.
87
+
88
+ Comment out any of the `fail` lines in any of the files in the `spec/filters/bugs` directory, run `$bundle exec rake`, and watch it fail. Make it pass and submit a pull request - that's all there is to it :) Happy hacking!
data/Gemfile CHANGED
@@ -25,3 +25,6 @@ unless ENV['CI']
25
25
  end
26
26
 
27
27
  gem 'mspec', github: 'rubyspec/mspec'
28
+
29
+ sprockets_version = ENV['SPROCKETS_VERSION']
30
+ gem 'sprockets', sprockets_version if sprockets_version
data/README.md CHANGED
@@ -84,7 +84,7 @@ Run `bundle exec guard -i` to have it started.
84
84
 
85
85
  $ rake mspec
86
86
 
87
- Alternatively, you can just load up a rack instance using `rackup spec/config.ru`, and
87
+ Alternatively, you can just load up a rack instance using `rackup`, and
88
88
  visit `http://localhost:9292/` in any web browser.
89
89
 
90
90
 
@@ -127,17 +127,17 @@ Holds the stdlib that opal currently supports. This includes `Observable`,
127
127
  * Safari 5.1+
128
128
  * Opera 12.1x or (Current - 1) or Current
129
129
 
130
- Any problem above browsers should be considered and reported as a bug.
130
+ Any problems encountered using the browsers listed above should be reported as a bug.
131
131
 
132
132
  (Current - 1) or Current denotes that we support the current stable version of
133
133
  the browser and the version that preceded it. For example, if the current
134
134
  version of a browser is 24.x, we support the 24.x and 23.x versions.
135
135
 
136
136
  12.1x or (Current - 1) or Current denotes that we support Opera 12.1x as well
137
- as last 2 versions of Opera. For example, if the current Opera version is 20.x,
138
- we support Opera 12.1x, 19.x and 20.x but not Opera 15.x through 18.x.
137
+ as the last 2 versions of Opera. For example, if the current Opera version is 20.x,
138
+ then we support Opera 12.1x, 19.x and 20.x but not Opera 15.x through 18.x.
139
139
 
140
- Cross-browser testing sponsored by [BrowserStack](http://browserstack.com).
140
+ Cross-browser testing is sponsored by [BrowserStack](http://browserstack.com).
141
141
 
142
142
  ## License
143
143
 
data/config.ru CHANGED
@@ -4,7 +4,7 @@ Bundler.require
4
4
  require 'mspec/opal/rake_task'
5
5
 
6
6
  ::Opal::Processor.arity_check_enabled = true
7
- ::Opal::Processor.dynamic_require_severity = :raise
7
+ ::Opal::Processor.dynamic_require_severity = :error
8
8
 
9
9
  use Rack::ShowExceptions
10
10
  use Rack::ShowStatus
@@ -1,4 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'opal', :path => '../..'
4
+ gem 'thin' # webrick has a bug with safari
4
5
  gem 'sinatra'
@@ -6,20 +6,30 @@ opal = Opal::Server.new {|s|
6
6
  s.main = 'application'
7
7
  }
8
8
 
9
- map opal.source_maps.prefix do
10
- run opal.source_maps
9
+ sprockets = opal.sprockets
10
+ maps_prefix = '/__OPAL_SOURCE_MAPS__'
11
+ maps_app = Opal::SourceMapServer.new(sprockets, maps_prefix)
12
+
13
+ # Monkeypatch sourcemap header support into sprockets
14
+ ::Opal::Sprockets::SourceMapHeaderPatch.inject!(maps_prefix)
15
+
16
+ map maps_prefix do
17
+ run maps_app
11
18
  end
12
19
 
13
20
  map '/assets' do
14
- run opal.sprockets
21
+ run sprockets
15
22
  end
16
23
 
17
24
  get '/' do
25
+ opal_boot_code = Opal::Processor.load_asset_code(sprockets, 'application')
26
+
18
27
  <<-HTML
19
28
  <!doctype html>
20
29
  <html>
21
30
  <head>
22
31
  <script src="/assets/application.js"></script>
32
+ <script>#{opal_boot_code}</script>
23
33
  </head>
24
34
  </html>
25
35
  HTML
@@ -1,3 +1,4 @@
1
+ require 'opal'
1
2
  require 'rack'
2
3
  require 'webrick'
3
4
  require 'mspec/opal/special_calls'
@@ -37,7 +38,16 @@ module MSpec
37
38
 
38
39
  class Runner
39
40
  def initialize &block
40
- @app = RackApp.new(&block).to_app
41
+ @app = Rack::Builder.new do
42
+ ::Opal::Processor.arity_check_enabled = true
43
+ ::Opal::Processor.dynamic_require_severity = :error
44
+
45
+ use Rack::ShowExceptions
46
+ use Rack::ShowStatus
47
+ use MSpec::Opal::Index
48
+ run MSpec::Opal::Environment.new
49
+ end
50
+
41
51
  @port = 9999
42
52
  end
43
53
 
@@ -86,10 +96,7 @@ module MSpec
86
96
  end
87
97
 
88
98
  def start_server
89
- @server = Thread.new do
90
- Rack::Server.start(:app => app, :Port => port, :AccessLog => [],
91
- :Logger => WEBrick::Log.new("/dev/null"))
92
- end
99
+ @server = Thread.new { Rack::Server.start(:app => app, :Port => port) }
93
100
  end
94
101
  end
95
102
 
@@ -97,9 +104,6 @@ module MSpec
97
104
  attr_reader :basedir, :pattern
98
105
 
99
106
  def initialize(basedir = nil, pattern = nil)
100
- ::Opal::Processor.arity_check_enabled = true
101
- ::Opal::Processor.dynamic_require_severity = :error
102
-
103
107
  @pattern = pattern
104
108
  @basedir = basedir = File.expand_path(basedir || DEFAULT_BASEDIR)
105
109
 
@@ -173,10 +177,15 @@ module MSpec
173
177
 
174
178
  def rubyspec_white_list
175
179
  File.read("#{basedir}/rubyspecs").split("\n").reject do |line|
176
- line.sub(/#.*/, '').strip.empty?
180
+ line.sub(/#.*/, '').strip.empty? ||
181
+ (line.start_with?('!') && rubyspec_black_list.push(line.sub('!', '') + '.rb'))
177
182
  end
178
183
  end
179
184
 
185
+ def rubyspec_black_list
186
+ @rubyspec_black_list ||= []
187
+ end
188
+
180
189
  def files_to_run(pattern=nil)
181
190
  # add any filters in spec/filters of specs we dont want to run
182
191
  add_files paths_from_glob("#{basedir}/filters/**/*.rb"), :filters
@@ -195,6 +204,8 @@ module MSpec
195
204
  # add any rubyspecs we want to run (defined in spec/rubyspecs)
196
205
  add_files rubyspec_white_list, :rubyspecs
197
206
  end
207
+
208
+ files - rubyspec_black_list
198
209
  end
199
210
 
200
211
  def build_specs file = "#{basedir}/build/specs.js"
@@ -205,27 +216,6 @@ module MSpec
205
216
  end
206
217
  end
207
218
 
208
- class RackApp < Rack::Builder
209
- attr_accessor :pattern, :basedir
210
-
211
- def initialize
212
- self.pattern = nil
213
- self.basedir = DEFAULT_BASEDIR
214
-
215
- yield(self) if block_given?
216
- super()
217
-
218
- use Rack::ShowExceptions
219
- use Rack::ShowStatus
220
- use Index
221
- run environment
222
- end
223
-
224
- def environment
225
- @environment ||= Environment.new(basedir, pattern)
226
- end
227
- end
228
-
229
219
  class Index
230
220
  HTML = <<-HTML
231
221
  <!DOCTYPE html>
@@ -236,6 +226,7 @@ module MSpec
236
226
  </head>
237
227
  <body>
238
228
  <script src="/mspec/opal/main.js"></script>
229
+ <script>Opal.load('mspec/opal/main');</script>
239
230
  </body>
240
231
  </html>
241
232
  HTML
@@ -227,7 +227,44 @@ class OSpecRunner
227
227
  MSpec.actions :start
228
228
  end
229
229
 
230
+ def bm!(repeat)
231
+ `self.bm = {}`
232
+ MSpec.repeat = repeat;
233
+ MSpec.register :before, self
234
+ MSpec.register :after, self
235
+ end
236
+
237
+ def before(state = nil)
238
+ %x{
239
+ if (self.bm && !self.bm.hasOwnProperty(state.description)) {
240
+ self.bm[state.description] = {started: Date.now()};
241
+ }
242
+ }
243
+ end
244
+
245
+ def after(state = nil)
246
+ %x{
247
+ if (self.bm) {
248
+ self.bm[state.description].stopped = Date.now();
249
+ }
250
+ }
251
+ end
252
+
230
253
  def did_finish
254
+ %x{
255
+ var obj = self.bm, key, val, json, file;
256
+ if (obj) {
257
+ for (key in obj) {
258
+ if (obj.hasOwnProperty(key)) {
259
+ val = obj[key];
260
+ obj[key] = val.stopped - val.started;
261
+ }
262
+ }
263
+ json = JSON.stringify(obj, null, ' ');
264
+ file = #{Time.now.strftime('tmp/bm_%Y-%m-%d_%H-%M-%S-%L.json')};
265
+ #{File.open(`file`, 'w') {|f| f.write(`json`)}}
266
+ }
267
+ }
231
268
  MSpec.actions :finish
232
269
  end
233
270
  end
@@ -22,6 +22,12 @@ class Opal::Nodes::CallNode
22
22
  end
23
23
  end
24
24
 
25
+ add_special :not_compliant_on do
26
+ unless arglist.flatten.include? :opal
27
+ compile_default!
28
+ end
29
+ end
30
+
25
31
  add_special :platform_is_not do
26
32
  unless arglist.flatten.include? :opal
27
33
  compile_default!
data/lib/opal/builder.rb CHANGED
@@ -101,6 +101,7 @@ module Opal
101
101
  end
102
102
 
103
103
  def process_require(filename, options)
104
+ filename.gsub!(/\.(rb|js|opal)$/, '')
104
105
  return if prerequired.include?(filename)
105
106
  return if already_processed.include?(filename)
106
107
  already_processed << filename
@@ -87,7 +87,7 @@ module Opal
87
87
 
88
88
  def compiled
89
89
  @compiled ||= begin
90
- compiler = compiler_for(@source, file: @filename)
90
+ compiler = compiler_for(@source, file: @filename.gsub(/\.(rb|js|opal)$/, ''))
91
91
  compiler.compile
92
92
  compiler
93
93
  end
@@ -102,7 +102,10 @@ module Opal
102
102
  end
103
103
 
104
104
  def required_trees
105
- compiled.required_trees
105
+ compiled.required_trees.map do |tree|
106
+ # Remove any leading ./ after joining to dirname
107
+ File.join(File.dirname(@filename), tree).sub(%r{^(\./)*}, '')
108
+ end
106
109
  end
107
110
 
108
111
  def compiler_class
@@ -8,11 +8,20 @@ page.onConsoleMessage = function(msg) {
8
8
 
9
9
  var opal_code = fs.read('/dev/stdin');
10
10
 
11
+ /*
12
+ * Exit phantom instance "safely" see - https://github.com/ariya/phantomjs/issues/12697
13
+ * https://github.com/nobuoka/gulp-qunit/commit/d242aff9b79de7543d956e294b2ee36eda4bac6c
14
+ */
15
+ function phantom_exit(code) {
16
+ page.close();
17
+ setTimeout(function () { phantom.exit(code); }, 0);
18
+ }
19
+
11
20
  page.onCallback = function(data) {
12
21
  switch (data[0]) {
13
22
  case 'exit':
14
23
  var status = data[1] || 0;
15
- phantom.exit(status);
24
+ phantom_exit(status);
16
25
  case 'stdout':
17
26
  system.stdout.write(data[1] || '');
18
27
  break;