sprockets-iife 1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e41521bf2ed014357870be6f06f8bfdf55d9189b
4
+ data.tar.gz: 3742bed7965f3c1bd5c2796ed9b01c1b9a6e358d
5
+ SHA512:
6
+ metadata.gz: 1401a23d3d008b20c9eba50150799fab8fcc6f1052a0cb0d186be6e8895eb9f5bea0f8a10dcdc7e7514e5f8ab15db0e87df4a397088179749656c71627b9417b
7
+ data.tar.gz: bb51cff871d3dde93a3b1bb916525a0af4903bda2e8718a428071dd1437aee25f3f22bc05343e40fcecd1e8cdc2d7cedcea2ae3aee7dca3ffad1be0f7a6be168
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.gem
2
+ *.lock
3
+ .bundle
4
+ .ruby-version
5
+ pkg/
6
+ tmp/
7
+ /.idea/
data/README.md ADDED
File without changes
@@ -0,0 +1,10 @@
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
@@ -0,0 +1,27 @@
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
@@ -0,0 +1,18 @@
1
+ module SprocketsIIFE
2
+ class Railtie < Rails::Engine
3
+ initializer :sprockets_iife do |app|
4
+ proc = -> (env = nil) {
5
+ (env || app.assets).register_bundle_processor 'application/javascript', ::SprocketsIIFE::Processor
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
12
+ else
13
+ require 'sprockets-iife/processor-v2'
14
+ proc.call
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module SprocketsIIFE
2
+ VERSION = '1.0'
3
+ end
@@ -0,0 +1 @@
1
+ require 'sprockets-iife/railtie'
@@ -0,0 +1,19 @@
1
+ require File.expand_path('../lib/sprockets-iife/version', __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'sprockets-iife'
5
+ s.version = SprocketsIIFE::VERSION
6
+ s.author = 'Yaroslav Konoplov'
7
+ s.email = 'yaroslav@inbox.com'
8
+ s.summary = 'sprockets-iife'
9
+ s.description = 'sprockets-iife'
10
+ s.homepage = 'https://github.com/yivo/sprockets-iife'
11
+ s.license = 'MIT'
12
+
13
+ s.executables = `git ls-files -z -- bin/*`.split("\x0").map{ |f| File.basename(f) }
14
+ s.files = `git ls-files -z`.split("\x0")
15
+ s.test_files = `git ls-files -z -- {test,spec,features}/*`.split("\x0")
16
+ s.require_paths = ['lib']
17
+
18
+ s.add_dependency 'sprockets', '>= 2.0.0', '< 4.0.0'
19
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sprockets-iife
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - Yaroslav Konoplov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sprockets
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 4.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 4.0.0
33
+ description: sprockets-iife
34
+ email: yaroslav@inbox.com
35
+ executables: []
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - ".gitignore"
40
+ - README.md
41
+ - lib/sprockets-iife.rb
42
+ - lib/sprockets-iife/processor-v2.rb
43
+ - lib/sprockets-iife/processor-v3.rb
44
+ - lib/sprockets-iife/railtie.rb
45
+ - lib/sprockets-iife/version.rb
46
+ - sprockets-iife.gemspec
47
+ homepage: https://github.com/yivo/sprockets-iife
48
+ licenses:
49
+ - MIT
50
+ metadata: {}
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 2.5.1
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: sprockets-iife
71
+ test_files: []