sprockets-foo 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -8,15 +8,19 @@ module Sprockets
8
8
  end
9
9
 
10
10
  def evaluate_in(preprocessor)
11
- compile_ejs
12
- super(preprocessor)
11
+ if template_file_path
12
+ compile_ejs(template_file_path.to_s)
13
+ super(preprocessor)
14
+ else
15
+ raise_load_error
16
+ end
13
17
  end
14
18
 
15
19
  protected
16
20
 
17
- def compile_ejs
21
+ def compile_ejs(source_file)
18
22
  compiler = Ejs::Compiler.new
19
- compiler.compile(template_file_path.to_s, namespace)
23
+ compiler.compile(source_file, namespace)
20
24
  end
21
25
 
22
26
  def namespace
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sprockets-foo}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ben Curren"]
@@ -49,6 +49,7 @@ Gem::Specification.new do |s|
49
49
  "lib/sprockets-foo.rb",
50
50
  "lib/sprockets/directives/template_directive.rb",
51
51
  "sprockets-foo.gemspec",
52
+ "test/fixtures/requiring_a_file_that_does_not_exist_should_raise_an_error.js",
52
53
  "test/fixtures/requiring_a_template_should_compile_then_require.js",
53
54
  "test/fixtures/requiring_a_template_with_namespace_should_compile_then_require.js",
54
55
  "test/fixtures/src/MyTemplate.ejs",
@@ -0,0 +1 @@
1
+ //= template <does_not_exist>
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  window.MyTemplate = window.MyTemplate || {};
5
- MyTemplate.template = function(options) {
5
+ MyTemplate.render = function(options) {
6
6
  var p = [];
7
7
  with(options) {
8
8
  p.push('<p>Content</p>\n');
@@ -4,7 +4,7 @@
4
4
  window.or = window.or || {};
5
5
  window.or.ui = window.or.ui || {};
6
6
  window.or.ui.MyNamespacedTemplate = window.or.ui.MyNamespacedTemplate || {};
7
- or.ui.MyNamespacedTemplate.template = function(options) {
7
+ or.ui.MyNamespacedTemplate.render = function(options) {
8
8
  var p = [];
9
9
  with(options) {
10
10
  p.push('<p>Content</p>\n');
@@ -16,7 +16,7 @@ class PreprocessorTest < Test::Unit::TestCase
16
16
  window.or = window.or || {};
17
17
  window.or.ui = window.or.ui || {};
18
18
  window.or.ui.MyNamespacedTemplate = window.or.ui.MyNamespacedTemplate || {};
19
- or.ui.MyNamespacedTemplate.template = function(options) {
19
+ or.ui.MyNamespacedTemplate.render = function(options) {
20
20
  var p = [];
21
21
  with(options) {
22
22
  p.push('<p>Content</p>\\n');
@@ -35,7 +35,7 @@ class PreprocessorTest < Test::Unit::TestCase
35
35
 
36
36
 
37
37
  window.MyTemplate = window.MyTemplate || {};
38
- MyTemplate.template = function(options) {
38
+ MyTemplate.render = function(options) {
39
39
  var p = [];
40
40
  with(options) {
41
41
  p.push('<p>Content</p>\\n');
@@ -46,6 +46,12 @@ class PreprocessorTest < Test::Unit::TestCase
46
46
  LINES
47
47
  end
48
48
 
49
+ def test_requiring_a_file_that_does_not_exist_should_raise_an_error
50
+ assert_raises(Sprockets::LoadError) do
51
+ require_file_for_this_test
52
+ end
53
+ end
54
+
49
55
  protected
50
56
 
51
57
  attr_reader :environment, :preprocessor
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ben Curren
@@ -73,6 +73,7 @@ files:
73
73
  - lib/sprockets-foo.rb
74
74
  - lib/sprockets/directives/template_directive.rb
75
75
  - sprockets-foo.gemspec
76
+ - test/fixtures/requiring_a_file_that_does_not_exist_should_raise_an_error.js
76
77
  - test/fixtures/requiring_a_template_should_compile_then_require.js
77
78
  - test/fixtures/requiring_a_template_with_namespace_should_compile_then_require.js
78
79
  - test/fixtures/src/MyTemplate.ejs