sinatra-coffee 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/sinatra/coffee.rb +14 -8
  2. metadata +2 -2
@@ -10,16 +10,22 @@ end
10
10
 
11
11
 
12
12
  class CoffeeTemplate < Tilt::Template
13
+ class << self
14
+ attr_accessor :coffee_path
15
+ end
16
+
13
17
  def initialize_engine
14
- ENV['PATH'].split(':').each do |p|
15
- coffee_path = File.join(p, 'coffee')
16
- if File.executable?(coffee_path)
17
- @@coffee_path = coffee_path
18
- break
18
+ unless self.class.coffee_path
19
+ ENV['PATH'].split(':').each do |p|
20
+ coffee_path = File.join(p, 'coffee')
21
+ if File.executable?(coffee_path)
22
+ self.class.coffee_path = coffee_path
23
+ break
24
+ end
19
25
  end
20
26
  end
21
27
 
22
- raise StandardError, 'Unable to find "coffee" executable in your PATH' unless @@coffee_path
28
+ raise StandardError, 'Unable to find "coffee" executable in your PATH' unless File.executable?(self.class.coffee_path)
23
29
  end
24
30
 
25
31
  def prepare
@@ -29,12 +35,12 @@ class CoffeeTemplate < Tilt::Template
29
35
  compiled = nil
30
36
  error_message = nil
31
37
 
32
- Open3.popen3(@@coffee_path, '-s', '-p') do |stdin, stdout, stderr, waitth|
38
+ Open3.popen3(self.class.coffee_path, '-s', '-p', '--no-wrap') do |stdin, stdout, stderr, waitth|
33
39
  stdin.write(data)
34
40
  stdin.close_write
35
41
  compiled = stdout.read
36
42
  error_message = stderr.read
37
- raise RuntimeError, "CoffeeScript compile failed. #{error_message}" unless waitth.value == 0
43
+ raise "CoffeeScript compile failed. #{error_message}" unless waitth.value == 0
38
44
  end
39
45
 
40
46
  compiled
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Dan Farino