barber 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/lib/barber/ember/precompiler.rb +16 -0
- data/lib/barber/precompiler.rb +21 -3
- data/lib/barber/version.rb +1 -1
- data/test/ember/precompiler_test.rb +6 -0
- data/test/precompiler_test.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bdca05df2d8ce7c39c863a2468049b9f34f9e0d
|
4
|
+
data.tar.gz: 2dbe50ca6ab5665a105e4813438ca2c59c2d46dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b716fdc824e1d374274a8c0e8dd844a664ef01422471301d4007223c2ba7733a9737bdd8090b02025ea70a2e779b5c44c54326dde970b455a9a69d042a88aed
|
7
|
+
data.tar.gz: 722dd8299c6baac11c9589b1d90aafe7509cbc8de7f905a1af5eaa6fae368955c2cddd07b48e0c1fd6f5f6917243de24333ec7f2d9b7b610f1887e9c2292ebc2
|
data/.travis.yml
CHANGED
@@ -13,6 +13,22 @@ module Barber
|
|
13
13
|
def sources
|
14
14
|
super + [ember_template_precompiler]
|
15
15
|
end
|
16
|
+
|
17
|
+
def compiler_version
|
18
|
+
cache_key = "ember-source:#{::Ember::VERSION}"
|
19
|
+
|
20
|
+
if handlebars_version
|
21
|
+
"handlebars:#{handlebars_version}/#{cache_key}"
|
22
|
+
else
|
23
|
+
cache_key
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def handlebars_version
|
30
|
+
@handlebars_version ||= context.eval('typeof require !== "undefined" && require("handlebars") && require("handlebars").VERSION');
|
31
|
+
end
|
16
32
|
end
|
17
33
|
end
|
18
34
|
end
|
data/lib/barber/precompiler.rb
CHANGED
@@ -5,7 +5,17 @@ module Barber
|
|
5
5
|
class Precompiler
|
6
6
|
class << self
|
7
7
|
def compile(template)
|
8
|
-
|
8
|
+
instance.compile(template)
|
9
|
+
end
|
10
|
+
|
11
|
+
def compiler_version
|
12
|
+
instance.compiler_version
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def instance
|
18
|
+
@instance ||= new
|
9
19
|
end
|
10
20
|
end
|
11
21
|
|
@@ -29,6 +39,10 @@ module Barber
|
|
29
39
|
@handlebars ||= File.new(Handlebars::Source.bundled_path)
|
30
40
|
end
|
31
41
|
|
42
|
+
def compiler_version
|
43
|
+
"handlebars:#{handlebars_version}"
|
44
|
+
end
|
45
|
+
|
32
46
|
private
|
33
47
|
# This method handles different types of user input. The precompiler
|
34
48
|
# can be called from many different places which create interesting
|
@@ -88,10 +102,14 @@ if (typeof window === 'undefined') {
|
|
88
102
|
|
89
103
|
def handlebars_available?
|
90
104
|
require "handlebars/source" # handlebars precompilation is optional feature.
|
91
|
-
rescue LoadError
|
92
|
-
|
105
|
+
rescue LoadError => e
|
106
|
+
raise e unless e.message == 'cannot load such file -- handlebars/source'
|
93
107
|
ensure
|
94
108
|
return !!defined?(Handlebars::Source)
|
95
109
|
end
|
110
|
+
|
111
|
+
def handlebars_version
|
112
|
+
@handlebars_version ||= context.eval('Handlebars.VERSION')
|
113
|
+
end
|
96
114
|
end
|
97
115
|
end
|
data/lib/barber/version.rb
CHANGED
@@ -12,6 +12,12 @@ class EmberPrecompilerTest < MiniTest::Unit::TestCase
|
|
12
12
|
"Ember precompile should inherit from Barber::Precompiler"
|
13
13
|
end
|
14
14
|
|
15
|
+
def test_compiler_version
|
16
|
+
assert Barber::Ember::Precompiler.compiler_version
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
15
21
|
def compile(template)
|
16
22
|
Barber::Ember::Precompiler.compile template
|
17
23
|
end
|
data/test/precompiler_test.rb
CHANGED
@@ -99,7 +99,12 @@ class PrecompilerTest < MiniTest::Unit::TestCase
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
+
def test_compiler_version
|
103
|
+
assert Barber::Precompiler.compiler_version
|
104
|
+
end
|
105
|
+
|
102
106
|
private
|
107
|
+
|
103
108
|
def compile(template)
|
104
109
|
Barber::Precompiler.compile template
|
105
110
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: barber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tchak
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-03-
|
12
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: execjs
|