sprockets-iife 1.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sprockets-iife/legacy-processor.rb +20 -0
- data/lib/sprockets-iife/processor.rb +25 -0
- data/lib/sprockets-iife/railtie.rb +17 -12
- data/lib/sprockets-iife/version.rb +4 -1
- data/lib/sprockets-iife.rb +13 -1
- data/sprockets-iife.gemspec +7 -4
- metadata +11 -17
- data/lib/sprockets-iife/processor-v2.rb +0 -10
- data/lib/sprockets-iife/processor-v3.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 451f2f25122ef8ea36d31a1f6c65bed8b5b8c4ec
|
4
|
+
data.tar.gz: 01139b632cd7501c1f400e30d27cbe38f6538160
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4da0ec29ee45283ee0ea9d2d00ea882141189635575469760f4fb09d68be57d7a03b5393b3b56680d4762f212253a27b1369ab48cac1999cfc990f681cf643d
|
7
|
+
data.tar.gz: 0c93d33fd93c2071e30e18f5a5fb9c5996b0392020492ad221643c29e7d5d00d1bcaefcfcb2f1a716d29278d5f07088d7738424a2b7a1e5e2c3549d90ce8eec0
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'tilt'
|
5
|
+
|
6
|
+
module SprocketsIIFE
|
7
|
+
class Processor < Tilt::Template
|
8
|
+
def prepare
|
9
|
+
end
|
10
|
+
|
11
|
+
# Call processor block with `context` and `data`.
|
12
|
+
def evaluate(context, locals, &block)
|
13
|
+
source_file = file
|
14
|
+
iife_file = File.join(File.dirname(source_file), "#{File.basename(source_file, '.*')}-iife.js.erb")
|
15
|
+
File.readable?(iife_file) ? ERB.new(File.read(iife_file)).result(binding) : data
|
16
|
+
end
|
17
|
+
|
18
|
+
alias source data
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module SprocketsIIFE
|
5
|
+
class Processor
|
6
|
+
include Singleton
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def call(input)
|
10
|
+
instance.call(input)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(input)
|
15
|
+
@input = input
|
16
|
+
source_path = @input[:filename]
|
17
|
+
iife_path = File.join(File.dirname(source_path), "#{File.basename(source_path, '.*')}-iife.js.erb")
|
18
|
+
File.readable?(iife_path) ? ERB.new(File.read(iife_path)).result(binding) : input[:data]
|
19
|
+
end
|
20
|
+
|
21
|
+
def source
|
22
|
+
@input[:data]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,17 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
1
4
|
module SprocketsIIFE
|
2
|
-
class Railtie < Rails::
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
if app.config.assets.respond_to?(:configure)
|
8
|
-
app.config.assets.configure do |env|
|
9
|
-
require 'sprockets-iife/processor-v3'
|
10
|
-
proc.call(env)
|
11
|
-
end
|
5
|
+
class Railtie < Rails::Railtie
|
6
|
+
def configure_assets(app)
|
7
|
+
if config.respond_to?(:assets) && config.assets.respond_to?(:configure)
|
8
|
+
# Rails 4.x
|
9
|
+
config.assets.configure { |env| yield(env) }
|
12
10
|
else
|
13
|
-
|
14
|
-
|
11
|
+
# Rails 3.2
|
12
|
+
yield(app.assets)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
initializer 'sprockets.iife', group: :all, after: 'sprockets.environment' do |app|
|
17
|
+
configure_assets(app) do |env|
|
18
|
+
# Sprockets 2, 3, and 4
|
19
|
+
env.register_bundle_processor 'application/javascript', SprocketsIIFE::Processor
|
15
20
|
end
|
16
21
|
end
|
17
22
|
end
|
data/lib/sprockets-iife.rb
CHANGED
@@ -1 +1,13 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'sprockets'
|
5
|
+
|
6
|
+
Sprockets::VERSION =~ /\A\d/
|
7
|
+
if $&.to_i > 2
|
8
|
+
require 'sprockets-iife/processor'
|
9
|
+
else
|
10
|
+
require 'sprockets-iife/legacy-processor'
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'sprockets-iife/railtie' if defined?(Rails)
|
data/sprockets-iife.gemspec
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
1
4
|
require File.expand_path('../lib/sprockets-iife/version', __FILE__)
|
2
5
|
|
3
6
|
Gem::Specification.new do |s|
|
4
7
|
s.name = 'sprockets-iife'
|
5
8
|
s.version = SprocketsIIFE::VERSION
|
6
9
|
s.author = 'Yaroslav Konoplov'
|
7
|
-
s.email = '
|
8
|
-
s.summary = '
|
9
|
-
s.description = '
|
10
|
+
s.email = 'eahome00@gmail.com'
|
11
|
+
s.summary = 'IIFE wrapper generator for Sprockets'
|
12
|
+
s.description = 'Generates IIFE wrapper for Sprockets JavaScript bundles'
|
10
13
|
s.homepage = 'https://github.com/yivo/sprockets-iife'
|
11
14
|
s.license = 'MIT'
|
12
15
|
|
@@ -15,5 +18,5 @@ Gem::Specification.new do |s|
|
|
15
18
|
s.test_files = `git ls-files -z -- {test,spec,features}/*`.split("\x0")
|
16
19
|
s.require_paths = ['lib']
|
17
20
|
|
18
|
-
s.add_dependency 'sprockets', '
|
21
|
+
s.add_dependency 'sprockets', '~> 0'
|
19
22
|
end
|
metadata
CHANGED
@@ -1,37 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-iife
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaroslav Konoplov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sprockets
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 4.0.0
|
19
|
+
version: '0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 2.0.0
|
30
|
-
- - "<"
|
24
|
+
- - "~>"
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
33
|
-
description:
|
34
|
-
email:
|
26
|
+
version: '0'
|
27
|
+
description: Generates IIFE wrapper for Sprockets JavaScript bundles
|
28
|
+
email: eahome00@gmail.com
|
35
29
|
executables: []
|
36
30
|
extensions: []
|
37
31
|
extra_rdoc_files: []
|
@@ -39,8 +33,8 @@ files:
|
|
39
33
|
- ".gitignore"
|
40
34
|
- README.md
|
41
35
|
- lib/sprockets-iife.rb
|
42
|
-
- lib/sprockets-iife/processor
|
43
|
-
- lib/sprockets-iife/processor
|
36
|
+
- lib/sprockets-iife/legacy-processor.rb
|
37
|
+
- lib/sprockets-iife/processor.rb
|
44
38
|
- lib/sprockets-iife/railtie.rb
|
45
39
|
- lib/sprockets-iife/version.rb
|
46
40
|
- sprockets-iife.gemspec
|
@@ -67,5 +61,5 @@ rubyforge_project:
|
|
67
61
|
rubygems_version: 2.5.1
|
68
62
|
signing_key:
|
69
63
|
specification_version: 4
|
70
|
-
summary:
|
64
|
+
summary: IIFE wrapper generator for Sprockets
|
71
65
|
test_files: []
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module SprocketsIIFE
|
2
|
-
class Processor < Sprockets::Processor
|
3
|
-
def evaluate(context, locals)
|
4
|
-
iife = File.join(File.dirname(file), "#{File.basename(file, '.*')}-iife.js.erb")
|
5
|
-
File.exists?(iife) ? ERB.new(File.read(iife)).result(binding) : data
|
6
|
-
end
|
7
|
-
|
8
|
-
alias source data
|
9
|
-
end
|
10
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module SprocketsIIFE
|
2
|
-
class Processor
|
3
|
-
VERSION = '1'
|
4
|
-
include Singleton
|
5
|
-
|
6
|
-
class << self
|
7
|
-
delegate :call, :cache_key, to: :instance
|
8
|
-
end
|
9
|
-
|
10
|
-
attr_reader :cache_key
|
11
|
-
|
12
|
-
def initialize(options = {})
|
13
|
-
@cache_key = [self.class.name, VERSION, options].freeze
|
14
|
-
end
|
15
|
-
|
16
|
-
def call(input)
|
17
|
-
@input = input
|
18
|
-
filepath = @input[:filename]
|
19
|
-
iife = File.join(File.dirname(filepath), "#{File.basename(filepath, '.*')}-iife.js.erb")
|
20
|
-
File.exists?(iife) ? ERB.new(File.read(iife)).result(binding) : input[:data]
|
21
|
-
end
|
22
|
-
|
23
|
-
def source
|
24
|
-
@input[:data]
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|