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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35d273659beb5900a0795a6fb6c50b4386f0ac6f
4
- data.tar.gz: 2637f0d67c40fe574f73588f887823468fbaaef2
3
+ metadata.gz: 7b57161371802c88947bf586d9dbb07dcdc482b9
4
+ data.tar.gz: 00f610fda3e32b792659376d20e921c1a91ccd01
5
5
  SHA512:
6
- metadata.gz: 37cb5bc48b85b6bca5a886aa38033e2758814b442f186f6ed724de1f77561fb9af830596eb584497312ee5078ba09dd86584777d94f50ff13ea92db6765e7c5b
7
- data.tar.gz: 94bcfb8ddfa200a80a2d19daf3ae2bd43e99c4a2dccb5bc7ddfaa8527bdc5bfa83dc9c1256762fb1a9904f02a887609d5a24b0739ef1e091cbf34f4a76dc4055
6
+ metadata.gz: 0eae35cd13fe0aa7c79f5971f5773d2945573ba305f04ac8e1c31987ae122ed9f0618da28cfccd1c8ad2449bd6615b58bfdcb70a013ff440bdae12993d292a84
7
+ data.tar.gz: 7e5aa9ee09d45fdbadde8086888d24ca6a038c6edb75e3dc3db00a6894668bc05bf329c4f3b1e63b66ee83763049bb61909f53de40acbec5042eeb5ba164d020
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.2
5
+ - 2.1
6
+ - 2.0
7
+ - 1.9.3
@@ -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.append_path Pathname.new(__dir__).join("..")
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
- export.strip!
24
- body = format_body(head, tail)
25
-
26
- { namespace: namespace, export: export, body: body }
23
+ { namespace: namespace,
24
+ export: format(export),
25
+ head: format(head),
26
+ tail: format(tail) }
27
27
  end
28
28
 
29
- def format_body(head, tail)
30
- [head, tail]
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(@body, 4) %>
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
- CONTENT = Pathname.new(__dir__).join("template.js.erb").read
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(CONTENT).result(binding)
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)
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Export
3
- VERSION = "0.9.0"
3
+ VERSION = "0.9.1"
4
4
  end
5
5
  end
@@ -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 "bundler", "~> 1.12"
23
- spec.add_development_dependency "rake", "~> 10.0"
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.0
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-16 00:00:00.000000000 Z
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: '1.12'
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: '1.12'
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: '10.0'
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: '10.0'
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