opal-sprockets 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +2 -0
- data/.travis.yml +9 -0
- data/lib/opal/sprockets/processor.rb +1 -2
- data/lib/opal/sprockets/server.rb +17 -4
- data/lib/opal/sprockets/version.rb +1 -1
- data/spec/opal/sprockets/server_spec.rb +15 -0
- metadata +17 -24
- data/lib/opal/sprockets/source_map_header.rb +0 -22
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f599646138983764d471f03e02ca55d2d9d7b8ee
|
4
|
+
data.tar.gz: 3683e235bd9da2c28ae8e72256fa38f0a56c86fe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 668349a8e33e7db6615ad32b32d8061bd4c4136e0a4cc3858ac0c5a290300bb7782c99480107a80d6a4f2146f7f5040fb467899e5476383b61469af2db9502d1
|
7
|
+
data.tar.gz: 5a9cef7b65581cc8ff6a9ee3246bfe00f5445b6608ac0aaef936aa418c94d5c98b6e3b87de3833f00f5c4879d5734ec414bcc43a286023be7eae48d08187cde4
|
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -72,13 +72,12 @@ module Opal
|
|
72
72
|
parser = Opal::RequireParser.new
|
73
73
|
result = parser.parse data, options
|
74
74
|
|
75
|
-
|
76
75
|
parser.requires.each do |r|
|
77
76
|
path = find_opal_require context.environment, r
|
78
77
|
context.require_asset path
|
79
78
|
end
|
80
79
|
|
81
|
-
if
|
80
|
+
if options[:source_map_enabled]
|
82
81
|
$OPAL_SOURCE_MAPS[context.pathname] = Opal::SourceMap.new(parser.fragments, "file://#{context.pathname.to_s}").to_s
|
83
82
|
"#{result}\n//@ sourceMappingURL=/__opal_source_maps__/#{context.logical_path}.js.map\n"
|
84
83
|
else
|
@@ -1,8 +1,9 @@
|
|
1
|
+
require 'rack/file'
|
2
|
+
require 'rack/urlmap'
|
1
3
|
require 'rack/builder'
|
2
4
|
require 'rack/directory'
|
3
5
|
require 'rack/showexceptions'
|
4
6
|
require 'opal/source_map'
|
5
|
-
require 'opal/sprockets/source_map_header'
|
6
7
|
require 'opal/sprockets/environment'
|
7
8
|
require 'erb'
|
8
9
|
|
@@ -38,15 +39,27 @@ module Opal
|
|
38
39
|
|
39
40
|
attr_accessor :debug, :index_path, :main, :public_dir, :sprockets
|
40
41
|
|
41
|
-
def initialize
|
42
|
+
def initialize debug_or_options = {}
|
43
|
+
unless Hash === debug_or_options
|
44
|
+
warn "passing a boolean to control debug is deprecated.\n"+
|
45
|
+
"Please pass an Hash instead: Server.new(debug: true)"
|
46
|
+
options = {:debug => debug_or_options}
|
47
|
+
else
|
48
|
+
options = debug_or_options
|
49
|
+
end
|
50
|
+
|
42
51
|
@public_dir = '.'
|
43
52
|
@sprockets = Environment.new
|
44
|
-
@debug = debug
|
53
|
+
@debug = options.fetch(:debug, true)
|
45
54
|
|
46
55
|
yield self if block_given?
|
47
56
|
create_app
|
48
57
|
end
|
49
58
|
|
59
|
+
def source_map_enabled
|
60
|
+
Opal::Processor.source_map_enabled
|
61
|
+
end
|
62
|
+
|
50
63
|
def append_path path
|
51
64
|
@sprockets.append_path path
|
52
65
|
end
|
@@ -61,7 +74,7 @@ module Opal
|
|
61
74
|
@app = Rack::Builder.app do
|
62
75
|
use Rack::ShowExceptions
|
63
76
|
map('/assets') { run sprockets }
|
64
|
-
map(server.source_maps.prefix) { run server.source_maps }
|
77
|
+
map(server.source_maps.prefix) { run server.source_maps } if @source_map_enabled
|
65
78
|
use Index, server
|
66
79
|
run Rack::Directory.new(server.public_dir)
|
67
80
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Opal::Server do
|
4
|
+
it 'serves source maps only if they are enbled on the Processor' do
|
5
|
+
original_value = Opal::Processor.source_map_enabled
|
6
|
+
begin
|
7
|
+
[true, false].each do |bool|
|
8
|
+
Opal::Processor.source_map_enabled = bool
|
9
|
+
expect(subject.source_map_enabled).to eq(bool)
|
10
|
+
end
|
11
|
+
ensure
|
12
|
+
Opal::Processor.source_map_enabled = original_value
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,36 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-sprockets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Adam Beynon
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-10-23 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: sprockets
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: opal
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,33 +41,29 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
description: Sprockets suppoer for opal.
|
@@ -82,6 +73,8 @@ extensions: []
|
|
82
73
|
extra_rdoc_files: []
|
83
74
|
files:
|
84
75
|
- .gitignore
|
76
|
+
- .rspec
|
77
|
+
- .travis.yml
|
85
78
|
- Gemfile
|
86
79
|
- README.md
|
87
80
|
- Rakefile
|
@@ -96,39 +89,39 @@ files:
|
|
96
89
|
- lib/opal/sprockets/erb.rb
|
97
90
|
- lib/opal/sprockets/processor.rb
|
98
91
|
- lib/opal/sprockets/server.rb
|
99
|
-
- lib/opal/sprockets/source_map_header.rb
|
100
92
|
- lib/opal/sprockets/version.rb
|
101
93
|
- opal-sprockets.gemspec
|
102
94
|
- spec/fixtures/app/foo.rb
|
103
95
|
- spec/fixtures/app2/bar.js
|
96
|
+
- spec/opal/sprockets/server_spec.rb
|
104
97
|
- spec/processor_spec.rb
|
105
98
|
- spec/spec_helper.rb
|
106
99
|
homepage: http://opalrb.org
|
107
100
|
licenses: []
|
101
|
+
metadata: {}
|
108
102
|
post_install_message:
|
109
103
|
rdoc_options: []
|
110
104
|
require_paths:
|
111
105
|
- lib
|
112
106
|
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
107
|
requirements:
|
115
|
-
- -
|
108
|
+
- - '>='
|
116
109
|
- !ruby/object:Gem::Version
|
117
110
|
version: '0'
|
118
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
-
none: false
|
120
112
|
requirements:
|
121
|
-
- -
|
113
|
+
- - '>='
|
122
114
|
- !ruby/object:Gem::Version
|
123
115
|
version: '0'
|
124
116
|
requirements: []
|
125
117
|
rubyforge_project:
|
126
|
-
rubygems_version: 1.
|
118
|
+
rubygems_version: 2.1.9
|
127
119
|
signing_key:
|
128
|
-
specification_version:
|
120
|
+
specification_version: 4
|
129
121
|
summary: Sprockets support for opal
|
130
122
|
test_files:
|
131
123
|
- spec/fixtures/app/foo.rb
|
132
124
|
- spec/fixtures/app2/bar.js
|
125
|
+
- spec/opal/sprockets/server_spec.rb
|
133
126
|
- spec/processor_spec.rb
|
134
127
|
- spec/spec_helper.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'sprockets/server'
|
2
|
-
|
3
|
-
module Sprockets
|
4
|
-
module Server
|
5
|
-
|
6
|
-
# Adds the source map header to all sprocket responses for assets
|
7
|
-
# with a .rb or .opal extension in the extension chain.
|
8
|
-
def headers_with_opal_source_maps(env, asset, length)
|
9
|
-
headers_without_opal_source_maps(env, asset, length).tap do |headers|
|
10
|
-
if asset.pathname.to_s =~ /\.(rb|opal)\b/
|
11
|
-
headers['X-SourceMap'] = '/__opal_source_maps__/'+asset.logical_path + '.map'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# Poor man's alias_method_chain :)
|
17
|
-
alias headers_without_opal_source_maps headers
|
18
|
-
alias headers headers_with_opal_source_maps
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|