sprockets-export 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -0
- data/lib/sprockets/export.rb +8 -1
- data/lib/sprockets/export/bundle_processor.rb +6 -11
- data/lib/sprockets/export/template.js.erb +3 -1
- data/lib/sprockets/export/template.rb +5 -3
- data/lib/sprockets/export/version.rb +1 -1
- data/sprockets-export.gemspec +3 -2
- metadata +25 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b57161371802c88947bf586d9dbb07dcdc482b9
|
4
|
+
data.tar.gz: 00f610fda3e32b792659376d20e921c1a91ccd01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0eae35cd13fe0aa7c79f5971f5773d2945573ba305f04ac8e1c31987ae122ed9f0618da28cfccd1c8ad2449bd6615b58bfdcb70a013ff440bdae12993d292a84
|
7
|
+
data.tar.gz: 7e5aa9ee09d45fdbadde8086888d24ca6a038c6edb75e3dc3db00a6894668bc05bf329c4f3b1e63b66ee83763049bb61909f53de40acbec5042eeb5ba164d020
|
data/.travis.yml
ADDED
data/lib/sprockets/export.rb
CHANGED
@@ -6,6 +6,13 @@ require "sprockets/export/directive_processor"
|
|
6
6
|
require "sprockets/export/metadata_injector"
|
7
7
|
require "sprockets/export/bundle_processor"
|
8
8
|
|
9
|
-
Sprockets
|
9
|
+
module Sprockets::Export
|
10
|
+
def self.lib_path
|
11
|
+
@lib_path ||= Pathname.new(File.expand_path("../..", __FILE__))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
Sprockets.append_path Sprockets::Export.lib_path
|
10
17
|
Sprockets.register_postprocessor "application/javascript", Sprockets::Export::MetadataInjector
|
11
18
|
Sprockets.register_bundle_processor "application/javascript", Sprockets::Export::BundleProcessor
|
@@ -20,18 +20,13 @@ module Sprockets::Export::BundleProcessor
|
|
20
20
|
def extract_template_data(js)
|
21
21
|
_, head, namespace, export, tail = *js.match(PATTERN)
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
{ namespace: namespace,
|
24
|
+
export: format(export),
|
25
|
+
head: format(head),
|
26
|
+
tail: format(tail) }
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
|
31
|
-
.reject { |s| s == "" }
|
32
|
-
.map(&:strip)
|
33
|
-
.join("\n")
|
34
|
-
.gsub(/\A;$/, "")
|
35
|
-
.strip
|
29
|
+
def format(part)
|
30
|
+
part.strip.gsub(/\A;$/, "").strip
|
36
31
|
end
|
37
32
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
<%= @head %>
|
2
|
+
|
1
3
|
(function() {
|
2
4
|
(function() {
|
3
5
|
<%= indent(@export, 4 )%>
|
@@ -6,7 +8,7 @@
|
|
6
8
|
var <%= @namespace %> = this.<%= @namespace %>;
|
7
9
|
|
8
10
|
(function() {
|
9
|
-
<%= indent(@
|
11
|
+
<%= indent(@tail, 4) %>
|
10
12
|
}).call(this);
|
11
13
|
|
12
14
|
if (typeof module === "object" && module.exports) {
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require "erb"
|
2
2
|
|
3
3
|
class Sprockets::Export::Template
|
4
|
-
|
4
|
+
def self.content
|
5
|
+
@content ||= Sprockets::Export.lib_path.join("sprockets/export/template.js.erb").read
|
6
|
+
end
|
5
7
|
|
6
8
|
def initialize(data = {})
|
7
9
|
data.each do |key, value|
|
@@ -10,12 +12,12 @@ class Sprockets::Export::Template
|
|
10
12
|
end
|
11
13
|
|
12
14
|
def render
|
13
|
-
ERB.new(
|
15
|
+
ERB.new(self.class.content).result(binding).strip + "\n"
|
14
16
|
end
|
15
17
|
|
16
18
|
private
|
17
19
|
def indent(string, amount)
|
18
|
-
lines = string.lines
|
20
|
+
lines = string.lines.to_a
|
19
21
|
result = lines.shift
|
20
22
|
lines.each do |line|
|
21
23
|
result << line.gsub(/^(?!$)/, " " * amount)
|
data/sprockets-export.gemspec
CHANGED
@@ -19,7 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_development_dependency "
|
23
|
-
spec.add_development_dependency "
|
22
|
+
spec.add_development_dependency "sprockets", ">= 3.0"
|
23
|
+
spec.add_development_dependency "bundler"
|
24
|
+
spec.add_development_dependency "rake"
|
24
25
|
spec.add_development_dependency "minitest"
|
25
26
|
end
|
metadata
CHANGED
@@ -1,43 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-export
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
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-05-
|
11
|
+
date: 2016-05-17 00:00:00.000000000 Z
|
12
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: '3.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
|
-
- - "
|
31
|
+
- - ">="
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
33
|
+
version: '0'
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
|
-
- - "
|
38
|
+
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - "
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - "
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: minitest
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,6 +74,7 @@ extensions: []
|
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
62
76
|
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
63
78
|
- Gemfile
|
64
79
|
- LICENSE.txt
|
65
80
|
- README.md
|