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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b161286814792680bb32b76fc78204223cd7b9c
4
- data.tar.gz: 1ff091c2f4b109b41d5b6d3a02110e74c179734f
3
+ metadata.gz: 7bdca05df2d8ce7c39c863a2468049b9f34f9e0d
4
+ data.tar.gz: 2dbe50ca6ab5665a105e4813438ca2c59c2d46dd
5
5
  SHA512:
6
- metadata.gz: 2e5d864ca502f27db60cdd529d987cd961ca7f1ed6a9ed2a9079756c621686332e954eea6b01b6a7a05c2fae1cc2aa278bfcaf15153cabbee82d7fa0376360b7
7
- data.tar.gz: dd9fc53964221a9559f3ebac87ccedb557baa5e1977751bd530920efa8fb5ac22b9a29227fcc5f49f8928479369757b117b5c7015382ebd5f057309a68d696db
6
+ metadata.gz: 9b716fdc824e1d374274a8c0e8dd844a664ef01422471301d4007223c2ba7733a9737bdd8090b02025ea70a2e779b5c44c54326dde970b455a9a69d042a88aed
7
+ data.tar.gz: 722dd8299c6baac11c9589b1d90aafe7509cbc8de7f905a1af5eaa6fae368955c2cddd07b48e0c1fd6f5f6917243de24333ec7f2d9b7b610f1887e9c2292ebc2
@@ -1,5 +1,4 @@
1
1
  rvm:
2
- - "1.9.3"
3
2
  - "2.0.0"
4
3
  - "2.1"
5
4
  - "2.2"
@@ -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
@@ -5,7 +5,17 @@ module Barber
5
5
  class Precompiler
6
6
  class << self
7
7
  def compile(template)
8
- new.compile(template)
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
- # noop
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
@@ -1,3 +1,3 @@
1
1
  module Barber
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
@@ -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
@@ -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.7.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-13 00:00:00.000000000 Z
12
+ date: 2015-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: execjs