sprockets-export 0.9.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/lib/sprockets/export.rb +2 -1
- data/lib/sprockets/export/bundle_processor.rb +12 -4
- data/lib/sprockets/export/directive_processor.rb +2 -2
- data/lib/sprockets/export/metadata_injector.rb +2 -2
- data/lib/sprockets/export/{namespace.rb → store.rb} +4 -4
- data/lib/sprockets/export/template.js.erb +5 -3
- data/lib/sprockets/export/template.rb +1 -1
- data/lib/sprockets/export/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0c9478e9f2c18af7ca58c3408cf613f0839b696
|
4
|
+
data.tar.gz: a5f200a57e54820e93ee6b223733dc14c58d8057
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a66534a884c3464cbd54d478b4a036ce53189c23b48c57faa9f208d63ebdff47d09948a7773056ff16c8caba0995f55b49cec56105566db4470684f44d916ac6
|
7
|
+
data.tar.gz: 75a4ab47980c3921c41f941a7fe7f5c823a05a44706c17c78e26ad79b00ab053ce10e6b4eff5fe9a064352e20a051a78372835b5b2ea77ee7ab8ca02694a66de
|
data/Gemfile
CHANGED
data/lib/sprockets/export.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require "pathname"
|
2
2
|
|
3
|
+
require "sprockets"
|
3
4
|
require "sprockets/export/version"
|
4
|
-
require "sprockets/export/
|
5
|
+
require "sprockets/export/store"
|
5
6
|
require "sprockets/export/directive_processor"
|
6
7
|
require "sprockets/export/metadata_injector"
|
7
8
|
require "sprockets/export/bundle_processor"
|
@@ -1,12 +1,13 @@
|
|
1
1
|
require "sprockets/export/template"
|
2
|
+
require "ostruct"
|
2
3
|
|
3
4
|
module Sprockets::Export::BundleProcessor
|
4
5
|
extend self
|
5
6
|
|
6
|
-
PATTERN = /(.*)\/\* !START EXPORT (
|
7
|
+
PATTERN = /(.*)\/\* !START EXPORT (\S*)\s*(\S*) \*\/(.*)\/\* !END EXPORT \*\/(.*)/m
|
7
8
|
|
8
9
|
def call(input)
|
9
|
-
Sprockets::Export::
|
10
|
+
Sprockets::Export::Store.reset
|
10
11
|
data = input[:data]
|
11
12
|
|
12
13
|
if data =~ PATTERN
|
@@ -18,15 +19,22 @@ module Sprockets::Export::BundleProcessor
|
|
18
19
|
|
19
20
|
private
|
20
21
|
def extract_template_data(js)
|
21
|
-
_, head, namespace, export, tail = *js.match(PATTERN)
|
22
|
+
_, head, namespace, flags, export, tail = *js.match(PATTERN)
|
22
23
|
|
23
24
|
{ namespace: namespace,
|
25
|
+
flags: create_flags(flags),
|
24
26
|
export: format(export),
|
25
27
|
head: format(head),
|
26
28
|
tail: format(tail) }
|
27
29
|
end
|
28
30
|
|
29
31
|
def format(part)
|
30
|
-
part.strip.gsub(/\A
|
32
|
+
part.strip.gsub(/\A\s*;\n*|\n;\s*\z/, "").strip
|
33
|
+
end
|
34
|
+
|
35
|
+
def create_flags(string = "")
|
36
|
+
flags = {}
|
37
|
+
string.split.each { |flag| flags[flag] = true }
|
38
|
+
OpenStruct.new(flags)
|
31
39
|
end
|
32
40
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Sprockets::DirectiveProcessor
|
2
|
-
def process_export_directive(namespace)
|
2
|
+
def process_export_directive(namespace, *flags)
|
3
3
|
if @content_type == "application/javascript"
|
4
|
-
Sprockets::Export::
|
4
|
+
Sprockets::Export::Store.set(@environment, @filename, [namespace, flags].flatten.join(" "))
|
5
5
|
process_depend_on_directive "sprockets/export/version.rb"
|
6
6
|
end
|
7
7
|
end
|
@@ -4,8 +4,8 @@ module Sprockets::Export::MetadataInjector
|
|
4
4
|
def call(input)
|
5
5
|
data, environment, filename = *input.values_at(:data, :environment, :filename)
|
6
6
|
|
7
|
-
if
|
8
|
-
open = "/* !START EXPORT #{
|
7
|
+
if metadata = Sprockets::Export::Store.get(environment, filename)
|
8
|
+
open = "/* !START EXPORT #{metadata} */"
|
9
9
|
close = "/* !END EXPORT */"
|
10
10
|
data = [open, data.chomp, close].join("\n") + "\n"
|
11
11
|
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
module Sprockets::Export::
|
1
|
+
module Sprockets::Export::Store
|
2
2
|
extend self
|
3
3
|
|
4
|
-
def
|
4
|
+
def set(environment, filename, data)
|
5
5
|
mapping[environment] ||= {}
|
6
|
-
mapping[environment][filename] =
|
6
|
+
mapping[environment][filename] = data
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
9
|
+
def get(environment, filename)
|
10
10
|
if mapping[environment]
|
11
11
|
mapping[environment][filename]
|
12
12
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
<%= @head %>
|
2
2
|
|
3
3
|
(function() {
|
4
|
+
var context = <%= @flags.noglobal ? "{}" : "this" %>;
|
5
|
+
|
4
6
|
(function() {
|
5
|
-
<%= indent(@export, 4
|
6
|
-
}).call(
|
7
|
+
<%= indent(@export, 4)%>
|
8
|
+
}).call(context);
|
7
9
|
|
8
|
-
var <%= @namespace %> =
|
10
|
+
var <%= @namespace %> = context.<%= @namespace %>;
|
9
11
|
|
10
12
|
(function() {
|
11
13
|
<%= indent(@tail, 4) %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-export
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javan Makhmali
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sprockets
|
@@ -85,7 +85,7 @@ files:
|
|
85
85
|
- lib/sprockets/export/bundle_processor.rb
|
86
86
|
- lib/sprockets/export/directive_processor.rb
|
87
87
|
- lib/sprockets/export/metadata_injector.rb
|
88
|
-
- lib/sprockets/export/
|
88
|
+
- lib/sprockets/export/store.rb
|
89
89
|
- lib/sprockets/export/template.js.erb
|
90
90
|
- lib/sprockets/export/template.rb
|
91
91
|
- lib/sprockets/export/version.rb
|
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
112
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.6.6
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: Sprockets Export
|