sprockets-vue 0.0.3 → 0.0.4
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 +4 -4
- data/lib/sprockets/vue/script.rb +39 -0
- data/lib/sprockets/vue/style.rb +30 -0
- data/lib/sprockets/vue/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d38a9eeb83c5f834ff700e4968f64396516eb96f
|
4
|
+
data.tar.gz: 3e63bffae0b3aeab5838cb91c1fd87258bc484f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b35f836aaa41861b43c03e4bd8106a665de95e642e46d821b89c6db6c8ee2c4140c46cb8237d7a72d4795825a04f4f67fc242a7801a6c2b68c1088843b88a75a
|
7
|
+
data.tar.gz: 453d6d3f08a7415d42864bea57b918e7b437ee98d730cb44cfb83deb6a2f3637c19fe941f7add8aa1717c016be6bc4617e4788585fac8e7ffac2388aecea706c
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Sprockets::Vue::Script
|
2
|
+
class << self
|
3
|
+
include ActionView::Helpers::JavaScriptHelper
|
4
|
+
SCRIPT_COMPILES = {
|
5
|
+
'coffee' => ->(s, input){
|
6
|
+
CoffeeScript.compile(s, sourceMap: true, sourceFiles: [input[:source_path]], no_wrap: true)
|
7
|
+
},
|
8
|
+
'es6' => ->(s, input){
|
9
|
+
Babel::Transpiler.transform(data, {}) #TODO
|
10
|
+
}
|
11
|
+
}
|
12
|
+
def call(input)
|
13
|
+
data = input[:data]
|
14
|
+
name = input[:name]
|
15
|
+
input[:cache].fetch([cache_key, input[:source_path], data]) do
|
16
|
+
script_r = /\<script *(lang="(\w+)")?\>([\s\S]+)\<\/script\>/
|
17
|
+
template_r = /\<template\>([\s\S]+)\<\/template\>/
|
18
|
+
script = script_r.match(data)
|
19
|
+
lang = script[2]
|
20
|
+
template = template_r.match(data)
|
21
|
+
|
22
|
+
result = SCRIPT_COMPILES[lang].call(script[3], input)
|
23
|
+
|
24
|
+
output = ";if (typeof(VCompents)==='undefined')VCompents = {};
|
25
|
+
VCompents['#{name}'] = #{result['js']};"
|
26
|
+
output << "VCompents['#{name}'].template = '#{escape_javascript template[1]}';" if template
|
27
|
+
|
28
|
+
{ data: output }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def cache_key
|
33
|
+
[
|
34
|
+
self.name,
|
35
|
+
::Sprockets::Vue::VERSION,
|
36
|
+
].freeze
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class Sprockets::Vue::Style
|
2
|
+
class << self
|
3
|
+
STYLE_COMPILES = {
|
4
|
+
'scss' => Sprockets::ScssProcessor,
|
5
|
+
'sass' => Sprockets::SassProcessor,
|
6
|
+
nil => ->(i){i[:data]}
|
7
|
+
}
|
8
|
+
def call(input)
|
9
|
+
data = input[:data]
|
10
|
+
input[:cache].fetch([cache_key, input[:filename], data]) do
|
11
|
+
style_r = /\<style *(lang="(\w+)")?\>([\s\S]+)\<\/style\>/
|
12
|
+
style = style_r.match(data)
|
13
|
+
if style
|
14
|
+
lang = style[2]
|
15
|
+
input[:data] = style[3]
|
16
|
+
STYLE_COMPILES[lang].call(input)
|
17
|
+
else
|
18
|
+
''
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def cache_key
|
24
|
+
[
|
25
|
+
self.name,
|
26
|
+
::Sprockets::Vue::VERSION,
|
27
|
+
].freeze
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-vue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kikyous
|
@@ -62,6 +62,8 @@ files:
|
|
62
62
|
- MIT-LICENSE
|
63
63
|
- README.md
|
64
64
|
- lib/sprockets/vue.rb
|
65
|
+
- lib/sprockets/vue/script.rb
|
66
|
+
- lib/sprockets/vue/style.rb
|
65
67
|
- lib/sprockets/vue/version.rb
|
66
68
|
homepage: https://github.com/kikyous/sprockets-vue
|
67
69
|
licenses:
|