opal 0.7.0.beta2 → 0.7.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/CHANGELOG.md +7 -0
- data/Rakefile +1 -0
- data/benchmarks/prova.js.rb +13 -0
- data/lib/mspec/opal/new.html.erb +1 -0
- data/lib/opal/sprockets.rb +0 -1
- data/lib/opal/sprockets/environment.rb +2 -0
- data/lib/opal/sprockets/processor.rb +2 -2
- data/lib/opal/sprockets/server.rb +8 -2
- data/lib/opal/version.rb +1 -1
- data/opal/corelib/enumerable.rb +2 -2
- data/opal/corelib/hash.rb +48 -10
- data/opal/corelib/regexp.rb +1 -1
- data/opal/corelib/string.rb +1 -1
- data/spec/filters/bugs/hash.rb +2 -2
- data/spec/lib/fixtures/source_map.rb +1 -0
- data/spec/lib/fixtures/source_map/subfolder/other_file.rb +1 -0
- data/spec/lib/sprockets/path_reader_spec.rb +1 -1
- data/spec/lib/sprockets/server_spec.rb +48 -0
- metadata +9 -5
- data/spec/lib/sprockets/environment_spec.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56f72a2aa585530e324d1024147329f90ac699ef
|
4
|
+
data.tar.gz: a75ca4d5fc0abc995d98d6e9884286986fe54666
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2dd0158e79a73ea54fed5a02fe222606b8a4d45198c1338f3c17f902a30e37e19da3d8347d82256a2f8e70faeb31c04a6076bc16a630662c93d9c0d52b657cd7
|
7
|
+
data.tar.gz: f59534fa214044c4cb01096f722745db095b4c67dc4b1129b5ec70fe24d4e7653729e219847b62445281ca061f905a83a945f917b92825d43c42a1059a4be0d8
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## edge (upcoming 0.7)
|
2
2
|
|
3
|
+
* `String#to_proc` now uses `__send__` instead of `send` for calling
|
4
|
+
methods on receivers.
|
5
|
+
|
6
|
+
* Deprecated `Opal::Sprockets::Environment`. It can easily be replaced by `Opal::Server` or by appending `Opal.paths` to a `Sprockets::Environment`:
|
7
|
+
|
8
|
+
Sprockets::Environment.new.tap { |e| Opal.paths.each {|p| e.append_path(p)} }
|
9
|
+
|
3
10
|
* Add `Set` methods `#classify`, `#collect!`, `#map!`, `#subtract` `#replace`,
|
4
11
|
`#difference` and `#eql?`
|
5
12
|
|
data/Rakefile
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
|
data/lib/opal/sprockets.rb
CHANGED
@@ -19,6 +19,8 @@ module Opal
|
|
19
19
|
# do this for you.
|
20
20
|
class Environment < ::Sprockets::Environment
|
21
21
|
def initialize *args
|
22
|
+
warn "WARNING: Opal::Sprockets::Environment is deprecated. "\
|
23
|
+
"Please use Opal::Server directly or append Opal.paths to the environment manually."
|
22
24
|
super
|
23
25
|
append_opal_paths
|
24
26
|
end
|
@@ -75,7 +75,7 @@ module Opal
|
|
75
75
|
|
76
76
|
if self.class.source_map_enabled
|
77
77
|
register_source_map(context.logical_path, result.source_map.to_s)
|
78
|
-
"#{result.to_s}\n//# sourceMappingURL=#{context.logical_path}.map\n"
|
78
|
+
"#{result.to_s}\n//# sourceMappingURL=#{File.basename(context.logical_path)}.map\n"
|
79
79
|
else
|
80
80
|
result.to_s
|
81
81
|
end
|
@@ -104,7 +104,7 @@ module Opal
|
|
104
104
|
:const_missing => const_missing_enabled,
|
105
105
|
:dynamic_require_severity => dynamic_require_severity,
|
106
106
|
:irb => irb_enabled,
|
107
|
-
:inline_operators => inline_operators_enabled
|
107
|
+
:inline_operators => inline_operators_enabled,
|
108
108
|
}
|
109
109
|
|
110
110
|
path_reader = ::Opal::Sprockets::PathReader.new(context.environment, context)
|
@@ -6,7 +6,8 @@ require 'rack/deflater'
|
|
6
6
|
require 'rack/directory'
|
7
7
|
require 'rack/showexceptions'
|
8
8
|
require 'opal/source_map'
|
9
|
-
require '
|
9
|
+
require 'sprockets'
|
10
|
+
require 'sourcemap'
|
10
11
|
require 'erb'
|
11
12
|
|
12
13
|
module Opal
|
@@ -35,6 +36,9 @@ module Opal
|
|
35
36
|
|
36
37
|
# "logical_name" of a BundledAsset keeps the .js extension
|
37
38
|
source = register[asset.logical_path.sub(/\.js$/, '')]
|
39
|
+
map = JSON.parse(source)
|
40
|
+
map['sources'] = map['sources'].map {|s| "#{prefix}/#{s}"}
|
41
|
+
source = map.to_json
|
38
42
|
return not_found(asset) if source.nil?
|
39
43
|
|
40
44
|
return [200, {"Content-Type" => "text/json"}, [source.to_s]]
|
@@ -73,10 +77,12 @@ module Opal
|
|
73
77
|
@use_index = true
|
74
78
|
@public_root = nil
|
75
79
|
@public_urls = ['/']
|
76
|
-
@sprockets = options.fetch(:sprockets, Environment.new)
|
80
|
+
@sprockets = options.fetch(:sprockets, ::Sprockets::Environment.new)
|
77
81
|
@debug = options.fetch(:debug, true)
|
78
82
|
@prefix = options.fetch(:prefix, '/assets')
|
79
83
|
|
84
|
+
Opal.paths.each { |p| @sprockets.append_path(p) }
|
85
|
+
|
80
86
|
yield self if block_given?
|
81
87
|
create_app
|
82
88
|
end
|
data/lib/opal/version.rb
CHANGED
data/opal/corelib/enumerable.rb
CHANGED
@@ -16,7 +16,7 @@ module Enumerable
|
|
16
16
|
result = false;
|
17
17
|
return $breaker;
|
18
18
|
}
|
19
|
-
}
|
19
|
+
};
|
20
20
|
}
|
21
21
|
else {
|
22
22
|
self.$each.$$p = function(obj) {
|
@@ -24,7 +24,7 @@ module Enumerable
|
|
24
24
|
result = false;
|
25
25
|
return $breaker;
|
26
26
|
}
|
27
|
-
}
|
27
|
+
};
|
28
28
|
}
|
29
29
|
|
30
30
|
self.$each();
|
data/opal/corelib/hash.rb
CHANGED
@@ -501,6 +501,44 @@ class Hash
|
|
501
501
|
}
|
502
502
|
end
|
503
503
|
|
504
|
+
`var hash_ids = null;`
|
505
|
+
def hash
|
506
|
+
%x{
|
507
|
+
var top = (hash_ids === null);
|
508
|
+
try {
|
509
|
+
var key, value,
|
510
|
+
hash = ['Hash'],
|
511
|
+
keys = self.keys,
|
512
|
+
id = self.$object_id(),
|
513
|
+
counter = 0;
|
514
|
+
|
515
|
+
if (top) {
|
516
|
+
hash_ids = {}
|
517
|
+
}
|
518
|
+
|
519
|
+
if (hash_ids.hasOwnProperty(id)) {
|
520
|
+
return 'self';
|
521
|
+
}
|
522
|
+
|
523
|
+
hash_ids[id] = true;
|
524
|
+
|
525
|
+
for (var i = 0, length = keys.length; i < length; i++) {
|
526
|
+
key = keys[i];
|
527
|
+
value = key.$$is_string ? self.smap[key] : self.map[key.$hash()];
|
528
|
+
key = key.$hash();
|
529
|
+
value = (typeof(value) === 'undefined') ? '' : value.$hash();
|
530
|
+
hash.push([key,value]);
|
531
|
+
}
|
532
|
+
|
533
|
+
return hash.sort().join();
|
534
|
+
} finally {
|
535
|
+
if (top) {
|
536
|
+
hash_ids = null;
|
537
|
+
}
|
538
|
+
}
|
539
|
+
}
|
540
|
+
end
|
541
|
+
|
504
542
|
alias include? has_key?
|
505
543
|
|
506
544
|
def index(object)
|
@@ -569,11 +607,12 @@ class Hash
|
|
569
607
|
%x{
|
570
608
|
var top = (inspect_ids === null);
|
571
609
|
try {
|
572
|
-
|
610
|
+
|
611
|
+
var key, value,
|
612
|
+
inspect = [],
|
573
613
|
keys = self.keys
|
574
|
-
|
575
|
-
|
576
|
-
id = #{object_id};
|
614
|
+
id = self.$object_id(),
|
615
|
+
counter = 0;
|
577
616
|
|
578
617
|
if (top) {
|
579
618
|
inspect_ids = {}
|
@@ -586,12 +625,11 @@ class Hash
|
|
586
625
|
inspect_ids[id] = true;
|
587
626
|
|
588
627
|
for (var i = 0, length = keys.length; i < length; i++) {
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
value = value;
|
593
|
-
key
|
594
|
-
inspect.push(key.$inspect() + '=>' + value.$inspect());
|
628
|
+
key = keys[i];
|
629
|
+
value = key.$$is_string ? self.smap[key] : self.map[key.$hash()];
|
630
|
+
key = key.$inspect();
|
631
|
+
value = value.$inspect();
|
632
|
+
inspect.push(key + '=>' + value);
|
595
633
|
}
|
596
634
|
|
597
635
|
return '{' + inspect.join(', ') + '}';
|
data/opal/corelib/regexp.rb
CHANGED
data/opal/corelib/string.rb
CHANGED
data/spec/filters/bugs/hash.rb
CHANGED
@@ -57,8 +57,8 @@ opal_filter "Hash" do
|
|
57
57
|
|
58
58
|
fails "Hash#hash returns the same hash for recursive hashes through arrays"
|
59
59
|
fails "Hash#hash returns the same hash for recursive hashes"
|
60
|
-
fails "Hash#hash generates a hash for recursive hash structures"
|
61
|
-
fails "Hash#hash returns a value which doesn't depend on the hash order"
|
60
|
+
# fails "Hash#hash generates a hash for recursive hash structures"
|
61
|
+
# fails "Hash#hash returns a value which doesn't depend on the hash order"
|
62
62
|
|
63
63
|
fails "Hash#invert compares new keys with eql? semantics"
|
64
64
|
|
@@ -0,0 +1 @@
|
|
1
|
+
puts 'smap!'
|
@@ -0,0 +1 @@
|
|
1
|
+
puts 'other!'
|
@@ -5,7 +5,7 @@ require 'opal/sprockets/path_reader'
|
|
5
5
|
describe Opal::Sprockets::PathReader do
|
6
6
|
subject(:path_reader) { described_class.new(env, context) }
|
7
7
|
|
8
|
-
let(:env) {
|
8
|
+
let(:env) { Sprockets::Environment.new.tap { |e| Opal.paths.each {|p| e.append_path(p)} } }
|
9
9
|
let(:context) { double('context', depend_on: nil, depend_on_asset: nil) }
|
10
10
|
|
11
11
|
let(:logical_path) { 'sprockets_file' }
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'lib/spec_helper'
|
2
|
+
require 'sourcemap'
|
2
3
|
require 'rack/test'
|
3
4
|
|
4
5
|
describe Opal::Server do
|
@@ -8,6 +9,7 @@ describe Opal::Server do
|
|
8
9
|
described_class.new { |s|
|
9
10
|
s.main = 'opal'
|
10
11
|
s.debug = false
|
12
|
+
s.append_path File.expand_path('../../fixtures', __FILE__)
|
11
13
|
s.sprockets.logger = Logger.new('/dev/null')
|
12
14
|
}
|
13
15
|
end
|
@@ -17,4 +19,50 @@ describe Opal::Server do
|
|
17
19
|
expect(last_response).to be_ok
|
18
20
|
end
|
19
21
|
|
22
|
+
describe 'source maps' do
|
23
|
+
it 'serves map on a top level file' do
|
24
|
+
get '/assets/source_map.js'
|
25
|
+
expect(last_response).to be_ok
|
26
|
+
|
27
|
+
get '/assets/source_map.map'
|
28
|
+
expect(last_response).to be_ok
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'serves map on a subfolder file' do
|
32
|
+
js_path = '/assets/source_map/subfolder/other_file.js'
|
33
|
+
map_path = '/assets/source_map/subfolder/other_file.map'
|
34
|
+
|
35
|
+
get js_path
|
36
|
+
|
37
|
+
expect(last_response).to be_ok
|
38
|
+
received_map_path = extract_linked_map(last_response.body)
|
39
|
+
expect(File.expand_path(received_map_path, js_path+'/..')).to eq(map_path)
|
40
|
+
|
41
|
+
get '/assets/source_map/subfolder/other_file.map'
|
42
|
+
expect(last_response).to be_ok
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'serves map on a subfolder file' do
|
46
|
+
js_path = '/assets/source_map/subfolder/other_file.js'
|
47
|
+
map_path = '/assets/source_map/subfolder/other_file.map'
|
48
|
+
|
49
|
+
get js_path
|
50
|
+
|
51
|
+
expect(last_response).to be_ok
|
52
|
+
received_map_path = extract_linked_map(last_response.body)
|
53
|
+
expect(File.expand_path(received_map_path, js_path+'/..')).to eq(map_path)
|
54
|
+
|
55
|
+
|
56
|
+
get '/assets/source_map/subfolder/other_file.map'
|
57
|
+
expect(last_response).to be_ok
|
58
|
+
map = ::SourceMap::Map.from_json(last_response.body)
|
59
|
+
expect(map.sources).to include('/assets/source_map/subfolder/other_file.rb')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def extract_linked_map(body)
|
64
|
+
source_map_comment_regexp = %r{//# sourceMappingURL=(.*)$}
|
65
|
+
expect(body).to match(source_map_comment_regexp)
|
66
|
+
body.scan(source_map_comment_regexp).first.first
|
67
|
+
end
|
20
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.0.
|
4
|
+
version: 0.7.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Beynon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sourcemap
|
@@ -209,6 +209,7 @@ files:
|
|
209
209
|
- README.md
|
210
210
|
- Rakefile
|
211
211
|
- benchmarks/operators.rb
|
212
|
+
- benchmarks/prova.js.rb
|
212
213
|
- bin/opal
|
213
214
|
- bin/opal-build
|
214
215
|
- bin/opal-mspec
|
@@ -223,6 +224,7 @@ files:
|
|
223
224
|
- examples/sinatra/app/application.rb
|
224
225
|
- examples/sinatra/config.ru
|
225
226
|
- lib/mspec/opal/main.rb.erb
|
227
|
+
- lib/mspec/opal/new.html.erb
|
226
228
|
- lib/mspec/opal/rake_task.rb
|
227
229
|
- lib/mspec/opal/runner.rb
|
228
230
|
- lib/mspec/opal/special_calls.rb
|
@@ -378,6 +380,8 @@ files:
|
|
378
380
|
- spec/lib/fixtures/required_tree_test/required_file1.rb
|
379
381
|
- spec/lib/fixtures/required_tree_test/required_file2.rb
|
380
382
|
- spec/lib/fixtures/requires.rb
|
383
|
+
- spec/lib/fixtures/source_map.rb
|
384
|
+
- spec/lib/fixtures/source_map/subfolder/other_file.rb
|
381
385
|
- spec/lib/fixtures/sprockets_file.js.rb
|
382
386
|
- spec/lib/fixtures/sprockets_require_tree_test.rb
|
383
387
|
- spec/lib/hike_path_finder_spec.rb
|
@@ -416,7 +420,6 @@ files:
|
|
416
420
|
- spec/lib/shared/path_finder_shared.rb
|
417
421
|
- spec/lib/shared/path_reader_shared.rb
|
418
422
|
- spec/lib/spec_helper.rb
|
419
|
-
- spec/lib/sprockets/environment_spec.rb
|
420
423
|
- spec/lib/sprockets/erb_spec.rb
|
421
424
|
- spec/lib/sprockets/path_reader_spec.rb
|
422
425
|
- spec/lib/sprockets/processor_spec.rb
|
@@ -695,7 +698,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
695
698
|
version: 1.3.1
|
696
699
|
requirements: []
|
697
700
|
rubyforge_project:
|
698
|
-
rubygems_version: 2.4.
|
701
|
+
rubygems_version: 2.4.3
|
699
702
|
signing_key:
|
700
703
|
specification_version: 4
|
701
704
|
summary: Ruby runtime and core library for javascript
|
@@ -751,6 +754,8 @@ test_files:
|
|
751
754
|
- spec/lib/fixtures/required_tree_test/required_file1.rb
|
752
755
|
- spec/lib/fixtures/required_tree_test/required_file2.rb
|
753
756
|
- spec/lib/fixtures/requires.rb
|
757
|
+
- spec/lib/fixtures/source_map.rb
|
758
|
+
- spec/lib/fixtures/source_map/subfolder/other_file.rb
|
754
759
|
- spec/lib/fixtures/sprockets_file.js.rb
|
755
760
|
- spec/lib/fixtures/sprockets_require_tree_test.rb
|
756
761
|
- spec/lib/hike_path_finder_spec.rb
|
@@ -789,7 +794,6 @@ test_files:
|
|
789
794
|
- spec/lib/shared/path_finder_shared.rb
|
790
795
|
- spec/lib/shared/path_reader_shared.rb
|
791
796
|
- spec/lib/spec_helper.rb
|
792
|
-
- spec/lib/sprockets/environment_spec.rb
|
793
797
|
- spec/lib/sprockets/erb_spec.rb
|
794
798
|
- spec/lib/sprockets/path_reader_spec.rb
|
795
799
|
- spec/lib/sprockets/processor_spec.rb
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'lib/spec_helper'
|
2
|
-
require 'opal/sprockets/environment'
|
3
|
-
|
4
|
-
describe Opal::Environment do
|
5
|
-
let(:env) { described_class.new }
|
6
|
-
let(:logical_path) { 'sprockets_file' }
|
7
|
-
|
8
|
-
before { env.append_path File.expand_path('../../fixtures/', __FILE__) }
|
9
|
-
|
10
|
-
it 'compiles Ruby to JS' do
|
11
|
-
expect(env[logical_path].source).to include('$puts(')
|
12
|
-
expect(env[logical_path+'.js'].source).to include('$puts(')
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'require_tree sprockets directive' do
|
16
|
-
it 'is still supported' do
|
17
|
-
source = env['sprockets_require_tree_test'].source
|
18
|
-
expect(source).to include('required_file1')
|
19
|
-
expect(source).to include('required_file2')
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe 'require_tree helper' do
|
24
|
-
it 'is handled by the processor' do
|
25
|
-
source = env['require_tree_test'].source
|
26
|
-
expect(source).to include('required_file1')
|
27
|
-
expect(source).to include('required_file2')
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|