opal-sprockets 0.4.8.1.0.3.7 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +26 -0
- data/CHANGELOG.md +34 -2
- data/bin/console +14 -0
- data/bin/rake +6 -0
- data/bin/rspec +29 -0
- data/bin/setup +8 -0
- data/lib/opal/environment.rb +4 -0
- data/lib/opal/processor.rb +4 -0
- data/lib/opal/sprockets/assets_helper.rb +78 -0
- data/lib/opal/sprockets/environment.rb +12 -14
- data/lib/opal/sprockets/erb.rb +12 -16
- data/lib/opal/sprockets/mime_types.rb +19 -0
- data/lib/opal/sprockets/processor.rb +112 -115
- data/lib/opal/sprockets/server.rb +94 -98
- data/lib/opal/sprockets/version.rb +1 -8
- data/lib/opal/sprockets.rb +13 -81
- data/opal-sprockets.gemspec +38 -24
- data/spec/fixtures/complex_sprockets.js.rb.erb +1 -1
- data/spec/fixtures/{jst_file.js.jst → jst_file.jst.ejs} +0 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/sprockets/erb_spec.rb +15 -25
- data/spec/sprockets/processor_spec.rb +53 -57
- data/spec/sprockets/server_spec.rb +95 -25
- data/spec/sprockets_spec.rb +2 -2
- data/spec/tilt/opal_spec.rb +1 -1
- metadata +69 -27
- data/.travis.yml +0 -21
- data/lib/opal/sprockets/path_reader.rb +0 -36
- data/spec/shared/path_finder_shared.rb +0 -19
- data/spec/shared/path_reader_shared.rb +0 -31
- data/spec/sprockets/path_reader_spec.rb +0 -41
data/.travis.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
branches:
|
4
|
-
only:
|
5
|
-
- master
|
6
|
-
- /^.*-stable$/
|
7
|
-
- /^.*ci-check$/
|
8
|
-
|
9
|
-
matrix:
|
10
|
-
include:
|
11
|
-
- rvm: 2.3
|
12
|
-
env: OPAL_VERSION='~> 1.0.0'
|
13
|
-
- rvm: 2.4
|
14
|
-
env: OPAL_VERSION='~> 1.0.0'
|
15
|
-
- rvm: 2.5
|
16
|
-
env: OPAL_VERSION='~> 1.0.0'
|
17
|
-
- rvm: 2.6
|
18
|
-
env: OPAL_VERSION='~> 1.0.0'
|
19
|
-
|
20
|
-
notifications:
|
21
|
-
irc: "irc.freenode.org#opal"
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module Opal
|
2
|
-
module Sprockets
|
3
|
-
|
4
|
-
class PathReader
|
5
|
-
def initialize(env, context)
|
6
|
-
@env ||= env
|
7
|
-
@context ||= context
|
8
|
-
end
|
9
|
-
|
10
|
-
def read path
|
11
|
-
if path.end_with? '.js'
|
12
|
-
context.depend_on_asset(path)
|
13
|
-
env[path, bundle: true].to_s
|
14
|
-
else
|
15
|
-
context.depend_on(path)
|
16
|
-
File.open(expand(path), 'rb:UTF-8'){|f| f.read}
|
17
|
-
end
|
18
|
-
rescue ::Sprockets::FileNotFound
|
19
|
-
nil
|
20
|
-
end
|
21
|
-
|
22
|
-
def expand path
|
23
|
-
env.resolve(path) or
|
24
|
-
# Sprockets 3 just returns nil for unknown paths
|
25
|
-
raise ::Sprockets::FileNotFound, path.inspect
|
26
|
-
end
|
27
|
-
|
28
|
-
def paths
|
29
|
-
env.paths
|
30
|
-
end
|
31
|
-
|
32
|
-
attr_reader :env, :context
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
shared_examples :path_finder do
|
4
|
-
# @param path
|
5
|
-
# the path we want to read
|
6
|
-
#
|
7
|
-
# @param full_path
|
8
|
-
# the expanded path that should be found
|
9
|
-
#
|
10
|
-
it 'returns the full path if the path exists' do
|
11
|
-
expect(path_finder.find(path)).to eq(full_path)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'returns nil if the path is missing' do
|
15
|
-
expect(path_finder.find('unexpected-path')).to eq(nil)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
# Below the helpers expected from a spec that
|
4
|
-
# includes these shared examples:
|
5
|
-
#
|
6
|
-
# @object [PathReader] path_reader the object under test
|
7
|
-
# @method [String] path the path we want to read
|
8
|
-
# @method [String] contents the contents we expect to be read
|
9
|
-
#
|
10
|
-
shared_examples :path_reader do
|
11
|
-
describe '#paths' do
|
12
|
-
it 'is an Enumberable' do
|
13
|
-
expect(path_reader.paths).to be_an(Enumerable)
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'includes Opal.paths' do
|
17
|
-
paths = path_reader.paths.to_a
|
18
|
-
Opal.paths.each { |path| expect(paths).to include(path) }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#read' do
|
23
|
-
it 'responds to #path' do
|
24
|
-
expect(path_reader.read(path)).to eq(contents)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'returns nil if the file is missing' do
|
28
|
-
expect(path_reader.read('unexpected-path!')).to be_nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'shared/path_reader_shared'
|
3
|
-
require 'opal/sprockets/path_reader'
|
4
|
-
|
5
|
-
describe Opal::Sprockets::PathReader do
|
6
|
-
let(:env) { Sprockets::Environment.new }
|
7
|
-
let(:context) { double('context', depend_on: nil, depend_on_asset: nil) }
|
8
|
-
let(:contents) { File.read(full_path) }
|
9
|
-
let(:full_path) { fixtures_dir.join(logical_path+'.js.rb') }
|
10
|
-
let(:logical_path) { 'sprockets_file' }
|
11
|
-
let(:fixtures_dir) { Pathname('../../fixtures/').expand_path(__FILE__) }
|
12
|
-
|
13
|
-
subject(:path_reader) { described_class.new(env, context) }
|
14
|
-
|
15
|
-
before do
|
16
|
-
Opal.paths.each {|p| env.append_path(p)}
|
17
|
-
env.append_path fixtures_dir
|
18
|
-
end
|
19
|
-
|
20
|
-
include_examples :path_reader do
|
21
|
-
let(:path) { logical_path }
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'can read stuff from sprockets env' do
|
25
|
-
expect(path_reader.read(logical_path)).to eq(contents)
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'reads js files processing their directives' do
|
29
|
-
path = 'file_with_directives.js'
|
30
|
-
full_path = fixtures_dir.join(path)
|
31
|
-
required_contents = File.read(fixtures_dir.join('required_file.js')).strip
|
32
|
-
read_contents = path_reader.read(path)
|
33
|
-
actual_contents = full_path.read
|
34
|
-
|
35
|
-
expect(actual_contents).to include('//= require')
|
36
|
-
expect(read_contents).not_to include('//= require')
|
37
|
-
|
38
|
-
expect(read_contents).to include(required_contents)
|
39
|
-
expect(actual_contents).not_to include(required_contents)
|
40
|
-
end
|
41
|
-
end
|