livescript-rails 2.0.1 → 2.0.2

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: 1a90a71958b8258974bf0da8b5d04352d27a959b
4
- data.tar.gz: e5f82cad0ac3de2299f9e55cc3793bc994ae1906
3
+ metadata.gz: 784cb9156ad6e834d25a11f209aa802767332541
4
+ data.tar.gz: 28dcdca43b5ac9d97c5bba180b639df144d8db22
5
5
  SHA512:
6
- metadata.gz: 7ce950a5215e4186c2e27b4603b9c672a1695e31d82d1dc7030163a32634e78e3fab16f69a93a262d42099d3131809cfaf733a9ab8f6970341a335e5027d13af
7
- data.tar.gz: 42a6c2916a217c253620ead1355f5d24dbe3c25af748c90b49dbc7b00fa4c35bfae49201833fba0b0fe58f91c157cb72cc52fa79c28f73d47b0e62d52412995b
6
+ metadata.gz: 52605b2a5dfa6a32980e9a09dc616735a6d7e73d06f9fbd8fea0a9b246a59b5290847348431bddafce67d89670519c1408c0bae28ce8fddedadfe48ec142c3c7
7
+ data.tar.gz: 40131073d579f1d428b588267946b077e7e6b71a4b3f366d33e02be9382884be9c1b5021167ac264c870008bf54fb812688d6a869b8bdf1c022ecab52221b55d
data/README.md CHANGED
@@ -4,6 +4,8 @@ LiveScript adapter for the Rails asset pipeline.
4
4
 
5
5
  Depends on [Roonin-mx/livescript-ruby](https://github.com/Roonin-mx/livescript-ruby) to compile LiveScript to javascript.
6
6
 
7
+ Source map is available if `Sprockets` >= 4.0.
8
+
7
9
  ## Installation
8
10
 
9
11
  Add the following lines to your `Gemfile`:
@@ -25,16 +27,20 @@ end
25
27
  You can set compile options in `config/initializers/assets.rb`:
26
28
 
27
29
  ```
28
- # These are default options. User set options will override default options
29
30
  Rails.application.config.assets.livescript = {
30
- bare: true,
31
31
  header: false,
32
- map: 'linked-src',
33
32
  }
34
33
  ```
35
34
 
36
35
  See [Roonin-mx/livescript-ruby](https://github.com/Roonin-mx/livescript-ruby) for more options.
37
36
 
37
+ Default options:
38
+
39
+ * bare: true (for backward compatibility)
40
+ * header: true
41
+
42
+ `filename` and `map` options are set internally and not allowed to change.
43
+
38
44
  ## License
39
45
 
40
46
  MIT
@@ -1,6 +1,11 @@
1
+ require 'sprockets'
2
+
1
3
  module LiveScript
2
4
  module Rails
3
5
  module SprocketsProcessor
6
+ # only enable source map when sprockets >= 4.0
7
+ ENABLE_SOURCE_MAP = Sprockets::VERSION >= '4.0'
8
+
4
9
  def self.cache_key
5
10
  @cache_key ||= "#{name}:#{LiveScript::Source::VERSION}:#{LiveScript::VERSION}:#{LiveScript::Rails::VERSION}".freeze
6
11
  end
@@ -9,20 +14,23 @@ module LiveScript
9
14
  data = input[:data]
10
15
  options = {
11
16
  bare: true,
12
- header: false,
13
- map: 'linked-src',
14
- filename: input[:source_path] || input[:filename],
17
+ header: true,
15
18
  }.merge(::Rails.application.config.assets.livescript || {})
16
19
 
20
+ options.merge!({
21
+ filename: input[:source_path] || input[:filename],
22
+ map: ENABLE_SOURCE_MAP ? 'linked-src' : 'none',
23
+ })
24
+
17
25
  result = input[:cache].fetch([self.cache_key, data]) do
18
26
  LiveScript.compile(data, options)
19
27
  end
20
28
 
21
- # when map: none, result is String; otherwise, result is Hash
22
- if result.kind_of? Hash
29
+ if ENABLE_SOURCE_MAP
30
+ map = Sprockets::SourceMapUtils.decode_vlq_mappings(result['map']['mappings'], sources: result['map']['sources'], names: result['map']['names'])
23
31
  {
24
32
  data: result['code'],
25
- map: result['map'],
33
+ map: Sprockets::SourceMapUtils.combine_source_maps(input[:metadata][:map], map),
26
34
  }
27
35
  else
28
36
  result
@@ -1,5 +1,5 @@
1
1
  module LiveScript
2
2
  module Rails
3
- VERSION = '2.0.1'
3
+ VERSION = '2.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: livescript-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Hugo Borja
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-23 00:00:00.000000000 Z
12
+ date: 2016-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: execjs